Skip to content

Commit 691f0fb

Browse files
committed
- fixed ABI parsing when "tuple[]" is involved
- fixed ABI method signature creation when tuple is in paramater list
1 parent caf54ae commit 691f0fb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Sources/web3swift/EthereumABI/ABIParameterTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ extension ABI.Element.ParameterType: ABIEncoding {
220220
case .tuple(types: let types):
221221
let typesRepresentation = types.map({return $0.abiRepresentation})
222222
let typesJoined = typesRepresentation.joined(separator: ",")
223-
return "tuple(\(typesJoined))"
223+
return "(\(typesJoined))"
224224
case .string:
225225
return "string"
226226
}

Sources/web3swift/EthereumABI/ABIParsing.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ extension ABI.Input {
134134
let nativeInput = ABI.Element.InOut(name: name, type: type)
135135
return nativeInput
136136
}
137+
else if case .array(type: .tuple(types: _), length: _) = parameterType {
138+
let components = try self.components?.compactMap({ (inp: ABI.Input) throws -> ABI.Element.ParameterType in
139+
let input = try inp.parse()
140+
return input.type
141+
})
142+
let tupleType = ABI.Element.ParameterType.tuple(types: components!)
143+
144+
let newType: ABI.Element.ParameterType = .array(type: tupleType, length: 0)
145+
let nativeInput = ABI.Element.InOut(name: name, type: newType)
146+
return nativeInput
147+
}
137148
else {
138149
let nativeInput = ABI.Element.InOut(name: name, type: parameterType)
139150
return nativeInput

0 commit comments

Comments
 (0)