Remove assetDataUtils everywhere (#2373)
* remove assetDataUtils everywhere * export IAssetDataContract from @0x/contract-wrappers to allow @0x/instant to decode asset data synchronously * export generic function `decodeAssetDataOrThrow` and add ERC20Bridge support * export `hexUtils` from order-utils instead of contracts-test-utils
This commit is contained in:
@@ -3,11 +3,10 @@ import {
|
||||
constants,
|
||||
expect,
|
||||
filterLogsToArguments,
|
||||
hexRandom,
|
||||
Numberish,
|
||||
shortZip,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { BigNumber, StakingRevertErrors } from '@0x/utils';
|
||||
import { BigNumber, hexUtils, StakingRevertErrors } from '@0x/utils';
|
||||
import { LogEntry } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@@ -34,8 +33,8 @@ blockchainTests.resets('Finalizer unit tests', env => {
|
||||
let testContract: TestFinalizerContract;
|
||||
|
||||
before(async () => {
|
||||
operatorRewardsReceiver = hexRandom(constants.ADDRESS_LENGTH);
|
||||
membersRewardsReceiver = hexRandom(constants.ADDRESS_LENGTH);
|
||||
operatorRewardsReceiver = hexUtils.random(constants.ADDRESS_LENGTH);
|
||||
membersRewardsReceiver = hexUtils.random(constants.ADDRESS_LENGTH);
|
||||
testContract = await TestFinalizerContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestFinalizer,
|
||||
env.provider,
|
||||
@@ -69,7 +68,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
|
||||
async function addActivePoolAsync(opts?: Partial<ActivePoolOpts>): Promise<ActivePoolOpts> {
|
||||
const maxAmount = toBaseUnitAmount(1e9);
|
||||
const _opts = {
|
||||
poolId: hexRandom(),
|
||||
poolId: hexUtils.random(),
|
||||
operatorShare: Math.floor(Math.random() * constants.PPM_DENOMINATOR) / constants.PPM_DENOMINATOR,
|
||||
feesCollected: getRandomInteger(0, maxAmount),
|
||||
membersStake: getRandomInteger(0, maxAmount),
|
||||
@@ -346,7 +345,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
|
||||
describe('_finalizePool()', () => {
|
||||
it('does nothing if there were no pools to finalize', async () => {
|
||||
await testContract.endEpoch().awaitTransactionSuccessAsync();
|
||||
const poolId = hexRandom();
|
||||
const poolId = hexUtils.random();
|
||||
const logs = await finalizePoolsAsync([poolId]);
|
||||
expect(logs).to.deep.eq([]);
|
||||
});
|
||||
@@ -459,7 +458,7 @@ blockchainTests.resets('Finalizer unit tests', env => {
|
||||
});
|
||||
|
||||
it('rolls over leftover rewards into the next epoch', async () => {
|
||||
const poolIds = _.times(3, () => hexRandom());
|
||||
const poolIds = _.times(3, () => hexUtils.random());
|
||||
await Promise.all(poolIds.map(async id => addActivePoolAsync({ poolId: id })));
|
||||
await testContract.endEpoch().awaitTransactionSuccessAsync();
|
||||
const finalizeLogs = await finalizePoolsAsync(poolIds);
|
||||
@@ -496,13 +495,13 @@ blockchainTests.resets('Finalizer unit tests', env => {
|
||||
};
|
||||
|
||||
it('returns empty if epoch is 1', async () => {
|
||||
const poolId = hexRandom();
|
||||
const poolId = hexUtils.random();
|
||||
return assertUnfinalizedPoolRewardsAsync(poolId, ZERO_REWARDS);
|
||||
});
|
||||
|
||||
it('returns empty if pool did not earn rewards', async () => {
|
||||
await testContract.endEpoch().awaitTransactionSuccessAsync();
|
||||
const poolId = hexRandom();
|
||||
const poolId = hexUtils.random();
|
||||
return assertUnfinalizedPoolRewardsAsync(poolId, ZERO_REWARDS);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user