File tree Expand file tree Collapse file tree 3 files changed +26
-14
lines changed Expand file tree Collapse file tree 3 files changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -271,17 +271,6 @@ public struct EthereumTransaction: CustomStringConvertible {
271
271
if ( transaction. inferedChainID != nil && transaction. v >= BigUInt ( 37 ) ) {
272
272
transaction. chainID = inferedChainID
273
273
}
274
- // let hash = json["hash"] as? String
275
- // if hash != nil {
276
- // let calculatedHash = transaction.hash
277
- // let receivedHash = Data.fromHex(hash!)
278
- // if (receivedHash != calculatedHash) {
279
- // print("hash mismatch, dat")
280
- // print(String(describing: transaction))
281
- // print(json)
282
- // return nil
283
- // }
284
- // }
285
274
return transaction
286
275
}
287
276
Original file line number Diff line number Diff line change @@ -56,12 +56,13 @@ extension Web3Options:Decodable {
56
56
let gasPrice = try decodeHexToBigUInt ( container, key: . gasPrice)
57
57
self . gasPrice = gasPrice
58
58
59
- let toString = try container. decode ( String . self, forKey: . to)
59
+ let toString = try container. decode ( String ? . self, forKey: . to)
60
60
var to : EthereumAddress ?
61
- if toString == " 0x " || toString == " 0x0 " {
61
+ if toString == nil || toString == " 0x " || toString == " 0x0 " {
62
62
to = EthereumAddress . contractDeploymentAddress ( )
63
63
} else {
64
- guard let ethAddr = EthereumAddress ( toString) else { throw Web3Error . dataError}
64
+ guard let addressString = toString else { throw Web3Error . dataError}
65
+ guard let ethAddr = EthereumAddress ( addressString) else { throw Web3Error . dataError}
65
66
to = ethAddr
66
67
}
67
68
self . to = to
Original file line number Diff line number Diff line change @@ -84,4 +84,26 @@ class web3swift_User_cases: XCTestCase {
84
84
XCTAssert ( assembled. gasPrice == options. gasPrice)
85
85
}
86
86
87
+ func testParseTransactionDetailsForContractCreation( ) {
88
+ let web3 = Web3 . InfuraMainnetWeb3 ( )
89
+ let details = web3. eth. getTransactionDetails ( " 0x1c85b9b7f7c2cbdb3fa264f6b78b226360aa2084c48cf7869b756e0762bd851b " )
90
+ switch details {
91
+ case . success( let details) :
92
+ print ( details)
93
+ XCTAssert ( details. transaction. to == . contractDeploymentAddress( ) )
94
+ case . failure( let error) :
95
+ print ( error)
96
+ XCTFail ( )
97
+ }
98
+ let receipt = web3. eth. getTransactionReceipt ( " 0x1c85b9b7f7c2cbdb3fa264f6b78b226360aa2084c48cf7869b756e0762bd851b " )
99
+ switch receipt {
100
+ case . success( let receipt) :
101
+ print ( receipt)
102
+ XCTAssert ( receipt. contractAddress != nil )
103
+ case . failure( let error) :
104
+ print ( error)
105
+ XCTFail ( )
106
+ }
107
+ }
108
+
87
109
}
You can’t perform that action at this time.
0 commit comments