diff --git a/web3swift.xcodeproj/project.pbxproj b/web3swift.xcodeproj/project.pbxproj index 1ad924e6c..2ebdfddd4 100755 --- a/web3swift.xcodeproj/project.pbxproj +++ b/web3swift.xcodeproj/project.pbxproj @@ -10,6 +10,21 @@ 00E5FE8220EA3FF40030E0D6 /* web3swift_infura_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00E5FE8120EA3FF40030E0D6 /* web3swift_infura_Tests.swift */; }; 13AE5971A972F5B55FA6FB69 /* libPods-web3swift-iOS_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8349531F1984454E50389370 /* libPods-web3swift-iOS_Tests.a */; }; 1CD91B341FD769A6007BFB45 /* web3swift_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CD91AFC1FD76910007BFB45 /* web3swift_iOS.framework */; }; + 3AC1E7CB222D6A8C004F43D8 /* Web3+BrowserFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81C0FCF8204456E600D82FAF /* Web3+BrowserFunctions.swift */; }; + 3AC1E7CC222D6A99004F43D8 /* Web3+ERC1376.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8083521CB142000B6BF15 /* Web3+ERC1376.swift */; }; + 3AC1E7CD222D6A99004F43D8 /* Web3+ERC1155.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8083221CB0EF300B6BF15 /* Web3+ERC1155.swift */; }; + 3AC1E7CE222D6A99004F43D8 /* Web3+ERC721x.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082F21CB096D00B6BF15 /* Web3+ERC721x.swift */; }; + 3AC1E7CF222D6A99004F43D8 /* Web3+ERC1633.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082C21CB009A00B6BF15 /* Web3+ERC1633.swift */; }; + 3AC1E7D0222D6A99004F43D8 /* Web3+ERC1643.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082921CAA07000B6BF15 /* Web3+ERC1643.swift */; }; + 3AC1E7D1222D6A99004F43D8 /* Web3+ERC1644.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082621CA9F3100B6BF15 /* Web3+ERC1644.swift */; }; + 3AC1E7D2222D6A99004F43D8 /* Web3+ERC1594.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8082321CA9C3B00B6BF15 /* Web3+ERC1594.swift */; }; + 3AC1E7D3222D6A99004F43D8 /* Web3+ERC1410.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2F8081E21CA90BA00B6BF15 /* Web3+ERC1410.swift */; }; + 3AC1E7D4222D6A99004F43D8 /* Web3+ERC888.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9FD21C48A570081695F /* Web3+ERC888.swift */; }; + 3AC1E7D5222D6A99004F43D8 /* Web3+ERC1400.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9FA21C4860F0081695F /* Web3+ERC1400.swift */; }; + 3AC1E7D6222D6A99004F43D8 /* Web3+ERC820.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9F721C47CD00081695F /* Web3+ERC820.swift */; }; + 3AC1E7D7222D6A99004F43D8 /* Web3+ERC777.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9F421C47B4A0081695F /* Web3+ERC777.swift */; }; + 3AC1E7D8222D6A99004F43D8 /* Web3+ERC165.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9EE21C46A140081695F /* Web3+ERC165.swift */; }; + 3AC1E7D9222D6AA0004F43D8 /* Web3+BrowserFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81C0FCF8204456E600D82FAF /* Web3+BrowserFunctions.swift */; }; 4194811B203630530065A83B /* Web3+HttpProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 817EBB142004FE4200E02EAA /* Web3+HttpProvider.swift */; }; 4194811E203630530065A83B /* Web3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81DDECCE1FDF004E0063684A /* Web3.swift */; }; 4194811F203630530065A83B /* Web3+Instance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 818ABD5A1FE95F8F002657BB /* Web3+Instance.swift */; }; @@ -180,38 +195,6 @@ E2065FB92181D7D700701068 /* Promise+Web3+Contract+GetIndexedEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81195AAF20D7FF8500ABC6B1 /* Promise+Web3+Contract+GetIndexedEvents.swift */; }; E2065FBA2181D7D700701068 /* Promise+Web3+TxPool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 985BFD4D216E2E0A00B28C14 /* Promise+Web3+TxPool.swift */; }; E2065FBB2181D7D700701068 /* Web3+TxPool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 985BFD49216CE8B100B28C14 /* Web3+TxPool.swift */; }; - E228BE0021A4492A0085268C /* TransactionSignerLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BD8D21A4492A0085268C /* TransactionSignerLegacy.swift */; }; - E228BE0121A4492A0085268C /* TransactionSignerLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BD8D21A4492A0085268C /* TransactionSignerLegacy.swift */; }; - E228BE0221A4492A0085268C /* EthereumTransactionLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BD8E21A4492A0085268C /* EthereumTransactionLegacy.swift */; }; - E228BE0321A4492A0085268C /* EthereumTransactionLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BD8E21A4492A0085268C /* EthereumTransactionLegacy.swift */; }; - E228BE0C21A4492A0085268C /* ContractABIv2Legacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BD9521A4492A0085268C /* ContractABIv2Legacy.swift */; }; - E228BE0D21A4492A0085268C /* ContractABIv2Legacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BD9521A4492A0085268C /* ContractABIv2Legacy.swift */; }; - E228BE3621A4492A0085268C /* Web3Legacy+TransactionIntermediate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDAE21A4492A0085268C /* Web3Legacy+TransactionIntermediate.swift */; }; - E228BE3721A4492A0085268C /* Web3Legacy+TransactionIntermediate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDAE21A4492A0085268C /* Web3Legacy+TransactionIntermediate.swift */; }; - E228BE3E21A4492A0085268C /* Web3Legacy+Options.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDB221A4492A0085268C /* Web3Legacy+Options.swift */; }; - E228BE3F21A4492A0085268C /* Web3Legacy+Options.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDB221A4492A0085268C /* Web3Legacy+Options.swift */; }; - E228BE4421A4492A0085268C /* ENSLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDBA21A4492A0085268C /* ENSLegacy.swift */; }; - E228BE4521A4492A0085268C /* ENSLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDBA21A4492A0085268C /* ENSLegacy.swift */; }; - E228BE4C21A4492A0085268C /* ENSResolverLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDBE21A4492A0085268C /* ENSResolverLegacy.swift */; }; - E228BE4D21A4492A0085268C /* ENSResolverLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDBE21A4492A0085268C /* ENSResolverLegacy.swift */; }; - E228BE5A21A4492B0085268C /* Promise+Web3Legacy+Eth+SendTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDC721A4492A0085268C /* Promise+Web3Legacy+Eth+SendTransaction.swift */; }; - E228BE5B21A4492B0085268C /* Promise+Web3Legacy+Eth+SendTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDC721A4492A0085268C /* Promise+Web3Legacy+Eth+SendTransaction.swift */; }; - E228BE6221A4492B0085268C /* Promise+Web3Legacy+Eth+EstimateGas.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDCB21A4492A0085268C /* Promise+Web3Legacy+Eth+EstimateGas.swift */; }; - E228BE6321A4492B0085268C /* Promise+Web3Legacy+Eth+EstimateGas.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDCB21A4492A0085268C /* Promise+Web3Legacy+Eth+EstimateGas.swift */; }; - E228BE7421A4492B0085268C /* Promise+Web3Legacy+Eth+Call.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDD421A4492A0085268C /* Promise+Web3Legacy+Eth+Call.swift */; }; - E228BE7521A4492B0085268C /* Promise+Web3Legacy+Eth+Call.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDD421A4492A0085268C /* Promise+Web3Legacy+Eth+Call.swift */; }; - E228BE7821A4492B0085268C /* Web3Legacy+BrowserFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDD821A4492A0085268C /* Web3Legacy+BrowserFunctions.swift */; }; - E228BE7921A4492B0085268C /* Web3Legacy+BrowserFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDD821A4492A0085268C /* Web3Legacy+BrowserFunctions.swift */; }; - E228BE7E21A4492B0085268C /* ABIv2Legacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDDD21A4492A0085268C /* ABIv2Legacy.swift */; }; - E228BE7F21A4492B0085268C /* ABIv2Legacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDDD21A4492A0085268C /* ABIv2Legacy.swift */; }; - E228BE9C21A4492B0085268C /* AbstractKeystoreLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDEE21A4492A0085268C /* AbstractKeystoreLegacy.swift */; }; - E228BE9D21A4492B0085268C /* AbstractKeystoreLegacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BDEE21A4492A0085268C /* AbstractKeystoreLegacy.swift */; }; - E228BECD21A4C89F0085268C /* Web3Legacy+Contract.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BEC821A4C89E0085268C /* Web3Legacy+Contract.swift */; }; - E228BECE21A4C89F0085268C /* Web3Legacy+Contract.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BEC821A4C89E0085268C /* Web3Legacy+Contract.swift */; }; - E228BECF21A4C89F0085268C /* Web3Legacy+Eth.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BEC921A4C89E0085268C /* Web3Legacy+Eth.swift */; }; - E228BED021A4C89F0085268C /* Web3Legacy+Eth.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BEC921A4C89E0085268C /* Web3Legacy+Eth.swift */; }; - E228BED121A4C89F0085268C /* Web3Legacy+Instance.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BECA21A4C89F0085268C /* Web3Legacy+Instance.swift */; }; - E228BED221A4C89F0085268C /* Web3Legacy+Instance.swift in Sources */ = {isa = PBXBuildFile; fileRef = E228BECA21A4C89F0085268C /* Web3Legacy+Instance.swift */; }; E279C9EF21C46A140081695F /* Web3+ERC165.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9EE21C46A140081695F /* Web3+ERC165.swift */; }; E279C9F521C47B4A0081695F /* Web3+ERC777.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9F421C47B4A0081695F /* Web3+ERC777.swift */; }; E279C9F821C47CD00081695F /* Web3+ERC820.swift in Sources */ = {isa = PBXBuildFile; fileRef = E279C9F721C47CD00081695F /* Web3+ERC820.swift */; }; @@ -385,22 +368,6 @@ B5AFAFC5440E52BE57C7BA13 /* Pods_web3swiftTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_web3swiftTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CA3F7E825AEBF3455D00150A /* Pods-web3swift-macOS_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-web3swift-macOS_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-web3swift-macOS_Tests/Pods-web3swift-macOS_Tests.debug.xcconfig"; sourceTree = ""; }; CDCB852B5E2E84636B80BB99 /* Pods-web3swift-iOS_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-web3swift-iOS_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-web3swift-iOS_Tests/Pods-web3swift-iOS_Tests.release.xcconfig"; sourceTree = ""; }; - E228BD8D21A4492A0085268C /* TransactionSignerLegacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransactionSignerLegacy.swift; sourceTree = ""; }; - E228BD8E21A4492A0085268C /* EthereumTransactionLegacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EthereumTransactionLegacy.swift; sourceTree = ""; }; - E228BD9521A4492A0085268C /* ContractABIv2Legacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContractABIv2Legacy.swift; sourceTree = ""; }; - E228BDAE21A4492A0085268C /* Web3Legacy+TransactionIntermediate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3Legacy+TransactionIntermediate.swift"; sourceTree = ""; }; - E228BDB221A4492A0085268C /* Web3Legacy+Options.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3Legacy+Options.swift"; sourceTree = ""; }; - E228BDBA21A4492A0085268C /* ENSLegacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ENSLegacy.swift; sourceTree = ""; }; - E228BDBE21A4492A0085268C /* ENSResolverLegacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ENSResolverLegacy.swift; sourceTree = ""; }; - E228BDC721A4492A0085268C /* Promise+Web3Legacy+Eth+SendTransaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Promise+Web3Legacy+Eth+SendTransaction.swift"; sourceTree = ""; }; - E228BDCB21A4492A0085268C /* Promise+Web3Legacy+Eth+EstimateGas.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Promise+Web3Legacy+Eth+EstimateGas.swift"; sourceTree = ""; }; - E228BDD421A4492A0085268C /* Promise+Web3Legacy+Eth+Call.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Promise+Web3Legacy+Eth+Call.swift"; sourceTree = ""; }; - E228BDD821A4492A0085268C /* Web3Legacy+BrowserFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3Legacy+BrowserFunctions.swift"; sourceTree = ""; }; - E228BDDD21A4492A0085268C /* ABIv2Legacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ABIv2Legacy.swift; sourceTree = ""; }; - E228BDEE21A4492A0085268C /* AbstractKeystoreLegacy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AbstractKeystoreLegacy.swift; sourceTree = ""; }; - E228BEC821A4C89E0085268C /* Web3Legacy+Contract.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3Legacy+Contract.swift"; sourceTree = ""; }; - E228BEC921A4C89E0085268C /* Web3Legacy+Eth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3Legacy+Eth.swift"; sourceTree = ""; }; - E228BECA21A4C89F0085268C /* Web3Legacy+Instance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3Legacy+Instance.swift"; sourceTree = ""; }; E23B5ADA20EA67D800DC7F32 /* web3swift_AdvancedABIv2_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = web3swift_AdvancedABIv2_Tests.swift; sourceTree = ""; }; E23B5ADC20EA685D00DC7F32 /* web3swift_EIP67_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = web3swift_EIP67_Tests.swift; sourceTree = ""; }; E23B5AE020EA695400DC7F32 /* web3swift_rinkeby_personalSignature_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = web3swift_rinkeby_personalSignature_Tests.swift; sourceTree = ""; }; @@ -490,7 +457,6 @@ 1CD91AFE1FD76910007BFB45 /* web3swift */ = { isa = PBXGroup; children = ( - E228BD8921A4492A0085268C /* web3swiftLegacy */, 8159C50921343EF900197B91 /* PrecompiledContracts */, 81FECD43211ADE20006DA367 /* ObjectiveCbridge */, 81A1821220D5A2430016741F /* Promises */, @@ -835,157 +801,6 @@ name = Pods; sourceTree = ""; }; - E228BD8921A4492A0085268C /* web3swiftLegacy */ = { - isa = PBXGroup; - children = ( - E228BD8A21A4492A0085268C /* TransactionLegacy */, - E228BD8F21A4492A0085268C /* ContractLegacy */, - E228BDA121A4492A0085268C /* Web3Legacy */, - E228BDB821A4492A0085268C /* UtilsLegacy */, - E228BDBF21A4492A0085268C /* PromisesLegacy */, - E228BDD521A4492A0085268C /* HookedFunctionsLegacy */, - E228BDD921A4492A0085268C /* ABIv2Legacy */, - E228BDE221A4492A0085268C /* KeystoreManagerLegacy */, - ); - path = web3swiftLegacy; - sourceTree = ""; - }; - E228BD8A21A4492A0085268C /* TransactionLegacy */ = { - isa = PBXGroup; - children = ( - E228BD8B21A4492A0085268C /* Classes */, - ); - path = TransactionLegacy; - sourceTree = ""; - }; - E228BD8B21A4492A0085268C /* Classes */ = { - isa = PBXGroup; - children = ( - E228BD8D21A4492A0085268C /* TransactionSignerLegacy.swift */, - E228BD8E21A4492A0085268C /* EthereumTransactionLegacy.swift */, - ); - path = Classes; - sourceTree = ""; - }; - E228BD8F21A4492A0085268C /* ContractLegacy */ = { - isa = PBXGroup; - children = ( - E228BD9021A4492A0085268C /* Classes */, - ); - path = ContractLegacy; - sourceTree = ""; - }; - E228BD9021A4492A0085268C /* Classes */ = { - isa = PBXGroup; - children = ( - E228BD9521A4492A0085268C /* ContractABIv2Legacy.swift */, - ); - path = Classes; - sourceTree = ""; - }; - E228BDA121A4492A0085268C /* Web3Legacy */ = { - isa = PBXGroup; - children = ( - E228BDA221A4492A0085268C /* Classes */, - ); - path = Web3Legacy; - sourceTree = ""; - }; - E228BDA221A4492A0085268C /* Classes */ = { - isa = PBXGroup; - children = ( - E228BDAE21A4492A0085268C /* Web3Legacy+TransactionIntermediate.swift */, - E228BDB221A4492A0085268C /* Web3Legacy+Options.swift */, - E228BEC821A4C89E0085268C /* Web3Legacy+Contract.swift */, - E228BEC921A4C89E0085268C /* Web3Legacy+Eth.swift */, - E228BECA21A4C89F0085268C /* Web3Legacy+Instance.swift */, - ); - path = Classes; - sourceTree = ""; - }; - E228BDB821A4492A0085268C /* UtilsLegacy */ = { - isa = PBXGroup; - children = ( - E228BDB921A4492A0085268C /* Classes */, - ); - path = UtilsLegacy; - sourceTree = ""; - }; - E228BDB921A4492A0085268C /* Classes */ = { - isa = PBXGroup; - children = ( - E228BDBA21A4492A0085268C /* ENSLegacy.swift */, - E228BDBE21A4492A0085268C /* ENSResolverLegacy.swift */, - ); - path = Classes; - sourceTree = ""; - }; - E228BDBF21A4492A0085268C /* PromisesLegacy */ = { - isa = PBXGroup; - children = ( - E228BDC021A4492A0085268C /* Classes */, - ); - path = PromisesLegacy; - sourceTree = ""; - }; - E228BDC021A4492A0085268C /* Classes */ = { - isa = PBXGroup; - children = ( - E228BDC721A4492A0085268C /* Promise+Web3Legacy+Eth+SendTransaction.swift */, - E228BDCB21A4492A0085268C /* Promise+Web3Legacy+Eth+EstimateGas.swift */, - E228BDD421A4492A0085268C /* Promise+Web3Legacy+Eth+Call.swift */, - ); - path = Classes; - sourceTree = ""; - }; - E228BDD521A4492A0085268C /* HookedFunctionsLegacy */ = { - isa = PBXGroup; - children = ( - E228BDD621A4492A0085268C /* Classes */, - ); - path = HookedFunctionsLegacy; - sourceTree = ""; - }; - E228BDD621A4492A0085268C /* Classes */ = { - isa = PBXGroup; - children = ( - E228BDD821A4492A0085268C /* Web3Legacy+BrowserFunctions.swift */, - ); - path = Classes; - sourceTree = ""; - }; - E228BDD921A4492A0085268C /* ABIv2Legacy */ = { - isa = PBXGroup; - children = ( - E228BDDA21A4492A0085268C /* Classes */, - ); - path = ABIv2Legacy; - sourceTree = ""; - }; - E228BDDA21A4492A0085268C /* Classes */ = { - isa = PBXGroup; - children = ( - E228BDDD21A4492A0085268C /* ABIv2Legacy.swift */, - ); - path = Classes; - sourceTree = ""; - }; - E228BDE221A4492A0085268C /* KeystoreManagerLegacy */ = { - isa = PBXGroup; - children = ( - E228BDE321A4492A0085268C /* Classes */, - ); - path = KeystoreManagerLegacy; - sourceTree = ""; - }; - E228BDE321A4492A0085268C /* Classes */ = { - isa = PBXGroup; - children = ( - E228BDEE21A4492A0085268C /* AbstractKeystoreLegacy.swift */, - ); - path = Classes; - sourceTree = ""; - }; E279C9ED21C3F2970081695F /* ERC165 */ = { isa = PBXGroup; children = ( @@ -1356,31 +1171,26 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3AC1E7CB222D6A8C004F43D8 /* Web3+BrowserFunctions.swift in Sources */, E2DCA654218C879900F94FBA /* ENS.swift in Sources */, E2DCA655218C879900F94FBA /* ENSResolver.swift in Sources */, E2F8082421CA9C3B00B6BF15 /* Web3+ERC1594.swift in Sources */, 81C146F71FF274B200AA943E /* Web3+Structures.swift in Sources */, 8104E2281FE82BDC00F952CB /* Web3+Utils.swift in Sources */, - E228BE3E21A4492A0085268C /* Web3Legacy+Options.swift in Sources */, - E228BE0C21A4492A0085268C /* ContractABIv2Legacy.swift in Sources */, 81909D2B218852E2007D2AE5 /* Web3+ERC20.swift in Sources */, - E228BE4C21A4492A0085268C /* ENSResolverLegacy.swift in Sources */, 818ABD5D1FE95FC9002657BB /* Web3+Contract.swift in Sources */, 8113D2CA1FD7E1590074282C /* KeystoreManager.swift in Sources */, 817EBB1F2006265400E02EAA /* Base58.swift in Sources */, - E228BE9C21A4492B0085268C /* AbstractKeystoreLegacy.swift in Sources */, 817EBB2520066E2B00E02EAA /* AbstractKeystore.swift in Sources */, 81C0FCF720441A1D00D82FAF /* TransactionSigner.swift in Sources */, 8125F06920499AC300A0F2FE /* BloomFilter.swift in Sources */, 810B0F9A1FEC446B00CF0DA2 /* Web3+JSONRPC.swift in Sources */, 81195AB020D7FF8500ABC6B1 /* Promise+Web3+Contract+GetIndexedEvents.swift in Sources */, 81EB1E4B208173D7003BD47F /* Web3+Personal.swift in Sources */, - E228BE7821A4492B0085268C /* Web3Legacy+BrowserFunctions.swift in Sources */, 81909D1821862D5A007D2AE5 /* Web3+Eventloop.swift in Sources */, E2F8082721CA9F3100B6BF15 /* Web3+ERC1644.swift in Sources */, 81A1824B20D7DF1B0016741F /* Promise+Web3+Personal+UnlockAccount.swift in Sources */, 81A1823A20D79AD40016741F /* Promise+Web3+Eth+SendRawTransaction.swift in Sources */, - E228BE0021A4492A0085268C /* TransactionSignerLegacy.swift in Sources */, 81D7D97520A3240900A193EC /* EthereumFilterEncodingExtensions.swift in Sources */, 817EBB122004FE2F00E02EAA /* BIP32HDNode.swift in Sources */, 8113D2C41FD7E1590074282C /* CryptoExtensions.swift in Sources */, @@ -1394,7 +1204,6 @@ 817EBB27200673D100E02EAA /* KeystoreV3JSONStructure.swift in Sources */, 81FB21FE207BB297007F9A83 /* EIP67Code.swift in Sources */, 81A1821A20D5A6F70016741F /* Promise+HttpProvider.swift in Sources */, - E228BECD21A4C89F0085268C /* Web3Legacy+Contract.swift in Sources */, E2F8083621CB142000B6BF15 /* Web3+ERC1376.swift in Sources */, E279C9F821C47CD00081695F /* Web3+ERC820.swift in Sources */, 81A1823720D6E2BB0016741F /* Promise+Web3+Eth+GetBlockByHash.swift in Sources */, @@ -1405,11 +1214,9 @@ 81C5DA282072E18200424CD6 /* NativeTypesEncoding+Extensions.swift in Sources */, 8123E1C7200CBAC200B6D3AB /* Dictionary+Extension.swift in Sources */, E2F8083321CB0EF300B6BF15 /* Web3+ERC1155.swift in Sources */, - E228BE7421A4492B0085268C /* Promise+Web3Legacy+Eth+Call.swift in Sources */, 985BFD4E216E2E0A00B28C14 /* Promise+Web3+TxPool.swift in Sources */, 985BFD4A216CE8B100B28C14 /* Web3+TxPool.swift in Sources */, 81D7D97820A61E3800A193EC /* EventFiltering.swift in Sources */, - E228BE7E21A4492B0085268C /* ABIv2Legacy.swift in Sources */, 8160E5CE20B8245A0070070B /* IBAN.swift in Sources */, 81909D1521862D37007D2AE5 /* Web3+MutatingTransaction.swift in Sources */, 810B0F9C1FEC520500CF0DA2 /* Web3+Methods.swift in Sources */, @@ -1421,7 +1228,6 @@ 810B0F9E1FEC5B9C00CF0DA2 /* Web3+Eth.swift in Sources */, 81531AA01FE7C07A002192CC /* EthereumKeystoreV3.swift in Sources */, 81A1824820D7DDA20016741F /* Promise+Web3+Personal+Sign.swift in Sources */, - E228BE5A21A4492B0085268C /* Promise+Web3Legacy+Eth+SendTransaction.swift in Sources */, 8123E1C9200CBAF800B6D3AB /* Data+Extension.swift in Sources */, 817EBB23200649E000E02EAA /* RIPEMD160+StackOveflow.swift in Sources */, 8116666320455E33008D8AD0 /* Web3+Wallet.swift in Sources */, @@ -1430,19 +1236,13 @@ 81A1823420D6E1FD0016741F /* Promise+Web3+Eth+GetBlockByNumber.swift in Sources */, 81A1822820D678BF0016741F /* Promise+Web3+Eth+GetAccounts.swift in Sources */, E2F8081F21CA90BA00B6BF15 /* Web3+ERC1410.swift in Sources */, - E228BE3621A4492A0085268C /* Web3Legacy+TransactionIntermediate.swift in Sources */, 81A7B2512143C3A8004CD2C7 /* NameHash.swift in Sources */, E2F8083021CB096D00B6BF15 /* Web3+ERC721x.swift in Sources */, 81C5DA312074EC1E00424CD6 /* ContractProtocol.swift in Sources */, - E228BED121A4C89F0085268C /* Web3Legacy+Instance.swift in Sources */, 815630002007B48800A0EC2F /* BIP32KeystoreJSONStructure.swift in Sources */, 8123E1CB200CBB2200B6D3AB /* Array+Extension.swift in Sources */, - E228BECF21A4C89F0085268C /* Web3Legacy+Eth.swift in Sources */, - E228BE6221A4492B0085268C /* Promise+Web3Legacy+Eth+EstimateGas.swift in Sources */, - E228BE0221A4492A0085268C /* EthereumTransactionLegacy.swift in Sources */, E2F8082D21CB009A00B6BF15 /* Web3+ERC1633.swift in Sources */, 813FFF8D1FD82EEB006379A2 /* String+Extension.swift in Sources */, - E228BE4421A4492A0085268C /* ENSLegacy.swift in Sources */, 81A1823120D68A110016741F /* Promise+Batching.swift in Sources */, 817EBB162004FE4200E02EAA /* Web3+HttpProvider.swift in Sources */, 8103BBCC2077B84400499769 /* PlainKeystore.swift in Sources */, @@ -1492,29 +1292,37 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3AC1E7D9222D6AA0004F43D8 /* Web3+BrowserFunctions.swift in Sources */, + 3AC1E7CC222D6A99004F43D8 /* Web3+ERC1376.swift in Sources */, + 3AC1E7CD222D6A99004F43D8 /* Web3+ERC1155.swift in Sources */, + 3AC1E7CE222D6A99004F43D8 /* Web3+ERC721x.swift in Sources */, + 3AC1E7CF222D6A99004F43D8 /* Web3+ERC1633.swift in Sources */, + 3AC1E7D0222D6A99004F43D8 /* Web3+ERC1643.swift in Sources */, + 3AC1E7D1222D6A99004F43D8 /* Web3+ERC1644.swift in Sources */, + 3AC1E7D2222D6A99004F43D8 /* Web3+ERC1594.swift in Sources */, + 3AC1E7D3222D6A99004F43D8 /* Web3+ERC1410.swift in Sources */, + 3AC1E7D4222D6A99004F43D8 /* Web3+ERC888.swift in Sources */, + 3AC1E7D5222D6A99004F43D8 /* Web3+ERC1400.swift in Sources */, + 3AC1E7D6222D6A99004F43D8 /* Web3+ERC820.swift in Sources */, + 3AC1E7D7222D6A99004F43D8 /* Web3+ERC777.swift in Sources */, + 3AC1E7D8222D6A99004F43D8 /* Web3+ERC165.swift in Sources */, E2DCA656218C87A500F94FBA /* ENS.swift in Sources */, E2DCA657218C87A500F94FBA /* ENSResolver.swift in Sources */, E2065FB82181D7D700701068 /* Promise+Web3+Eth+EstimateGas.swift in Sources */, E2065FB92181D7D700701068 /* Promise+Web3+Contract+GetIndexedEvents.swift in Sources */, - E228BE3F21A4492A0085268C /* Web3Legacy+Options.swift in Sources */, - E228BE0D21A4492A0085268C /* ContractABIv2Legacy.swift in Sources */, 81909D2C218852E2007D2AE5 /* Web3+ERC20.swift in Sources */, - E228BE4D21A4492A0085268C /* ENSResolverLegacy.swift in Sources */, E2065FBA2181D7D700701068 /* Promise+Web3+TxPool.swift in Sources */, E2065FBB2181D7D700701068 /* Web3+TxPool.swift in Sources */, 4194811B203630530065A83B /* Web3+HttpProvider.swift in Sources */, - E228BE9D21A4492B0085268C /* AbstractKeystoreLegacy.swift in Sources */, 4194811E203630530065A83B /* Web3.swift in Sources */, 4194811F203630530065A83B /* Web3+Instance.swift in Sources */, 41948120203630530065A83B /* Web3+Contract.swift in Sources */, 41948121203630530065A83B /* Web3+Utils.swift in Sources */, 81909D1921862D5A007D2AE5 /* Web3+Eventloop.swift in Sources */, 8125F06A20499AC300A0F2FE /* BloomFilter.swift in Sources */, - E228BE7921A4492B0085268C /* Web3Legacy+BrowserFunctions.swift in Sources */, 81C0FD062044A8D100D82FAF /* TransactionSigner.swift in Sources */, 41948123203630530065A83B /* Web3+JSONRPC.swift in Sources */, 41948124203630530065A83B /* Web3+Structures.swift in Sources */, - E228BE0121A4492A0085268C /* TransactionSignerLegacy.swift in Sources */, 41948125203630530065A83B /* Web3+Methods.swift in Sources */, 81EB1E4C208173D7003BD47F /* Web3+Personal.swift in Sources */, 81D7D97620A3240900A193EC /* EthereumFilterEncodingExtensions.swift in Sources */, @@ -1528,17 +1336,14 @@ 81A1823D20D79C290016741F /* Promise+Web3+Eth+Call.swift in Sources */, 81FB21FF207BB297007F9A83 /* EIP67Code.swift in Sources */, 81A1821B20D5A6F80016741F /* Promise+HttpProvider.swift in Sources */, - E228BECE21A4C89F0085268C /* Web3Legacy+Contract.swift in Sources */, 81A1823820D6E2BB0016741F /* Promise+Web3+Eth+GetBlockByHash.swift in Sources */, 81909D52218DAEC0007D2AE5 /* Promise+Web3+Personal+CreateAccount.swift in Sources */, 818D16D0204D42940084D2A4 /* Web3+EventParser.swift in Sources */, 4194812E203630530065A83B /* AbstractKeystore.swift in Sources */, 81C5DA292072E18200424CD6 /* NativeTypesEncoding+Extensions.swift in Sources */, - E228BE7521A4492B0085268C /* Promise+Web3Legacy+Eth+Call.swift in Sources */, 41948130203630530065A83B /* BIP32Keystore.swift in Sources */, 81D7D97920A61E3800A193EC /* EventFiltering.swift in Sources */, 8160E5CF20B8245A0070070B /* IBAN.swift in Sources */, - E228BE7F21A4492B0085268C /* ABIv2Legacy.swift in Sources */, 41948131203630530065A83B /* BIP32KeystoreJSONStructure.swift in Sources */, 41948132203630530065A83B /* BIP32HDNode.swift in Sources */, 81A7B2522143C3A8004CD2C7 /* NameHash.swift in Sources */, @@ -1549,7 +1354,6 @@ 41948133203630530065A83B /* BIP39.swift in Sources */, 81C5DA2F2074EBF500424CD6 /* EthereumContract.swift in Sources */, 81A1824320D7AA750016741F /* Promise+Web3+Eth+SendTransaction.swift in Sources */, - E228BE5B21A4492B0085268C /* Promise+Web3Legacy+Eth+SendTransaction.swift in Sources */, 41948134203630530065A83B /* BIP39+WordLists.swift in Sources */, 41948135203630530065A83B /* EthereumKeystoreV3.swift in Sources */, 41948136203630530065A83B /* KeystoreV3JSONStructure.swift in Sources */, @@ -1557,17 +1361,11 @@ 81909D2221884893007D2AE5 /* BigUInt+Extensions.swift in Sources */, 41948137203630530065A83B /* EthereumTransaction.swift in Sources */, 41948138203630530065A83B /* CryptoExtensions.swift in Sources */, - E228BE3721A4492A0085268C /* Web3Legacy+TransactionIntermediate.swift in Sources */, 81C0FD052044A8AE00D82FAF /* Web3+Protocols.swift in Sources */, 81A1823520D6E1FD0016741F /* Promise+Web3+Eth+GetBlockByNumber.swift in Sources */, - E228BED221A4C89F0085268C /* Web3Legacy+Instance.swift in Sources */, 81A1822920D678BF0016741F /* Promise+Web3+Eth+GetAccounts.swift in Sources */, 81C5DA322074EC1E00424CD6 /* ContractProtocol.swift in Sources */, - E228BED021A4C89F0085268C /* Web3Legacy+Eth.swift in Sources */, - E228BE6321A4492B0085268C /* Promise+Web3Legacy+Eth+EstimateGas.swift in Sources */, - E228BE0321A4492A0085268C /* EthereumTransactionLegacy.swift in Sources */, 81A1824C20D7DF1B0016741F /* Promise+Web3+Personal+UnlockAccount.swift in Sources */, - E228BE4521A4492A0085268C /* ENSLegacy.swift in Sources */, 4194813B203630530065A83B /* NSRegularExpressionExtension.swift in Sources */, 81C0FD042044A8A700D82FAF /* Web3+Options.swift in Sources */, 81A1823220D68A110016741F /* Promise+Batching.swift in Sources */, diff --git a/web3swift/Contract/Classes/EthereumContract.swift b/web3swift/Contract/Classes/EthereumContract.swift index 516c01ad7..5d5fd944c 100755 --- a/web3swift/Contract/Classes/EthereumContract.swift +++ b/web3swift/Contract/Classes/EthereumContract.swift @@ -9,7 +9,6 @@ import EthereumAddress import EthereumABI public struct EthereumContract:ContractProtocol { - public var options: Web3Options? = Web3Options.defaultOptions() public var transactionOptions: TransactionOptions? = TransactionOptions.defaultOptions public var address: EthereumAddress? = nil diff --git a/web3swift/HookedFunctions/Classes/Web3+BrowserFunctions.swift b/web3swift/HookedFunctions/Classes/Web3+BrowserFunctions.swift index f776821aa..1d34a9577 100755 --- a/web3swift/HookedFunctions/Classes/Web3+BrowserFunctions.swift +++ b/web3swift/HookedFunctions/Classes/Web3+BrowserFunctions.swift @@ -68,13 +68,7 @@ extension web3.BrowserFunctions { public func sendTransaction(_ transactionJSON: [String: Any], password: String = "web3swift") -> [String:Any]? { guard let transaction = EthereumTransaction.fromJSON(transactionJSON) else {return nil} - guard let options = Web3Options.fromJSON(transactionJSON) else {return nil} - var transactionOptions = TransactionOptions() - transactionOptions.from = options.from - transactionOptions.to = options.to - transactionOptions.value = options.value - transactionOptions.gasLimit = options.gasLimit != nil ? .limited(options.gasLimit!) : .automatic - transactionOptions.gasPrice = options.gasPrice != nil ? .manual(options.gasPrice!) : .automatic + guard let transactionOptions = TransactionOptions.fromJSON(transactionJSON) else {return nil} return self.sendTransaction(transaction, transactionOptions: transactionOptions, password: password) } @@ -89,13 +83,7 @@ extension web3.BrowserFunctions { public func estimateGas(_ transactionJSON: [String: Any]) -> BigUInt? { guard let transaction = EthereumTransaction.fromJSON(transactionJSON) else {return nil} - guard let options = Web3Options.fromJSON(transactionJSON) else {return nil} - var transactionOptions = TransactionOptions() - transactionOptions.from = options.from - transactionOptions.to = options.to - transactionOptions.value = options.value - transactionOptions.gasLimit = .automatic - transactionOptions.gasPrice = options.gasPrice != nil ? .manual(options.gasPrice!) : .automatic + guard let transactionOptions = TransactionOptions.fromJSON(transactionJSON) else {return nil} return self.estimateGas(transaction, transactionOptions: transactionOptions) } @@ -134,13 +122,7 @@ extension web3.BrowserFunctions { public func signTransaction(_ transactionJSON: [String: Any], password: String = "web3swift") -> String? { guard let transaction = EthereumTransaction.fromJSON(transactionJSON) else {return nil} - guard let options = Web3Options.fromJSON(transactionJSON) else {return nil} - var transactionOptions = TransactionOptions() - transactionOptions.from = options.from - transactionOptions.to = options.to - transactionOptions.value = options.value - transactionOptions.gasLimit = options.gasLimit != nil ? .limited(options.gasLimit!) : .automatic - transactionOptions.gasPrice = options.gasPrice != nil ? .manual(options.gasPrice!) : .automatic + guard var transactionOptions = TransactionOptions.fromJSON(transactionJSON) else {return nil} if let nonceString = transactionJSON["nonce"] as? String, let nonce = BigUInt(nonceString.stripHexPrefix(), radix: 16) { transactionOptions.nonce = .manual(nonce) } else { diff --git a/web3swift/PrecompiledContracts/ERC1155/Web3+ERC1155.swift b/web3swift/PrecompiledContracts/ERC1155/Web3+ERC1155.swift index 387a6aab3..7d129d82e 100644 --- a/web3swift/PrecompiledContracts/ERC1155/Web3+ERC1155.swift +++ b/web3swift/PrecompiledContracts/ERC1155/Web3+ERC1155.swift @@ -32,9 +32,6 @@ protocol IERC1155Metadata { public class ERC1155: IERC1155 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _tokenId: BigUInt? = nil private var _hasReadProperties: Bool = false diff --git a/web3swift/PrecompiledContracts/ERC1376/Web3+ERC1376.swift b/web3swift/PrecompiledContracts/ERC1376/Web3+ERC1376.swift index d259a3909..868dbb7c3 100644 --- a/web3swift/PrecompiledContracts/ERC1376/Web3+ERC1376.swift +++ b/web3swift/PrecompiledContracts/ERC1376/Web3+ERC1376.swift @@ -69,9 +69,6 @@ protocol IERC1376: IERC20 { public class ERC1376: IERC1376 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _name: String? = nil private var _symbol: String? = nil private var _decimals: UInt8? = nil diff --git a/web3swift/PrecompiledContracts/ERC1400/Web3+ERC1400.swift b/web3swift/PrecompiledContracts/ERC1400/Web3+ERC1400.swift index faa97ea04..ae51bf0ad 100644 --- a/web3swift/PrecompiledContracts/ERC1400/Web3+ERC1400.swift +++ b/web3swift/PrecompiledContracts/ERC1400/Web3+ERC1400.swift @@ -66,9 +66,6 @@ protocol IERC1400: IERC20 { // can be imperatively read and saved public class ERC1400: IERC1400 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _name: String? = nil private var _symbol: String? = nil private var _decimals: UInt8? = nil diff --git a/web3swift/PrecompiledContracts/ERC1410/Web3+ERC1410.swift b/web3swift/PrecompiledContracts/ERC1410/Web3+ERC1410.swift index 82c7ba8d8..8bdec4635 100644 --- a/web3swift/PrecompiledContracts/ERC1410/Web3+ERC1410.swift +++ b/web3swift/PrecompiledContracts/ERC1410/Web3+ERC1410.swift @@ -44,9 +44,6 @@ protocol IERC1410: IERC20 { public class ERC1410: IERC1410 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _name: String? = nil private var _symbol: String? = nil private var _decimals: UInt8? = nil diff --git a/web3swift/PrecompiledContracts/ERC1594/Web3+ERC1594.swift b/web3swift/PrecompiledContracts/ERC1594/Web3+ERC1594.swift index cb32899fa..3590a2de3 100644 --- a/web3swift/PrecompiledContracts/ERC1594/Web3+ERC1594.swift +++ b/web3swift/PrecompiledContracts/ERC1594/Web3+ERC1594.swift @@ -34,9 +34,6 @@ protocol IERC1594: IERC20 { public class ERC1594: IERC1594 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _name: String? = nil private var _symbol: String? = nil private var _decimals: UInt8? = nil diff --git a/web3swift/PrecompiledContracts/ERC1633/Web3+ERC1633.swift b/web3swift/PrecompiledContracts/ERC1633/Web3+ERC1633.swift index b4c9ba061..a71e051b8 100644 --- a/web3swift/PrecompiledContracts/ERC1633/Web3+ERC1633.swift +++ b/web3swift/PrecompiledContracts/ERC1633/Web3+ERC1633.swift @@ -21,9 +21,6 @@ protocol IERC1633: IERC20, IERC165 { public class ERC1633: IERC1633 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _name: String? = nil private var _symbol: String? = nil private var _decimals: UInt8? = nil diff --git a/web3swift/PrecompiledContracts/ERC1643/Web3+ERC1643.swift b/web3swift/PrecompiledContracts/ERC1643/Web3+ERC1643.swift index 6ba4c056e..231d8b5df 100644 --- a/web3swift/PrecompiledContracts/ERC1643/Web3+ERC1643.swift +++ b/web3swift/PrecompiledContracts/ERC1643/Web3+ERC1643.swift @@ -23,8 +23,6 @@ protocol IERC1643: IERC20 { } public class ERC1643: IERC1643 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() private var _name: String? = nil private var _symbol: String? = nil diff --git a/web3swift/PrecompiledContracts/ERC1644/Web3+ERC1644.swift b/web3swift/PrecompiledContracts/ERC1644/Web3+ERC1644.swift index 819ff3a64..a82cc2da7 100644 --- a/web3swift/PrecompiledContracts/ERC1644/Web3+ERC1644.swift +++ b/web3swift/PrecompiledContracts/ERC1644/Web3+ERC1644.swift @@ -22,8 +22,6 @@ protocol IERC1644: IERC20 { } public class ERC1644: IERC1644 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() private var _name: String? = nil private var _symbol: String? = nil diff --git a/web3swift/PrecompiledContracts/ERC20/Web3+ERC20.swift b/web3swift/PrecompiledContracts/ERC20/Web3+ERC20.swift index c6bd0b6b4..b4116e264 100644 --- a/web3swift/PrecompiledContracts/ERC20/Web3+ERC20.swift +++ b/web3swift/PrecompiledContracts/ERC20/Web3+ERC20.swift @@ -25,9 +25,6 @@ protocol IERC20 { // can be imperatively read and saved public class ERC20: IERC20 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _name: String? = nil private var _symbol: String? = nil private var _decimals: UInt8? = nil diff --git a/web3swift/PrecompiledContracts/ERC721/Web3+ERC721.swift b/web3swift/PrecompiledContracts/ERC721/Web3+ERC721.swift index 58c159c63..1960b095a 100644 --- a/web3swift/PrecompiledContracts/ERC721/Web3+ERC721.swift +++ b/web3swift/PrecompiledContracts/ERC721/Web3+ERC721.swift @@ -52,9 +52,6 @@ protocol IERC721Enumerable { // can be imperatively read and saved public class ERC721: IERC721 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _tokenId: BigUInt? = nil private var _hasReadProperties: Bool = false diff --git a/web3swift/PrecompiledContracts/ERC721x/Web3+ERC721x.swift b/web3swift/PrecompiledContracts/ERC721x/Web3+ERC721x.swift index e014148d3..ccaff5438 100644 --- a/web3swift/PrecompiledContracts/ERC721x/Web3+ERC721x.swift +++ b/web3swift/PrecompiledContracts/ERC721x/Web3+ERC721x.swift @@ -38,9 +38,6 @@ protocol IERC721x: IERC721, IERC721Metadata, IERC721Enumerable { public class ERC721x: IERC721x { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _tokenId: BigUInt? = nil private var _hasReadProperties: Bool = false diff --git a/web3swift/PrecompiledContracts/ERC888/Web3+ERC888.swift b/web3swift/PrecompiledContracts/ERC888/Web3+ERC888.swift index 4da36bbf8..f5201c158 100644 --- a/web3swift/PrecompiledContracts/ERC888/Web3+ERC888.swift +++ b/web3swift/PrecompiledContracts/ERC888/Web3+ERC888.swift @@ -19,9 +19,6 @@ protocol IERC888 { public class ERC888: IERC888 { - @available(*, deprecated, renamed: "transactionOptions") - public var options: Web3Options = .init() - private var _name: String? = nil private var _symbol: String? = nil private var _decimals: UInt8? = nil diff --git a/web3swift/Transaction/Classes/EthereumTransaction.swift b/web3swift/Transaction/Classes/EthereumTransaction.swift index f3c4bb5ca..f0af760a3 100755 --- a/web3swift/Transaction/Classes/EthereumTransaction.swift +++ b/web3swift/Transaction/Classes/EthereumTransaction.swift @@ -280,3 +280,110 @@ public struct EthereumTransaction: CustomStringConvertible { return request } } + +extension EthereumTransaction { + public init(to: EthereumAddress, data: Data, options: TransactionOptions) { + let defaults = TransactionOptions.defaultOptions + let merged = defaults.merge(options) + self.nonce = BigUInt(0) + + if let gP = merged.gasPrice { + switch gP { + case .manual(let value): + self.gasPrice = value + default: + self.gasPrice = BigUInt("5000000000")! + } + } + + if let gL = merged.gasLimit { + switch gL { + case .manual(let value): + self.gasLimit = value + default: + self.gasLimit = BigUInt(UInt64(21000)) + } + } + + self.value = merged.value! + self.to = to + self.data = data + } + + public func mergedWithOptions(_ options: TransactionOptions) -> EthereumTransaction { + var tx = self; + + if let gP = options.gasPrice { + switch gP { + case .manual(let value): + tx.gasPrice = value + default: + tx.gasPrice = BigUInt("5000000000")! + } + } + + if let gL = options.gasLimit { + switch gL { + case .manual(let value): + tx.gasLimit = value + default: + tx.gasLimit = BigUInt(UInt64(21000)) + } + } + + if options.value != nil { + tx.value = options.value! + } + if options.to != nil { + tx.to = options.to! + } + return tx + } + + static func fromJSON(_ json: [String: Any]) -> EthereumTransaction? { + guard let options = TransactionOptions.fromJSON(json) else {return nil} + guard let toString = json["to"] as? String else {return nil} + var to: EthereumAddress + if toString == "0x" || toString == "0x0" { + to = EthereumAddress.contractDeploymentAddress() + } else { + guard let ethAddr = EthereumAddress(toString) else {return nil} + to = ethAddr + } + // if (!to.isValid) { + // return nil + // } + var dataString = json["data"] as? String + if (dataString == nil) { + dataString = json["input"] as? String + } + guard dataString != nil, let data = Data.fromHex(dataString!) else {return nil} + var transaction = EthereumTransaction(to: to, data: data, options: options) + if let nonceString = json["nonce"] as? String { + guard let nonce = BigUInt(nonceString.stripHexPrefix(), radix: 16) else {return nil} + transaction.nonce = nonce + } + if let vString = json["v"] as? String { + guard let v = BigUInt(vString.stripHexPrefix(), radix: 16) else {return nil} + transaction.v = v + } + if let rString = json["r"] as? String { + guard let r = BigUInt(rString.stripHexPrefix(), radix: 16) else {return nil} + transaction.r = r + } + if let sString = json["s"] as? String { + guard let s = BigUInt(sString.stripHexPrefix(), radix: 16) else {return nil} + transaction.s = s + } + if let valueString = json["value"] as? String { + guard let value = BigUInt(valueString.stripHexPrefix(), radix: 16) else {return nil} + transaction.value = value + } + let inferedChainID = transaction.inferedChainID + if (transaction.inferedChainID != nil && transaction.v >= BigUInt(37)) { + transaction.chainID = inferedChainID + } + return transaction + } + +} diff --git a/web3swift/Web3/Classes/Web3+Contract.swift b/web3swift/Web3/Classes/Web3+Contract.swift index da3276838..3d1df7762 100755 --- a/web3swift/Web3/Classes/Web3+Contract.swift +++ b/web3swift/Web3/Classes/Web3+Contract.swift @@ -21,9 +21,6 @@ extension web3 { var web3 : web3 public var transactionOptions: TransactionOptions? = nil - @available(*, deprecated, message: "Use transactioinOptions instead") - public var options: Web3Options? = nil - /// Initialize the bound contract instance by supplying the Web3 provider bound object, ABI, Ethereum address and some default /// options for further function calls. By default the contract inherits options from the web3 object. Additionally supplied "options" /// do override inherited ones. @@ -45,31 +42,6 @@ extension web3 { self.transactionOptions = mergedOptions } - - @available(*, deprecated, message: "Use init with transactionOptions instead") - public init?(web3 web3Instance:web3, abiString: String, at: EthereumAddress? = nil, options: Web3Options?, abiVersion: Int = 2) { - self.web3 = web3Instance - self.options = web3.options - switch abiVersion { - case 1: - print("ABIv1 bound contract is now deprecated") - return nil - case 2: - guard let c = EthereumContract(abiString, at: at) else {return nil} - contract = c - default: - return nil - } - var mergedOptions = Web3Options.merge(self.options, with: options) - if at != nil { - contract.address = at - mergedOptions?.to = at - } else if let addr = mergedOptions?.to { - contract.address = addr - } - self.options = mergedOptions - } - /// Deploys a constact instance using the previously provided (at initialization) ABI, some bytecode, constructor parameters and options. /// If extraData is supplied it is appended to encoded bytecode and constructor parameters. /// diff --git a/web3swift/Web3/Classes/Web3+Instance.swift b/web3swift/Web3/Classes/Web3+Instance.swift index 7b5d699e3..6bef463ff 100755 --- a/web3swift/Web3/Classes/Web3+Instance.swift +++ b/web3swift/Web3/Classes/Web3+Instance.swift @@ -11,9 +11,6 @@ import PromiseKit /// A web3 instance bound to provider. All further functionality is provided under web.*. namespaces. public class web3 { - @available(*, deprecated, message: "Don't use Web3Options") - public var options : Web3Options = Web3Options.defaultOptions() - public var provider : Web3Provider public var transactionOptions: TransactionOptions = TransactionOptions.defaultOptions public var defaultBlock = "latest" @@ -55,8 +52,6 @@ public class web3 { var provider:Web3Provider // weak var web3: web3? var web3: web3 - @available(*, deprecated, message: "Don't use Web3Options") - public var options : Web3Options = Web3Options.defaultOptions() public init(provider prov: Web3Provider, web3 web3instance: web3) { provider = prov web3 = web3instance @@ -78,8 +73,6 @@ public class web3 { var provider:Web3Provider // weak var web3: web3? var web3: web3 - @available(*, deprecated, message: "Don't use Web3Options") - public var options : Web3Options = Web3Options.defaultOptions() public init(provider prov: Web3Provider, web3 web3instance: web3) { provider = prov web3 = web3instance @@ -101,8 +94,6 @@ public class web3 { var provider:Web3Provider // weak var web3: web3? var web3: web3 - @available(*, deprecated, message: "Don't use Web3Options") - public var options : Web3Options = Web3Options.defaultOptions() public init(provider prov: Web3Provider, web3 web3instance: web3) { provider = prov web3 = web3instance @@ -145,8 +136,6 @@ public class web3 { var provider:Web3Provider // weak var web3: web3? var web3: web3 - @available(*, deprecated, message: "Don't use Web3Options") - public var options : Web3Options = Web3Options.defaultOptions() public init(provider prov: Web3Provider, web3 web3instance: web3) { provider = prov web3 = web3instance @@ -166,9 +155,6 @@ public class web3 { public class Eventloop { - @available(*, deprecated, message: "Don't use Web3Options") - public var options : Web3Options = Web3Options.defaultOptions() - public typealias EventLoopCall = (web3) -> Void public typealias EventLoopContractCall = (web3contract) -> Void @@ -226,17 +212,17 @@ public class web3 { public var preSubmissionHooks: [SubmissionHook] = [SubmissionHook]() public var postSubmissionHooks: [SubmissionResultHook] = [SubmissionResultHook]() - #warning("Old ERC721 instance. Don't use it") - @available(*, deprecated, message: "Use ERC721 separate class") - var erc721Instance: web3.ERC721? - - /// Public web3.browserFunctions.* namespace. - @available(*, deprecated, message: "Use ERC721 separate instance") - public var erc721: web3.ERC721 { - if (self.erc721Instance != nil) { - return self.erc721Instance! - } - self.erc721Instance = web3.ERC721(provider : self.provider, web3: self) - return self.erc721Instance! - } +// #warning("Old ERC721 instance. Don't use it") +// @available(*, deprecated, message: "Use ERC721 separate class") +// var erc721Instance: web3.ERC721? +// +// /// Public web3.browserFunctions.* namespace. +// @available(*, deprecated, message: "Use ERC721 separate instance") +// public var erc721: web3.ERC721 { +// if (self.erc721Instance != nil) { +// return self.erc721Instance! +// } +// self.erc721Instance = web3.ERC721(provider : self.provider, web3: self) +// return self.erc721Instance! +// } } diff --git a/web3swift/Web3/Classes/Web3+MutatingTransaction.swift b/web3swift/Web3/Classes/Web3+MutatingTransaction.swift index d5a399582..4f2eaf8f5 100644 --- a/web3swift/Web3/Classes/Web3+MutatingTransaction.swift +++ b/web3swift/Web3/Classes/Web3+MutatingTransaction.swift @@ -89,7 +89,7 @@ public class WriteTransaction: ReadTransaction { } let gasPricePromise : Promise = self.web3.eth.getGasPricePromise() - var promisesToFulfill: [Promise] = [getNoncePromise!, gasPricePromise, gasPricePromise] + var promisesToFulfill: [Promise] = [getNoncePromise!, gasEstimatePromise, gasPricePromise] when(resolved: getNoncePromise!, gasEstimatePromise, gasPricePromise).map(on: queue, { (results:[PromiseResult]) throws -> EthereumTransaction in promisesToFulfill.removeAll() diff --git a/web3swift/Web3/Classes/Web3+Options.swift b/web3swift/Web3/Classes/Web3+Options.swift index 80127155b..b46210db6 100755 --- a/web3swift/Web3/Classes/Web3+Options.swift +++ b/web3swift/Web3/Classes/Web3+Options.swift @@ -117,66 +117,80 @@ public struct TransactionOptions { return opts } -// public static func fromJSON(_ json: [String: Any]) -> Web3Options? { -// var options = Web3Options() -// if let gas = json["gas"] as? String, let gasBiguint = BigUInt(gas.stripHexPrefix().lowercased(), radix: 16) { -// options.gasLimit = gasBiguint -// } -// if let gasPrice = json["gasPrice"] as? String, let gasPriceBiguint = BigUInt(gasPrice.stripHexPrefix().lowercased(), radix: 16) { -// options.gasPrice = gasPriceBiguint -// } -// if let value = json["value"] as? String, let valueBiguint = BigUInt(value.stripHexPrefix().lowercased(), radix: 16) { -// options.value = valueBiguint -// } -// if let fromString = json["from"] as? String { -// guard let addressFrom = EthereumAddress(fromString) else {return nil} -// options.from = addressFrom -// } -// return options -// } -// -// /// Merges two sets of topions by overriding the parameters from the first set by parameters from the second -// /// set if those are not nil. -// /// -// /// Returns default options if both parameters are nil. -// public static func merge(_ options:Web3Options?, with other:Web3Options?) -> Web3Options? { -// if (other == nil && options == nil) { -// return Web3Options.defaultOptions() -// } -// var newOptions = Web3Options.defaultOptions() -// if (other?.to != nil) { -// newOptions.to = other?.to -// } else { -// newOptions.to = options?.to -// } -// if (other?.from != nil) { -// newOptions.from = other?.from -// } else { -// newOptions.from = options?.from -// } -// if (other?.gasLimit != nil) { -// newOptions.gasLimit = other?.gasLimit -// } else { -// newOptions.gasLimit = options?.gasLimit -// } -// if (other?.gasPrice != nil) { -// newOptions.gasPrice = other?.gasPrice -// } else { -// newOptions.gasPrice = options?.gasPrice -// } -// if (other?.value != nil) { -// newOptions.value = other?.value -// } else { -// newOptions.value = options?.value -// } -// return newOptions -// } -// + public static func fromJSON(_ json: [String: Any]) -> TransactionOptions? { + var options = TransactionOptions() + if let gas = json["gas"] as? String, let gasBiguint = BigUInt(gas.stripHexPrefix().lowercased(), radix: 16) { + options.gasLimit = .manual(gasBiguint) + } else { + options.gasLimit = .automatic + } + if let gasPrice = json["gasPrice"] as? String, let gasPriceBiguint = BigUInt(gasPrice.stripHexPrefix().lowercased(), radix: 16) { + options.gasPrice = .manual(gasPriceBiguint) + } else { + options.gasPrice = .automatic + } + if let value = json["value"] as? String, let valueBiguint = BigUInt(value.stripHexPrefix().lowercased(), radix: 16) { + options.value = valueBiguint + } + if let fromString = json["from"] as? String { + guard let addressFrom = EthereumAddress(fromString) else {return nil} + options.from = addressFrom + } + if let nonceString = json["nonce"] as? String, let nonce = BigUInt(nonceString.stripHexPrefix(), radix: 16) { + options.nonce = .manual(nonce) + } else { + options.nonce = .pending + } + if let callOnBlockString = json["callOnBlock"] as? String, let callOnBlock = BigUInt(callOnBlockString.stripHexPrefix(), radix: 16) { + options.callOnBlock = .exactBlockNumber(callOnBlock) + } else { + options.callOnBlock = .pending + } + return options + } + + /// Merges two sets of topions by overriding the parameters from the first set by parameters from the second + /// set if those are not nil. + /// + /// Returns default options if both parameters are nil. + public static func merge(_ options:TransactionOptions?, with other:TransactionOptions?) -> TransactionOptions? { + if (other == nil && options == nil) { + return TransactionOptions.defaultOptions + } + var newOptions = TransactionOptions.defaultOptions + if (other?.to != nil) { + newOptions.to = other?.to + } else { + newOptions.to = options?.to + } + if (other?.from != nil) { + newOptions.from = other?.from + } else { + newOptions.from = options?.from + } + if (other?.gasLimit != nil) { + newOptions.gasLimit = other?.gasLimit + } else { + newOptions.gasLimit = options?.gasLimit + } + if (other?.gasPrice != nil) { + newOptions.gasPrice = other?.gasPrice + } else { + newOptions.gasPrice = options?.gasPrice + } + if (other?.value != nil) { + newOptions.value = other?.value + } else { + newOptions.value = options?.value + } + return newOptions + } + // /// merges two sets of options along with a gas estimate to try to guess the final gas limit value required by user. // /// // /// Please refer to the source code for a logic. -// public static func smartMergeGasLimit(originalOptions: Web3Options?, extraOptions: Web3Options?, gasEstimate: BigUInt) -> BigUInt? { -// guard let mergedOptions = Web3Options.merge(originalOptions, with: extraOptions) else {return nil} //just require any non-nils +// public static func smartMergeGasLimit(originalOptions: TransactionOptions?, extraOptions: TransactionOptions?, gasEstimate: BigUInt) -> BigUInt? { +// guard let mergedOptions = TransactionOptions.merge(originalOptions, with: extraOptions) else {return nil} //just require any non-nils // if mergedOptions.gasLimit == nil { // return gasEstimate // for user's convenience we just use an estimate // // return nil // there is no opinion from user, so we can not proceed @@ -198,7 +212,7 @@ public struct TransactionOptions { // } // } // } -// + // public static func smartMergeGasPrice(originalOptions: Web3Options?, extraOptions: Web3Options?, priceEstimate: BigUInt) -> BigUInt? { // guard let mergedOptions = Web3Options.merge(originalOptions, with: extraOptions) else {return nil} //just require any non-nils // if mergedOptions.gasPrice == nil { diff --git a/web3swift/Web3/Classes/Web3+Structures.swift b/web3swift/Web3/Classes/Web3+Structures.swift index 4aca8d629..141970913 100755 --- a/web3swift/Web3/Classes/Web3+Structures.swift +++ b/web3swift/Web3/Classes/Web3+Structures.swift @@ -38,7 +38,7 @@ fileprivate func decodeHexToBigUInt(_ container: KeyedDecodingContainer, k } } -extension Web3Options:Decodable { +extension TransactionOptions: Decodable { enum CodingKeys: String, CodingKey { case from @@ -46,15 +46,23 @@ extension Web3Options:Decodable { case gasPrice case gas case value + case nonce + case callOnBlock } public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - let gasLimit = try decodeHexToBigUInt(container, key: .gas) - self.gasLimit = gasLimit + if let gasLimit = try decodeHexToBigUInt(container, key: .gas) { + self.gasLimit = .manual(gasLimit) + } else { + self.gasLimit = .automatic + } - let gasPrice = try decodeHexToBigUInt(container, key: .gasPrice) - self.gasPrice = gasPrice + if let gasPrice = try decodeHexToBigUInt(container, key: .gasPrice) { + self.gasPrice = .manual(gasPrice) + } else { + self.gasPrice = .automatic + } let toString = try container.decode(String?.self, forKey: .to) var to: EthereumAddress? @@ -67,19 +75,31 @@ extension Web3Options:Decodable { } self.to = to let from = try container.decodeIfPresent(EthereumAddress.self, forKey: .to) -// var from: EthereumAddress? -// if fromString != nil { -// guard let ethAddr = EthereumAddress(toString) else {throw Web3Error.dataError} -// from = ethAddr -// } + // var from: EthereumAddress? + // if fromString != nil { + // guard let ethAddr = EthereumAddress(toString) else {throw Web3Error.dataError} + // from = ethAddr + // } self.from = from let value = try decodeHexToBigUInt(container, key: .value) self.value = value + + if let nonce = try decodeHexToBigUInt(container, key: .nonce) { + self.nonce = .manual(nonce) + } else { + self.nonce = .pending + } + + if let callOnBlock = try decodeHexToBigUInt(container, key: .nonce) { + self.callOnBlock = .exactBlockNumber(callOnBlock) + } else { + self.callOnBlock = .pending + } } } -extension EthereumTransaction:Decodable { +extension EthereumTransaction: Decodable { enum CodingKeys: String, CodingKey { case to @@ -93,7 +113,7 @@ extension EthereumTransaction:Decodable { } public init(from decoder: Decoder) throws { - let options = try Web3Options(from: decoder) + let options = try TransactionOptions(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) var data = try decodeHexToData(container, key: .data, allowOptional: true) @@ -125,8 +145,24 @@ extension EthereumTransaction:Decodable { } self.value = options.value! self.to = options.to! - self.gasPrice = options.gasPrice! - self.gasLimit = options.gasLimit! + + if let gP = options.gasPrice { + switch gP { + case .manual(let value): + self.gasPrice = value + default: + self.gasPrice = BigUInt("5000000000")! + } + } + + if let gL = options.gasLimit { + switch gL { + case .manual(let value): + self.gasLimit = value + default: + self.gasLimit = BigUInt(21000) + } + } let inferedChainID = self.inferedChainID if (self.inferedChainID != nil && self.v >= BigUInt(37)) { diff --git a/web3swift/web3swiftLegacy/ABIv2Legacy/Classes/ABIv2Legacy.swift b/web3swift/web3swiftLegacy/ABIv2Legacy/Classes/ABIv2Legacy.swift deleted file mode 100755 index c05c91d7c..000000000 --- a/web3swift/web3swiftLegacy/ABIv2Legacy/Classes/ABIv2Legacy.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// ABIv2.swift -// web3swift -// -// Created by Alexander Vlasov on 02.04.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use ABI pod instead") -public struct ABIv2 { - -} diff --git a/web3swift/web3swiftLegacy/ContractLegacy/Classes/ContractABIv2Legacy.swift b/web3swift/web3swiftLegacy/ContractLegacy/Classes/ContractABIv2Legacy.swift deleted file mode 100755 index f5bb9df64..000000000 --- a/web3swift/web3swiftLegacy/ContractLegacy/Classes/ContractABIv2Legacy.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// ContractABIv2.swift -// web3swift -// -// Created by Alexander Vlasov on 04.04.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -import BigInt -import EthereumAddress -import EthereumABI - -@available(*, deprecated, message: "Use EthereumContract instead") -public struct ContractV2 { - -} diff --git a/web3swift/web3swiftLegacy/HookedFunctionsLegacy/Classes/Web3Legacy+BrowserFunctions.swift b/web3swift/web3swiftLegacy/HookedFunctionsLegacy/Classes/Web3Legacy+BrowserFunctions.swift deleted file mode 100755 index 95e7b50d6..000000000 --- a/web3swift/web3swiftLegacy/HookedFunctionsLegacy/Classes/Web3Legacy+BrowserFunctions.swift +++ /dev/null @@ -1,89 +0,0 @@ -// -// Web3+BrowserFunctions.swift -// web3swift-iOS -// -// Created by Alexander Vlasov on 26.02.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -import BigInt -import secp256k1_swift - -extension web3.BrowserFunctions { - - @available(*, deprecated, message: "Use TransactionOptions instead") - public func sendTransaction(_ transaction: EthereumTransaction, options: Web3Options, password: String = "web3swift") -> [String:Any]? { - let result = self.web3.eth.sendTransaction(transaction, options: options, password: password) - switch result { - case .failure(_): - return nil - case .success(let res): - return ["txhash": res.hash] - } - } - - @available(*, deprecated, message: "Use TransactionOptions instead") - public func estimateGas(_ transaction: EthereumTransaction, options: Web3Options) -> BigUInt? { - let result = self.web3.eth.estimateGas(transaction, options: options) - switch result { - case .failure(_): - return nil - case .success(let res): - return res - } - } - - @available(*, deprecated, message: "Use TransactionOptions instead") - public func prepareTxForApproval(_ transactionJSON: [String: Any]) -> (transaction: EthereumTransaction?, options: Web3Options?) { - guard let transaction = EthereumTransaction.fromJSON(transactionJSON) else {return (nil, nil)} - guard let options = Web3Options.fromJSON(transactionJSON) else {return (nil, nil)} - return self.prepareTxForApproval(transaction, options: options) - } - - @available(*, deprecated, message: "Use TransactionOptions instead") - public func prepareTxForApproval(_ trans: EthereumTransaction, options opts: Web3Options) -> (transaction: EthereumTransaction?, options: Web3Options?) { - var transaction = trans - var options = opts - guard let _ = options.from else {return (nil, nil)} - guard let gasPriceResult = try? self.web3.eth.getGasPrice() else { - return (nil, nil) - } - transaction.gasPrice = gasPriceResult - options.gasPrice = gasPriceResult - guard let gasEstimate = self.estimateGas(transaction, options: options) else {return (nil, nil)} - transaction.gasLimit = gasEstimate - options.gasLimit = gasEstimate - print(transaction) - return (transaction, options) - } - - @available(*, deprecated, message: "Use TransactionOptions instead") - public func signTransaction(_ trans: EthereumTransaction, options: Web3Options, password: String = "web3swift") -> String? { - do { - var transaction = trans - guard let from = options.from else {return nil} - guard let keystoreManager = self.web3.provider.attachedKeystoreManager else {return nil} - let gasPriceResult = try self.web3.eth.getGasPrice() - transaction.gasPrice = gasPriceResult - guard let gasEstimate = self.estimateGas(transaction, options: options) else {return nil} - transaction.gasLimit = gasEstimate - - let nonceResult = try self.web3.eth.getTransactionCount(address: from, onBlock: "pending") - transaction.nonce = nonceResult - - if (self.web3.provider.network != nil) { - transaction.chainID = self.web3.provider.network?.chainID - } - - guard let keystore = keystoreManager.walletForAddress(from) else {return nil} - try Web3Signer.signTX(transaction: &transaction, keystore: keystore, account: from, password: password) - print(transaction) - let signedData = transaction.encode(forSignature: false, chainID: nil)?.toHexString().addHexPrefix() - return signedData - } - catch { - return nil - } - } -} diff --git a/web3swift/web3swiftLegacy/KeystoreManagerLegacy/Classes/AbstractKeystoreLegacy.swift b/web3swift/web3swiftLegacy/KeystoreManagerLegacy/Classes/AbstractKeystoreLegacy.swift deleted file mode 100755 index fc247c920..000000000 --- a/web3swift/web3swiftLegacy/KeystoreManagerLegacy/Classes/AbstractKeystoreLegacy.swift +++ /dev/null @@ -1,13 +0,0 @@ -// -// AbstractKeystore.swift -// web3swift -// -// Created by Alexander Vlasov on 10.01.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation - -@available(*, deprecated, message: "Use ReadTransaction or WriteTransaction instead") -public typealias TransactionIntermediate = web3.web3contract.TransactionIntermediate - diff --git a/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+Call.swift b/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+Call.swift deleted file mode 100755 index f42b3cd57..000000000 --- a/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+Call.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// Promise+Web3+Eth+Call.swift -// web3swift-iOS -// -// Created by Alexander Vlasov on 18.06.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -import PromiseKit - -extension web3.Eth { - - @available(*, deprecated, message: "Use transactionOptions instead") - func callPromise(_ transaction: EthereumTransaction, options: Web3Options, onBlock: String = "latest") -> Promise{ - let queue = web3.requestDispatcher.queue - do { - guard let request = EthereumTransaction.createRequest(method: .call, transaction: transaction, onBlock: onBlock, options: options) else { - throw Web3Error.processingError(desc: "Transaction is invalid") - } - let rp = web3.dispatch(request) - return rp.map(on: queue ) { response in - guard let value: Data = response.getValue() else { - if response.error != nil { - throw Web3Error.nodeError(desc: response.error!.message) - } - throw Web3Error.nodeError(desc: "Invalid value from Ethereum node") - } - return value - } - } catch { - let returnPromise = Promise.pending() - queue.async { - returnPromise.resolver.reject(error) - } - return returnPromise.promise - } - } -} diff --git a/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+EstimateGas.swift b/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+EstimateGas.swift deleted file mode 100755 index a3027904f..000000000 --- a/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+EstimateGas.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// Promise+Web3+Eth+EstimateGas.swift -// web3swift-iOS -// -// Created by Alexander Vlasov on 18.06.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -import BigInt -import PromiseKit - -extension web3.Eth { - - @available(*, deprecated, message: "Use TransactionOptions instead") - func estimateGasPromise(_ transaction: EthereumTransaction, options: Web3Options?, onBlock: String = "latest") -> Promise{ - let queue = web3.requestDispatcher.queue - do { - guard let request = EthereumTransaction.createRequest(method: .estimateGas, transaction: transaction, onBlock: onBlock, options: options) else { - throw Web3Error.processingError(desc: "Transaction is invalid") - } - let rp = web3.dispatch(request) - return rp.map(on: queue ) { response in - guard let value: BigUInt = response.getValue() else { - if response.error != nil { - throw Web3Error.nodeError(desc: response.error!.message) - } - throw Web3Error.nodeError(desc: "Invalid value from Ethereum node") - } - return value - } - } catch { - let returnPromise = Promise.pending() - queue.async { - returnPromise.resolver.reject(error) - } - return returnPromise.promise - } - } -} - diff --git a/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+SendTransaction.swift b/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+SendTransaction.swift deleted file mode 100755 index d9aafcab2..000000000 --- a/web3swift/web3swiftLegacy/PromisesLegacy/Classes/Promise+Web3Legacy+Eth+SendTransaction.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// Promise+Web3+Eth+SendTransaction.swift -// web3swift -// -// Created by Alexander Vlasov on 18.06.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -import BigInt -import PromiseKit - -extension web3.Eth { - - @available(*, deprecated, message: "Use TransactionOptions instead") - func sendTransactionPromise(_ transaction: EthereumTransaction, options: Web3Options, password:String = "web3swift") -> Promise { -// print(transaction) - var assembledTransaction : EthereumTransaction = transaction.mergedWithOptions(options) - let queue = web3.requestDispatcher.queue - do { - if self.web3.provider.attachedKeystoreManager == nil { - guard let request = EthereumTransaction.createRequest(method: JSONRPCmethod.sendTransaction, transaction: assembledTransaction, onBlock: nil, options: options) else - { - throw Web3Error.processingError(desc: "Failed to create a request to send transaction") - } - return self.web3.dispatch(request).map(on: queue) {response in - guard let value: String = response.getValue() else { - if response.error != nil { - throw Web3Error.nodeError(desc: response.error!.message) - } - throw Web3Error.nodeError(desc: "Invalid value from Ethereum node") - } - let result = TransactionSendingResult(transaction: assembledTransaction, hash: value) - return result - } - } - guard let from = options.from else { - throw Web3Error.inputError(desc: "No 'from' field provided") - } - do { - try Web3Signer.signTX(transaction: &assembledTransaction, keystore: self.web3.provider.attachedKeystoreManager!, account: from, password: password) - } catch { - throw Web3Error.inputError(desc: "Failed to locally sign a transaction") - } - return self.web3.eth.sendRawTransactionPromise(assembledTransaction) - } catch { - let returnPromise = Promise.pending() - queue.async { - returnPromise.resolver.reject(error) - } - return returnPromise.promise - } - } -} diff --git a/web3swift/web3swiftLegacy/TransactionLegacy/Classes/EthereumTransactionLegacy.swift b/web3swift/web3swiftLegacy/TransactionLegacy/Classes/EthereumTransactionLegacy.swift deleted file mode 100755 index 72aafa8eb..000000000 --- a/web3swift/web3swiftLegacy/TransactionLegacy/Classes/EthereumTransactionLegacy.swift +++ /dev/null @@ -1,112 +0,0 @@ -// -// EthereumTransaction.swift -// web3swift -// -// Created by Alexander Vlasov on 05.12.2017. -// Copyright © 2017 Alexander Vlasov. All rights reserved. -// - -import Foundation -import BigInt -import SwiftRLP -import secp256k1_swift -import EthereumAddress - -extension EthereumTransaction { - - @available(*, deprecated, message: "Don't use Web3Options") - public init(to: EthereumAddress, data: Data, options: Web3Options) { - let defaults = Web3Options.defaultOptions() - let merged = Web3Options.merge(defaults, with: options) - self.nonce = BigUInt(0) - self.gasLimit = merged!.gasLimit! - self.gasPrice = merged!.gasPrice! - self.value = merged!.value! - self.to = to - self.data = data - } - - @available(*, deprecated, message: "Use TransactionOptions instead") - public func mergedWithOptions(_ options: Web3Options) -> EthereumTransaction { - var tx = self; - if options.gasPrice != nil { - tx.gasPrice = options.gasPrice! - } - if options.gasLimit != nil { - tx.gasLimit = options.gasLimit! - } - if options.value != nil { - tx.value = options.value! - } - if options.to != nil { - tx.to = options.to! - } - return tx - } - - @available(*, deprecated, message: "This method uses Web3Options inside that was deprecated") - static func fromJSON(_ json: [String: Any]) -> EthereumTransaction? { - guard let options = Web3Options.fromJSON(json) else {return nil} - guard let toString = json["to"] as? String else {return nil} - var to: EthereumAddress - if toString == "0x" || toString == "0x0" { - to = EthereumAddress.contractDeploymentAddress() - } else { - guard let ethAddr = EthereumAddress(toString) else {return nil} - to = ethAddr - } -// if (!to.isValid) { -// return nil -// } - var dataString = json["data"] as? String - if (dataString == nil) { - dataString = json["input"] as? String - } - guard dataString != nil, let data = Data.fromHex(dataString!) else {return nil} - var transaction = EthereumTransaction(to: to, data: data, options: options) - if let nonceString = json["nonce"] as? String { - guard let nonce = BigUInt(nonceString.stripHexPrefix(), radix: 16) else {return nil} - transaction.nonce = nonce - } - if let vString = json["v"] as? String { - guard let v = BigUInt(vString.stripHexPrefix(), radix: 16) else {return nil} - transaction.v = v - } - if let rString = json["r"] as? String { - guard let r = BigUInt(rString.stripHexPrefix(), radix: 16) else {return nil} - transaction.r = r - } - if let sString = json["s"] as? String { - guard let s = BigUInt(sString.stripHexPrefix(), radix: 16) else {return nil} - transaction.s = s - } - if let valueString = json["value"] as? String { - guard let value = BigUInt(valueString.stripHexPrefix(), radix: 16) else {return nil} - transaction.value = value - } - let inferedChainID = transaction.inferedChainID - if (transaction.inferedChainID != nil && transaction.v >= BigUInt(37)) { - transaction.chainID = inferedChainID - } - return transaction - } - - @available(*, deprecated, message: "This method uses Web3Options inside that was deprecated") - static func createRequest(method: JSONRPCmethod, transaction: EthereumTransaction, onBlock: String? = nil, options: Web3Options?) -> JSONRPCrequest? { - var request = JSONRPCrequest() - request.method = method -// guard let from = options?.from else {return nil} - guard var txParams = transaction.encodeAsDictionary(from: options?.from) else {return nil} - if method == .estimateGas || options?.gasLimit == nil { - txParams.gas = nil - } - var params = [txParams] as Array - if method.requiredNumOfParameters == 2 && onBlock != nil { - params.append(onBlock as Encodable) - } - let pars = JSONRPCparams(params: params) - request.params = pars - if !request.isValid {return nil} - return request - } -} diff --git a/web3swift/web3swiftLegacy/TransactionLegacy/Classes/TransactionSignerLegacy.swift b/web3swift/web3swiftLegacy/TransactionLegacy/Classes/TransactionSignerLegacy.swift deleted file mode 100755 index 97100a6e8..000000000 --- a/web3swift/web3swiftLegacy/TransactionLegacy/Classes/TransactionSignerLegacy.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// TransactionSigner.swift -// web3swift-iOS -// -// Created by Alexander Vlasov on 26.02.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -//import Result -import BigInt -import secp256k1_swift -import EthereumAddress - -extension Web3Signer { - - @available(*, deprecated, message: "Don't use TransactionIntermediate anymore") - public static func signIntermediate(intermediate:inout TransactionIntermediate, keystore: AbstractKeystore, account: EthereumAddress, password: String, useExtraEntropy: Bool = false) throws { - var tx = intermediate.transaction - try Web3Signer.signTX(transaction: &tx, keystore: keystore, account: account, password: password, useExtraEntropy: useExtraEntropy) - intermediate.transaction = tx - } - -} - - - - diff --git a/web3swift/web3swiftLegacy/UtilsLegacy/Classes/ENSLegacy.swift b/web3swift/web3swiftLegacy/UtilsLegacy/Classes/ENSLegacy.swift deleted file mode 100755 index e05f91220..000000000 --- a/web3swift/web3swiftLegacy/UtilsLegacy/Classes/ENSLegacy.swift +++ /dev/null @@ -1,117 +0,0 @@ -// -// ENS.swift -// web3swift-iOS -// - -import Foundation -import BigInt -import Result -import EthereumAddress - -extension ENS { - - @available(*, deprecated, message: "Don't use Web3Options and Result") - public func setAddress(domain: String, address: EthereumAddress, options: Web3Options, password: String? = nil) -> Result{ - do { - var resolver = try self.resolver(forDomain: domain) - let isSetAddrSupported = try resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.addr.hash()) - if isSetAddrSupported { - return resolver.setAddr(node: domain, address: address, options: options, password: password) - } else { - return Result.failure(Web3Error.dataError) - } - } catch { - return Result.failure(Web3Error.dataError) - } - } - - @available(*, deprecated, message: "Don't use Web3Options and Result") - public func setPubkey(domain: String, x: String, y: String, options: Web3Options, password: String? = nil) -> Result { - do { - var resolver = try self.resolver(forDomain: domain) - return resolver.setPubkey(node: domain, x: x, y: y, options: options, password: password) - } catch { - return Result.failure(Web3Error.dataError) - } - } - - @available(*, deprecated, message: "Don't use Web3Options and Result") - public func setContent(domain: String, hash: String, options: Web3Options, password: String? = nil) -> Result { - do { - var resolver = try self.resolver(forDomain: domain) - return resolver.setContent(node: domain, hash: hash, options: options, password: password) - } catch { - return Result.failure(Web3Error.dataError) - } - } - - // function setOwner(bytes32 node, address owner); - @available(*, deprecated, message: "Don't use Web3Options and Result") - public func setOwner(node: String, owner: EthereumAddress, options: Web3Options, password: String? = nil) -> Result { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.registryContract.method("setOwner", parameters: [nameHash, owner] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError)} - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - switch result { - case .failure(let error): - return Result.failure(error) - case .success(let value): - return Result(value) - } - } - - // function setSubnodeOwner(bytes32 node, bytes32 label, address owner); - @available(*, deprecated, message: "Don't use Web3Options and Result") - public func setSubnodeOwner(node: String, label: String, owner: EthereumAddress, options: Web3Options, password: String? = nil) -> Result { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let labelHash = NameHash.nameHash(label) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.registryContract.method("setSubnodeOwner", parameters: [nameHash, labelHash, owner] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError)} - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - switch result { - case .success(let value): - return Result(value) - case .failure(let error): - return Result.failure(error) - } - } - - // function setResolver(bytes32 node, address resolver); - @available(*, deprecated, message: "Don't use Web3Options and Result") - public func setResolver(node: String, resolver: EthereumAddress, options: Web3Options, password: String? = nil) -> Result { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.registryContract.method("setResolver", parameters: [nameHash, resolver] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - switch result { - case .success(let value): - return Result(value) - case .failure(let error): - return Result.failure(error) - } - - } - - // function setTTL(bytes32 node, uint64 ttl); - @available(*, deprecated, message: "Don't use Web3Options and Result") - public func setTTL(node: String, ttl: BigUInt, options: Web3Options, password: String? = nil) -> Result { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.registryContract.method("setTTL", parameters: [nameHash, ttl] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - switch result { - case .failure(let error): - return Result.failure(error) - case .success(let value): - return Result(value) - } - } - - @available(*, deprecated, message: "Don't use Web3Options") - private func getOptions(_ options: Web3Options) -> Web3Options { - var options = options - options.to = self.ensContractAddress - return options - } -} - diff --git a/web3swift/web3swiftLegacy/UtilsLegacy/Classes/ENSResolverLegacy.swift b/web3swift/web3swiftLegacy/UtilsLegacy/Classes/ENSResolverLegacy.swift deleted file mode 100755 index 87f8616be..000000000 --- a/web3swift/web3swiftLegacy/UtilsLegacy/Classes/ENSResolverLegacy.swift +++ /dev/null @@ -1,87 +0,0 @@ -// -// ENSResolver.swift -// web3swift-iOS -// -// Created by NewUser on 21/09/2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -import BigInt -import Result -import EthereumAddress - -extension ResolverENS { - - //function setAddr(bytes32 node, address addr) - @available(*, deprecated, message: "Don't use Result and Web3Options") - mutating public func setAddr(node: String, address: EthereumAddress, options: Web3Options, password: String? = nil) -> Result { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError)} - guard let transaction = self.resolverContract.method("setAddr", parameters: [nameHash, address] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - return result - } - - @available(*, deprecated, message: "Don't use Result and Web3Options") - mutating func setName(node: String, name: String, options: Web3Options, password: String? = nil) -> Result{ - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.resolverContract.method("setName", parameters: [nameHash, name] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - return result - } - - @available(*, deprecated, message: "Don't use Result and Web3Options") - mutating func setABI(node: String, contentType: BigUInt, data: Data, options: Web3Options, password: String? = nil) -> Result { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.resolverContract.method("setABI", parameters: [nameHash, contentType, data] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - return result - } - - @available(*, deprecated, message: "Don't use Result and Web3Options") - mutating public func setPubkey(node: String, x: String, y: String, options: Web3Options, password: String? = nil) -> Result { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.resolverContract.method("getPubkey", parameters: [nameHash, x, y] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - return result - } - - @available(*, deprecated, message: "Don't use Result and Web3Options") - mutating func setContent(node: String, hash: String, options: Web3Options, password: String? = nil) -> Result { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.resolverContract.method("setContent", parameters: [nameHash, hash] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - return result - } - - //function setMultihash(bytes32 node, bytes hash) public only_owner(node) - @available(*, deprecated, message: "Don't use Result and Web3Options") - mutating public func setMultihash(node: String, hash: Data, options: Web3Options, password: String? = nil) -> Result { - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.transactionSerializationError) } - let options = getOptions(options) - guard let transaction = self.resolverContract.method("setMultihash", parameters: [nameHash, hash] as [AnyObject], options: options) else { return Result.failure(Web3Error.dataError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - return result - } - - //function setText(bytes32 node, string key, string value) public only_owner(node) - @available(*, deprecated, message: "Don't use Result and Web3Options") - mutating public func setText(node: String, key: String, value: String, options: Web3Options, password: String? = nil) -> Result { - guard let nameHash = NameHash.nameHash(node) else { return Result.failure(Web3Error.dataError) } - guard let transaction = self.resolverContract.method("setText", parameters: [nameHash, key, value] as [AnyObject], options: options) else { return Result.failure(Web3Error.transactionSerializationError) } - let result = password == nil ? transaction.send(options: nil) : transaction.send(password: password!, options: options) - return result - } - - @available(*, deprecated, message: "Use TransacionOptions type instead") - private func getOptions(_ options: Web3Options) -> Web3Options { - var options = options - options.to = self.resolverAddress - return options - } -} diff --git a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Contract.swift b/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Contract.swift deleted file mode 100644 index a3f22fa46..000000000 --- a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Contract.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// Web3Legacy+Contract.swift -// web3swift -// -// Created by Anton Grigorev on 21.11.2018. -// Copyright © 2018 The Matter Inc. All rights reserved. -// - -import Foundation -import BigInt -import EthereumAddress - -extension web3.web3contract { - - /// Deploys a constact instance using the previously provided (at initialization) ABI, some bytecode, constructor parameters and options. - /// If extraData is supplied it is appended to encoded bytecode and constructor parameters. - /// - /// Returns a "Transaction intermediate" object. - @available(*, deprecated, message: "Use deploy with transactionOptions instead") - public func deploy(bytecode: Data, parameters: [AnyObject] = [AnyObject](), extraData: Data = Data(), options: Web3Options?) -> TransactionIntermediate? { - - let mergedOptions = Web3Options.merge(self.options, with: options) - guard var tx = self.contract.deploy(bytecode: bytecode, parameters: parameters, extraData: extraData) else {return nil} - tx.chainID = self.web3.provider.network?.chainID - let intermediate = TransactionIntermediate(transaction: tx, web3: self.web3, contract: self.contract, method: "fallback", options: mergedOptions) - return intermediate - } - - /// Creates and object responsible for calling a particular function of the contract. If method name is not found in ABI - returns nil. - /// If extraData is supplied it is appended to encoded function parameters. Can be usefull if one wants to call - /// the function not listed in ABI. "Parameters" should be an array corresponding to the list of parameters of the function. - /// Elements of "parameters" can be other arrays or instances of String, Data, BigInt, BigUInt, Int or EthereumAddress. - /// - /// Returns a "Transaction intermediate" object. - @available(*, deprecated, message: "Use method with transactionOptions instead") - public func method(_ method:String = "fallback", parameters: [AnyObject] = [AnyObject](), extraData: Data = Data(), options: Web3Options?) -> TransactionIntermediate? { - let mergedOptions = Web3Options.merge(self.options, with: options) - guard var tx = self.contract.method(method, parameters: parameters, extraData: extraData) else {return nil} - tx.chainID = self.web3.provider.network?.chainID - let intermediate = TransactionIntermediate(transaction: tx, web3: self.web3, contract: self.contract, method: method, options: mergedOptions) - return intermediate - } -} diff --git a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Eth.swift b/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Eth.swift deleted file mode 100644 index fab39a14c..000000000 --- a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Eth.swift +++ /dev/null @@ -1,212 +0,0 @@ -// web3swift -// -// Created by Alex Vlasov. -// Copyright © 2018 Alex Vlasov. All rights reserved. -// - -import Foundation -import BigInt -import EthereumAddress -import Result - -extension web3.Eth { - - /// Send an EthereumTransaction object to the network. Transaction is either signed locally if there is a KeystoreManager - /// object bound to the web3 instance, or sent unsigned to the node. For local signing the password is required. - /// - /// "options" object can override the "to", "gasPrice", "gasLimit" and "value" parameters is pre-formed transaction. - /// "from" field in "options" is mandatory for both local and remote signing. - /// - /// This function is synchronous! - /// - /// Returns the Result object that indicates either success of failure. - @available(*, deprecated, message: "Use sendTransaction with TransactionOptions instead") - public func sendTransaction(_ transaction: EthereumTransaction, options: Web3Options, password:String = "web3swift") -> Result { - do { - let result = try self.sendTransactionPromise(transaction, options: options, password: password).wait() - return Result(result) - } catch { - if let err = error as? Web3Error { - return Result.failure(err) - } - return Result.failure(Web3Error.generalError(err: error)) - } - } - - /// Performs a non-mutating "call" to some smart-contract. EthereumTransaction bears all function parameters required for the call. - /// Does NOT decode the data returned from the smart-contract. - /// "options" object can override the "to", "gasPrice", "gasLimit" and "value" parameters is pre-formed transaction. - /// "from" field in "options" is mandatory for both local and remote signing. - /// - /// "onString" field determines if value is returned based on the state of a blockchain on the latest mined block ("latest") - /// or the expected state after all the transactions in memory pool are applied ("pending"). - /// - /// This function is synchronous! - /// - /// Returns the Result object that indicates either success of failure. - @available(*, deprecated, message: "Use call with TransactionOptions instead") - func call(_ transaction: EthereumTransaction, options: Web3Options, onBlock:String = "latest") -> Result { - do { - let result = try self.callPromise(transaction, options: options, onBlock: onBlock).wait() - return Result(result) - } catch { - if let err = error as? Web3Error { - return Result.failure(err) - } - return Result.failure(Web3Error.generalError(err: error)) - } - } - - /// Estimates a minimal amount of gas required to run a transaction. To do it the Ethereum node tries to run it and counts - /// how much gas it consumes for computations. Setting the transaction gas limit lower than the estimate will most likely - /// result in a failing transaction. - /// - /// "onString" field determines if value is returned based on the state of a blockchain on the latest mined block ("latest") - /// or the expected state after all the transactions in memory pool are applied ("pending"). - /// - /// This function is synchronous! - /// - /// Returns the Result object that indicates either success of failure. - /// Error can also indicate that transaction is invalid in the current state, so formally it's gas limit is infinite. - /// An example of such transaction can be sending an amount of ETH that is larger than the current account balance. - @available(*, deprecated, message: "Use estimateGas with TransactionOptions and without onBlock instead") - public func estimateGas(_ transaction: EthereumTransaction, options: Web3Options?, onBlock: String = "latest") -> Result { - do { - let result = try self.estimateGasPromise(transaction, options: options, onBlock: onBlock).wait() - return Result(result) - } catch { - if let err = error as? Web3Error { - return Result.failure(err) - } - return Result.failure(Web3Error.generalError(err: error)) - } - } - - /** - Convenience wrapper to send Ethereum to another address. Internally it creates a virtual contract and encodes all the options and data. - - Parameters: - - to: EthereumAddress to send funds to - - amount: BigUInt indicating the amount in wei - - extraData: Additional data to attach to the transaction - - options: Web3Options to override the default gas price, gas limit. "Value" field of the options is ignored and the "amount" parameter is used instead - - - returns: - - TransactionIntermediate object - - */ - @available(*, deprecated, message: "Use sendETH with TransactionOptions instead") - public func sendETH(to: EthereumAddress, amount: BigUInt, extraData: Data = Data(), options: Web3Options?) -> TransactionIntermediate? { - let contract = self.web3.contract(Web3.Utils.coldWalletABI, at: to, abiVersion: 2) - guard var mergedOptions = Web3Options.merge(self.options, with: options) else {return nil} - mergedOptions.value = amount - let intermediate = contract?.method("fallback", extraData: extraData, options: mergedOptions) - return intermediate - } - - /** - *Convenience wrapper to send Ethereum to another address. Internally it creates a virtual contract and encodes all the options and data.* - - - parameters: - - to: EthereumAddress to send funds to - - amount: String in "units" demonimation. It can contain either "," or "." decimal separator. - - units: Ethereum units indicating the denomination of amout about - - extraData: Additional data to attach to the transaction - - options: Web3Options to override the default gas price, gas limit. "Value" field of the options is ignored and the "amount" parameter is used instead - - - returns: - - TransactionIntermediate object - - * String "1.01" and units: .eth will result in sending 1.01 ETH to another address* - */ - @available(*, deprecated, message: "Use sendETH with TransactionOptions instead") - public func sendETH(to: EthereumAddress, amount: String, units: Web3.Utils.Units = .eth, extraData: Data = Data(), options: Web3Options?) -> TransactionIntermediate? { - guard let value = Web3.Utils.parseToBigUInt(amount, units: .eth) else {return nil} - return sendETH(to: to, amount: value, extraData: extraData, options: options) - } - - /** - *Convenience wrapper to send Ethereum to another address. Internally it creates a virtual contract and encodes all the options and data.* - - - parameters: - - from: EthereumAddress to send funds from - - to: EthereumAddress to send funds to - - amount: String in "units" demonimation. It can contain either "," or "." decimal separator. - - units: Ethereum units indicating the denomination of amout about - - extraData: Additional data to attach to the transaction - - options: Web3Options to override the default gas price, gas limit. "Value" field of the options is ignored and the "amount" parameter is used instead. "From" parameter is also ignored. - - - returns: - - TransactionIntermediate object - - * String "1.01" and units: .eth will result in sending 1.01 ETH to another address* - */ - @available(*, deprecated, message: "Use sendETH with TransactionOptions instead") - public func sendETH(from: EthereumAddress, to: EthereumAddress, amount: String, units: Web3.Utils.Units = .eth, extraData: Data = Data(), options: Web3Options?) -> TransactionIntermediate? { - guard let value = Web3.Utils.parseToBigUInt(amount, units: .eth) else {return nil} - guard var mergedOptions = Web3Options.merge(self.options, with: options) else {return nil} - mergedOptions.from = from - return sendETH(to: to, amount: value, extraData: extraData, options: mergedOptions) - } - - /** - *Convenience wrapper to send ERC20 tokens to another address. Internally it creates a virtual contract and encodes all the options and data. Assumes that the sender knows the decimal units of the underlying token.* - - - parameters: - - tokenAddress: EthereumAddress of the token contract - - from: EthereumAddress to send tokens from - - to: EthereumAddress to send tokens to - - amount: BigUInt indicating the number of tokens in the the smallest indivisible units (mind that sender knows the number of decimals) - - options: Web3Options to override the default gas price, gas limit. "Value" field of the options is ignored and the "amount" parameter is used instead. "From" parameter is also ignored. - - - returns: - - TransactionIntermediate object - - */ - @available(*, deprecated, message: "Use sendERC20tokensWithKnownDecimals with TransactionOptions instead") - public func sendERC20tokensWithKnownDecimals(tokenAddress: EthereumAddress, from: EthereumAddress, to: EthereumAddress, amount: BigUInt, options: Web3Options?) -> TransactionIntermediate? { - let contract = self.web3.contract(Web3.Utils.erc20ABI, at: tokenAddress, abiVersion: 2) - guard var mergedOptions = Web3Options.merge(self.options, with: options) else {return nil} - mergedOptions.from = from - guard let intermediate = contract?.method("transfer", parameters: [to, amount] as [AnyObject], options: mergedOptions) else {return nil} - return intermediate - } - - /** - *Convenience wrapper to send ERC20 tokens to another address. Internally it creates a virtual contract and encodes all the options and data. Pulls the number of decimals of the token under the hood.* - - - parameters: - - tokenAddress: EthereumAddress of the token contract - - from: EthereumAddress to send tokens from - - to: EthereumAddress to send tokens to - - amount: String in "natura" demonimation. It can contain either "," or "." decimal separator. - - options: Web3Options to override the default gas price, gas limit. "Value" field of the options is ignored and the "amount" parameter is used instead. "From" parameter is also ignored. - - - returns: - - TransactionIntermediate object - - - important: This call is synchronous - - * If the amount is "1.01" and token has 9 decimals it will result in sending 1010000000 of the smallest invidisible token units.* - */ - @available(*, deprecated, message: "Use sendERC20tokensWithNaturalUnits with TransactionOptions instead") - public func sendERC20tokensWithNaturalUnits(tokenAddress: EthereumAddress, from: EthereumAddress, to: EthereumAddress, amount: String, options: Web3Options?) -> TransactionIntermediate? { - let contract = self.web3.contract(Web3.Utils.erc20ABI, at: tokenAddress, abiVersion: 2) - guard var mergedOptions = Web3Options.merge(self.options, with: options) else {return nil} - mergedOptions.from = from - guard let intermediate = contract?.method("decimals", options: mergedOptions) else {return nil} - let callResult = intermediate.call(options: mergedOptions, onBlock: "latest") - var decimals = BigUInt(0) - switch callResult { - case .success(let response): - guard let dec = response["0"], let decTyped = dec as? BigUInt else {return nil} - decimals = decTyped - break - case .failure(_): - break - } - let intDecimals = Int(decimals) - guard let value = Web3.Utils.parseToBigUInt(amount, decimals: intDecimals) else {return nil} - return sendERC20tokensWithKnownDecimals(tokenAddress: tokenAddress, from: from, to: to, amount: value, options: options) - } - -} diff --git a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Instance.swift b/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Instance.swift deleted file mode 100644 index cdfacb09a..000000000 --- a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Instance.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// Web3Legacy+Instance.swift -// web3swift -// -// Created by Anton Grigorev on 21.11.2018. -// Copyright © 2018 The Matter Inc. All rights reserved. -// - -import Foundation - -extension web3 { - @available(*, deprecated, message: "Use ERC721 separate class") - public class ERC721: Web3OptionsInheritable { - var provider:Web3Provider - // weak var web3: web3? - var web3: web3 - public var options: Web3Options { - return self.web3.options - } - public init(provider prov: Web3Provider, web3 web3instance: web3) { - provider = prov - web3 = web3instance - } - } -} diff --git a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Options.swift b/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Options.swift deleted file mode 100755 index 11d91a852..000000000 --- a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+Options.swift +++ /dev/null @@ -1,148 +0,0 @@ -// -// Web3+Options.swift -// web3swift-iOS -// -// Created by Alexander Vlasov on 26.02.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -import BigInt -import EthereumAddress - -public protocol Web3OptionsInheritable { - var options: Web3Options {get} -} - -/// Options for sending or calling a particular Ethereum transaction -@available(*, deprecated, message: "Use TransactionOptions instead") -public struct Web3Options { - /// Sets the transaction destination. It can either be a contract address or a private key controlled wallet address. - /// - /// Usually should never be nil. - public var to: EthereumAddress? = nil - /// Sets from what account a transaction should be sent. Used only internally as the sender of Ethereum transaction - /// is determined purely from the transaction signature. Indicates to the Ethereum node or to the local keystore what private key - /// should be used to sign a transaction. - /// - /// Can be nil if one reads the information from the blockchain. - public var from: EthereumAddress? = nil - /// Sets the gas limit for a transaction. - /// - /// If set to nil it's usually determined automatically. - public var gasLimit: BigUInt? = nil - /// Sets the gas price for a transaction. - /// - /// If set to nil it's usually determined automatically. - public var gasPrice: BigUInt? = nil - /// Sets the value (amount of Wei) sent along the transaction. - /// - /// If set to nil it's equal to zero - public var value: BigUInt? = nil - - public init() { - } - - /// Default options filler. Sets gas limit, gas price and value to zeroes. - public static func defaultOptions() -> Web3Options{ - var options = Web3Options() - options.gasLimit = BigUInt(0) - options.gasPrice = BigUInt(0) - options.value = BigUInt(0) - return options - } - - - public static func fromJSON(_ json: [String: Any]) -> Web3Options? { - var options = Web3Options() - if let gas = json["gas"] as? String, let gasBiguint = BigUInt(gas.stripHexPrefix().lowercased(), radix: 16) { - options.gasLimit = gasBiguint - } - if let gasPrice = json["gasPrice"] as? String, let gasPriceBiguint = BigUInt(gasPrice.stripHexPrefix().lowercased(), radix: 16) { - options.gasPrice = gasPriceBiguint - } - if let value = json["value"] as? String, let valueBiguint = BigUInt(value.stripHexPrefix().lowercased(), radix: 16) { - options.value = valueBiguint - } - if let fromString = json["from"] as? String { - guard let addressFrom = EthereumAddress(fromString) else {return nil} - options.from = addressFrom - } - return options - } - - /// Merges two sets of topions by overriding the parameters from the first set by parameters from the second - /// set if those are not nil. - /// - /// Returns default options if both parameters are nil. - public static func merge(_ options:Web3Options?, with other:Web3Options?) -> Web3Options? { - if (other == nil && options == nil) { - return Web3Options.defaultOptions() - } - var newOptions = Web3Options.defaultOptions() - if (other?.to != nil) { - newOptions.to = other?.to - } else { - newOptions.to = options?.to - } - if (other?.from != nil) { - newOptions.from = other?.from - } else { - newOptions.from = options?.from - } - if (other?.gasLimit != nil) { - newOptions.gasLimit = other?.gasLimit - } else { - newOptions.gasLimit = options?.gasLimit - } - if (other?.gasPrice != nil) { - newOptions.gasPrice = other?.gasPrice - } else { - newOptions.gasPrice = options?.gasPrice - } - if (other?.value != nil) { - newOptions.value = other?.value - } else { - newOptions.value = options?.value - } - return newOptions - } - - /// merges two sets of options along with a gas estimate to try to guess the final gas limit value required by user. - /// - /// Please refer to the source code for a logic. - public static func smartMergeGasLimit(originalOptions: Web3Options?, extraOptions: Web3Options?, gasEstimate: BigUInt) -> BigUInt? { - guard let mergedOptions = Web3Options.merge(originalOptions, with: extraOptions) else {return nil} //just require any non-nils - if mergedOptions.gasLimit == nil { - return gasEstimate // for user's convenience we just use an estimate -// return nil // there is no opinion from user, so we can not proceed - } else { - if originalOptions != nil, originalOptions!.gasLimit != nil, originalOptions!.gasLimit! < gasEstimate { // original gas estimate was less than what's required, so we check extra options - if extraOptions != nil, extraOptions!.gasLimit != nil, extraOptions!.gasLimit! >= gasEstimate { - return extraOptions!.gasLimit! - } else { - return gasEstimate // for user's convenience we just use an estimate -// return nil // estimate is lower than allowed - } - } else { - if extraOptions != nil, extraOptions!.gasLimit != nil, extraOptions!.gasLimit! >= gasEstimate { - return extraOptions!.gasLimit! - } else { - return gasEstimate // for user's convenience we just use an estimate - // return nil // estimate is lower than allowed - } - } - } - } - - public static func smartMergeGasPrice(originalOptions: Web3Options?, extraOptions: Web3Options?, priceEstimate: BigUInt) -> BigUInt? { - guard let mergedOptions = Web3Options.merge(originalOptions, with: extraOptions) else {return nil} //just require any non-nils - if mergedOptions.gasPrice == nil { - return priceEstimate - } else if mergedOptions.gasPrice == 0 { - return priceEstimate - } else { - return mergedOptions.gasPrice! - } - } -} diff --git a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+TransactionIntermediate.swift b/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+TransactionIntermediate.swift deleted file mode 100755 index e980c1738..000000000 --- a/web3swift/web3swiftLegacy/Web3Legacy/Classes/Web3Legacy+TransactionIntermediate.swift +++ /dev/null @@ -1,272 +0,0 @@ -// -// Web3+TransactionIntermediate.swift -// web3swift-iOS -// -// Created by Alexander Vlasov on 26.02.2018. -// Copyright © 2018 Bankex Foundation. All rights reserved. -// - -import Foundation -import enum Result.Result -import BigInt -import PromiseKit -fileprivate typealias PromiseResult = PromiseKit.Result - -@available(*, deprecated, message: "Use ReadTransaction or WriteTransaction instead") -extension web3.web3contract { - - /// TransactionIntermediate is an almost-ready transaction or a smart-contract function call. It bears all the required information - /// to call the smart-contract and decode the returned information, or estimate gas required for transaction, or send a transaciton - /// to the blockchain. - public class TransactionIntermediate{ - public var transaction:EthereumTransaction - public var contract: ContractProtocol - public var method: String - public var options: Web3Options? = Web3Options.defaultOptions() - var web3: web3 - public init (transaction: EthereumTransaction, web3 web3Instance: web3, contract: ContractProtocol, method: String, options: Web3Options?) { - self.transaction = transaction - self.web3 = web3Instance - self.contract = contract - //self.contract.options = options - self.method = method - self.options = Web3Options.merge(web3.options, with: options) - if self.web3.provider.network != nil { - self.transaction.chainID = self.web3.provider.network?.chainID - } - } - - /** - *Send a prepared transaction to the blockchain. Internally checks the nonce for a sending account, assigns it, get a gas estimate and signs a transaction either locally or on the remote node.* - - - parameters: - - password: Password for a private key if transaction is signed locally - - options: Web3Options to override the previously assigned gas price, gas limit and value. - - onBlock: String field determines if nonce value and the gas estimate are based on the state of a blockchain on the latest mined block ("latest") or the expected state after all the transactions in memory pool are applied ("pending"). Using "pending" allows to send transactions one after another without waiting for inclusion of the previous one in some block. - - - returns: - - Result object - - - important: This call is synchronous - - */ - public func send(password: String = "web3swift", options: Web3Options?, onBlock: String = "pending") -> Result { - do { - let result = try self.sendPromise(password: password, options: options, onBlock: onBlock).wait() - return Result(result) - } catch { - if let err = error as? Web3Error { - return Result.failure(err) - } - return Result.failure(Web3Error.generalError(err: error)) - } - } - - /** - *Calls a function of the smart-contract and parses the returned data to native objects.* - - - parameters: - - options: Web3Options to override the previously assigned gas price, gas limit and value. - - onBlock: String field determines if nonce value and the gas estimate are based on the state of a blockchain on the latest mined block ("latest") or the expected state after all the transactions in memory pool are applied ("pending"). Using "pending" allows to send transactions one after another without waiting for inclusion of the previous one in some block. - - - returns: - - Result object - - - important: This call is synchronous - - */ - public func call(options: Web3Options?, onBlock: String = "latest") -> Result<[String:Any], Web3Error> { - do { - let result = try self.callPromise(options: options, onBlock: onBlock).wait() - return Result(result) - } catch { - if let err = error as? Web3Error { - return Result.failure(err) - } - return Result.failure(Web3Error.generalError(err: error)) - } - } - - /** - *Estimates gas required to execute the transaction. Setting a gas limit lower than the estimate will most likely result in a failed transaction. If this call returns an error it can also indicate that transaction is invalid as itself.* - - - parameters: - - options: Web3Options to override the previously assigned gas price, gas limit and value. - - onBlock: String field determines if nonce value and the gas estimate are based on the state of a blockchain on the latest mined block ("latest") or the expected state after all the transactions in memory pool are applied ("pending"). Using "pending" allows to send transactions one after another without waiting for inclusion of the previous one in some block. - - - returns: - - Result object - - - important: This call is synchronous - - */ - public func estimateGas(options: Web3Options?, onBlock: String = "latest") -> Result { - do { - let result = try self.estimateGasPromise(options: options, onBlock: onBlock).wait() - return Result(result) - } catch { - if let err = error as? Web3Error { - return Result.failure(err) - } - return Result.failure(Web3Error.generalError(err: error)) - } - } - - /** - *Assembles (but does not sign!) a transaction by fetching the nonce value and applying provided options.* - - - parameters: - - options: Web3Options to override the previously assigned gas price, gas limit and value. - - onBlock: String field determines if nonce value and the gas estimate are based on the state of a blockchain on the latest mined block ("latest") or the expected state after all the transactions in memory pool are applied ("pending"). Using "pending" allows to send transactions one after another without waiting for inclusion of the previous one in some block. - - - returns: - - Result object - - - important: This call is synchronous - - */ - public func assemble(options: Web3Options?, onBlock: String = "pending") -> Result { - do { - let result = try self.assemblePromise(options: options, onBlock: onBlock).wait() - return Result(result) - } catch { - if let err = error as? Web3Error { - return Result.failure(err) - } - return Result.failure(Web3Error.generalError(err: error)) - } - } - - } -} - -extension web3.web3contract.TransactionIntermediate { - - public func assemblePromise(options: Web3Options?, onBlock: String = "pending") -> Promise { - var assembledTransaction : EthereumTransaction = self.transaction - let queue = self.web3.requestDispatcher.queue - let returnPromise = Promise { seal in - guard let mergedOptions = Web3Options.merge(self.options, with: options) else { - seal.reject(Web3Error.inputError(desc: "Provided options are invalid")) - return - } - guard let from = mergedOptions.from else { - seal.reject(Web3Error.inputError(desc: "No 'from' field provided")) - return - } - var optionsForGasEstimation = Web3Options() - optionsForGasEstimation.from = mergedOptions.from - optionsForGasEstimation.to = mergedOptions.to - optionsForGasEstimation.value = mergedOptions.value - let getNoncePromise : Promise = self.web3.eth.getTransactionCountPromise(address: from, onBlock: onBlock) - let gasEstimatePromise : Promise = self.web3.eth.estimateGasPromise(assembledTransaction, options: optionsForGasEstimation, onBlock: onBlock) - let gasPricePromise : Promise = self.web3.eth.getGasPricePromise() - var promisesToFulfill: [Promise] = [getNoncePromise, gasPricePromise, gasPricePromise] - when(resolved: getNoncePromise, gasEstimatePromise, gasPricePromise).map(on: queue, { (results:[PromiseResult]) throws -> EthereumTransaction in - - promisesToFulfill.removeAll() - guard case .fulfilled(let nonce) = results[0] else { - throw Web3Error.processingError(desc: "Failed to fetch nonce") - } - guard case .fulfilled(let gasEstimate) = results[1] else { - throw Web3Error.processingError(desc: "Failed to fetch gas estimate") - } - guard case .fulfilled(let gasPrice) = results[2] else { - throw Web3Error.processingError(desc: "Failed to fetch gas price") - } - guard let estimate = Web3Options.smartMergeGasLimit(originalOptions: options, extraOptions: mergedOptions, gasEstimate: gasEstimate) else { - throw Web3Error.processingError(desc: "Failed to calculate gas estimate that satisfied options") - } - assembledTransaction.nonce = nonce - assembledTransaction.gasLimit = estimate - guard let finalGasPrice = Web3Options.smartMergeGasPrice(originalOptions: options, extraOptions: mergedOptions, priceEstimate: gasPrice) else { - throw Web3Error.processingError(desc: "Missing parameter of gas price for transaction") - } - assembledTransaction.gasPrice = finalGasPrice -// if assembledTransaction.gasPrice == 0 { -// if mergedOptions.gasPrice != nil { -// assembledTransaction.gasPrice = mergedOptions.gasPrice! -// } else { -// assembledTransaction.gasPrice = gasPrice -// } -// } - return assembledTransaction - }).done(on: queue) {tx in - seal.fulfill(tx) - }.catch(on: queue) {err in - seal.reject(err) - } - } - return returnPromise - } - - public func sendPromise(password:String = "web3swift", options: Web3Options?, onBlock: String = "pending") -> Promise{ - let queue = self.web3.requestDispatcher.queue - return self.assemblePromise(options: options, onBlock: onBlock).then(on: queue) { transaction throws -> Promise in - guard let mergedOptions = Web3Options.merge(self.options, with: options) else { - throw Web3Error.inputError(desc: "Provided options are invalid") - } - var cleanedOptions = Web3Options() - cleanedOptions.from = mergedOptions.from - cleanedOptions.to = mergedOptions.to - return self.web3.eth.sendTransactionPromise(transaction, options: cleanedOptions, password: password) - } - } - - public func callPromise(options: Web3Options?, onBlock: String = "latest") -> Promise<[String: Any]>{ - let assembledTransaction : EthereumTransaction = self.transaction - let queue = self.web3.requestDispatcher.queue - let returnPromise = Promise<[String:Any]> { seal in - guard let mergedOptions = Web3Options.merge(self.options, with: options) else { - seal.reject(Web3Error.inputError(desc: "Provided options are invalid")) - return - } - var optionsForCall = Web3Options() - optionsForCall.from = mergedOptions.from - optionsForCall.to = mergedOptions.to - optionsForCall.value = mergedOptions.value - let callPromise : Promise = self.web3.eth.callPromise(assembledTransaction, options: optionsForCall, onBlock: onBlock) - callPromise.done(on: queue) {(data:Data) throws in - do { - if (self.method == "fallback") { - let resultHex = data.toHexString().addHexPrefix() - seal.fulfill(["result": resultHex as Any]) - return - } - guard let decodedData = self.contract.decodeReturnData(self.method, data: data) else - { - throw Web3Error.processingError(desc: "Can not decode returned parameters") - } - seal.fulfill(decodedData) - } catch{ - seal.reject(error) - } - }.catch(on: queue) {err in - seal.reject(err) - } - } - return returnPromise - } - - public func estimateGasPromise(options: Web3Options?, onBlock: String = "latest") -> Promise{ - let assembledTransaction : EthereumTransaction = self.transaction - let queue = self.web3.requestDispatcher.queue - let returnPromise = Promise { seal in - guard let mergedOptions = Web3Options.merge(self.options, with: options) else { - seal.reject(Web3Error.inputError(desc: "Provided options are invalid")) - return - } - var optionsForGasEstimation = Web3Options() - optionsForGasEstimation.from = mergedOptions.from - optionsForGasEstimation.to = mergedOptions.to - optionsForGasEstimation.value = mergedOptions.value - let promise = self.web3.eth.estimateGasPromise(assembledTransaction, options: optionsForGasEstimation, onBlock: onBlock) - promise.done(on: queue) {(estimate: BigUInt) in - seal.fulfill(estimate) - }.catch(on: queue) {err in - seal.reject(err) - } - } - return returnPromise - } -}