@@ -17,7 +17,7 @@ extension TransactionOptions: Decodable {
1717 case nonce
1818 case callOnBlock
1919 }
20-
20+
2121 public init ( from decoder: Decoder ) throws {
2222 let container = try decoder. container ( keyedBy: CodingKeys . self)
2323
@@ -79,30 +79,30 @@ extension EthereumTransaction: Decodable {
7979 case value
8080 case type // present in EIP-1559 transaction objects
8181 }
82-
82+
8383 public init ( from decoder: Decoder ) throws {
8484 let options = try TransactionOptions ( from: decoder)
8585 let container = try decoder. container ( keyedBy: CodingKeys . self)
86-
86+
8787 if let data = try ? container. decodeHex ( Data . self, forKey: . data) {
8888 self . data = data
8989 } else {
9090 guard let data = try ? container. decodeHex ( Data . self, forKey: . input) else { throw Web3Error . dataError }
9191 self . data = data
9292 }
93-
93+
9494 nonce = try container. decodeHex ( BigUInt . self, forKey: . nonce)
95- v = try container. decodeHex ( BigUInt . self, forKey: . v)
95+ v = try container. decodeHex ( BigUInt . self, forKey: . v)
9696 r = try container. decodeHex ( BigUInt . self, forKey: . r)
9797 s = try container. decodeHex ( BigUInt . self, forKey: . s)
98-
99- guard let to = options. to,
100- let gasLimit = options. gasLimit,
98+
99+ guard let to = options. to,
100+ let gasLimit = options. gasLimit,
101101 let gasPrice = options. gasPrice else { throw Web3Error . dataError }
102102
103103 self . to = to
104104 self . value = options. value
105-
105+
106106 switch gasPrice {
107107 case let . manual( gasPriceValue) :
108108 self . gasPrice = gasPriceValue
@@ -129,18 +129,18 @@ public struct TransactionDetails: Decodable {
129129 public var blockNumber : BigUInt ?
130130 public var transactionIndex : BigUInt ?
131131 public var transaction : EthereumTransaction
132-
132+
133133 enum CodingKeys : String , CodingKey {
134134 case blockHash
135135 case blockNumber
136136 case transactionIndex
137137 }
138-
138+
139139 public init ( from decoder: Decoder ) throws {
140140 let container = try decoder. container ( keyedBy: CodingKeys . self)
141141 self . blockNumber = try ? container. decodeHex ( BigUInt . self, forKey: . blockNumber)
142- self . blockHash = try ? container. decodeHex ( Data . self, forKey: . blockHash)
143- self . transactionIndex = try ? container. decodeHex ( BigUInt . self, forKey: . blockNumber )
142+ self . blockHash = try ? container. decodeHex ( Data . self, forKey: . blockHash)
143+ self . transactionIndex = try ? container. decodeHex ( BigUInt . self, forKey: . transactionIndex )
144144 self . transaction = try EthereumTransaction ( from: decoder)
145145 }
146146}
@@ -156,15 +156,14 @@ public struct TransactionReceipt: Decodable {
156156 public var logs : [ EventLog ]
157157 public var status : TXStatus
158158 public var logsBloom : EthereumBloomFilter ?
159-
159+
160160 public enum TXStatus {
161161 case ok
162162 case failed
163163 case notYetProcessed
164164 }
165-
166- enum CodingKeys : String , CodingKey
167- {
165+
166+ enum CodingKeys : String , CodingKey {
168167 case blockHash
169168 case blockNumber
170169 case transactionHash
@@ -176,7 +175,7 @@ public struct TransactionReceipt: Decodable {
176175 case logsBloom
177176 case status
178177 }
179-
178+
180179 static func notProcessed( transactionHash: Data ) -> TransactionReceipt {
181180 TransactionReceipt ( transactionHash: transactionHash, blockHash: Data ( ) , blockNumber: BigUInt ( 0 ) , transactionIndex: BigUInt ( 0 ) , contractAddress: nil , cumulativeGasUsed: BigUInt ( 0 ) , gasUsed: BigUInt ( 0 ) , logs: [ EventLog] ( ) , status: . notYetProcessed, logsBloom: nil )
182181 }
@@ -187,26 +186,26 @@ extension TransactionReceipt {
187186 let container = try decoder. container ( keyedBy: CodingKeys . self)
188187
189188 self . blockNumber = try container. decodeHex ( BigUInt . self, forKey: . blockNumber)
190-
189+
191190 self . blockHash = try container. decodeHex ( Data . self, forKey: . blockHash)
192-
191+
193192 self . transactionIndex = try container. decodeHex ( BigUInt . self, forKey: . transactionIndex)
194-
193+
195194 self . transactionHash = try container. decodeHex ( Data . self, forKey: . transactionHash)
196-
195+
197196 self . contractAddress = try ? container. decodeIfPresent ( EthereumAddress . self, forKey: . contractAddress)
198-
197+
199198 self . cumulativeGasUsed = try container. decodeHex ( BigUInt . self, forKey: . cumulativeGasUsed)
200-
199+
201200 self . gasUsed = try container. decodeHex ( BigUInt . self, forKey: . gasUsed)
202-
203- let status = try ? container. decodeHex ( BigUInt . self, forKey: . status)
201+
202+ let status = try ? container. decodeHex ( BigUInt . self, forKey: . status)
204203 switch status {
205- case nil : self . status = . notYetProcessed
206- case 1 : self . status = . ok
207- default : self . status = . failed
204+ case nil : self . status = . notYetProcessed
205+ case 1 : self . status = . ok
206+ default : self . status = . failed
208207 }
209-
208+
210209 self . logs = try container. decode ( [ EventLog ] . self, forKey: . logs)
211210 }
212211}
@@ -225,7 +224,7 @@ extension EthereumAddress: Codable {
225224 }
226225}
227226
228- public struct EventLog : Decodable {
227+ public struct EventLog : Decodable {
229228 public var address : EthereumAddress
230229 public var blockHash : Data
231230 public var blockNumber : BigUInt
@@ -235,24 +234,22 @@ public struct EventLog : Decodable {
235234 public var topics : [ Data ]
236235 public var transactionHash : Data
237236 public var transactionIndex : BigUInt
238-
239-
240- // address = 0x53066cddbc0099eb6c96785d9b3df2aaeede5da3;
241- // blockHash = 0x779c1f08f2b5252873f08fd6ec62d75bb54f956633bbb59d33bd7c49f1a3d389;
242- // blockNumber = 0x4f58f8;
243- // data = 0x0000000000000000000000000000000000000000000000004563918244f40000;
244- // logIndex = 0x84;
245- // removed = 0;
246- // topics = (
247- // 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef,
248- // 0x000000000000000000000000efdcf2c36f3756ce7247628afdb632fa4ee12ec5,
249- // 0x000000000000000000000000d5395c132c791a7f46fa8fc27f0ab6bacd824484
250- // );
251- // transactionHash = 0x9f7bb2633abb3192d35f65e50a96f9f7ca878fa2ee7bf5d3fca489c0c60dc79a;
252- // transactionIndex = 0x99;
253-
254- enum CodingKeys : String , CodingKey
255- {
237+
238+ // address = 0x53066cddbc0099eb6c96785d9b3df2aaeede5da3;
239+ // blockHash = 0x779c1f08f2b5252873f08fd6ec62d75bb54f956633bbb59d33bd7c49f1a3d389;
240+ // blockNumber = 0x4f58f8;
241+ // data = 0x0000000000000000000000000000000000000000000000004563918244f40000;
242+ // logIndex = 0x84;
243+ // removed = 0;
244+ // topics = (
245+ // 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef,
246+ // 0x000000000000000000000000efdcf2c36f3756ce7247628afdb632fa4ee12ec5,
247+ // 0x000000000000000000000000d5395c132c791a7f46fa8fc27f0ab6bacd824484
248+ // );
249+ // transactionHash = 0x9f7bb2633abb3192d35f65e50a96f9f7ca878fa2ee7bf5d3fca489c0c60dc79a;
250+ // transactionIndex = 0x99;
251+
252+ enum CodingKeys : String , CodingKey {
256253 case address
257254 case blockHash
258255 case blockNumber
@@ -263,31 +260,31 @@ public struct EventLog : Decodable {
263260 case transactionHash
264261 case transactionIndex
265262 }
266-
263+
267264 public init ( from decoder: Decoder ) throws {
268265 let container = try decoder. container ( keyedBy: CodingKeys . self)
269-
266+
270267 let address = try container. decode ( EthereumAddress . self, forKey: . address)
271268 self . address = address
272-
269+
273270 self . blockNumber = try container. decodeHex ( BigUInt . self, forKey: . blockNumber)
274-
271+
275272 self . blockHash = try container. decodeHex ( Data . self, forKey: . blockHash)
276-
273+
277274 self . transactionIndex = try container. decodeHex ( BigUInt . self, forKey: . transactionIndex)
278-
275+
279276 self . transactionHash = try container. decodeHex ( Data . self, forKey: . transactionHash)
280-
277+
281278 self . data = try container. decodeHex ( Data . self, forKey: . data)
282-
279+
283280 self . logIndex = try container. decodeHex ( BigUInt . self, forKey: . logIndex)
284-
281+
285282 let removed = try ? container. decodeHex ( BigUInt . self, forKey: . removed)
286283 self . removed = removed == 1 ? true : false
287-
284+
288285 let topicsStrings = try container. decode ( [ String ] . self, forKey: . topics)
289286
290- self . topics = try topicsStrings. map {
287+ self . topics = try topicsStrings. map {
291288 guard let topic = Data . fromHex ( $0) else { throw Web3Error . dataError }
292289 return topic
293290 }
@@ -298,7 +295,7 @@ public enum TransactionInBlock: Decodable {
298295 case hash( Data )
299296 case transaction( EthereumTransaction )
300297 case null
301-
298+
302299 public init ( from decoder: Decoder ) throws {
303300 let value = try decoder. singleValueContainer ( )
304301 if let string = try ? value. decode ( String . self) {
@@ -337,7 +334,7 @@ public struct Block: Decodable {
337334 public var timestamp : Date
338335 public var transactions : [ TransactionInBlock ]
339336 public var uncles : [ Data ]
340-
337+
341338 enum CodingKeys : String , CodingKey {
342339 case number
343340 case hash
@@ -353,11 +350,11 @@ public struct Block: Decodable {
353350 case totalDifficulty
354351 case extraData
355352 case size
356-
353+
357354 case gasLimit
358355 case gasUsed
359356 case baseFeePerGas
360-
357+
361358 case timestamp
362359 case transactions
363360 case uncles
@@ -411,11 +408,11 @@ extension Block {
411408 }
412409}
413410
414- public struct EventParserResult : EventParserResultProtocol {
411+ public struct EventParserResult : EventParserResultProtocol {
415412 public var eventName : String
416413 public var transactionReceipt : TransactionReceipt ?
417414 public var contractAddress : EthereumAddress
418- public var decodedResult : [ String : Any ]
415+ public var decodedResult : [ String : Any ]
419416 public var eventLog : EventLog ? = nil
420417}
421418
@@ -424,10 +421,10 @@ public struct TransactionSendingResult {
424421 public var hash : String
425422}
426423
427- public struct TxPoolStatus : Decodable {
424+ public struct TxPoolStatus : Decodable {
428425 public var pending : BigUInt
429426 public var queued : BigUInt
430-
427+
431428 enum CodingKeys : String , CodingKey {
432429 case pending
433430 case queued
@@ -442,15 +439,15 @@ public extension TxPoolStatus {
442439 }
443440}
444441
445- public struct TxPoolContent : Decodable {
442+ public struct TxPoolContent : Decodable {
446443 public var pending : [ EthereumAddress : [ TxPoolContentForNonce ] ]
447444 public var queued : [ EthereumAddress : [ TxPoolContentForNonce ] ]
448-
445+
449446 enum CodingKeys : String , CodingKey {
450447 case pending
451448 case queued
452449 }
453-
450+
454451 fileprivate static func decodePoolContentForKey< T> ( container: KeyedDecodingContainer < T > , key: KeyedDecodingContainer < T > . Key ) throws -> [ EthereumAddress : [ TxPoolContentForNonce ] ] {
455452 let raw = try container. nestedContainer ( keyedBy: AdditionalDataCodingKeys . self, forKey: key)
456453 var result = [ EthereumAddress: [ TxPoolContentForNonce] ] ( )
@@ -481,14 +478,13 @@ public struct TxPoolContent : Decodable {
481478 }
482479 return result
483480 }
484-
485-
481+
486482 fileprivate struct AdditionalDataCodingKeys : CodingKey {
487483 var stringValue : String
488484 init ? ( stringValue: String ) {
489485 self . stringValue = stringValue
490486 }
491-
487+
492488 var intValue : Int ?
493489 init ? ( intValue: Int ) {
494490 return nil
0 commit comments