aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/balance_proxy_allowance_lazy_store.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-11 01:12:30 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-13 09:03:18 +0800
commit6edae865168dc86a5a3b39558158d22a4ff3bd99 (patch)
tree9a22715c9b5d060dbac6d79f6c595e834e59a41f /src/stores/balance_proxy_allowance_lazy_store.ts
parentf163e6d8cc53dbbfd65168c977aa53c5ab9b3c08 (diff)
downloaddexon-sol-tools-6edae865168dc86a5a3b39558158d22a4ff3bd99.tar
dexon-sol-tools-6edae865168dc86a5a3b39558158d22a4ff3bd99.tar.gz
dexon-sol-tools-6edae865168dc86a5a3b39558158d22a4ff3bd99.tar.bz2
dexon-sol-tools-6edae865168dc86a5a3b39558158d22a4ff3bd99.tar.lz
dexon-sol-tools-6edae865168dc86a5a3b39558158d22a4ff3bd99.tar.xz
dexon-sol-tools-6edae865168dc86a5a3b39558158d22a4ff3bd99.tar.zst
dexon-sol-tools-6edae865168dc86a5a3b39558158d22a4ff3bd99.zip
Make store configurable by blockParam
Diffstat (limited to 'src/stores/balance_proxy_allowance_lazy_store.ts')
-rw-r--r--src/stores/balance_proxy_allowance_lazy_store.ts15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/stores/balance_proxy_allowance_lazy_store.ts b/src/stores/balance_proxy_allowance_lazy_store.ts
index 7f392cb82..2580fd449 100644
--- a/src/stores/balance_proxy_allowance_lazy_store.ts
+++ b/src/stores/balance_proxy_allowance_lazy_store.ts
@@ -1,4 +1,5 @@
import * as _ from 'lodash';
+import * as Web3 from 'web3';
import {BigNumber} from 'bignumber.js';
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
@@ -7,6 +8,7 @@ import {TokenWrapper} from '../contract_wrappers/token_wrapper';
*/
export class BalanceAndProxyAllowanceLazyStore {
private token: TokenWrapper;
+ private defaultBlock: Web3.BlockParam;
private balance: {
[tokenAddress: string]: {
[userAddress: string]: BigNumber,
@@ -17,14 +19,18 @@ export class BalanceAndProxyAllowanceLazyStore {
[userAddress: string]: BigNumber,
},
};
- constructor(token: TokenWrapper) {
+ constructor(token: TokenWrapper, defaultBlock: Web3.BlockParam) {
this.token = token;
+ this.defaultBlock = defaultBlock;
this.balance = {};
this.proxyAllowance = {};
}
public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
if (_.isUndefined(this.balance[tokenAddress]) || _.isUndefined(this.balance[tokenAddress][userAddress])) {
- const balance = await this.token.getBalanceAsync(tokenAddress, userAddress);
+ const methodOpts = {
+ defaultBlock: this.defaultBlock,
+ };
+ const balance = await this.token.getBalanceAsync(tokenAddress, userAddress, methodOpts);
this.setBalance(tokenAddress, userAddress, balance);
}
const cachedBalance = this.balance[tokenAddress][userAddress];
@@ -39,7 +45,10 @@ export class BalanceAndProxyAllowanceLazyStore {
public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
if (_.isUndefined(this.proxyAllowance[tokenAddress]) ||
_.isUndefined(this.proxyAllowance[tokenAddress][userAddress])) {
- const proxyAllowance = await this.token.getProxyAllowanceAsync(tokenAddress, userAddress);
+ const methodOpts = {
+ defaultBlock: this.defaultBlock,
+ };
+ const proxyAllowance = await this.token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance);
}
const cachedProxyAllowance = this.proxyAllowance[tokenAddress][userAddress];