Pass around DevUtilsContract so it's only instantiated once

This commit is contained in:
fabioberger
2019-11-08 22:58:22 +00:00
parent 35925de320
commit 8813bd26f6
4 changed files with 7 additions and 6 deletions

View File

@@ -88,7 +88,7 @@ blockchainTests('ExchangeTransferSimulator', env => {
const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore(
simpleERC20BalanceAndProxyAllowanceFetcher,
);
exchangeTransferSimulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore, env.provider);
exchangeTransferSimulator = new ExchangeTransferSimulator(balanceAndProxyAllowanceLazyStore, devUtils);
});
it("throws if the user doesn't have enough allowance", async () => {
return expect(

View File

@@ -55,9 +55,9 @@ export class ExchangeTransferSimulator {
* @param store A class that implements AbstractBalanceAndProxyAllowanceLazyStore
* @return an instance of ExchangeTransferSimulator
*/
constructor(store: AbstractBalanceAndProxyAllowanceLazyStore, provider: SupportedProvider) {
constructor(store: AbstractBalanceAndProxyAllowanceLazyStore, devUtilsContract: DevUtilsContract) {
this._store = store;
this._devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider);
this._devUtils = devUtilsContract;
}
/**
* Simulates transferFrom call performed by a proxy

View File

@@ -504,7 +504,7 @@ export class FillOrderCombinatorialUtils {
takerAssetFillAmount: BigNumber,
lazyStore: BalanceAndProxyAllowanceLazyStore,
): Promise<FillResults> {
const simulator = new FillOrderSimulator(lazyStore, this.provider);
const simulator = new FillOrderSimulator(lazyStore, devUtils);
return simulator.simulateFillOrderAsync(signedOrder, this.takerAddress, takerAssetFillAmount);
}

View File

@@ -1,3 +1,4 @@
import { DevUtilsContract } from '@0x/contracts-dev-utils';
import { constants, orderUtils } from '@0x/contracts-test-utils';
import { Order, SupportedProvider } from '@0x/order-utils';
import { FillResults } from '@0x/types';
@@ -25,9 +26,9 @@ export class FillOrderSimulator {
public readonly lazyStore: LazyStore;
private readonly _transferSimulator: ExchangeTransferSimulator;
constructor(lazyStore: LazyStore, provider: SupportedProvider) {
constructor(lazyStore: LazyStore, devUtilsContract: DevUtilsContract) {
this.lazyStore = lazyStore;
this._transferSimulator = new ExchangeTransferSimulator(lazyStore, provider);
this._transferSimulator = new ExchangeTransferSimulator(lazyStore, devUtilsContract);
}
public async simulateFillOrderAsync(