Merge pull request #1077 from ethereum/fixEncoding

Fix and rename makeFullTypeDefinition
pull/5370/head
yann300 6 years ago committed by GitHub
commit f7b77cdfc8
  1. 2
      remix-lib/src/execution/txFormat.js
  2. 11
      remix-lib/src/execution/txHelper.js
  3. 2
      remix-lib/src/execution/txListener.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

@ -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
}

@ -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)

Loading…
Cancel
Save