From c5116e5049016eb65b50c92d3d84b6a5f8a2c08a Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Tue, 9 May 2017 12:56:08 +0200 Subject: [PATCH] Fix event params decoding when no names for parameters #5409 (#5567) --- js/src/abi/spec/event/event.js | 6 +++--- js/src/api/contract/contract.js | 5 +++-- js/src/views/Contract/Events/Event/event.js | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/js/src/abi/spec/event/event.js b/js/src/abi/spec/event/event.js index 071a73965..604f58cb1 100644 --- a/js/src/abi/spec/event/event.js +++ b/js/src/abi/spec/event/event.js @@ -99,15 +99,15 @@ export default class Event { const namedTokens = {}; topicParams.forEach((param, idx) => { - namedTokens[param.name] = topicTokens[idx]; + namedTokens[param.name || idx] = topicTokens[idx]; }); dataParams.forEach((param, idx) => { - namedTokens[param.name] = dataTokens[idx]; + namedTokens[param.name || idx] = dataTokens[idx]; }); const inputParamTypes = this.inputParamTypes(); const decodedParams = this.inputParamNames() - .map((name, idx) => new DecodedLogParam(name, inputParamTypes[idx], namedTokens[name])); + .map((name, idx) => new DecodedLogParam(name, inputParamTypes[idx], namedTokens[name || idx])); return new DecodedLog(decodedParams, address); } diff --git a/js/src/api/contract/contract.js b/js/src/api/contract/contract.js index 2156b8af1..0aff05684 100644 --- a/js/src/api/contract/contract.js +++ b/js/src/api/contract/contract.js @@ -182,10 +182,11 @@ export default class Contract { log.params = {}; log.event = event.name; - decoded.params.forEach((param) => { + decoded.params.forEach((param, index) => { const { type, value } = param.token; + const key = param.name || index; - log.params[param.name] = { type, value }; + log.params[key] = { type, value }; }); return log; diff --git a/js/src/views/Contract/Events/Event/event.js b/js/src/views/Contract/Events/Event/event.js index eb370e7f1..fc2436f8e 100644 --- a/js/src/views/Contract/Events/Event/event.js +++ b/js/src/views/Contract/Events/Event/event.js @@ -112,11 +112,16 @@ export default class Event extends Component { } renderParam (name, param) { + // Don't add a label id the name is an index key (ie. a Number) + const label = parseInt(name).toString() === name.toString() + ? undefined + : name; + return (