Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Web3Core/RLP/RLP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Web3Core/Transaction/Envelope/EIP1559Envelope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Web3Core/Transaction/Envelope/EIP2930Envelope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Web3Core/Transaction/Envelope/LegacyEnvelope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down