aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-10 12:16:26 +0800
committerFabio Berger <me@fabioberger.com>2017-11-10 12:16:26 +0800
commit0205f9ede337e5574245b45e1ee940b8ace89456 (patch)
treeec81269d3beb7b4ba51d8810eea1f450593f8272
parent960c83315b60398df7ca7ac0a3f4ae5dde7771f1 (diff)
downloaddexon-sol-tools-0205f9ede337e5574245b45e1ee940b8ace89456.tar.gz
dexon-sol-tools-0205f9ede337e5574245b45e1ee940b8ace89456.tar.zst
dexon-sol-tools-0205f9ede337e5574245b45e1ee940b8ace89456.zip
Simplify to/from block code
-rw-r--r--src/order_watcher/event_watcher.ts13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/order_watcher/event_watcher.ts b/src/order_watcher/event_watcher.ts
index 786470f1d..2a1b6dacf 100644
--- a/src/order_watcher/event_watcher.ts
+++ b/src/order_watcher/event_watcher.ts
@@ -53,19 +53,16 @@ export class EventWatcher {
this._lastEvents = pendingEvents;
}
private async _getEventsAsync(): Promise<Web3.LogEntry[]> {
- let fromBlock: BlockParamLiteral|number;
- let toBlock: BlockParamLiteral|number;
+ let latestBlock: BlockParamLiteral|number;
if (this._numConfirmations === 0) {
- fromBlock = BlockParamLiteral.Pending;
- toBlock = fromBlock;
+ latestBlock = BlockParamLiteral.Pending;
} else {
const currentBlock = await this._web3Wrapper.getBlockNumberAsync();
- toBlock = currentBlock - this._numConfirmations;
- fromBlock = toBlock;
+ latestBlock = currentBlock - this._numConfirmations;
}
const eventFilter = {
- fromBlock,
- toBlock,
+ fromBlock: latestBlock,
+ toBlock: latestBlock,
};
const events = await this._web3Wrapper.getLogsAsync(eventFilter);
return events;