diff options
author | Jacob Evans <dekz@dekz.net> | 2018-02-06 08:36:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-06 08:36:46 +0800 |
commit | 7e9ae458e2f180e27f591856aef4b712f1f2308b (patch) | |
tree | dd534a87dd00076d158be327ddfe91966a737969 /packages/utils/src/abi_decoder.ts | |
parent | 4e284f5e6cbe48b307f3d3163dd7f158c56a5e82 (diff) | |
parent | 2205e2b9a0dab345a14724731098043d04827c4f (diff) | |
download | dexon-sol-tools-7e9ae458e2f180e27f591856aef4b712f1f2308b.tar dexon-sol-tools-7e9ae458e2f180e27f591856aef4b712f1f2308b.tar.gz dexon-sol-tools-7e9ae458e2f180e27f591856aef4b712f1f2308b.tar.bz2 dexon-sol-tools-7e9ae458e2f180e27f591856aef4b712f1f2308b.tar.lz dexon-sol-tools-7e9ae458e2f180e27f591856aef4b712f1f2308b.tar.xz dexon-sol-tools-7e9ae458e2f180e27f591856aef4b712f1f2308b.tar.zst dexon-sol-tools-7e9ae458e2f180e27f591856aef4b712f1f2308b.zip |
Merge branch 'development' into feature/subproviders/nonce-tracker
Diffstat (limited to 'packages/utils/src/abi_decoder.ts')
-rw-r--r-- | packages/utils/src/abi_decoder.ts | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts index f96ee2edb..368973b1b 100644 --- a/packages/utils/src/abi_decoder.ts +++ b/packages/utils/src/abi_decoder.ts @@ -18,7 +18,7 @@ export class AbiDecoder { return `0x${formatted}`; } constructor(abiArrays: Web3.AbiDefinition[][]) { - _.map(abiArrays, this._addABI.bind(this)); + _.forEach(abiArrays, this._addABI.bind(this)); } // This method can only decode logs from the 0x & ERC20 smart contracts public tryToDecodeLogOrNoop<ArgsType>(log: Web3.LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { @@ -36,9 +36,14 @@ export class AbiDecoder { const dataTypes = _.map(nonIndexedInputs, input => input.type); const decodedData = SolidityCoder.decodeParams(dataTypes, logData.slice('0x'.length)); - _.map(event.inputs, (param: Web3.EventParameter) => { + let failedToDecode = false; + _.forEach(event.inputs, (param: Web3.EventParameter) => { // Indexed parameters are stored in topics. Non-indexed ones in decodedData let value: BigNumber | string = param.indexed ? log.topics[topicsIndex++] : decodedData[dataIndex++]; + if (_.isUndefined(value)) { + failedToDecode = true; + return; + } if (param.type === SolidityTypes.Address) { value = AbiDecoder._padZeros(new BigNumber(value).toString(16)); } else if ( @@ -51,11 +56,15 @@ export class AbiDecoder { decodedParams[param.name] = value; }); - return { - ...log, - event: event.name, - args: decodedParams, - }; + if (failedToDecode) { + return log; + } else { + return { + ...log, + event: event.name, + args: decodedParams, + }; + } } private _addABI(abiArray: Web3.AbiDefinition[]): void { _.map(abiArray, (abi: Web3.AbiDefinition) => { |