aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/order_filled_cancelled_lazy_store.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-11 04:03:53 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-13 09:03:18 +0800
commit70436fa535f51eca5c1b5951e1218e72f9a767e0 (patch)
tree00b092d7fc5b62d72efcf0ab5b89f180ae5c099b /src/stores/order_filled_cancelled_lazy_store.ts
parent4921f61e76d2e6f1b2c8718766a7e93e11ad4671 (diff)
downloaddexon-sol-tools-70436fa535f51eca5c1b5951e1218e72f9a767e0.tar
dexon-sol-tools-70436fa535f51eca5c1b5951e1218e72f9a767e0.tar.gz
dexon-sol-tools-70436fa535f51eca5c1b5951e1218e72f9a767e0.tar.bz2
dexon-sol-tools-70436fa535f51eca5c1b5951e1218e72f9a767e0.tar.lz
dexon-sol-tools-70436fa535f51eca5c1b5951e1218e72f9a767e0.tar.xz
dexon-sol-tools-70436fa535f51eca5c1b5951e1218e72f9a767e0.tar.zst
dexon-sol-tools-70436fa535f51eca5c1b5951e1218e72f9a767e0.zip
Make stores accept numConfirmations and blockStore instead of defaultBlock
Diffstat (limited to 'src/stores/order_filled_cancelled_lazy_store.ts')
-rw-r--r--src/stores/order_filled_cancelled_lazy_store.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/stores/order_filled_cancelled_lazy_store.ts b/src/stores/order_filled_cancelled_lazy_store.ts
index cb4c786f3..978de0b18 100644
--- a/src/stores/order_filled_cancelled_lazy_store.ts
+++ b/src/stores/order_filled_cancelled_lazy_store.ts
@@ -2,29 +2,33 @@ import * as _ from 'lodash';
import * as Web3 from 'web3';
import {BigNumber} from 'bignumber.js';
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
+import {BlockStore} from './block_store';
/**
* Copy on read store for filled/cancelled taker amounts
*/
export class OrderFilledCancelledLazyStore {
private exchange: ExchangeWrapper;
- private defaultBlock: Web3.BlockParam;
+ private numConfirmations: number;
+ private blockStore: BlockStore;
private filledTakerAmount: {
[orderHash: string]: BigNumber,
};
private cancelledTakerAmount: {
[orderHash: string]: BigNumber,
};
- constructor(exchange: ExchangeWrapper, defaultBlock: Web3.BlockParam) {
+ constructor(exchange: ExchangeWrapper, blockStore: BlockStore, numConfirmations: number) {
this.exchange = exchange;
- this.defaultBlock = defaultBlock;
+ this.numConfirmations = numConfirmations;
+ this.blockStore = blockStore;
this.filledTakerAmount = {};
this.cancelledTakerAmount = {};
}
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
if (_.isUndefined(this.filledTakerAmount[orderHash])) {
+ const defaultBlock = this.blockStore.getBlockNumberWithNConfirmations(this.numConfirmations);
const methodOpts = {
- defaultBlock: this.defaultBlock,
+ defaultBlock,
};
const filledTakerAmount = await this.exchange.getFilledTakerAmountAsync(orderHash, methodOpts);
this.setFilledTakerAmount(orderHash, filledTakerAmount);
@@ -40,8 +44,9 @@ export class OrderFilledCancelledLazyStore {
}
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
if (_.isUndefined(this.cancelledTakerAmount[orderHash])) {
+ const defaultBlock = this.blockStore.getBlockNumberWithNConfirmations(this.numConfirmations);
const methodOpts = {
- defaultBlock: this.defaultBlock,
+ defaultBlock,
};
const cancelledTakerAmount = await this.exchange.getCanceledTakerAmountAsync(orderHash, methodOpts);
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);