fix and rename makeFullTypeDefinition

pull/5370/head
yann300 6 years ago
parent 413ba39028
commit ed7bc34db5
  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 = [] var outputTypes = []
for (i = 0; i < fnabi.outputs.length; i++) { for (i = 0; i < fnabi.outputs.length; i++) {
var type = fnabi.outputs[i].type 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 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') var ethers = require('ethers')
module.exports = { module.exports = {
makeFullTupleTypeDefinition: function (typeDef) { makeFullTypeDefinition: function (typeDef) {
if (typeDef && typeDef.type.indexOf('tuple') === 0 && typeDef.components) { 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 `tuple(${innerTypes.join(',')})${this.extractSize(typeDef.type)}`
} }
return typeDef.type return typeDef.type
@ -15,7 +15,7 @@ module.exports = {
if (funABI.inputs && funABI.inputs.length) { if (funABI.inputs && funABI.inputs.length) {
for (var i = 0; i < funABI.inputs.length; i++) { for (var i = 0; i < funABI.inputs.length; i++) {
var type = funABI.inputs[i].type 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) { if (args.length < types.length) {
args.push('') args.push('')
} }
@ -95,9 +95,8 @@ module.exports = {
var fn = abi[i] var fn = abi[i]
if (fn.type === 'function' && fnName === fn.name + '(' + fn.inputs.map((value) => { if (fn.type === 'function' && fnName === fn.name + '(' + fn.inputs.map((value) => {
if (value.components) { if (value.components) {
// we extract the size (if array) and append it later let fullType = this.makeFullTypeDefinition(value)
var size = this.extractSize(value.type) return fullType.replace(/tuple/g, '') // return of makeFullTypeDefinition might contain `tuple`, need to remove it cause `methodIdentifier` (fnName) does not include `tuple` keyword
return `(${value.components.map((value) => { return value.type }).join(',')})${size}`
} else { } else {
return value.type return value.type
} }

@ -330,7 +330,7 @@ class TxListener {
var inputTypes = [] var inputTypes = []
for (var i = 0; i < abi.inputs.length; i++) { for (var i = 0; i < abi.inputs.length; i++) {
var type = abi.inputs[i].type 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 abiCoder = new ethers.utils.AbiCoder()
var decoded = abiCoder.decode(inputTypes, data) var decoded = abiCoder.decode(inputTypes, data)

Loading…
Cancel
Save