Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Fix and rename makeFullTypeDefinition #1077

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion remix-lib/src/execution/txFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions remix-lib/src/execution/txHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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('')
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion remix-lib/src/execution/txListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down