Fix event params decoding when no names for parameters #5409 (#5567)

This commit is contained in:
Nicolas Gotchac 2017-05-09 12:56:08 +02:00 committed by Jaco Greeff
parent 1288b4b28f
commit c5116e5049
3 changed files with 12 additions and 6 deletions

View File

@ -99,15 +99,15 @@ export default class Event {
const namedTokens = {}; const namedTokens = {};
topicParams.forEach((param, idx) => { topicParams.forEach((param, idx) => {
namedTokens[param.name] = topicTokens[idx]; namedTokens[param.name || idx] = topicTokens[idx];
}); });
dataParams.forEach((param, idx) => { dataParams.forEach((param, idx) => {
namedTokens[param.name] = dataTokens[idx]; namedTokens[param.name || idx] = dataTokens[idx];
}); });
const inputParamTypes = this.inputParamTypes(); const inputParamTypes = this.inputParamTypes();
const decodedParams = this.inputParamNames() 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); return new DecodedLog(decodedParams, address);
} }

View File

@ -182,10 +182,11 @@ export default class Contract {
log.params = {}; log.params = {};
log.event = event.name; log.event = event.name;
decoded.params.forEach((param) => { decoded.params.forEach((param, index) => {
const { type, value } = param.token; const { type, value } = param.token;
const key = param.name || index;
log.params[param.name] = { type, value }; log.params[key] = { type, value };
}); });
return log; return log;

View File

@ -112,11 +112,16 @@ export default class Event extends Component {
} }
renderParam (name, param) { 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 ( return (
<TypedInput <TypedInput
allowCopy allowCopy
className={ styles.input } className={ styles.input }
label={ name } label={ label }
param={ param.type } param={ param.type }
readOnly readOnly
value={ param.value } value={ param.value }