Fix an exception when a signature collision happens

This commit is contained in:
Leonid Logvinov
2018-02-05 12:59:10 +01:00
parent c7ad6ebad6
commit 5458a1c1b7
2 changed files with 18 additions and 5 deletions

View File

@@ -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)

View File

@@ -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) => {