From ed7bc34db5dd31413a3cf2afd706a4df00917c61 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 23 Nov 2018 11:53:34 +0100 Subject: [PATCH] fix and rename makeFullTypeDefinition --- remix-lib/src/execution/txFormat.js | 2 +- remix-lib/src/execution/txHelper.js | 11 +++++------ remix-lib/src/execution/txListener.js | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/remix-lib/src/execution/txFormat.js b/remix-lib/src/execution/txFormat.js index 4048c85c13..b462700866 100644 --- a/remix-lib/src/execution/txFormat.js +++ b/remix-lib/src/execution/txFormat.js @@ -364,7 +364,7 @@ module.exports = { var outputTypes = [] for (i = 0; i < fnabi.outputs.length; i++) { var type = fnabi.outputs[i].type - outputTypes.push(type.indexOf('tuple') === 0 ? helper.makeFullTupleTypeDefinition(fnabi.outputs[i]) : type) + outputTypes.push(type.indexOf('tuple') === 0 ? helper.makeFullTypeDefinition(fnabi.outputs[i]) : type) } if (!response.length) response = new Uint8Array(32 * fnabi.outputs.length) // ensuring the data is at least filled by 0 cause `AbiCoder` throws if there's not engouh data diff --git a/remix-lib/src/execution/txHelper.js b/remix-lib/src/execution/txHelper.js index 49bfd244f3..954a311c66 100644 --- a/remix-lib/src/execution/txHelper.js +++ b/remix-lib/src/execution/txHelper.js @@ -2,9 +2,9 @@ var ethers = require('ethers') module.exports = { - makeFullTupleTypeDefinition: function (typeDef) { + makeFullTypeDefinition: function (typeDef) { if (typeDef && typeDef.type.indexOf('tuple') === 0 && typeDef.components) { - var innerTypes = typeDef.components.map((innerType) => innerType.type) + var innerTypes = typeDef.components.map((innerType) => { return this.makeFullTypeDefinition(innerType) }) return `tuple(${innerTypes.join(',')})${this.extractSize(typeDef.type)}` } return typeDef.type @@ -15,7 +15,7 @@ module.exports = { if (funABI.inputs && funABI.inputs.length) { for (var i = 0; i < funABI.inputs.length; i++) { var type = funABI.inputs[i].type - types.push(type.indexOf('tuple') === 0 ? this.makeFullTupleTypeDefinition(funABI.inputs[i]) : type) + types.push(type.indexOf('tuple') === 0 ? this.makeFullTypeDefinition(funABI.inputs[i]) : type) if (args.length < types.length) { args.push('') } @@ -95,9 +95,8 @@ module.exports = { var fn = abi[i] if (fn.type === 'function' && fnName === fn.name + '(' + fn.inputs.map((value) => { if (value.components) { - // we extract the size (if array) and append it later - var size = this.extractSize(value.type) - return `(${value.components.map((value) => { return value.type }).join(',')})${size}` + let fullType = this.makeFullTypeDefinition(value) + return fullType.replace(/tuple/g, '') // return of makeFullTypeDefinition might contain `tuple`, need to remove it cause `methodIdentifier` (fnName) does not include `tuple` keyword } else { return value.type } diff --git a/remix-lib/src/execution/txListener.js b/remix-lib/src/execution/txListener.js index ec2e713e85..2fa624c68c 100644 --- a/remix-lib/src/execution/txListener.js +++ b/remix-lib/src/execution/txListener.js @@ -330,7 +330,7 @@ class TxListener { var inputTypes = [] for (var i = 0; i < abi.inputs.length; i++) { var type = abi.inputs[i].type - inputTypes.push(type.indexOf('tuple') === 0 ? txHelper.makeFullTupleTypeDefinition(abi.inputs[i]) : type) + inputTypes.push(type.indexOf('tuple') === 0 ? txHelper.makeFullTypeDefinition(abi.inputs[i]) : type) } var abiCoder = new ethers.utils.AbiCoder() var decoded = abiCoder.decode(inputTypes, data)