aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-05 19:59:10 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-05 19:59:10 +0800
commit5458a1c1b741fb2ccb477cf2ac0ba81d4e351402 (patch)
tree81accda2213d4acbb4a71e69a5c59fde7df3e99f /packages/utils
parentc7ad6ebad6ab65a4b1e4a2084e744c6ca2bc09b8 (diff)
downloaddexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.tar
dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.tar.gz
dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.tar.bz2
dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.tar.lz
dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.tar.xz
dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.tar.zst
dexon-0x-contracts-5458a1c1b741fb2ccb477cf2ac0ba81d4e351402.zip
Fix an exception when a signature collision happens
Diffstat (limited to 'packages/utils')
-rw-r--r--packages/utils/src/abi_decoder.ts19
1 files changed, 14 insertions, 5 deletions
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) => {