From 21f7722f1023cc9d1848737b7c986f7df7a07122 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 11 Jun 2018 19:21:32 +0200 Subject: Move OrderValidationUtils (+ tests) and ExchangeTransferSimulator to order-utils --- ...le_erc20_balance_and_proxy_allowance_fetcher.ts | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts (limited to 'packages/order-utils/test/utils/simple_erc20_balance_and_proxy_allowance_fetcher.ts') 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 { + // 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 { + // 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; + } +} -- cgit v1.2.3