diff options
author | Fabio Berger <me@fabioberger.com> | 2017-06-02 03:14:30 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-06-02 03:14:30 +0800 |
commit | 3e0c2ad7530927fa1c9019bbc311a88d327e2306 (patch) | |
tree | 435dd8a0efe6c057958d348bc0e9bfd3dcbba6cc /test/utils | |
parent | aade6891e834dda7e80d76740882facdb45bc014 (diff) | |
parent | f663a15c9b000d639bd0d58d0c177e6de9d47346 (diff) | |
download | dexon-sol-tools-3e0c2ad7530927fa1c9019bbc311a88d327e2306.tar dexon-sol-tools-3e0c2ad7530927fa1c9019bbc311a88d327e2306.tar.gz dexon-sol-tools-3e0c2ad7530927fa1c9019bbc311a88d327e2306.tar.bz2 dexon-sol-tools-3e0c2ad7530927fa1c9019bbc311a88d327e2306.tar.lz dexon-sol-tools-3e0c2ad7530927fa1c9019bbc311a88d327e2306.tar.xz dexon-sol-tools-3e0c2ad7530927fa1c9019bbc311a88d327e2306.tar.zst dexon-sol-tools-3e0c2ad7530927fa1c9019bbc311a88d327e2306.zip |
Merge branch 'fillOrderAsync' into unavailableFilledCancelled
Diffstat (limited to 'test/utils')
-rw-r--r-- | test/utils/fill_scenarios.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/utils/fill_scenarios.ts b/test/utils/fill_scenarios.ts new file mode 100644 index 000000000..ac233ad50 --- /dev/null +++ b/test/utils/fill_scenarios.ts @@ -0,0 +1,29 @@ +import * as BigNumber from 'bignumber.js'; +import {ZeroEx} from '../../src/0x.js'; +import {Token, SignedOrder} from '../../src/types'; +import {orderFactory} from '../utils/order_factory'; + +export class FillScenarios { + private zeroEx: ZeroEx; + private userAddresses: string[]; + private tokens: Token[]; + constructor(zeroEx: ZeroEx, userAddresses: string[], tokens: Token[]) { + this.zeroEx = zeroEx; + this.userAddresses = userAddresses; + this.tokens = tokens; + } + public async createAFillableSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string, + takerAddress: string, fillableAmount: BigNumber.BigNumber, + expirationUnixTimestampSec?: BigNumber.BigNumber): + Promise<SignedOrder> { + const [makerAddress] = this.userAddresses; + await this.zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, fillableAmount); + await this.zeroEx.token.transferAsync(takerTokenAddress, makerAddress, takerAddress, fillableAmount); + await this.zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress, fillableAmount); + + const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, makerAddress, + takerAddress, fillableAmount, makerTokenAddress, fillableAmount, takerTokenAddress, + expirationUnixTimestampSec); + return signedOrder; + } +} |