From 5458a1c1b741fb2ccb477cf2ac0ba81d4e351402 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 5 Feb 2018 12:59:10 +0100 Subject: Fix an exception when a signature collision happens --- packages/0x.js/CHANGELOG.md | 4 ++++ packages/utils/src/abi_decoder.ts | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'packages') diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 5250402c6..eef6f3642 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v0.x.x - _TBD, 2018_ + + * Fixed the bug causing order watcher to throw if there is the event with the same signature but different indexed fields (#) + ## v0.31.1 - _February 1, 2018_ * Fix the bug causing order watcher to throw is makerToken === zrx (#357) diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts index f96ee2edb..2dd7134a7 100644 --- a/packages/utils/src/abi_decoder.ts +++ b/packages/utils/src/abi_decoder.ts @@ -36,9 +36,14 @@ export class AbiDecoder { const dataTypes = _.map(nonIndexedInputs, input => input.type); const decodedData = SolidityCoder.decodeParams(dataTypes, logData.slice('0x'.length)); + let failedToDecode = false; _.map(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) => { -- cgit v1.2.3