Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fix event params decoding when no names for parameters #5409 (#5567)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngotchac authored and jacogr committed May 9, 2017
1 parent 1288b4b commit c5116e5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions js/src/abi/spec/event/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 3 additions & 2 deletions js/src/api/contract/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion js/src/views/Contract/Events/Event/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<TypedInput
allowCopy
className={ styles.input }
label={ name }
label={ label }
param={ param.type }
readOnly
value={ param.value }
Expand Down

0 comments on commit c5116e5

Please sign in to comment.