diff options
author | Fabio Berger <me@fabioberger.com> | 2017-06-02 18:40:22 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-06-02 18:40:22 +0800 |
commit | ab5b5a881bc8f8f8d176ae65440de8fcd25ad906 (patch) | |
tree | 79241b27828fd328668c5bab0713b6b1181d6e10 /test/utils | |
parent | 03bc3f08cd0d1c51dc9eb4441a3415e131b72c95 (diff) | |
parent | 2a0c6abbe7f9abeacc4fea05bc468413ec1f4732 (diff) | |
download | dexon-0x-contracts-ab5b5a881bc8f8f8d176ae65440de8fcd25ad906.tar dexon-0x-contracts-ab5b5a881bc8f8f8d176ae65440de8fcd25ad906.tar.gz dexon-0x-contracts-ab5b5a881bc8f8f8d176ae65440de8fcd25ad906.tar.bz2 dexon-0x-contracts-ab5b5a881bc8f8f8d176ae65440de8fcd25ad906.tar.lz dexon-0x-contracts-ab5b5a881bc8f8f8d176ae65440de8fcd25ad906.tar.xz dexon-0x-contracts-ab5b5a881bc8f8f8d176ae65440de8fcd25ad906.tar.zst dexon-0x-contracts-ab5b5a881bc8f8f8d176ae65440de8fcd25ad906.zip |
Merge branch 'fillOrderAsync' into unavailableFilledCancelled
# Conflicts:
# src/0x.js.ts
# test/exchange_wrapper_test.ts
Diffstat (limited to 'test/utils')
-rw-r--r-- | test/utils/fill_scenarios.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/test/utils/fill_scenarios.ts b/test/utils/fill_scenarios.ts index 36656b455..17c2dbeba 100644 --- a/test/utils/fill_scenarios.ts +++ b/test/utils/fill_scenarios.ts @@ -7,29 +7,35 @@ export class FillScenarios { private zeroEx: ZeroEx; private userAddresses: string[]; private tokens: Token[]; + private coinBase: string; constructor(zeroEx: ZeroEx, userAddresses: string[], tokens: Token[]) { this.zeroEx = zeroEx; this.userAddresses = userAddresses; this.tokens = tokens; + this.coinBase = userAddresses[0]; } public async createAFillableSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string, - takerAddress: string, fillableAmount: BigNumber.BigNumber, + makerAddress: string, takerAddress: string, + fillableAmount: BigNumber.BigNumber, expirationUnixTimestampSec?: BigNumber.BigNumber): Promise<SignedOrder> { - const [makerAddress] = this.userAddresses; + await this.zeroEx.token.transferAsync(makerTokenAddress, this.coinBase, makerAddress, fillableAmount); await this.zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, fillableAmount); - await this.zeroEx.token.transferAsync(takerTokenAddress, makerAddress, takerAddress, fillableAmount); + await this.zeroEx.token.transferAsync(takerTokenAddress, this.coinBase, takerAddress, fillableAmount); await this.zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress, fillableAmount); + const transactionSenderAccount = await this.zeroEx.getTransactionSenderAccountIfExistsAsync(); + this.zeroEx.setTransactionSenderAccount(makerAddress); const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, makerAddress, takerAddress, fillableAmount, makerTokenAddress, fillableAmount, takerTokenAddress, expirationUnixTimestampSec); + this.zeroEx.setTransactionSenderAccount(transactionSenderAccount as string); return signedOrder; } public async createPartiallyFilledSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string, takerAddress: string, fillableAmount: BigNumber.BigNumber, partialFillAmount: BigNumber.BigNumber) { - const prevSenderAccount = await this.zeroEx.getTransactionSenderAccountAsync(); + const prevSenderAccount = await this.zeroEx.getTransactionSenderAccountIfExistsAsync(); const [makerAddress] = this.userAddresses; await this.zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, fillableAmount); await this.zeroEx.token.transferAsync(takerTokenAddress, makerAddress, takerAddress, fillableAmount); @@ -43,7 +49,7 @@ export class FillScenarios { await this.zeroEx.exchange.fillOrderAsync(signedOrder, partialFillAmount, shouldCheckTransfer); // Re-set sender account so as to avoid introducing side-effects - this.zeroEx.setTransactionSenderAccount(prevSenderAccount); + this.zeroEx.setTransactionSenderAccount(prevSenderAccount as string); return signedOrder; } } |