diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-06-13 05:01:19 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-06-13 05:01:19 +0800 |
commit | 39692a8b3fd69e5b37e2de568ee74766840ad4b8 (patch) | |
tree | cc2d1ec295d987a360ce07a5c80723b96b0d1816 /packages/contract-wrappers | |
parent | 2af6d3f6bc03932f53d199971694c3c0d9441ba8 (diff) | |
parent | 787015f5370718e31c7990446fb1da298ed13e6b (diff) | |
download | dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.gz dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.bz2 dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.lz dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.xz dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.tar.zst dexon-sol-tools-39692a8b3fd69e5b37e2de568ee74766840ad4b8.zip |
Merge branch 'v2-prototype' of https://github.com/0xProject/0x-monorepo into feature/website/onboarding-flow-allowances
Diffstat (limited to 'packages/contract-wrappers')
10 files changed, 109 insertions, 41 deletions
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 71c2ee780..d5d4bfbc8 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -24,7 +24,7 @@ "update_compact_artifacts": "copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts", "update_test_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/1.0.0/$i.json test/artifacts; done;", "clean": "shx rm -rf _bundles lib test_temp scripts test/artifacts src/contract_wrappers/generated", - "run_mocha": "mocha lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit", + "run_mocha": "mocha --require source-map-support/register lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit", "manual:postpublish": "yarn build; node ./scripts/postpublish.js" }, "config": { diff --git a/packages/contract-wrappers/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts b/packages/contract-wrappers/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts new file mode 100644 index 000000000..1f139f1ef --- /dev/null +++ b/packages/contract-wrappers/src/abstract/abstract_balance_and_proxy_allowance_lazy_store.ts @@ -0,0 +1,11 @@ +import { BigNumber } from '@0xproject/utils'; + +export abstract class AbstractBalanceAndProxyAllowanceLazyStore { + public abstract async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>; + public abstract async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>; + public abstract setBalance(tokenAddress: string, userAddress: string, balance: BigNumber): void; + public abstract deleteBalance(tokenAddress: string, userAddress: string): void; + public abstract setProxyAllowance(tokenAddress: string, userAddress: string, proxyAllowance: BigNumber): void; + public abstract deleteProxyAllowance(tokenAddress: string, userAddress: string): void; + public abstract deleteAll(): void; +} diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index 2d5261900..430ce9c5e 100644 --- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts @@ -18,6 +18,7 @@ import * as _ from 'lodash'; import { artifacts } from '../artifacts'; import { SimpleBalanceAndProxyAllowanceFetcher } from '../fetchers/simple_balance_and_proxy_allowance_fetcher'; import { SimpleOrderFilledCancelledFetcher } from '../fetchers/simple_order_filled_cancelled_fetcher'; +import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store'; import { BlockRange, EventCallback, @@ -54,7 +55,7 @@ interface ExchangeContractErrCodesToMsgs { */ export class ExchangeWrapper extends ContractWrapper { private _exchangeContractIfExists?: ExchangeContract; - private _orderValidationUtils: OrderValidationUtils; + private _orderValidationUtilsIfExists?: OrderValidationUtils; private _tokenWrapper: TokenWrapper; private _exchangeContractErrCodesToMsg: ExchangeContractErrCodesToMsgs = { [ExchangeContractErrCodes.ERROR_FILL_EXPIRED]: ExchangeContractErrs.OrderFillExpired, @@ -75,7 +76,6 @@ export class ExchangeWrapper extends ContractWrapper { ) { super(web3Wrapper, networkId); this._tokenWrapper = tokenWrapper; - this._orderValidationUtils = new OrderValidationUtils(this); this._contractAddressIfExists = contractAddressIfExists; this._zrxContractAddressIfExists = zrxContractAddressIfExists; } @@ -177,8 +177,13 @@ export class ExchangeWrapper extends ContractWrapper { : orderTransactionOpts.shouldValidate; if (shouldValidate) { const zrxTokenAddress = this.getZRXTokenAddress(); - const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest); - await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync( + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + this._tokenWrapper, + BlockParamLiteral.Latest, + ); + const exchangeTradeEmulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); + const orderValidationUtils = await this._getOrderValidationUtilsAsync(); + await orderValidationUtils.validateFillOrderThrowIfInvalidAsync( exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, @@ -252,9 +257,14 @@ export class ExchangeWrapper extends ContractWrapper { if (shouldValidate) { let filledTakerTokenAmount = new BigNumber(0); const zrxTokenAddress = this.getZRXTokenAddress(); - const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest); + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + this._tokenWrapper, + BlockParamLiteral.Latest, + ); + const exchangeTradeEmulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); + const orderValidationUtils = await this._getOrderValidationUtilsAsync(); for (const signedOrder of signedOrders) { - const singleFilledTakerTokenAmount = await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync( + const singleFilledTakerTokenAmount = await orderValidationUtils.validateFillOrderThrowIfInvalidAsync( exchangeTradeEmulator, signedOrder, fillTakerTokenAmount.minus(filledTakerTokenAmount), @@ -345,9 +355,14 @@ export class ExchangeWrapper extends ContractWrapper { : orderTransactionOpts.shouldValidate; if (shouldValidate) { const zrxTokenAddress = this.getZRXTokenAddress(); - const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest); + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + this._tokenWrapper, + BlockParamLiteral.Latest, + ); + const exchangeTradeEmulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); + const orderValidationUtils = await this._getOrderValidationUtilsAsync(); for (const orderFillRequest of orderFillRequests) { - await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync( + await orderValidationUtils.validateFillOrderThrowIfInvalidAsync( exchangeTradeEmulator, orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount, @@ -421,8 +436,13 @@ export class ExchangeWrapper extends ContractWrapper { : orderTransactionOpts.shouldValidate; if (shouldValidate) { const zrxTokenAddress = this.getZRXTokenAddress(); - const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest); - await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync( + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + this._tokenWrapper, + BlockParamLiteral.Latest, + ); + const exchangeTradeEmulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); + const orderValidationUtils = await this._getOrderValidationUtilsAsync(); + await orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync( exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, @@ -483,9 +503,14 @@ export class ExchangeWrapper extends ContractWrapper { : orderTransactionOpts.shouldValidate; if (shouldValidate) { const zrxTokenAddress = this.getZRXTokenAddress(); - const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest); + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + this._tokenWrapper, + BlockParamLiteral.Latest, + ); + const exchangeTradeEmulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); + const orderValidationUtils = await this._getOrderValidationUtilsAsync(); for (const orderFillRequest of orderFillRequests) { - await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync( + await orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync( exchangeTradeEmulator, orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount, @@ -733,8 +758,13 @@ export class ExchangeWrapper extends ContractWrapper { assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); const zrxTokenAddress = this.getZRXTokenAddress(); const expectedFillTakerTokenAmount = !_.isUndefined(opts) ? opts.expectedFillTakerTokenAmount : undefined; - const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest); - await this._orderValidationUtils.validateOrderFillableOrThrowAsync( + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + this._tokenWrapper, + BlockParamLiteral.Latest, + ); + const exchangeTradeEmulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); + const orderValidationUtils = await this._getOrderValidationUtilsAsync(); + await orderValidationUtils.validateOrderFillableOrThrowAsync( exchangeTradeEmulator, signedOrder, zrxTokenAddress, @@ -759,8 +789,13 @@ export class ExchangeWrapper extends ContractWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); const normalizedTakerAddress = takerAddress.toLowerCase(); const zrxTokenAddress = this.getZRXTokenAddress(); - const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest); - await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync( + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + this._tokenWrapper, + BlockParamLiteral.Latest, + ); + const exchangeTradeEmulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); + const orderValidationUtils = await this._getOrderValidationUtilsAsync(); + await orderValidationUtils.validateFillOrderThrowIfInvalidAsync( exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, @@ -806,8 +841,13 @@ export class ExchangeWrapper extends ContractWrapper { await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper); const normalizedTakerAddress = takerAddress.toLowerCase(); const zrxTokenAddress = this.getZRXTokenAddress(); - const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest); - await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync( + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + this._tokenWrapper, + BlockParamLiteral.Latest, + ); + const exchangeTradeEmulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); + const orderValidationUtils = await this._getOrderValidationUtilsAsync(); + await orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync( exchangeTradeEmulator, signedOrder, fillTakerTokenAmount, @@ -917,6 +957,14 @@ export class ExchangeWrapper extends ContractWrapper { const orderHashHex = await exchangeInstance.getOrderHash.callAsync(orderAddresses, orderValues); return orderHashHex; } + private async _getOrderValidationUtilsAsync(): Promise<OrderValidationUtils> { + if (!_.isUndefined(this._orderValidationUtilsIfExists)) { + return this._orderValidationUtilsIfExists; + } + const exchangeContract = await this._getExchangeContractAsync(); + this._orderValidationUtilsIfExists = new OrderValidationUtils(exchangeContract); + return this._orderValidationUtilsIfExists; + } // tslint:enable:no-unused-variable private async _getExchangeContractAsync(): Promise<ExchangeContract> { if (!_.isUndefined(this._exchangeContractIfExists)) { diff --git a/packages/contract-wrappers/src/stores/balance_proxy_allowance_lazy_store.ts b/packages/contract-wrappers/src/stores/balance_proxy_allowance_lazy_store.ts index 614195157..c0250ce7c 100644 --- a/packages/contract-wrappers/src/stores/balance_proxy_allowance_lazy_store.ts +++ b/packages/contract-wrappers/src/stores/balance_proxy_allowance_lazy_store.ts @@ -1,14 +1,14 @@ -import { AbstractBalanceAndProxyAllowanceFetcher } from '@0xproject/order-utils'; import { BlockParamLiteral } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; +import { AbstractBalanceAndProxyAllowanceLazyStore } from '../abstract/abstract_balance_and_proxy_allowance_lazy_store'; import { TokenWrapper } from '../contract_wrappers/token_wrapper'; /** * Copy on read store for balances/proxyAllowances of tokens/accounts */ -export class BalanceAndProxyAllowanceLazyStore implements AbstractBalanceAndProxyAllowanceFetcher { +export class BalanceAndProxyAllowanceLazyStore implements AbstractBalanceAndProxyAllowanceLazyStore { private _tokenWrapper: TokenWrapper; private _defaultBlock: BlockParamLiteral; private _balance: { diff --git a/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts b/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts index 395945fe3..527b8575d 100644 --- a/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts +++ b/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts @@ -1,8 +1,8 @@ import { BlockParamLiteral, ExchangeContractErrs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; +import { AbstractBalanceAndProxyAllowanceLazyStore } from '../abstract/abstract_balance_and_proxy_allowance_lazy_store'; import { TokenWrapper } from '../contract_wrappers/token_wrapper'; -import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store'; import { TradeSide, TransferType } from '../types'; import { constants } from '../utils/constants'; @@ -35,8 +35,7 @@ const ERR_MSG_MAPPING = { }; export class ExchangeTransferSimulator { - private _store: BalanceAndProxyAllowanceLazyStore; - private _UNLIMITED_ALLOWANCE_IN_BASE_UNITS: BigNumber; + private _store: AbstractBalanceAndProxyAllowanceLazyStore; private static _throwValidationError( failureReason: FailureReason, tradeSide: TradeSide, @@ -45,9 +44,8 @@ export class ExchangeTransferSimulator { const errMsg = ERR_MSG_MAPPING[failureReason][tradeSide][transferType]; throw new Error(errMsg); } - constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) { - this._store = new BalanceAndProxyAllowanceLazyStore(token, defaultBlock); - this._UNLIMITED_ALLOWANCE_IN_BASE_UNITS = token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; + constructor(store: AbstractBalanceAndProxyAllowanceLazyStore) { + this._store = store; } /** * Simulates transferFrom call performed by a proxy @@ -91,7 +89,7 @@ export class ExchangeTransferSimulator { amountInBaseUnits: BigNumber, ): Promise<void> { const proxyAllowance = await this._store.getProxyAllowanceAsync(tokenAddress, userAddress); - if (!proxyAllowance.eq(this._UNLIMITED_ALLOWANCE_IN_BASE_UNITS)) { + if (!proxyAllowance.eq(constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS)) { this._store.setProxyAllowance(tokenAddress, userAddress, proxyAllowance.minus(amountInBaseUnits)); } } diff --git a/packages/contract-wrappers/src/utils/order_validation_utils.ts b/packages/contract-wrappers/src/utils/order_validation_utils.ts index b6b3334a6..c6ef26275 100644 --- a/packages/contract-wrappers/src/utils/order_validation_utils.ts +++ b/packages/contract-wrappers/src/utils/order_validation_utils.ts @@ -3,7 +3,7 @@ import { ExchangeContractErrs, Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; -import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper'; +import { ExchangeContract } from '../contract_wrappers/generated/exchange'; import { TradeSide, TransferType } from '../types'; import { constants } from '../utils/constants'; import { utils } from '../utils/utils'; @@ -11,7 +11,7 @@ import { utils } from '../utils/utils'; import { ExchangeTransferSimulator } from './exchange_transfer_simulator'; export class OrderValidationUtils { - private _exchangeWrapper: ExchangeWrapper; + private _exchangeContract: ExchangeContract; public static validateCancelOrderThrowIfInvalid( order: Order, cancelTakerTokenAmount: BigNumber, @@ -104,8 +104,8 @@ export class OrderValidationUtils { .round(0); return fillMakerTokenAmount; } - constructor(exchangeWrapper: ExchangeWrapper) { - this._exchangeWrapper = exchangeWrapper; + constructor(exchangeContract: ExchangeContract) { + this._exchangeContract = exchangeContract; } public async validateOrderFillableOrThrowAsync( exchangeTradeEmulator: ExchangeTransferSimulator, @@ -114,7 +114,9 @@ export class OrderValidationUtils { expectedFillTakerTokenAmount?: BigNumber, ): Promise<void> { const orderHash = getOrderHashHex(signedOrder); - const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash); + const unavailableTakerTokenAmount = await this._exchangeContract.getUnavailableTakerTokenAmount.callAsync( + orderHash, + ); OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow( signedOrder.takerTokenAmount, unavailableTakerTokenAmount, @@ -146,7 +148,9 @@ export class OrderValidationUtils { if (!isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker)) { throw new Error(OrderError.InvalidSignature); } - const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash); + const unavailableTakerTokenAmount = await this._exchangeContract.getUnavailableTakerTokenAmount.callAsync( + orderHash, + ); OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow( signedOrder.takerTokenAmount, unavailableTakerTokenAmount, @@ -167,7 +171,7 @@ export class OrderValidationUtils { zrxTokenAddress, ); - const wouldRoundingErrorOccur = await this._exchangeWrapper.isRoundingErrorAsync( + const wouldRoundingErrorOccur = await this._exchangeContract.isRoundingError.callAsync( filledTakerTokenAmount, signedOrder.takerTokenAmount, signedOrder.makerTokenAmount, diff --git a/packages/contract-wrappers/src/utils/utils.ts b/packages/contract-wrappers/src/utils/utils.ts index 7cf9450a0..689a7ee0a 100644 --- a/packages/contract-wrappers/src/utils/utils.ts +++ b/packages/contract-wrappers/src/utils/utils.ts @@ -1,9 +1,6 @@ import { BigNumber } from '@0xproject/utils'; export const utils = { - spawnSwitchErr(name: string, value: any): Error { - return new Error(`Unexpected switch value: ${value} encountered for ${name}`); - }, getCurrentUnixTimestampSec(): BigNumber { const milisecondsInSecond = 1000; return new BigNumber(Date.now() / milisecondsInSecond).round(); diff --git a/packages/contract-wrappers/test/exchange_transfer_simulator_test.ts b/packages/contract-wrappers/test/exchange_transfer_simulator_test.ts index 8bbe04d6c..1690eb392 100644 --- a/packages/contract-wrappers/test/exchange_transfer_simulator_test.ts +++ b/packages/contract-wrappers/test/exchange_transfer_simulator_test.ts @@ -5,6 +5,7 @@ import * as chai from 'chai'; import 'make-promises-safe'; import { ContractWrappers, ExchangeContractErrs } from '../src'; +import { BalanceAndProxyAllowanceLazyStore } from '../src/stores/balance_proxy_allowance_lazy_store'; import { TradeSide, TransferType } from '../src/types'; import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simulator'; @@ -44,7 +45,11 @@ describe('ExchangeTransferSimulator', () => { }); describe('#transferFromAsync', () => { beforeEach(() => { - exchangeTransferSimulator = new ExchangeTransferSimulator(contractWrappers.token, BlockParamLiteral.Latest); + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + contractWrappers.token, + BlockParamLiteral.Latest, + ); + exchangeTransferSimulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); }); it("throws if the user doesn't have enough allowance", async () => { return expect( diff --git a/packages/contract-wrappers/test/global_hooks.ts b/packages/contract-wrappers/test/global_hooks.ts index 9d6903af5..52a384ada 100644 --- a/packages/contract-wrappers/test/global_hooks.ts +++ b/packages/contract-wrappers/test/global_hooks.ts @@ -6,7 +6,7 @@ import { provider } from './utils/web3_wrapper'; before('migrate contracts', async function(): Promise<void> { // HACK: Since the migrations take longer then our global mocha timeout limit // we manually increase it for this before hook. - const mochaTestTimeoutMs = 20000; + const mochaTestTimeoutMs = 50000; this.timeout(mochaTestTimeoutMs); const txDefaults = { gas: devConstants.GAS_LIMIT, diff --git a/packages/contract-wrappers/test/order_validation_test.ts b/packages/contract-wrappers/test/order_validation_test.ts index a42a6a368..b88684dd0 100644 --- a/packages/contract-wrappers/test/order_validation_test.ts +++ b/packages/contract-wrappers/test/order_validation_test.ts @@ -8,6 +8,7 @@ import 'make-promises-safe'; import * as Sinon from 'sinon'; import { ContractWrappers, ExchangeContractErrs, SignedOrder, Token } from '../src'; +import { BalanceAndProxyAllowanceLazyStore } from '../src/stores/balance_proxy_allowance_lazy_store'; import { TradeSide, TransferType } from '../src/types'; import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simulator'; import { OrderValidationUtils } from '../src/utils/order_validation_utils'; @@ -332,7 +333,11 @@ describe('OrderValidation', () => { return Sinon.match((value: BigNumber) => value.eq(expected)); }; beforeEach('create exchangeTransferSimulator', async () => { - exchangeTransferSimulator = new ExchangeTransferSimulator(contractWrappers.token, BlockParamLiteral.Latest); + const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( + contractWrappers.token, + BlockParamLiteral.Latest, + ); + exchangeTransferSimulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore); transferFromAsync = Sinon.spy(); exchangeTransferSimulator.transferFromAsync = transferFromAsync as any; }); |