aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-04 20:36:57 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-05 20:35:37 +0800
commite37a3155cd52d35da3eef9a8dc450b9b3df0b888 (patch)
treede2e57b09c63e734d81f7635d7cd9c2ffe2a46de /src
parent542cf7b1cb04cd86da86fc1ff39fdcbd1b9b0403 (diff)
downloaddexon-0x-contracts-e37a3155cd52d35da3eef9a8dc450b9b3df0b888.tar.gz
dexon-0x-contracts-e37a3155cd52d35da3eef9a8dc450b9b3df0b888.tar.zst
dexon-0x-contracts-e37a3155cd52d35da3eef9a8dc450b9b3df0b888.zip
Instantiate logAndBlockStreamer
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/contract_wrapper.ts7
-rw-r--r--src/web3_wrapper.ts8
2 files changed, 13 insertions, 2 deletions
diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts
index 743dfc9b2..927a09b52 100644
--- a/src/contract_wrappers/contract_wrapper.ts
+++ b/src/contract_wrappers/contract_wrapper.ts
@@ -1,6 +1,7 @@
import * as _ from 'lodash';
import * as Web3 from 'web3';
import * as ethUtil from 'ethereumjs-util';
+import {BlockAndLogStreamer} from 'ethereumjs-blockstream';
import {Web3Wrapper} from '../web3_wrapper';
import {AbiDecoder} from '../utils/abi_decoder';
import {
@@ -19,9 +20,15 @@ const TOPIC_LENGTH = 32;
export class ContractWrapper {
protected _web3Wrapper: Web3Wrapper;
private _abiDecoder?: AbiDecoder;
+ private _blockAndLogStreamer: BlockAndLogStreamer;
constructor(web3Wrapper: Web3Wrapper, abiDecoder?: AbiDecoder) {
this._web3Wrapper = web3Wrapper;
this._abiDecoder = abiDecoder;
+ const getBlockAsync = async (hash: string) => this._web3Wrapper.getBlockAsync(hash);
+ this._blockAndLogStreamer = new BlockAndLogStreamer(
+ this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
+ this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
+ );
}
protected async _getLogsAsync(address: string, eventName: ContractEvents, subscriptionOpts: SubscriptionOpts,
indexFilterValues: IndexedFilterValues,
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index 7576f3d40..fd9b74b8b 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -94,8 +94,12 @@ export class Web3Wrapper {
const signData = await promisify(this.web3.eth.sign)(address, message);
return signData;
}
- public async getBlockTimestampAsync(blockHash: string): Promise<number> {
- const {timestamp} = await promisify(this.web3.eth.getBlock)(blockHash);
+ public async getBlockAsync(blockParam: string|Web3.BlockParam): Promise<Web3.BlockWithoutTransactionData> {
+ const block = await promisify(this.web3.eth.getBlock)(blockParam);
+ return block;
+ }
+ public async getBlockTimestampAsync(blockParam: string|Web3.BlockParam): Promise<number> {
+ const {timestamp} = await this.getBlockAsync(blockParam);
return timestamp;
}
public async getAvailableAddressesAsync(): Promise<string[]> {