diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/contract_wrappers/contract_wrapper.ts | 7 | ||||
-rw-r--r-- | src/web3_wrapper.ts | 8 |
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[]> { |