diff options
Diffstat (limited to 'packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts')
-rw-r--r-- | packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts index ede1319fe..c8395415e 100644 --- a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts +++ b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts @@ -3,12 +3,13 @@ import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import { TokenWrapper } from '../contract_wrappers/token_wrapper'; +import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher'; /** * Copy on read store for balances/proxyAllowances of tokens/accounts */ -export class BalanceAndProxyAllowanceLazyStore { - private _token: TokenWrapper; +export class BalanceAndProxyAllowanceLazyStore implements BalanceAndProxyAllowanceFetcher { + private _tokenWrapper: TokenWrapper; private _defaultBlock: BlockParamLiteral; private _balance: { [tokenAddress: string]: { @@ -21,7 +22,7 @@ export class BalanceAndProxyAllowanceLazyStore { }; }; constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) { - this._token = token; + this._tokenWrapper = token; this._defaultBlock = defaultBlock; this._balance = {}; this._proxyAllowance = {}; @@ -31,7 +32,7 @@ export class BalanceAndProxyAllowanceLazyStore { const methodOpts = { defaultBlock: this._defaultBlock, }; - const balance = await this._token.getBalanceAsync(tokenAddress, userAddress, methodOpts); + const balance = await this._tokenWrapper.getBalanceAsync(tokenAddress, userAddress, methodOpts); this.setBalance(tokenAddress, userAddress, balance); } const cachedBalance = this._balance[tokenAddress][userAddress]; @@ -59,7 +60,7 @@ export class BalanceAndProxyAllowanceLazyStore { const methodOpts = { defaultBlock: this._defaultBlock, }; - const proxyAllowance = await this._token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts); + const proxyAllowance = await this._tokenWrapper.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts); this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance); } const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress]; |