aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test/utils/fill_scenarios.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-12-14 22:31:37 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-12-14 22:47:03 +0800
commit28c409fc6d635ee8ed1430d97d9bbdde2f613e37 (patch)
tree419b94ff1d080c279ebe0ce94a87a42aeb20f746 /packages/0x.js/test/utils/fill_scenarios.ts
parent449a04d39ce49ac06e0de989dcbefe6f4a7d2e84 (diff)
downloaddexon-sol-tools-28c409fc6d635ee8ed1430d97d9bbdde2f613e37.tar.gz
dexon-sol-tools-28c409fc6d635ee8ed1430d97d9bbdde2f613e37.tar.zst
dexon-sol-tools-28c409fc6d635ee8ed1430d97d9bbdde2f613e37.zip
Add a function to init token balances
Diffstat (limited to 'packages/0x.js/test/utils/fill_scenarios.ts')
-rw-r--r--packages/0x.js/test/utils/fill_scenarios.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/0x.js/test/utils/fill_scenarios.ts b/packages/0x.js/test/utils/fill_scenarios.ts
index 090493935..bcaa63c78 100644
--- a/packages/0x.js/test/utils/fill_scenarios.ts
+++ b/packages/0x.js/test/utils/fill_scenarios.ts
@@ -1,10 +1,15 @@
+import {Web3Wrapper} from '@0xproject/web3-wrapper';
import BigNumber from 'bignumber.js';
import {SignedOrder, Token, ZeroEx} from '../../src';
+import {artifacts} from '../../src/artifacts';
+import {DummyTokenContract} from '../../src/contract_wrappers/generated/dummy_token';
import {orderFactory} from '../utils/order_factory';
import {constants} from './constants';
+const INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS = new BigNumber(100);
+
export class FillScenarios {
private zeroEx: ZeroEx;
private userAddresses: string[];
@@ -21,6 +26,26 @@ export class FillScenarios {
this.zrxTokenAddress = zrxTokenAddress;
this.exchangeContractAddress = exchangeContractAddress;
}
+ public async initTokenBalancesAsync() {
+ const web3Wrapper = (this.zeroEx as any)._web3Wrapper as Web3Wrapper;
+ for (const token of this.tokens) {
+ if (token.symbol === 'WETH') {
+ // _.noop
+ } else if (token.symbol !== 'ZRX') {
+ const contractInstance = web3Wrapper.getContractInstance(
+ artifacts.DummyTokenArtifact.abi, token.address,
+ );
+ const dummyToken = new DummyTokenContract(contractInstance, {});
+ const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals);
+ const txHash = await dummyToken.setBalance.sendTransactionAsync(this.coinbase, tokenSupply, {
+ from: this.coinbase,
+ });
+ await this.zeroEx.awaitTransactionMinedAsync(txHash);
+ } else {
+ // no-op
+ }
+ }
+ }
public async createFillableSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string,
makerAddress: string, takerAddress: string,
fillableAmount: BigNumber,