From 691f0fb3d4b9593f503287c9c6f8a19c8fd217da Mon Sep 17 00:00:00 2001 From: Pavel Zak Date: Tue, 10 Aug 2021 14:40:21 +0200 Subject: [PATCH 1/3] - fixed ABI parsing when "tuple[]" is involved - fixed ABI method signature creation when tuple is in paramater list --- Sources/web3swift/EthereumABI/ABIParameterTypes.swift | 2 +- Sources/web3swift/EthereumABI/ABIParsing.swift | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/web3swift/EthereumABI/ABIParameterTypes.swift b/Sources/web3swift/EthereumABI/ABIParameterTypes.swift index 0bbd8038b..938d98cd4 100755 --- a/Sources/web3swift/EthereumABI/ABIParameterTypes.swift +++ b/Sources/web3swift/EthereumABI/ABIParameterTypes.swift @@ -220,7 +220,7 @@ extension ABI.Element.ParameterType: ABIEncoding { case .tuple(types: let types): let typesRepresentation = types.map({return $0.abiRepresentation}) let typesJoined = typesRepresentation.joined(separator: ",") - return "tuple(\(typesJoined))" + return "(\(typesJoined))" case .string: return "string" } diff --git a/Sources/web3swift/EthereumABI/ABIParsing.swift b/Sources/web3swift/EthereumABI/ABIParsing.swift index bc989ed7a..58ab19a8d 100755 --- a/Sources/web3swift/EthereumABI/ABIParsing.swift +++ b/Sources/web3swift/EthereumABI/ABIParsing.swift @@ -134,6 +134,17 @@ extension ABI.Input { let nativeInput = ABI.Element.InOut(name: name, type: type) return nativeInput } + else if case .array(type: .tuple(types: _), length: _) = parameterType { + let components = try self.components?.compactMap({ (inp: ABI.Input) throws -> ABI.Element.ParameterType in + let input = try inp.parse() + return input.type + }) + let tupleType = ABI.Element.ParameterType.tuple(types: components!) + + let newType: ABI.Element.ParameterType = .array(type: tupleType, length: 0) + let nativeInput = ABI.Element.InOut(name: name, type: newType) + return nativeInput + } else { let nativeInput = ABI.Element.InOut(name: name, type: parameterType) return nativeInput From 2d79524542905c868b343dad1d0a7176800c1f71 Mon Sep 17 00:00:00 2001 From: Pavel Zak Date: Thu, 12 Aug 2021 16:25:12 +0200 Subject: [PATCH 2/3] fixed decoding of tuples in an array --- Sources/web3swift/EthereumABI/ABIDecoding.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/web3swift/EthereumABI/ABIDecoding.swift b/Sources/web3swift/EthereumABI/ABIDecoding.swift index eae5c332b..90a2be648 100755 --- a/Sources/web3swift/EthereumABI/ABIDecoding.swift +++ b/Sources/web3swift/EthereumABI/ABIDecoding.swift @@ -137,7 +137,12 @@ extension ABIDecoder { let (v, c) = decodeSignleType(type: subType, data: dataSlice, pointer: subpointer) guard let valueUnwrapped = v, let consumedUnwrapped = c else {break} toReturn.append(valueUnwrapped) - subpointer = subpointer + consumedUnwrapped + if (subType.isStatic) { + subpointer = subpointer + consumedUnwrapped + } + else { + subpointer = consumedUnwrapped // need to go by nextElementPointer + } } return (toReturn as AnyObject, nextElementPointer) } From 8948d5a6315ce3fb55be138619e3dcacebedc502 Mon Sep 17 00:00:00 2001 From: Pavel Zak Date: Fri, 3 Sep 2021 17:30:03 +0200 Subject: [PATCH 3/3] fixed low gas when loading transactionOptions from Json --- Sources/web3swift/Web3/Web3+Options.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/web3swift/Web3/Web3+Options.swift b/Sources/web3swift/Web3/Web3+Options.swift index d9a9b7f55..91e5c52e6 100755 --- a/Sources/web3swift/Web3/Web3+Options.swift +++ b/Sources/web3swift/Web3/Web3+Options.swift @@ -125,7 +125,7 @@ public struct TransactionOptions { public static func fromJSON(_ json: [String: Any]) -> TransactionOptions? { var options = TransactionOptions() if let gas = json["gas"] as? String, let gasBiguint = BigUInt(gas.stripHexPrefix().lowercased(), radix: 16) { - options.gasLimit = .limited(gasBiguint) + options.gasLimit = .manual(gasBiguint) } else if let gasLimit = json["gasLimit"] as? String, let gasgasLimitBiguint = BigUInt(gasLimit.stripHexPrefix().lowercased(), radix: 16) { options.gasLimit = .limited(gasgasLimitBiguint) } else {