diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-08 00:00:13 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-08 00:00:13 +0800 |
commit | ab5e021bda5cc8e39d8595580c09c3540a09aff5 (patch) | |
tree | e40c3be709d10e1a2463cb0807419c7b276f1548 /packages/contracts/src/utils/simple_erc20_balance_and_allowance_fetcher.ts | |
parent | 0fc981400442e4c567ca363bdf0f4c03ba87473d (diff) | |
download | dexon-sol-tools-ab5e021bda5cc8e39d8595580c09c3540a09aff5.tar dexon-sol-tools-ab5e021bda5cc8e39d8595580c09c3540a09aff5.tar.gz dexon-sol-tools-ab5e021bda5cc8e39d8595580c09c3540a09aff5.tar.bz2 dexon-sol-tools-ab5e021bda5cc8e39d8595580c09c3540a09aff5.tar.lz dexon-sol-tools-ab5e021bda5cc8e39d8595580c09c3540a09aff5.tar.xz dexon-sol-tools-ab5e021bda5cc8e39d8595580c09c3540a09aff5.tar.zst dexon-sol-tools-ab5e021bda5cc8e39d8595580c09c3540a09aff5.zip |
POC: Generates an order from spec, get's the amount fillable
Diffstat (limited to 'packages/contracts/src/utils/simple_erc20_balance_and_allowance_fetcher.ts')
-rw-r--r-- | packages/contracts/src/utils/simple_erc20_balance_and_allowance_fetcher.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/contracts/src/utils/simple_erc20_balance_and_allowance_fetcher.ts b/packages/contracts/src/utils/simple_erc20_balance_and_allowance_fetcher.ts new file mode 100644 index 000000000..6eed9227a --- /dev/null +++ b/packages/contracts/src/utils/simple_erc20_balance_and_allowance_fetcher.ts @@ -0,0 +1,20 @@ +import { AbstractBalanceAndProxyAllowanceFetcher } from '@0xproject/order-utils'; +import { BigNumber } from '@0xproject/utils'; + +import { ERC20Wrapper } from './erc20_wrapper'; + +// TODO(fabio): Refactor this to also work for ERC721! +export class SimpleERC20BalanceAndProxyAllowanceFetcher implements AbstractBalanceAndProxyAllowanceFetcher { + private _erc20TokenWrapper: ERC20Wrapper; + constructor(erc20TokenWrapper: ERC20Wrapper) { + this._erc20TokenWrapper = erc20TokenWrapper; + } + public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> { + const balance = await this._erc20TokenWrapper.getBalanceAsync(userAddress, tokenAddress); + return balance; + } + public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> { + const proxyAllowance = await this._erc20TokenWrapper.getProxyAllowanceAsync(userAddress, tokenAddress); + return proxyAllowance; + } +} |