Skip to content

Commit ce9837e

Browse files
Fix after merge building issues.
1 parent aa076ba commit ce9837e

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

Sources/web3swift/Web3/Web3+Structures.swift

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ extension TransactionOptions: Decodable {
2121
public init(from decoder: Decoder) throws {
2222
let container = try decoder.container(keyedBy: CodingKeys.self)
2323

24-
if let gasLimit = try decodeHexToBigUInt(container, key: .gas, allowOptional: true) {
24+
if let gasLimit = try? container.decodeHex(to: BigUInt.self, key: .gas) {
2525
self.gasLimit = .manual(gasLimit)
2626
} else {
2727
self.gasLimit = .automatic
2828
}
2929

30-
if let gasPrice = try decodeHexToBigUInt(container, key: .gasPrice, allowOptional: true) {
30+
if let gasPrice = try? container.decodeHex(to: BigUInt.self, key: .gasPrice) {
3131
self.gasPrice = .manual(gasPrice)
3232
} else {
3333
self.gasPrice = .automatic
@@ -51,16 +51,15 @@ extension TransactionOptions: Decodable {
5151
// }
5252
self.from = from
5353

54-
let value = try decodeHexToBigUInt(container, key: .value)
55-
self.value = value
54+
self.value = try container.decodeHex(to: BigUInt.self, key: .value)
5655

57-
if let nonce = try decodeHexToBigUInt(container, key: .nonce, allowOptional: true) {
56+
if let nonce = try? container.decodeHex(to: BigUInt.self, key: .nonce) {
5857
self.nonce = .manual(nonce)
5958
} else {
6059
self.nonce = .pending
6160
}
6261

63-
if let callOnBlock = try decodeHexToBigUInt(container, key: .callOnBlock, allowOptional: true) {
62+
if let callOnBlock = try? container.decodeHex(to: BigUInt.self, key: .callOnBlock) {
6463
self.callOnBlock = .exactBlockNumber(callOnBlock)
6564
} else {
6665
self.callOnBlock = .pending
@@ -86,14 +85,13 @@ extension EthereumTransaction: Decodable {
8685
let container = try decoder.container(keyedBy: CodingKeys.self)
8786

8887
// test to see if it is a EIP-1559 wrapper
89-
if let envelope = try decodeHexToBigUInt(container, key: .type, allowOptional: true) {
88+
if let envelope = try? container.decodeHex(to: BigUInt.self, key: .type) {
9089
// if present and non-sero we are a new wrapper we can't decode
9190
if envelope != BigInt(0) { throw Web3Error.dataError }
9291
}
9392

94-
var data = try decodeHexToData(container, key: .data, allowOptional: true)
95-
if data != nil {
96-
self.data = data!
93+
if let data = try? container.decodeHex(to: Data.self, key: .data) {
94+
self.data = data
9795
} else {
9896
guard let data = try? container.decodeHex(to: Data.self, key: .input) else { throw Web3Error.dataError }
9997
self.data = data
@@ -214,21 +212,6 @@ extension TransactionReceipt {
214212
case 1: self.status = .ok
215213
default: self.status = .failed
216214
}
217-
218-
guard let cumulativeGasUsed = try decodeHexToBigUInt(container, key: .cumulativeGasUsed) else {throw Web3Error.dataError}
219-
self.cumulativeGasUsed = cumulativeGasUsed
220-
221-
guard let gasUsed = try decodeHexToBigUInt(container, key: .gasUsed) else {throw Web3Error.dataError}
222-
self.gasUsed = gasUsed
223-
224-
let status = try decodeHexToBigUInt(container, key: .status, allowOptional: true)
225-
if status == nil {
226-
self.status = TXStatus.notYetProcessed
227-
} else if status == 1 {
228-
self.status = TXStatus.ok
229-
} else {
230-
self.status = TXStatus.failed
231-
}
232215

233216
self.logs = try container.decode([EventLog].self, forKey: .logs)
234217
}

0 commit comments

Comments
 (0)