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 {
271271 if ( transaction. inferedChainID != nil && transaction. v >= BigUInt ( 37 ) ) {
272272 transaction. chainID = inferedChainID
273273 }
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- // }
285274 return transaction
286275 }
287276
Original file line number Diff line number Diff line change @@ -56,12 +56,13 @@ extension Web3Options:Decodable {
5656 let gasPrice = try decodeHexToBigUInt ( container, key: . gasPrice)
5757 self . gasPrice = gasPrice
5858
59- let toString = try container. decode ( String . self, forKey: . to)
59+ let toString = try container. decode ( String ? . self, forKey: . to)
6060 var to : EthereumAddress ?
61- if toString == " 0x " || toString == " 0x0 " {
61+ if toString == nil || toString == " 0x " || toString == " 0x0 " {
6262 to = EthereumAddress . contractDeploymentAddress ( )
6363 } 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}
6566 to = ethAddr
6667 }
6768 self . to = to
Original file line number Diff line number Diff line change @@ -84,4 +84,26 @@ class web3swift_User_cases: XCTestCase {
8484 XCTAssert ( assembled. gasPrice == options. gasPrice)
8585 }
8686
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+
87109}
You can’t perform that action at this time.
0 commit comments