diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-05 19:59:10 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-05 19:59:10 +0800 |
commit | 5458a1c1b741fb2ccb477cf2ac0ba81d4e351402 (patch) | |
tree | 81accda2213d4acbb4a71e69a5c59fde7df3e99f /packages | |
parent | c7ad6ebad6ab65a4b1e4a2084e744c6ca2bc09b8 (diff) | |
download | dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.tar.gz dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.tar.zst dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.zip |
Fix an exception when a signature collision happens
Diffstat (limited to 'packages')
-rw-r--r-- | packages/0x.js/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/utils/src/abi_decoder.ts | 19 |
2 files changed, 18 insertions, 5 deletions
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) => { |