diff --git a/web3sTests/Client/EthereumClientTests.swift b/web3sTests/Client/EthereumClientTests.swift index 1186c80c..29ba38cf 100644 --- a/web3sTests/Client/EthereumClientTests.swift +++ b/web3sTests/Client/EthereumClientTests.swift @@ -35,7 +35,6 @@ struct TransferMatchingSignatureEvent: ABIEvent { class EthereumClientTests: XCTestCase { var client: EthereumClient? var account: EthereumAccount? - let timeout = 10.0 override func setUp() { super.setUp() @@ -44,34 +43,25 @@ class EthereumClientTests: XCTestCase { print("Public address: \(self.account?.address.value ?? "NONE")") } - func testEthGetTransactionCount() { - let expectation = XCTestExpectation(description: "get transaction receipt") - - client?.eth_getTransactionCount(address: account!.address, block: .Latest, completion: { (error, count) in - XCTAssertNotNil(count, "Transaction count not available: \(error?.localizedDescription ?? "no error")") - expectation.fulfill() - }) - - wait(for: [expectation], timeout: timeout) + func testEthGetTransactionCount() async { + do { + let count = try await client?.eth_getTransactionCount(address: account!.address, block: .Latest) + XCTAssertNotEqual(count, 0) + } catch { + XCTFail("Expected count but failed \(error).") + } } - func testEthGetTransactionCountPending() { - let expectation = XCTestExpectation(description: "get transaction receipt") - - client?.eth_getTransactionCount(address: account!.address, block: .Pending, completion: { (error, count) in - XCTAssertNotNil(count, "Transaction count not available: \(error?.localizedDescription ?? "no error")") - expectation.fulfill() - }) - - wait(for: [expectation], timeout: timeout) + func testEthGetTransactionCountPending() async { + do { + let count = try await client?.eth_getTransactionCount(address: account!.address, block: .Pending) + XCTAssertNotEqual(count, 0) + } catch { + XCTFail("Expected count but failed \(error).") + } } -} - -#if compiler(>=5.5) && canImport(_Concurrency) -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) -extension EthereumClientTests { - func testEthGetBalance_Async() async throws { + func testEthGetBalance() async throws { do { let balance = try await client?.eth_getBalance(address: account?.address ?? .zero, block: .Latest) XCTAssertNotNil(balance, "Balance not available") @@ -80,7 +70,7 @@ extension EthereumClientTests { } } - func testEthGetBalanceIncorrectAddress_Async() async { + func testEthGetBalanceIncorrectAddress() async { do { _ = try await client?.eth_getBalance(address: EthereumAddress("0xnig42niog2"), block: .Latest) XCTFail("Expected to throw while awaiting, but succeeded") @@ -89,7 +79,7 @@ extension EthereumClientTests { } } - func testNetVersion_Async() async { + func testNetVersion() async { do { let network = try await client?.net_version() XCTAssertEqual(network, EthereumNetwork.Ropsten, "Network incorrect") @@ -98,7 +88,7 @@ extension EthereumClientTests { } } - func testEthGasPrice_Async() async { + func testEthGasPrice() async { do { let gas = try await client?.eth_gasPrice() XCTAssertNotNil(gas, "Gas not available") @@ -107,7 +97,7 @@ extension EthereumClientTests { } } - func testEthBlockNumber_Async() async { + func testEthBlockNumber() async { do { let block = try await client?.eth_blockNumber() XCTAssertNotNil(block, "Block not available") @@ -116,7 +106,7 @@ extension EthereumClientTests { } } - func testEthGetCode_Async() async { + func testEthGetCode() async { do { let code = try await client?.eth_getCode(address: EthereumAddress("0x112234455c3a32fd11230c42e7bccd4a84e02010")) XCTAssertNotNil(code, "Contract code not available") @@ -125,7 +115,7 @@ extension EthereumClientTests { } } - func testEthSendRawTransaction_Async() async { + func testEthSendRawTransaction() async { do { let tx = EthereumTransaction(from: nil, to: EthereumAddress("0x3c1bd6b420448cf16a389c8b0115ccb3660bb854"), value: BigUInt(1600000), data: nil, nonce: 2, gasPrice: BigUInt(4000000), gasLimit: BigUInt(500000), chainId: EthereumNetwork.Ropsten.intValue) @@ -136,7 +126,7 @@ extension EthereumClientTests { } } - func testEthGetTransactionReceipt_Async() async { + func testEthGetTransactionReceipt() async { do { let txHash = "0xc51002441dc669ad03697fd500a7096c054b1eb2ce094821e68831a3666fc878" let receipt = try await client?.eth_getTransactionReceipt(txHash: txHash) @@ -146,7 +136,7 @@ extension EthereumClientTests { } } - func testEthCall_Async() async { + func testEthCall() async { do { let tx = EthereumTransaction(from: nil, to: EthereumAddress("0x3c1bd6b420448cf16a389c8b0115ccb3660bb854"), value: BigUInt(1800000), data: nil, nonce: 2, gasPrice: BigUInt(400000), gasLimit: BigUInt(50000), chainId: EthereumNetwork.Ropsten.intValue) let txHash = try await client?.eth_call(tx, block: .Latest) @@ -156,7 +146,7 @@ extension EthereumClientTests { } } - func testSimpleEthGetLogs_Async() async { + func testSimpleEthGetLogs() async { do { let logs = try await client?.eth_getLogs(addresses: [EthereumAddress("0x23d0a442580c01e420270fba6ca836a8b2353acb")], topics: nil, fromBlock: .Earliest, toBlock: .Latest) XCTAssertNotNil(logs, "Logs not available") @@ -165,7 +155,7 @@ extension EthereumClientTests { } } - func testOrTopicsEthGetLogs_Async() async { + func testOrTopicsEthGetLogs() async { do { let logs = try await client?.eth_getLogs(addresses: nil, orTopics: [["0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c", "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65"], ["0x000000000000000000000000655ef694b98e55977a93259cb3b708560869a8f3"]], fromBlock: .Number(6540313), toBlock: .Number(6540397)) XCTAssertEqual(logs?.count, 2) @@ -175,7 +165,7 @@ extension EthereumClientTests { } } - func testGivenGenesisBlock_ThenReturnsByNumber_Async() async { + func testGivenGenesisBlock_ThenReturnsByNumber() async { do { let block = try await client?.eth_getBlockByNumber(.Number(0)) XCTAssertEqual(block?.timestamp.timeIntervalSince1970, 0) @@ -186,7 +176,7 @@ extension EthereumClientTests { } } - func testGivenLatestBlock_ThenReturnsByNumber_Async() async { + func testGivenLatestBlock_ThenReturnsByNumber() async { do { let block = try await client?.eth_getBlockByNumber(.Latest) XCTAssertNotNil(block?.number.intValue) @@ -195,7 +185,7 @@ extension EthereumClientTests { } } - func testGivenExistingBlock_ThenGetsBlockByNumber_Async() async { + func testGivenExistingBlock_ThenGetsBlockByNumber() async { do { let block = try await client?.eth_getBlockByNumber(.Number(3415757)) XCTAssertEqual(block?.number, .Number(3415757)) @@ -207,7 +197,7 @@ extension EthereumClientTests { } } - func testGivenUnexistingBlockNumber_ThenGetBlockByNumberReturnsError_Async() async { + func testGivenUnexistingBlockNumber_ThenGetBlockByNumberReturnsError() async { do { let _ = try await client?.eth_getBlockByNumber(.Number(Int.max)) XCTFail("Expected to throw while awaiting, but succeeded") @@ -216,7 +206,7 @@ extension EthereumClientTests { } } - func testGivenMinedTransactionHash_ThenGetsTransactionByHash_Async() async { + func testGivenMinedTransactionHash_ThenGetsTransactionByHash() async { do { let transaction = try await client?.eth_getTransaction(byHash: "0x014726c783ab2fd6828a9ca556850bccfc66f70926f411274eaf886385c704af") XCTAssertEqual(transaction?.from?.value, "0xbbf5029fd710d227630c8b7d338051b8e76d50b3") @@ -232,7 +222,7 @@ extension EthereumClientTests { } } - func testGivenUnexistingTransactionHash_ThenErrorsGetTransactionByHash_Async() async { + func testGivenUnexistingTransactionHash_ThenErrorsGetTransactionByHash() async { do { let _ = try await client?.eth_getTransaction(byHash: "0x01234") XCTFail("Expected to throw while awaiting, but succeeded") @@ -241,7 +231,7 @@ extension EthereumClientTests { } } - func testGivenNoFilters_WhenMatchingSingleTransferEvents_AllEventsReturned_Async() async { + func testGivenNoFilters_WhenMatchingSingleTransferEvents_AllEventsReturned() async { do { let to = try! ABIEncoder.encode(EthereumAddress("0x3C1Bd6B420448Cf16A389C8b0115CCB3660bB854")) @@ -257,7 +247,7 @@ extension EthereumClientTests { } } - func testGivenNoFilters_WhenMatchingMultipleTransferEvents_BothEventsReturned_Async() async { + func testGivenNoFilters_WhenMatchingMultipleTransferEvents_BothEventsReturned() async { do { let to = try! ABIEncoder.encode(EthereumAddress("0x3C1Bd6B420448Cf16A389C8b0115CCB3660bB854")) @@ -273,7 +263,7 @@ extension EthereumClientTests { } } - func testGivenContractFilter_WhenMatchingSingleTransferEvents_OnlyMatchingSourceEventReturned_Async() async { + func testGivenContractFilter_WhenMatchingSingleTransferEvents_OnlyMatchingSourceEventReturned() async { do { let to = try! ABIEncoder.encodeRaw("0x3C1Bd6B420448Cf16A389C8b0115CCB3660bB854", forType: ABIRawType.FixedAddress) let filters = [ @@ -292,7 +282,7 @@ extension EthereumClientTests { } } - func testGivenContractFilter_WhenMatchingMultipleTransferEvents_OnlyMatchingSourceEventsReturned_Async() async { + func testGivenContractFilter_WhenMatchingMultipleTransferEvents_OnlyMatchingSourceEventsReturned() async { do { let to = try! ABIEncoder.encode(EthereumAddress("0x3C1Bd6B420448Cf16A389C8b0115CCB3660bB854")) let filters = [ @@ -312,7 +302,7 @@ extension EthereumClientTests { } } - func test_GivenDynamicArrayResponse_ThenCallReceivesData_Async() async { + func test_GivenDynamicArrayResponse_ThenCallReceivesData() async { do { let function = GetGuardians(wallet: EthereumAddress("0x2A6295C34b4136F2C3c1445c6A0338D784fe0ddd")) @@ -323,7 +313,7 @@ extension EthereumClientTests { } } - func test_GivenUnimplementedMethod_WhenCallingContract_ThenFailsWithExecutionError_Async() async { + func test_GivenUnimplementedMethod_WhenCallingContract_ThenFailsWithExecutionError() async { do { let function = InvalidMethodA(param: .zero) let _ = try await function.call( @@ -340,7 +330,7 @@ extension EthereumClientTests { } } - func test_GivenValidTransaction_ThenEstimatesGas_Async() async { + func test_GivenValidTransaction_ThenEstimatesGas() async { do { let function = TransferToken(wallet: EthereumAddress("0xD18dE36e6FB4a5A069f673723Fab71cc00C6CE5F"), token: EthereumAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"), @@ -358,8 +348,6 @@ extension EthereumClientTests { } } -#endif - struct GetGuardians: ABIFunction { static let name = "getGuardians" let contract = EthereumAddress("0x25BD64224b7534f7B9e3E16dd10b6dED1A412b90") diff --git a/web3sTests/Contract/ABIEventTests.swift b/web3sTests/Contract/ABIEventTests.swift index 57e37452..37a14216 100644 --- a/web3sTests/Contract/ABIEventTests.swift +++ b/web3sTests/Contract/ABIEventTests.swift @@ -17,57 +17,7 @@ class ABIEventTests: XCTestCase { self.client = EthereumClient(url: URL(string: TestConfig.clientUrl)!) } - func test_givenEventWithData4_ItParsesCorrectly() { - let expect = expectation(description: "Request") - - let encodedAddress = (try? ABIEncoder.encode(EthereumAddress("0x3B6Def16666a23905DD29071d13E7a9db08240E2")).bytes) ?? [] - - client.getEvents(addresses: nil, - topics: [try? EnabledStaticCall.signature(), String(hexFromBytes: encodedAddress), nil], - fromBlock: .Number(8386245), - toBlock: .Number(8386245), - eventTypes: [EnabledStaticCall.self]) { (error, events, logs) in - XCTAssertNil(error) - let event = events.first as? EnabledStaticCall - XCTAssertEqual(event?.module, EthereumAddress("0x3b6def16666a23905dd29071d13e7a9db08240e2")) - XCTAssertEqual(event?.method, Data(hex: "0x20c13b0b")!) - - let event1 = events.last as? EnabledStaticCall - XCTAssertEqual(event1?.module, EthereumAddress("0x3b6def16666a23905dd29071d13e7a9db08240e2")) - XCTAssertEqual(event1?.method, Data(hex: "0x1626ba7e")!) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_givenEventWithData32_ItParsesCorrectly() { - let expect = expectation(description: "Request") - - client.getEvents(addresses: nil, - topics: [try? UpgraderRegistered.signature()], - fromBlock: .Number( - 8110676 ), - toBlock: .Number( - 8110676 ), - eventTypes: [UpgraderRegistered.self]) { (error, events, logs) in - XCTAssertNil(error) - XCTAssertEqual(events.count, 1) - let event = events.first as? UpgraderRegistered - XCTAssertEqual(event?.upgrader, EthereumAddress("0x17b11d842ae09eddedf5592f8271a7d07f6931e7")) - XCTAssertEqual(event?.name, Data(hex: "0x307864323664616666635f307833373731376663310000000000000000000000")!) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } -} - -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) -extension ABIEventTests { - func test_givenEventWithData4_ItParsesCorrectly_Async() async { + func test_givenEventWithData4_ItParsesCorrectly() async { do { let encodedAddress = (try? ABIEncoder.encode(EthereumAddress("0x3B6Def16666a23905DD29071d13E7a9db08240E2")).bytes) ?? [] @@ -89,7 +39,7 @@ extension ABIEventTests { } } - func test_givenEventWithData32_ItParsesCorrectly_Async() async { + func test_givenEventWithData32_ItParsesCorrectly() async { do { let eventsResult = try await client.getEvents(addresses: nil, topics: [try? UpgraderRegistered.signature()], @@ -109,8 +59,6 @@ extension ABIEventTests { } } -#endif - struct EnabledStaticCall: ABIEvent { static let name = "EnabledStaticCall" static let types: [ABIType.Type] = [EthereumAddress.self,Data4.self] diff --git a/web3sTests/ERC165/ERC165Tests.swift b/web3sTests/ERC165/ERC165Tests.swift index f17c6cec..910cc846 100644 --- a/web3sTests/ERC165/ERC165Tests.swift +++ b/web3sTests/ERC165/ERC165Tests.swift @@ -25,36 +25,7 @@ class ERC165Tests: XCTestCase { XCTAssertEqual(ERC165Functions.interfaceId.web3.hexString, "0x01ffc9a7") } - func test_GivenInterfaceffff_returnsNotSupported() { - let expect = expectation(description: "Supports own interface") - erc165.supportsInterface(contract: address, - id: "0xffffffff".web3.hexData!) { (error, supported) in - XCTAssertNil(error) - XCTAssertEqual(supported, false) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_GivenInterfaceERC165_returnsSupported() { - let expect = expectation(description: "Supports own interface") - erc165.supportsInterface(contract: address, - id: ERC165Functions.interfaceId) { (error, supported) in - XCTAssertNil(error) - XCTAssertEqual(supported, true) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } -} - -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) -extension ERC165Tests { - func test_GivenInterfaceffff_returnsNotSupported_Async() async { + func test_GivenInterfaceffff_returnsNotSupported() async { do { let supported = try await erc165.supportsInterface(contract: address, id: "0xffffffff".web3.hexData!) XCTAssertEqual(supported, false) @@ -63,7 +34,7 @@ extension ERC165Tests { } } - func test_GivenInterfaceERC165_returnsSupported_Async() async { + func test_GivenInterfaceERC165_returnsSupported() async { do { let supported = try await erc165.supportsInterface(contract: address, id: ERC165Functions.interfaceId) XCTAssertEqual(supported, true) @@ -73,4 +44,3 @@ extension ERC165Tests { } } -#endif diff --git a/web3sTests/ERC20/ERC20Tests.swift b/web3sTests/ERC20/ERC20Tests.swift index c1077c9c..ee9a12d8 100644 --- a/web3sTests/ERC20/ERC20Tests.swift +++ b/web3sTests/ERC20/ERC20Tests.swift @@ -25,105 +25,7 @@ class ERC20Tests: XCTestCase { super.tearDown() } - func testName() { - let expect = expectation(description: "Get token name") - erc20?.name(tokenContract: self.testContractAddress, completion: { (error, name) in - XCTAssertNil(error) - XCTAssertEqual(name, "BokkyPooBah Test Token") - expect.fulfill() - }) - waitForExpectations(timeout: 10) - } - - func testNonZeroDecimals() { - let expect = expectation(description: "Get token decimals") - erc20?.decimals(tokenContract: self.testContractAddress, completion: { (error, decimals) in - XCTAssertNil(error) - XCTAssertEqual(decimals, 18) - expect.fulfill() - }) - waitForExpectations(timeout: 10) - } - - func testSymbol() { - let expect = expectation(description: "Get token symbol") - erc20?.symbol(tokenContract: self.testContractAddress, completion: { (error, symbol) in - XCTAssertNil(error) - XCTAssertEqual(symbol, "BOKKY") - expect.fulfill() - }) - waitForExpectations(timeout: 10) - } - - func testTransferRawEvent() { - let expect = expectation(description: "Get transfer event") - - let result = try! ABIEncoder.encode(EthereumAddress("0x72e3b687805ef66bf2a1e6d9f03faf8b33f0267a")) - let sig = try! ERC20Events.Transfer.signature() - let topics = [ sig, result.hexString] - - self.client?.getEvents(addresses: nil, topics: topics, fromBlock: .Earliest, toBlock: .Latest, eventTypes: [ERC20Events.Transfer.self], completion: { (error, events, unprocessed) in - XCTAssert(events.count > 0) - expect.fulfill() - }) - waitForExpectations(timeout: 10) - } - - func testGivenAddressWithInTransfers_ThenGetsTheTransferEvents() { - let expect = expectation(description: "Get transfer events to") - - erc20?.transferEventsTo(recipient: EthereumAddress("0x72e3b687805ef66bf2a1e6d9f03faf8b33f0267a"), fromBlock: .Earliest, toBlock: .Latest, completion: { (error, events) in - XCTAssert(events!.count > 0) - expect.fulfill() - }) - - waitForExpectations(timeout: 10) - } - - func testGivenAddressWithoutInTransfers_ThenGetsNoTransferEvents() { - let expect = expectation(description: "Get transfer events to") - - erc20?.transferEventsTo(recipient: EthereumAddress("0x78eac6878f5ef99bf2b12698f03faf8b33f02676"), fromBlock: .Earliest, toBlock: .Latest, completion: { (error, events) in - XCTAssertEqual(events?.count, 0) - expect.fulfill() - }) - - waitForExpectations(timeout: 10) - } - - - func testGivenAddressWithOutgoingEvents_ThenGetsTheTransferEvents() { - let expect = expectation(description: "Get transfer events to") - - erc20?.transferEventsFrom(sender: EthereumAddress("0x2FB78FA9842f20bfD515A41C3196C4b368bDbC48"), fromBlock: .Earliest, toBlock: .Latest, completion: { (error, events) in - XCTAssertEqual(events?.first?.log.transactionHash, "0xfb6e0d7fdf8f9b97fe9b634cb5abc7041ee47a396191f23425955f9fda008efe") - XCTAssertEqual(events?.first?.to, EthereumAddress("0xFe325C1E3396b2285d517B0CE2E3ffA472260Bce")) - XCTAssertEqual(events?.first?.value, BigUInt(10).power(18)) - XCTAssertEqual(events?.first?.log.address, EthereumAddress("0xdb0040451f373949a4be60dcd7b6b8d6e42658b6")) - expect.fulfill() - }) - - waitForExpectations(timeout: 10) - } - - func testGivenAddressWithoutOutgoingEvents_ThenGetsTheTransferEvents() { - let expect = expectation(description: "Get transfer events to") - - erc20?.transferEventsFrom(sender: EthereumAddress("0x78eac6878f5ef99bf2b12698f03faf8b33f02676"), fromBlock: .Earliest, toBlock: .Latest, completion: { (error, events) in - XCTAssertEqual(events?.count, 0) - expect.fulfill() - }) - - waitForExpectations(timeout: 10) - } - -} - -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) -extension ERC20Tests { - func testName_Async() async { + func testName() async { do { let name = try await erc20?.name(tokenContract: self.testContractAddress) XCTAssertEqual(name, "BokkyPooBah Test Token") @@ -132,7 +34,7 @@ extension ERC20Tests { } } - func testNonZeroDecimals_Async() async { + func testNonZeroDecimals() async { do { let decimals = try await erc20?.decimals(tokenContract: self.testContractAddress) XCTAssertEqual(decimals, 18) @@ -141,7 +43,7 @@ extension ERC20Tests { } } - func testNoDecimals_Async() async { + func testNoDecimals() async { do { let decimals = try await erc20?.decimals(tokenContract: EthereumAddress("0x40dd3ac2481960cf34d96e647dd0bc52a1f03f52")) XCTAssertEqual(decimals, 0) @@ -150,7 +52,7 @@ extension ERC20Tests { } } - func testSymbol_Async() async { + func testSymbol() async { do { let symbol = try await erc20?.symbol(tokenContract: self.testContractAddress) XCTAssertEqual(symbol, "BOKKY") @@ -159,7 +61,7 @@ extension ERC20Tests { } } - func testTransferRawEvent_Async() async { + func testTransferRawEvent() async { do { let result = try! ABIEncoder.encode(EthereumAddress("0x72e3b687805ef66bf2a1e6d9f03faf8b33f0267a")) let sig = try! ERC20Events.Transfer.signature() @@ -172,7 +74,7 @@ extension ERC20Tests { } } - func testGivenAddressWithInTransfers_ThenGetsTheTransferEvents_Async() async { + func testGivenAddressWithInTransfers_ThenGetsTheTransferEvents() async { do { let events = try await erc20?.transferEventsTo(recipient: EthereumAddress("0x72e3b687805ef66bf2a1e6d9f03faf8b33f0267a"), fromBlock: .Earliest, toBlock: .Latest) XCTAssert(events!.count > 0) @@ -181,7 +83,7 @@ extension ERC20Tests { } } - func testGivenAddressWithoutInTransfers_ThenGetsNoTransferEvents_Async() async { + func testGivenAddressWithoutInTransfers_ThenGetsNoTransferEvents() async { do { let events = try await erc20?.transferEventsTo(recipient: EthereumAddress("0x78eac6878f5ef99bf2b12698f03faf8b33f02676"), fromBlock: .Earliest, toBlock: .Latest) XCTAssertEqual(events?.count, 0) @@ -191,7 +93,7 @@ extension ERC20Tests { } - func testGivenAddressWithOutgoingEvents_ThenGetsTheTransferEvents_Async() async { + func testGivenAddressWithOutgoingEvents_ThenGetsTheTransferEvents() async { do { let events = try await erc20?.transferEventsFrom(sender: EthereumAddress("0x2FB78FA9842f20bfD515A41C3196C4b368bDbC48"), fromBlock: .Earliest, toBlock: .Latest) XCTAssertEqual(events?.first?.log.transactionHash, "0xfb6e0d7fdf8f9b97fe9b634cb5abc7041ee47a396191f23425955f9fda008efe") @@ -203,7 +105,7 @@ extension ERC20Tests { } } - func testGivenAddressWithoutOutgoingEvents_ThenGetsTheTransferEvents_Async() async { + func testGivenAddressWithoutOutgoingEvents_ThenGetsTheTransferEvents() async { do { let events = try await erc20?.transferEventsFrom(sender: EthereumAddress("0x78eac6878f5ef99bf2b12698f03faf8b33f02676"), fromBlock: .Earliest, toBlock: .Latest) XCTAssertEqual(events?.count, 0) @@ -213,4 +115,3 @@ extension ERC20Tests { } } -#endif diff --git a/web3sTests/ERC721/ERC721Tests.swift b/web3sTests/ERC721/ERC721Tests.swift index d13460ae..bbacb4ad 100644 --- a/web3sTests/ERC721/ERC721Tests.swift +++ b/web3sTests/ERC721/ERC721Tests.swift @@ -32,219 +32,7 @@ class ERC721Tests: XCTestCase { self.erc721 = ERC721(client: client) } - func test_GivenAccountWithNFT_ThenBalanceCorrect() { - let expect = expectation(description: "BalanceOf") - erc721.balanceOf(contract: address, address: tokenOwner) { (error, balance) in - XCTAssertNil(error) - XCTAssertEqual(balance, BigUInt(3)) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_GivenAccountWithNOBalance_ThenBalanceCorrect() { - let expect = expectation(description: "BalanceOf") - erc721.balanceOf(contract: address, address: nonOwner) { (error, balance) in - XCTAssertNil(error) - XCTAssertEqual(balance, BigUInt(0)) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_GivenAccountWithNFT_ThenOwnerOfNFTIsAccount() { - let expect = expectation(description: "OwnerOf") - erc721.ownerOf(contract: address, tokenId: 23) { (error, balance) in - XCTAssertNil(error) - XCTAssertEqual(balance, tokenOwner) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_GivenAccountWithNFT_ThenOwnerOfAnotherNFTIsNotAccount() { - let expect = expectation(description: "OwnerOf") - erc721.ownerOf(contract: address, tokenId: 22) { (error, balance) in - XCTAssertNil(error) - XCTAssertNotEqual(balance, tokenOwner) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_GivenAddressWithTransfer_FindsInTransferEvent() { - let expect = expectation(description: "Events") - - erc721.transferEventsTo(recipient: tokenOwner, - fromBlock: .Number( - 6948276), - toBlock: .Number( - 6948276), - completion: { (error, events) in - XCTAssertEqual(events?.first?.from, previousOwner) - XCTAssertEqual(events?.first?.to, tokenOwner) - XCTAssertEqual(events?.first?.tokenId, 23) - expect.fulfill() - }) - - waitForExpectations(timeout: 10) - } - - func test_GivenAddressWithTransfer_FindsOutTransferEvent() { - let expect = expectation(description: "Events") - - erc721.transferEventsFrom(sender: previousOwner, - fromBlock: .Number( - 6948276), - toBlock: .Number( - 6948276), - completion: { (error, events) in - XCTAssertEqual(events?.first?.to, tokenOwner) - XCTAssertEqual(events?.first?.from, previousOwner) - XCTAssertEqual(events?.first?.tokenId, 23) - expect.fulfill() - }) - - waitForExpectations(timeout: 10) - } -} - -class ERC721MetadataTests: XCTestCase { - var client: EthereumClient! - var erc721: ERC721Metadata! - let address = EthereumAddress(TestConfig.erc721Contract) - let nftDetails = ERC721Metadata.Token(title: "Asset Metadata", - type: "object", - properties: ERC721Metadata.Token.Properties(name: ERC721Metadata.Token.Property(description: "Random Graph Token"), - description: ERC721Metadata.Token.Property(description: "NFT to represent Random Graph"), - image: ERC721Metadata.Token.Property(description: nftImageURL))) - - override func setUp() { - super.setUp() - self.client = EthereumClient(url: URL(string: TestConfig.clientUrl)!) - self.erc721 = ERC721Metadata(client: client, metadataSession: URLSession.shared) - } - - - func test_InterfaceIDMatch() { - XCTAssertEqual(ERC721MetadataFunctions.interfaceId.web3.hexString, "0x5b5e139f") - } - - func test_ReturnsName() { - let expect = expectation(description: "name") - erc721.name(contract: address) { (error, name) in - XCTAssertNil(error) - XCTAssertEqual(name, "Graph Art Token") - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_ReturnsSymbol() { - let expect = expectation(description: "symbol") - erc721.symbol(contract: address) { (error, symbol) in - XCTAssertNil(error) - XCTAssertEqual(symbol, "GAT") - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_ReturnsMetatadaURI() { - let expect = expectation(description: "tokenURI") - erc721.tokenURI(contract: address, tokenID: 23) { (error, url) in - XCTAssertNil(error) - XCTAssertEqual(url, nftURL) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_ReturnsMetatada() { - let expect = expectation(description: "tokenMetadata") - erc721.tokenMetadata(contract: address, tokenID: 23) { (error, metadata) in - XCTAssertNil(error) - XCTAssertEqual(metadata, self.nftDetails) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } -} - -class ERC721EnumerableTests: XCTestCase { - var client: EthereumClient! - var erc721: ERC721Enumerable! - let address = EthereumAddress(TestConfig.erc721Contract) - - override func setUp() { - super.setUp() - self.client = EthereumClient(url: URL(string: TestConfig.clientUrl)!) - self.erc721 = ERC721Enumerable(client: client) - } - - func test_InterfaceIDMatch() { - XCTAssertEqual(ERC721EnumerableFunctions.interfaceId.web3.hexString, "0x780e9d63") - } - - func test_returnsTotalSupply() { - let expect = expectation(description: "totalSupply") - erc721.totalSupply(contract: address) { (error, supply) in - XCTAssertNil(error) - XCTAssertGreaterThan(supply ?? 0, 22) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_returnsTokenByIndex() { - let expect = expectation(description: "tokenByIndex") - erc721.tokenByIndex(contract: address, index: 22) { (error, index) in - XCTAssertNil(error) - XCTAssertEqual(index, 23) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_GivenAddressWithNFT_returnsTokenOfOwnerByIndex() { - let expect = expectation(description: "tokenByIndex") - erc721.tokenOfOwnerByIndex(contract: address, owner: tokenOwner, index: 2) { error, tokenID in - XCTAssertNil(error) - XCTAssertEqual(tokenID, 23) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } - - func test_GivenAddressWithNoNFT_returnsIdZero() { - let expect = expectation(description: "tokenByIndex") - erc721.tokenOfOwnerByIndex(contract: address, owner: nonOwner, index: 0) { error, tokenID in - XCTAssertNil(error) - XCTAssertEqual(tokenID, 0) - expect.fulfill() - } - - waitForExpectations(timeout: 10) - } -} - - -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) -extension ERC721Tests { - func test_GivenAccountWithNFT_ThenBalanceCorrect_Async() async { + func test_GivenAccountWithNFT_ThenBalanceCorrect() async { do { let balance = try await erc721.balanceOf(contract: address, address: tokenOwner) XCTAssertEqual(balance, BigUInt(3)) @@ -253,7 +41,7 @@ extension ERC721Tests { } } - func test_GivenAccountWithNOBalance_ThenBalanceCorrect_Async() async { + func test_GivenAccountWithNOBalance_ThenBalanceCorrect() async { do { let balance = try await erc721.balanceOf(contract: address, address: nonOwner) XCTAssertEqual(balance, BigUInt(0)) @@ -262,7 +50,7 @@ extension ERC721Tests { } } - func test_GivenAccountWithNFT_ThenOwnerOfNFTIsAccount_Async() async { + func test_GivenAccountWithNFT_ThenOwnerOfNFTIsAccount() async { do { let balance = try await erc721.ownerOf(contract: address, tokenId: 23) XCTAssertEqual(balance, tokenOwner) @@ -271,7 +59,7 @@ extension ERC721Tests { } } - func test_GivenAccountWithNFT_ThenOwnerOfAnotherNFTIsNotAccount_Async() async { + func test_GivenAccountWithNFT_ThenOwnerOfAnotherNFTIsNotAccount() async { do { let balance = try await erc721.ownerOf(contract: address, tokenId: 22) XCTAssertNotEqual(balance, tokenOwner) @@ -280,7 +68,7 @@ extension ERC721Tests { } } - func test_GivenAddressWithTransfer_FindsInTransferEvent_Async() async { + func test_GivenAddressWithTransfer_FindsInTransferEvent() async { do { let events = try await erc721.transferEventsTo(recipient: tokenOwner, fromBlock: .Number( @@ -295,7 +83,7 @@ extension ERC721Tests { } } - func test_GivenAddressWithTransfer_FindsOutTransferEvent_Async() async { + func test_GivenAddressWithTransfer_FindsOutTransferEvent() async { do { let events = try await erc721.transferEventsFrom(sender: previousOwner, fromBlock: .Number( @@ -311,9 +99,28 @@ extension ERC721Tests { } } -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) -extension ERC721MetadataTests { - func test_ReturnsName_Async() async { +class ERC721MetadataTests: XCTestCase { + var client: EthereumClient! + var erc721: ERC721Metadata! + let address = EthereumAddress(TestConfig.erc721Contract) + let nftDetails = ERC721Metadata.Token(title: "Asset Metadata", + type: "object", + properties: ERC721Metadata.Token.Properties(name: ERC721Metadata.Token.Property(description: "Random Graph Token"), + description: ERC721Metadata.Token.Property(description: "NFT to represent Random Graph"), + image: ERC721Metadata.Token.Property(description: nftImageURL))) + + override func setUp() { + super.setUp() + self.client = EthereumClient(url: URL(string: TestConfig.clientUrl)!) + self.erc721 = ERC721Metadata(client: client, metadataSession: URLSession.shared) + } + + + func test_InterfaceIDMatch() { + XCTAssertEqual(ERC721MetadataFunctions.interfaceId.web3.hexString, "0x5b5e139f") + } + + func test_ReturnsName() async { do { let name = try await erc721.name(contract: address) XCTAssertEqual(name, "Graph Art Token") @@ -322,7 +129,7 @@ extension ERC721MetadataTests { } } - func test_ReturnsSymbol_Async() async { + func test_ReturnsSymbol() async { do { let symbol = try await erc721.symbol(contract: address) XCTAssertEqual(symbol, "GAT") @@ -331,7 +138,7 @@ extension ERC721MetadataTests { } } - func test_ReturnsMetatadaURI_Async() async { + func test_ReturnsMetatadaURI() async { do { let url = try await erc721.tokenURI(contract: address, tokenID: 23) XCTAssertEqual(url, nftURL) @@ -340,7 +147,7 @@ extension ERC721MetadataTests { } } - func test_ReturnsMetatada_Async() async { + func test_ReturnsMetatada() async { do { let metadata = try await erc721.tokenMetadata(contract: address, tokenID: 23) XCTAssertEqual(metadata, self.nftDetails) @@ -350,9 +157,22 @@ extension ERC721MetadataTests { } } -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) -extension ERC721EnumerableTests { - func test_returnsTotalSupply_Async() async { +class ERC721EnumerableTests: XCTestCase { + var client: EthereumClient! + var erc721: ERC721Enumerable! + let address = EthereumAddress(TestConfig.erc721Contract) + + override func setUp() { + super.setUp() + self.client = EthereumClient(url: URL(string: TestConfig.clientUrl)!) + self.erc721 = ERC721Enumerable(client: client) + } + + func test_InterfaceIDMatch() { + XCTAssertEqual(ERC721EnumerableFunctions.interfaceId.web3.hexString, "0x780e9d63") + } + + func test_returnsTotalSupply() async { do { let supply = try await erc721.totalSupply(contract: address) XCTAssertGreaterThan(supply, 22) @@ -361,7 +181,7 @@ extension ERC721EnumerableTests { } } - func test_returnsTokenByIndex_Async() async { + func test_returnsTokenByIndex() async { do { let index = try await erc721.tokenByIndex(contract: address, index: 22) XCTAssertEqual(index, 23) @@ -370,7 +190,7 @@ extension ERC721EnumerableTests { } } - func test_GivenAddressWithNFT_returnsTokenOfOwnerByIndex_Async() async { + func test_GivenAddressWithNFT_returnsTokenOfOwnerByIndex() async { do { let tokenID = try await erc721.tokenOfOwnerByIndex(contract: address, owner: tokenOwner, index: 2) XCTAssertEqual(tokenID, 23) @@ -379,7 +199,7 @@ extension ERC721EnumerableTests { } } - func test_GivenAddressWithNoNFT_returnsIdZero_Async() async { + func test_GivenAddressWithNoNFT_returnsIdZero() async { do { let tokenID = try await erc721.tokenOfOwnerByIndex(contract: address, owner: nonOwner, index: 0) XCTAssertEqual(tokenID, 0) @@ -388,5 +208,3 @@ extension ERC721EnumerableTests { } } } - -#endif diff --git a/web3sTests/Multicall/MulticallTests.swift b/web3sTests/Multicall/MulticallTests.swift index 16ba5c32..2e085ebf 100644 --- a/web3sTests/Multicall/MulticallTests.swift +++ b/web3sTests/Multicall/MulticallTests.swift @@ -20,52 +20,7 @@ class MulticallTests: XCTestCase { self.multicall = Multicall(client: client!) } - func testNameAndSymbol() throws { - var aggregator = Multicall.Aggregator() - - var name: String? - var decimals: UInt8? - - try aggregator.append(ERC20Functions.decimals(contract: testContractAddress)) { output in - decimals = try ERC20Responses.decimalsResponse(data: output.get())?.value - } - - try aggregator.append( - function: ERC20Functions.name(contract: testContractAddress), - response: ERC20Responses.nameResponse.self - ) { result in - name = try? result.get() - } - - try aggregator.append(ERC20Functions.symbol(contract: testContractAddress)) - - let expect = expectation(description: "Get token name and symbol") - multicall.aggregate(calls: aggregator.calls) { result in - do { - switch result { - case .failure(let error): - XCTFail("Multicall failed with error: \(error)") - case .success(let response): - let symbol = try ERC20Responses.symbolResponse(data: try response.outputs[2].get())?.value - XCTAssertEqual(symbol, "BOKKY") - } - } catch { - XCTFail("Unexpected failure while handling output") - } - expect.fulfill() - } - waitForExpectations(timeout: 10) - - XCTAssertEqual(decimals, 18) - XCTAssertEqual(name, "BokkyPooBah Test Token") - } -} - -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) -extension MulticallTests { - func testNameAndSymbol_Async() async throws { + func testNameAndSymbol() async throws { var aggregator = Multicall.Aggregator() var name: String? @@ -103,4 +58,3 @@ extension MulticallTests { } } -#endif diff --git a/web3swift/src/Client/EthereumClient.swift b/web3swift/src/Client/EthereumClient.swift index dde97b6a..21f3fa3b 100644 --- a/web3swift/src/Client/EthereumClient.swift +++ b/web3swift/src/Client/EthereumClient.swift @@ -43,53 +43,37 @@ public protocol EthereumClientProtocol: AnyObject { func eth_getLogs(addresses: [EthereumAddress]?, orTopics: [[String]?]?, fromBlock: EthereumBlock, toBlock: EthereumBlock, completion: @escaping((EthereumClientError?, [EthereumLog]?) -> Void)) func eth_getBlockByNumber(_ block: EthereumBlock, completion: @escaping((EthereumClientError?, EthereumBlockInfo?) -> Void)) -#if compiler(>=5.5) && canImport(_Concurrency) - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func net_version() async throws -> EthereumNetwork - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_gasPrice() async throws -> BigUInt - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_blockNumber() async throws -> Int - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_getBalance(address: EthereumAddress, block: EthereumBlock) async throws -> BigUInt - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_getCode(address: EthereumAddress, block: EthereumBlock) async throws -> String - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_estimateGas(_ transaction: EthereumTransaction, withAccount account: EthereumAccountProtocol) async throws -> BigUInt - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_sendRawTransaction(_ transaction: EthereumTransaction, withAccount account: EthereumAccountProtocol) async throws -> String - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_getTransactionCount(address: EthereumAddress, block: EthereumBlock) async throws -> Int - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_getTransaction(byHash txHash: String) async throws -> EthereumTransaction - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_getTransactionReceipt(txHash: String) async throws -> EthereumTransactionReceipt - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_call( _ transaction: EthereumTransaction, resolution: CallResolution, block: EthereumBlock ) async throws -> String - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_getLogs(addresses: [EthereumAddress]?, topics: [String?]?, fromBlock: EthereumBlock, toBlock: EthereumBlock) async throws -> [EthereumLog] - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_getLogs(addresses: [EthereumAddress]?, orTopics: [[String]?]?, fromBlock: EthereumBlock, toBlock: EthereumBlock) async throws -> [EthereumLog] - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func eth_getBlockByNumber(_ block: EthereumBlock) async throws -> EthereumBlockInfo -#endif } public enum EthereumClientError: Error, Equatable { @@ -435,9 +419,6 @@ public class EthereumClient: EthereumClientProtocol { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension EthereumClient { public func net_version() async throws -> EthereumNetwork { return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in @@ -614,4 +595,3 @@ extension EthereumClient { } } } -#endif diff --git a/web3swift/src/Client/JSONRPC.swift b/web3swift/src/Client/JSONRPC.swift index e11b762d..e258c397 100644 --- a/web3swift/src/Client/JSONRPC.swift +++ b/web3swift/src/Client/JSONRPC.swift @@ -122,9 +122,6 @@ public class EthereumRPC { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension EthereumRPC { public static func execute(session: URLSession, url: URL, method: String, params: T, receive: U.Type, id: Int = 1) async throws -> Any { return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in @@ -139,4 +136,3 @@ extension EthereumRPC { } } -#endif diff --git a/web3swift/src/Contract/Statically Typed/EthereumClient+Static.swift b/web3swift/src/Contract/Statically Typed/EthereumClient+Static.swift index 185d445a..1902b5fe 100644 --- a/web3swift/src/Contract/Statically Typed/EthereumClient+Static.swift +++ b/web3swift/src/Contract/Statically Typed/EthereumClient+Static.swift @@ -89,9 +89,6 @@ extension CallResolution { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) public extension ABIFunction { func execute(withClient client: EthereumClientProtocol, account: EthereumAccountProtocol) async throws -> String { return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in @@ -127,7 +124,6 @@ public extension ABIFunction { } } } -#endif public struct EventFilter { public let type: ABIEvent.Type @@ -269,15 +265,11 @@ public extension EthereumClientProtocol { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) public struct Events { let events: [ABIEvent] let logs: [EthereumLog] } -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) public extension EthereumClient { func getEvents(addresses: [EthereumAddress]?, orTopics: [[String]?]?, @@ -348,4 +340,3 @@ public extension EthereumClient { } } -#endif diff --git a/web3swift/src/ENS/ENSMultiResolver.swift b/web3swift/src/ENS/ENSMultiResolver.swift index 0f616182..9dad3ffc 100644 --- a/web3swift/src/ENS/ENSMultiResolver.swift +++ b/web3swift/src/ENS/ENSMultiResolver.swift @@ -31,9 +31,6 @@ extension EthereumNameService { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension EthereumNameService { public func resolve(addresses: [EthereumAddress]) async -> Result<[AddressResolveOutput], EthereumNameServiceError> { return await withCheckedContinuation { (continuation: CheckedContinuation, Never>) in @@ -52,8 +49,6 @@ extension EthereumNameService { } } -#endif - extension EthereumNameService { public enum ResolveOutput: Equatable { diff --git a/web3swift/src/ERC165/ERC165.swift b/web3swift/src/ERC165/ERC165.swift index d7a53e18..28452797 100644 --- a/web3swift/src/ERC165/ERC165.swift +++ b/web3swift/src/ERC165/ERC165.swift @@ -25,9 +25,6 @@ public class ERC165 { } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ERC165 { public func supportsInterface(contract: EthereumAddress, id: Data) async throws -> Bool { return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in @@ -41,7 +38,6 @@ extension ERC165 { } } } -#endif public enum ERC165Functions { public static var interfaceId: Data { diff --git a/web3swift/src/ERC20/ERC20.swift b/web3swift/src/ERC20/ERC20.swift index 911ee771..7ba6ba78 100644 --- a/web3swift/src/ERC20/ERC20.swift +++ b/web3swift/src/ERC20/ERC20.swift @@ -19,28 +19,19 @@ public protocol ERC20Protocol { func transferEventsTo(recipient: EthereumAddress, fromBlock: EthereumBlock, toBlock: EthereumBlock, completion: @escaping((Error?, [ERC20Events.Transfer]?) -> Void)) func transferEventsFrom(sender: EthereumAddress, fromBlock: EthereumBlock, toBlock: EthereumBlock, completion: @escaping((Error?, [ERC20Events.Transfer]?) -> Void)) -#if compiler(>=5.5) && canImport(_Concurrency) - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func name(tokenContract: EthereumAddress) async throws -> String - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func symbol(tokenContract: EthereumAddress) async throws -> String - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func decimals(tokenContract: EthereumAddress) async throws -> UInt8 - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func balanceOf(tokenContract: EthereumAddress, address: EthereumAddress) async throws -> BigUInt - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func allowance(tokenContract: EthereumAddress, address: EthereumAddress, spender: EthereumAddress) async throws -> BigUInt - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func transferEventsTo(recipient: EthereumAddress, fromBlock: EthereumBlock, toBlock: EthereumBlock) async throws -> [ERC20Events.Transfer] - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func transferEventsFrom(sender: EthereumAddress, fromBlock: EthereumBlock, toBlock: EthereumBlock) async throws -> [ERC20Events.Transfer] -#endif } public class ERC20: ERC20Protocol { @@ -134,9 +125,6 @@ public class ERC20: ERC20Protocol { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ERC20 { public func name(tokenContract: EthereumAddress) async throws -> String { return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in @@ -222,4 +210,3 @@ extension ERC20 { } } } -#endif diff --git a/web3swift/src/ERC721/ERC721.swift b/web3swift/src/ERC721/ERC721.swift index 028d6110..5bb67df2 100644 --- a/web3swift/src/ERC721/ERC721.swift +++ b/web3swift/src/ERC721/ERC721.swift @@ -81,9 +81,6 @@ public class ERC721: ERC165 { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ERC721 { public func balanceOf(contract: EthereumAddress, address: EthereumAddress) async throws -> BigUInt { return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in @@ -133,7 +130,6 @@ extension ERC721 { } } } -#endif public class ERC721Metadata: ERC721 { public struct Token: Equatable, Decodable { @@ -270,9 +266,6 @@ public class ERC721Metadata: ERC721 { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ERC721Metadata { public func name(contract: EthereumAddress) async throws -> String { return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in @@ -322,7 +315,6 @@ extension ERC721Metadata { } } } -#endif public class ERC721Enumerable: ERC721 { public func totalSupply(contract: EthereumAddress, @@ -357,9 +349,6 @@ public class ERC721Enumerable: ERC721 { } } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ERC721Enumerable { public func totalSupply(contract: EthereumAddress) async throws -> BigUInt { return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in @@ -397,4 +386,3 @@ extension ERC721Enumerable { } } } -#endif diff --git a/web3swift/src/Multicall/Multicall.swift b/web3swift/src/Multicall/Multicall.swift index 5e6547d7..820de339 100644 --- a/web3swift/src/Multicall/Multicall.swift +++ b/web3swift/src/Multicall/Multicall.swift @@ -48,9 +48,6 @@ public struct Multicall { } -#if compiler(>=5.5) && canImport(_Concurrency) - -@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension Multicall { public func aggregate(calls: [Call]) async -> Result { return await withCheckedContinuation { (continuation: CheckedContinuation, Never>) in @@ -61,8 +58,6 @@ extension Multicall { } } -#endif - extension Multicall { public enum MulticallError: Error {