diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-12 01:21:32 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-12 01:21:32 +0800 |
commit | 21f7722f1023cc9d1848737b7c986f7df7a07122 (patch) | |
tree | a4b9c57fa75fb8c92bf44ed968df8b7112f478de /packages/order-utils/test/utils | |
parent | e4afe603f9c4dd5128f2446f9fe075516a3d4894 (diff) | |
download | dexon-0x-contracts-21f7722f1023cc9d1848737b7c986f7df7a07122.tar dexon-0x-contracts-21f7722f1023cc9d1848737b7c986f7df7a07122.tar.gz dexon-0x-contracts-21f7722f1023cc9d1848737b7c986f7df7a07122.tar.bz2 dexon-0x-contracts-21f7722f1023cc9d1848737b7c986f7df7a07122.tar.lz dexon-0x-contracts-21f7722f1023cc9d1848737b7c986f7df7a07122.tar.xz dexon-0x-contracts-21f7722f1023cc9d1848737b7c986f7df7a07122.tar.zst dexon-0x-contracts-21f7722f1023cc9d1848737b7c986f7df7a07122.zip |
Move OrderValidationUtils (+ tests) and ExchangeTransferSimulator to order-utils
Diffstat (limited to 'packages/order-utils/test/utils')
-rw-r--r-- | packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts b/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts new file mode 100644 index 000000000..29b9a128b --- /dev/null +++ b/packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts @@ -0,0 +1,26 @@ +import { BigNumber } from '@0xproject/utils'; + +import { AbstractBalanceAndProxyAllowanceFetcher } from '../../src/abstract/abstract_balance_and_proxy_allowance_fetcher'; + +import { ERC20TokenContract } from '../../src/generated_contract_wrappers/e_r_c20_token'; + +export class SimpleERC20BalanceAndProxyAllowanceFetcher implements AbstractBalanceAndProxyAllowanceFetcher { + private _erc20TokenContract: ERC20TokenContract; + private _erc20ProxyAddress: string; + constructor(erc20TokenWrapper: ERC20TokenContract, erc20ProxyAddress: string) { + this._erc20TokenContract = erc20TokenWrapper; + this._erc20ProxyAddress = erc20ProxyAddress; + } + public async getBalanceAsync(assetData: string, userAddress: string): Promise<BigNumber> { + // HACK: We cheat and don't pass in the userData since it's always the same token used + // in our tests. + const balance = await this._erc20TokenContract.balanceOf.callAsync(userAddress); + return balance; + } + public async getProxyAllowanceAsync(assetData: string, userAddress: string): Promise<BigNumber> { + // HACK: We cheat and don't pass in the userData since it's always the same token used + // in our tests. + const proxyAllowance = await this._erc20TokenContract.allowance.callAsync(userAddress, this._erc20ProxyAddress); + return proxyAllowance; + } +} |