diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-13 17:52:59 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-13 17:52:59 +0800 |
commit | 0eaca6c691d92a10b08c0e69306291aa8de06bfb (patch) | |
tree | ffa00109b4115025b8be35822abbbbd4ddb05155 /src/utils | |
parent | ba654c04a086b8c4ce4330b3d6064716a4090599 (diff) | |
download | dexon-0x-contracts-0eaca6c691d92a10b08c0e69306291aa8de06bfb.tar.gz dexon-0x-contracts-0eaca6c691d92a10b08c0e69306291aa8de06bfb.tar.zst dexon-0x-contracts-0eaca6c691d92a10b08c0e69306291aa8de06bfb.zip |
Make logs fetching and sunscriptions more type-safe
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/abi_decoder.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/utils/abi_decoder.ts b/src/utils/abi_decoder.ts index 52b114c12..a6c45bee7 100644 --- a/src/utils/abi_decoder.ts +++ b/src/utils/abi_decoder.ts @@ -1,7 +1,7 @@ import * as Web3 from 'web3'; import * as _ from 'lodash'; import * as BigNumber from 'bignumber.js'; -import {AbiType, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes} from '../types'; +import {AbiType, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes, ContractEventArgs} from '../types'; import * as SolidityCoder from 'web3/lib/solidity/coder'; export class AbiDecoder { @@ -11,7 +11,8 @@ export class AbiDecoder { _.map(abiArrays, this.addABI.bind(this)); } // This method can only decode logs from the 0x smart contracts - public tryToDecodeLogOrNoop(log: Web3.LogEntry): LogWithDecodedArgs|RawLog { + public tryToDecodeLogOrNoop<ArgsType extends ContractEventArgs>( + log: Web3.LogEntry): LogWithDecodedArgs<ArgsType>|RawLog { const methodId = log.topics[0]; const event = this.methodIds[methodId]; if (_.isUndefined(event)) { |