Pass around DevUtilsContract so it's only instantiated once
This commit is contained in:
@@ -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(
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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(
|
||||
|
Reference in New Issue
Block a user