From ee0faba708072fd83d73d22069b71c86988ccbfc Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Thu, 12 Jul 2018 02:43:55 -0400 Subject: [PATCH] Fixed ABI coder for no-name indexed parameters in events. --- src.ts/utils/abi-coder.ts | 16 +++++++++++++++- utils/abi-coder.js | 12 ++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src.ts/utils/abi-coder.ts b/src.ts/utils/abi-coder.ts index 171e0ff0a..14b7e6099 100644 --- a/src.ts/utils/abi-coder.ts +++ b/src.ts/utils/abi-coder.ts @@ -82,6 +82,10 @@ function parseParam(param: string, allowIndexed?: boolean): ParamType { case ')': delete node.state; + if (allowIndexed && node.name === 'indexed') { + node.indexed = true; + node.name = ''; + } node.type = verifyType(node.type); var child = node; @@ -95,6 +99,10 @@ function parseParam(param: string, allowIndexed?: boolean): ParamType { case ',': delete node.state; + if (allowIndexed && node.name === 'indexed') { + node.indexed = true; + node.name = ''; + } node.type = verifyType(node.type); var sibling: ParseNode = { type: '', name: '', parent: node.parent, state: { allowType: true } }; @@ -169,6 +177,12 @@ function parseParam(param: string, allowIndexed?: boolean): ParamType { if (node.parent) { throw new Error("unexpected eof"); } delete parent.state; + + if (allowIndexed && node.name === 'indexed') { + node.indexed = true; + node.name = ''; + } + parent.type = verifyType(parent.type); return (parent); @@ -986,7 +1000,7 @@ export class AbiCoder { return hexlify(new CoderTuple(this.coerceFunc, coders, '_').encode(values)); } - decode(types: Array, data: Arrayish): any { + decode(types: Array, data: Arrayish): Array { var coders: Array = []; types.forEach(function(type) { diff --git a/utils/abi-coder.js b/utils/abi-coder.js index f8171cca7..e853ebad6 100644 --- a/utils/abi-coder.js +++ b/utils/abi-coder.js @@ -68,6 +68,10 @@ function parseParam(param, allowIndexed) { break; case ')': delete node.state; + if (allowIndexed && node.name === 'indexed') { + node.indexed = true; + node.name = ''; + } node.type = verifyType(node.type); var child = node; node = node.parent; @@ -81,6 +85,10 @@ function parseParam(param, allowIndexed) { break; case ',': delete node.state; + if (allowIndexed && node.name === 'indexed') { + node.indexed = true; + node.name = ''; + } node.type = verifyType(node.type); var sibling = { type: '', name: '', parent: node.parent, state: { allowType: true } }; node.parent.components.push(sibling); @@ -151,6 +159,10 @@ function parseParam(param, allowIndexed) { throw new Error("unexpected eof"); } delete parent.state; + if (allowIndexed && node.name === 'indexed') { + node.indexed = true; + node.name = ''; + } parent.type = verifyType(parent.type); return parent; }