diff --git a/Sources/Web3Core/RLP/RLP.swift b/Sources/Web3Core/RLP/RLP.swift index 588432db7..c60a0afde 100755 --- a/Sources/Web3Core/RLP/RLP.swift +++ b/Sources/Web3Core/RLP/RLP.swift @@ -113,10 +113,10 @@ public struct RLP { } // FIXME: Make encode generic to avoid casting it's argument to [AnyObject] - internal static func encode(_ elements: [AnyObject]) -> Data? { + internal static func encode(_ elements: [Any?]) -> Data? { var encodedData = Data() for e in elements { - if let encoded = encode(e) { + if let encoded = encode(e as AnyObject) { encodedData.append(encoded) } else { guard let asArray = e as? [AnyObject] else {return nil} diff --git a/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift b/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift index 673af57ce..052b931d9 100644 --- a/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift @@ -245,14 +245,14 @@ extension EIP1559Envelope { // } public func encode(for type: EncodeType = .transaction) -> Data? { - let fields: [AnyObject] + let fields: [Any?] let list = accessList.map { $0.encodeAsList() as AnyObject } switch type { case .transaction: - fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list, v, r, s] as [AnyObject] + fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list, v, r, s] case .signature: - fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list] as [AnyObject] + fields = [chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to.addressData, value, data, list] } guard var result = RLP.encode(fields) else { return nil } result.insert(UInt8(self.type.rawValue), at: 0) diff --git a/Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift b/Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift index fe4bcfb46..93cfcbfb7 100644 --- a/Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift @@ -206,14 +206,14 @@ extension EIP2930Envelope { } public func encode(for type: EncodeType = .transaction) -> Data? { - let fields: [AnyObject] + let fields: [Any?] let list = accessList.map { $0.encodeAsList() as AnyObject } switch type { case .transaction: - fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list, v, r, s] as [AnyObject] + fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list, v, r, s] case .signature: - fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list] as [AnyObject] + fields = [chainID, nonce, gasPrice, gasLimit, to.addressData, value, data, list] } guard var result = RLP.encode(fields) else { return nil } result.insert(UInt8(self.type.rawValue), at: 0) diff --git a/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift b/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift index b1c2c7e4c..121ecb63b 100644 --- a/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift +++ b/Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift @@ -192,15 +192,15 @@ extension LegacyEnvelope { // } public func encode(for type: EncodeType = .transaction) -> Data? { - let fields: [AnyObject] + let fields: [Any?] switch type { case .transaction: - fields = [nonce, gasPrice, gasLimit, to.addressData, value, data, v, r, s] as [AnyObject] + fields = [nonce, gasPrice, gasLimit, to.addressData, value, data, v, r, s] case .signature: if let chainID = chainID, chainID != 0 { - fields = [nonce, gasPrice, gasLimit, to.addressData, value, data, chainID, BigUInt(0), BigUInt(0)] as [AnyObject] + fields = [nonce, gasPrice, gasLimit, to.addressData, value, data, chainID, BigUInt(0), BigUInt(0)] } else { - fields = [nonce, gasPrice, gasLimit, to.addressData, value, data] as [AnyObject] + fields = [nonce, gasPrice, gasLimit, to.addressData, value, data] } } return RLP.encode(fields)