Fixed ABI coder for no-name indexed parameters in events.

This commit is contained in:
Richard Moore 2018-07-12 02:43:55 -04:00
parent e5d5871b95
commit ee0faba708
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
2 changed files with 27 additions and 1 deletions

@ -82,6 +82,10 @@ function parseParam(param: string, allowIndexed?: boolean): ParamType {
case ')': case ')':
delete node.state; delete node.state;
if (allowIndexed && node.name === 'indexed') {
node.indexed = true;
node.name = '';
}
node.type = verifyType(node.type); node.type = verifyType(node.type);
var child = node; var child = node;
@ -95,6 +99,10 @@ function parseParam(param: string, allowIndexed?: boolean): ParamType {
case ',': case ',':
delete node.state; delete node.state;
if (allowIndexed && node.name === 'indexed') {
node.indexed = true;
node.name = '';
}
node.type = verifyType(node.type); node.type = verifyType(node.type);
var sibling: ParseNode = { type: '', name: '', parent: node.parent, state: { allowType: true } }; 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"); } if (node.parent) { throw new Error("unexpected eof"); }
delete parent.state; delete parent.state;
if (allowIndexed && node.name === 'indexed') {
node.indexed = true;
node.name = '';
}
parent.type = verifyType(parent.type); parent.type = verifyType(parent.type);
return (<ParamType>parent); return (<ParamType>parent);
@ -986,7 +1000,7 @@ export class AbiCoder {
return hexlify(new CoderTuple(this.coerceFunc, coders, '_').encode(values)); return hexlify(new CoderTuple(this.coerceFunc, coders, '_').encode(values));
} }
decode(types: Array<string | ParamType>, data: Arrayish): any { decode(types: Array<string | ParamType>, data: Arrayish): Array<any> {
var coders: Array<Coder> = []; var coders: Array<Coder> = [];
types.forEach(function(type) { types.forEach(function(type) {

@ -68,6 +68,10 @@ function parseParam(param, allowIndexed) {
break; break;
case ')': case ')':
delete node.state; delete node.state;
if (allowIndexed && node.name === 'indexed') {
node.indexed = true;
node.name = '';
}
node.type = verifyType(node.type); node.type = verifyType(node.type);
var child = node; var child = node;
node = node.parent; node = node.parent;
@ -81,6 +85,10 @@ function parseParam(param, allowIndexed) {
break; break;
case ',': case ',':
delete node.state; delete node.state;
if (allowIndexed && node.name === 'indexed') {
node.indexed = true;
node.name = '';
}
node.type = verifyType(node.type); node.type = verifyType(node.type);
var sibling = { type: '', name: '', parent: node.parent, state: { allowType: true } }; var sibling = { type: '', name: '', parent: node.parent, state: { allowType: true } };
node.parent.components.push(sibling); node.parent.components.push(sibling);
@ -151,6 +159,10 @@ function parseParam(param, allowIndexed) {
throw new Error("unexpected eof"); throw new Error("unexpected eof");
} }
delete parent.state; delete parent.state;
if (allowIndexed && node.name === 'indexed') {
node.indexed = true;
node.name = '';
}
parent.type = verifyType(parent.type); parent.type = verifyType(parent.type);
return parent; return parent;
} }