diff --git a/CHANGELOG.md b/CHANGELOG.md index 556f129d3..fc1de418f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,340 +1,409 @@ # Change Log -## [Unreleased](https://github.com/matterinc/web3swift/tree/HEAD) +## [Unreleased](https://github.com/matter-labs/web3swift/tree/HEAD) -[Full Changelog](https://github.com/matterinc/web3swift/compare/1.5.1...HEAD) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.3...HEAD) -**Implemented enhancements:** - -- ENS for wallets [\#12](https://github.com/matterinc/web3swift/issues/12) -- Recover passphrase from BIP32 store [\#5](https://github.com/matterinc/web3swift/issues/5) +**Fixed bugs:** -**Merged pull requests:** +- Cannot load module 'Web3swift' as 'web3swift [\#133](https://github.com/matter-labs/web3swift/issues/133) -- hotfix update pods [\#71](https://github.com/matterinc/web3swift/pull/71) ([BaldyAsh](https://github.com/BaldyAsh)) +**Closed issues:** -## [1.5.1](https://github.com/matterinc/web3swift/tree/1.5.1) (2018-10-22) -[Full Changelog](https://github.com/matterinc/web3swift/compare/1.5...1.5.1) +- web3swift 2.1.3 [\#154](https://github.com/matter-labs/web3swift/issues/154) +- Sending ETH always results in zero value [\#149](https://github.com/matter-labs/web3swift/issues/149) +- WebSockets subscriptions [\#145](https://github.com/matter-labs/web3swift/issues/145) +- 依赖该库生成framework,真机情况下会出现问题 [\#143](https://github.com/matter-labs/web3swift/issues/143) +- Building fails with compilation errors [\#140](https://github.com/matter-labs/web3swift/issues/140) **Merged pull requests:** -- Function visibility fix [\#70](https://github.com/matterinc/web3swift/pull/70) ([shamatar](https://github.com/shamatar)) +- Updated example to 2.1.3 [\#158](https://github.com/matter-labs/web3swift/pull/158) ([BaldyAsh](https://github.com/BaldyAsh)) +- Documentation update [\#153](https://github.com/matter-labs/web3swift/pull/153) ([BaldyAsh](https://github.com/BaldyAsh)) -## [1.5](https://github.com/matterinc/web3swift/tree/1.5) (2018-10-18) -[Full Changelog](https://github.com/matterinc/web3swift/compare/1.1.10...1.5) +## [2.1.3](https://github.com/matter-labs/web3swift/tree/2.1.3) (2019-04-06) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.2...2.1.3) **Implemented enhancements:** -- Can you add support for ERC-721 tokens [\#7](https://github.com/matterinc/web3swift/issues/7) +- WIP: WebSockets subscriptions [\#144](https://github.com/matter-labs/web3swift/pull/144) ([BaldyAsh](https://github.com/BaldyAsh)) **Closed issues:** -- Creating a new wallet is too slow [\#63](https://github.com/matterinc/web3swift/issues/63) -- need to update for Xcode10 [\#49](https://github.com/matterinc/web3swift/issues/49) -- Web3.Utils.formatToEthereumUnits [\#48](https://github.com/matterinc/web3swift/issues/48) -- Interface ideas are welcome for v2.0 [\#3](https://github.com/matterinc/web3swift/issues/3) +- Use custom JSONRPCmethod and Units [\#148](https://github.com/matter-labs/web3swift/issues/148) +- ERC20 some functions are not working [\#146](https://github.com/matter-labs/web3swift/issues/146) +- fix `pod install` absolute paths [\#97](https://github.com/matter-labs/web3swift/issues/97) +- Installing issue by pod [\#76](https://github.com/matter-labs/web3swift/issues/76) **Merged pull requests:** -- Add TxPool and ERC721 native class [\#68](https://github.com/matterinc/web3swift/pull/68) ([shamatar](https://github.com/shamatar)) -- Feature/erc721 [\#67](https://github.com/matterinc/web3swift/pull/67) ([BaldyAsh](https://github.com/BaldyAsh)) -- Feature/adding logo [\#66](https://github.com/matterinc/web3swift/pull/66) ([BaldyAsh](https://github.com/BaldyAsh)) -- adds txpool function and its local node test [\#64](https://github.com/matterinc/web3swift/pull/64) ([currybab](https://github.com/currybab)) -- License got reverted somewhere after PRs [\#60](https://github.com/matterinc/web3swift/pull/60) ([shamatar](https://github.com/shamatar)) +- 2.1.3 fix No2 [\#152](https://github.com/matter-labs/web3swift/pull/152) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1.3 fix [\#151](https://github.com/matter-labs/web3swift/pull/151) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1.3 [\#150](https://github.com/matter-labs/web3swift/pull/150) ([BaldyAsh](https://github.com/BaldyAsh)) +- Swift 5 update [\#142](https://github.com/matter-labs/web3swift/pull/142) ([BaldyAsh](https://github.com/BaldyAsh)) -## [1.1.10](https://github.com/matterinc/web3swift/tree/1.1.10) (2018-10-04) -[Full Changelog](https://github.com/matterinc/web3swift/compare/1.1.9...1.1.10) +## [2.1.2](https://github.com/matter-labs/web3swift/tree/2.1.2) (2019-03-30) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.1...2.1.2) **Merged pull requests:** -- Preliminary ENS support, start module splitting [\#59](https://github.com/matterinc/web3swift/pull/59) ([shamatar](https://github.com/shamatar)) -- Feature/readme improvement [\#55](https://github.com/matterinc/web3swift/pull/55) ([BaldyAsh](https://github.com/BaldyAsh)) -- Feature/support obj c [\#54](https://github.com/matterinc/web3swift/pull/54) ([BaldyAsh](https://github.com/BaldyAsh)) -- Feature/ENSsupport [\#53](https://github.com/matterinc/web3swift/pull/53) ([FesenkoG](https://github.com/FesenkoG)) -- Add Travis configuration [\#52](https://github.com/matterinc/web3swift/pull/52) ([skywinder](https://github.com/skywinder)) -- Added ERC-20 token for testing web3swift lib [\#50](https://github.com/matterinc/web3swift/pull/50) ([BaldyAsh](https://github.com/BaldyAsh)) +- Swift 5 update [\#141](https://github.com/matter-labs/web3swift/pull/141) ([BaldyAsh](https://github.com/BaldyAsh)) +- Swift 5 update [\#139](https://github.com/matter-labs/web3swift/pull/139) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1.1 [\#136](https://github.com/matter-labs/web3swift/pull/136) ([BaldyAsh](https://github.com/BaldyAsh)) -## [1.1.9](https://github.com/matterinc/web3swift/tree/1.1.9) (2018-09-18) -[Full Changelog](https://github.com/matterinc/web3swift/compare/1.1.7...1.1.9) +## [2.1.1](https://github.com/matter-labs/web3swift/tree/2.1.1) (2019-03-26) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.1.0...2.1.1) -**Fixed bugs:** +**Implemented enhancements:** -- eth.getAccounts\(\) function returns an empty address Array [\#24](https://github.com/matterinc/web3swift/issues/24) -- EIP681 bug fixes, accessibility in Function changed [\#35](https://github.com/matterinc/web3swift/pull/35) ([FesenkoG](https://github.com/FesenkoG)) +- Support ST-20 [\#103](https://github.com/matter-labs/web3swift/issues/103) **Closed issues:** -- the version 1.1.6 couldn't from password and keystore to get the privateKey [\#32](https://github.com/matterinc/web3swift/issues/32) -- Need implementation of EIP-681 parsing [\#25](https://github.com/matterinc/web3swift/issues/25) +- Expected to decode Array\ but found a dictionary instead. [\#128](https://github.com/matter-labs/web3swift/issues/128) +- Decoding Input/Output data [\#127](https://github.com/matter-labs/web3swift/issues/127) +- nodeError\("replacement transaction underpriced"\) [\#42](https://github.com/matter-labs/web3swift/issues/42) **Merged pull requests:** -- Update for XCode 10 [\#39](https://github.com/matterinc/web3swift/pull/39) ([shamatar](https://github.com/shamatar)) -- Basic ENS support added, EIP681 parsing supports ENS from now. [\#38](https://github.com/matterinc/web3swift/pull/38) ([FesenkoG](https://github.com/FesenkoG)) +- Fix/podspec [\#135](https://github.com/matter-labs/web3swift/pull/135) ([BaldyAsh](https://github.com/BaldyAsh)) +- let some functions public for customization [\#132](https://github.com/matter-labs/web3swift/pull/132) ([scottphc](https://github.com/scottphc)) +- WIP: ST-20 and Security Token support [\#130](https://github.com/matter-labs/web3swift/pull/130) ([BaldyAsh](https://github.com/BaldyAsh)) +- Recent updates [\#126](https://github.com/matter-labs/web3swift/pull/126) ([BaldyAsh](https://github.com/BaldyAsh)) +- Recent updates [\#125](https://github.com/matter-labs/web3swift/pull/125) ([BaldyAsh](https://github.com/BaldyAsh)) -## [1.1.7](https://github.com/matterinc/web3swift/tree/1.1.7) (2018-09-13) -[Full Changelog](https://github.com/matterinc/web3swift/compare/1.1.6...1.1.7) +## [2.1.0](https://github.com/matter-labs/web3swift/tree/2.1.0) (2019-03-06) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.4...2.1.0) -**Fixed bugs:** +**Implemented enhancements:** -- Thread blocked [\#16](https://github.com/matterinc/web3swift/issues/16) +- Support ERC-888 [\#102](https://github.com/matter-labs/web3swift/issues/102) +- Support SRC-20 [\#101](https://github.com/matter-labs/web3swift/issues/101) +- Support S3 [\#99](https://github.com/matter-labs/web3swift/issues/99) +- Support ERC-1400 [\#98](https://github.com/matter-labs/web3swift/issues/98) +- ERC-165 support [\#82](https://github.com/matter-labs/web3swift/issues/82) +- ERC-777 support [\#81](https://github.com/matter-labs/web3swift/issues/81) +- How do I add an account to a node [\#78](https://github.com/matter-labs/web3swift/issues/78) +- Support Web3View functionality [\#30](https://github.com/matter-labs/web3swift/issues/30) **Closed issues:** -- How to create same address and keystore by mnemonics? [\#22](https://github.com/matterinc/web3swift/issues/22) +- eth\_estimateGas is not supplied the gasPrice parameter [\#118](https://github.com/matter-labs/web3swift/issues/118) +- Carthage support missing. [\#115](https://github.com/matter-labs/web3swift/issues/115) +- \[Utility\] Contract event listener [\#112](https://github.com/matter-labs/web3swift/issues/112) +- Support ERC-1644 [\#111](https://github.com/matter-labs/web3swift/issues/111) +- Support ERC-1643 [\#110](https://github.com/matter-labs/web3swift/issues/110) +- Support ERC-1594 [\#109](https://github.com/matter-labs/web3swift/issues/109) +- Support ERC-1410 [\#108](https://github.com/matter-labs/web3swift/issues/108) +- Support ERC-820 [\#107](https://github.com/matter-labs/web3swift/issues/107) +- Error: Failed to fetch gas estimate on intermediate call [\#106](https://github.com/matter-labs/web3swift/issues/106) +- Can't use ENS in 2.0 [\#92](https://github.com/matter-labs/web3swift/issues/92) +- Can't use EIP681 parser [\#91](https://github.com/matter-labs/web3swift/issues/91) +- enhancement - end to end newbie instructions to deploy erc20 token locally / initialize wallets - then successfully transfer it in app [\#89](https://github.com/matter-labs/web3swift/issues/89) +- Can you support objective-c [\#88](https://github.com/matter-labs/web3swift/issues/88) +- SolidityType has no member 'allSatisfy'? [\#87](https://github.com/matter-labs/web3swift/issues/87) +- How to encode data for appending constructor to bytecode for deploying contract? [\#86](https://github.com/matter-labs/web3swift/issues/86) +- web3swift.Web3Error error 4 for get balance [\#77](https://github.com/matter-labs/web3swift/issues/77) +- How to signed Transaction ? get raw [\#62](https://github.com/matter-labs/web3swift/issues/62) +- how to get token using Signing Transaction [\#58](https://github.com/matter-labs/web3swift/issues/58) +- Can the signtypedMessage function be added [\#45](https://github.com/matter-labs/web3swift/issues/45) +- How to get Keystore by PrivateKeyData ? [\#19](https://github.com/matter-labs/web3swift/issues/19) +- encoding name\(ens\) for sending register contract [\#15](https://github.com/matter-labs/web3swift/issues/15) **Merged pull requests:** -- Fix ethereum address parsing, add readme [\#34](https://github.com/matterinc/web3swift/pull/34) ([shamatar](https://github.com/shamatar)) -- complete EIP681, fix the most stupid Ethereum address parsing [\#33](https://github.com/matterinc/web3swift/pull/33) ([shamatar](https://github.com/shamatar)) -- Add examples to readme, prettify formatting [\#31](https://github.com/matterinc/web3swift/pull/31) ([skywinder](https://github.com/skywinder)) -- continue eip681 work [\#27](https://github.com/matterinc/web3swift/pull/27) ([shamatar](https://github.com/shamatar)) -- Implement EIP681 parser \(untested\) [\#26](https://github.com/matterinc/web3swift/pull/26) ([shamatar](https://github.com/shamatar)) -- Change access control of function fromRaw in struct EthereumTransaction [\#11](https://github.com/matterinc/web3swift/pull/11) ([Plazmathron](https://github.com/Plazmathron)) - -## [1.1.6](https://github.com/matterinc/web3swift/tree/1.1.6) (2018-09-04) -[Full Changelog](https://github.com/matterinc/web3swift/compare/1.1.5...1.1.6) +- 2.1.0 [\#124](https://github.com/matter-labs/web3swift/pull/124) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix/remove deprecated [\#123](https://github.com/matter-labs/web3swift/pull/123) ([BaldyAsh](https://github.com/BaldyAsh)) +- Revert "2.1" [\#122](https://github.com/matter-labs/web3swift/pull/122) ([BaldyAsh](https://github.com/BaldyAsh)) +- 2.1 [\#121](https://github.com/matter-labs/web3swift/pull/121) ([BaldyAsh](https://github.com/BaldyAsh)) +- Fix/remove deprecated [\#120](https://github.com/matter-labs/web3swift/pull/120) ([BaldyAsh](https://github.com/BaldyAsh)) +- fixed estimate gas problem [\#119](https://github.com/matter-labs/web3swift/pull/119) ([BaldyAsh](https://github.com/BaldyAsh)) +- Added Deed and Registrar ABI to Web3+Utils [\#114](https://github.com/matter-labs/web3swift/pull/114) ([barrasso](https://github.com/barrasso)) +- Fixed EIP681 and EIP67, added and improved a lot of ERCs [\#113](https://github.com/matter-labs/web3swift/pull/113) ([BaldyAsh](https://github.com/BaldyAsh)) +- Documentation [\#105](https://github.com/matter-labs/web3swift/pull/105) ([BaldyAsh](https://github.com/BaldyAsh)) +- recent changes [\#104](https://github.com/matter-labs/web3swift/pull/104) ([BaldyAsh](https://github.com/BaldyAsh)) +- Migration to 2.0 [\#96](https://github.com/matter-labs/web3swift/pull/96) ([BaldyAsh](https://github.com/BaldyAsh)) +- Feature/readme improvement [\#85](https://github.com/matter-labs/web3swift/pull/85) ([BaldyAsh](https://github.com/BaldyAsh)) + +## [2.0.4](https://github.com/matter-labs/web3swift/tree/2.0.4) (2018-11-20) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.3...2.0.4) **Merged pull requests:** -- Quick fix for scrypt performance [\#17](https://github.com/matterinc/web3swift/pull/17) ([shamatar](https://github.com/shamatar)) -- adding description string to Web3Error [\#1](https://github.com/matterinc/web3swift/pull/1) ([GabCas](https://github.com/GabCas)) - -[Full Changelog](https://github.com/bankex/web3swift/compare/0.6.0...HEAD) +- introduce a fix for invalid value in gas estimation, call and send transactions [\#95](https://github.com/matter-labs/web3swift/pull/95) ([shamatar](https://github.com/shamatar)) +- Master to develop for 2.0.2 [\#94](https://github.com/matter-labs/web3swift/pull/94) ([shamatar](https://github.com/shamatar)) +- 2.0.2 [\#93](https://github.com/matter-labs/web3swift/pull/93) ([shamatar](https://github.com/shamatar)) -**Closed issues:** +## [2.0.3](https://github.com/matter-labs/web3swift/tree/2.0.3) (2018-11-20) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.2...2.0.3) -- Transaction or options are malformed in Token Transfer [\#78](https://github.com/BANKEX/web3swift/issues/78) -- Error when install [\#75](https://github.com/BANKEX/web3swift/issues/75) +## [2.0.2](https://github.com/matter-labs/web3swift/tree/2.0.2) (2018-11-06) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.1...2.0.2) **Merged pull requests:** -- update podspec and readme [\#82](https://github.com/BANKEX/web3swift/pull/82) ([shamatar](https://github.com/shamatar)) +- 2.0.1 [\#84](https://github.com/matter-labs/web3swift/pull/84) ([shamatar](https://github.com/shamatar)) -## [0.6.0](https://github.com/bankex/web3swift/tree/0.6.0) (2018-04-24) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.5.6...0.6.0) +## [2.0.1](https://github.com/matter-labs/web3swift/tree/2.0.1) (2018-11-05) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/2.0.0...2.0.1) **Closed issues:** -- InValid Account Error [\#76](https://github.com/BANKEX/web3swift/issues/76) +- ENS Functionality [\#56](https://github.com/matter-labs/web3swift/issues/56) **Merged pull requests:** -- add example of ERC20 transfer in Example [\#81](https://github.com/BANKEX/web3swift/pull/81) ([shamatar](https://github.com/shamatar)) -- include example of ERC20 token transfer [\#80](https://github.com/BANKEX/web3swift/pull/80) ([shamatar](https://github.com/shamatar)) -- Allow BIP32 keystore init from seed directly Add convenience BIP32 keystore and KeystoreV3 serialization methods Test custom path derivation after saving Add new BIP39 languages [\#74](https://github.com/BANKEX/web3swift/pull/74) ([shamatar](https://github.com/shamatar)) +- ENS fix [\#83](https://github.com/matter-labs/web3swift/pull/83) ([BaldyAsh](https://github.com/BaldyAsh)) +- Get recent develop changes [\#80](https://github.com/matter-labs/web3swift/pull/80) ([BaldyAsh](https://github.com/BaldyAsh)) -## [0.5.6](https://github.com/bankex/web3swift/tree/0.5.6) (2018-04-20) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.5.5...0.5.6) +## [2.0.0](https://github.com/matter-labs/web3swift/tree/2.0.0) (2018-10-30) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.5.1...2.0.0) -**Fixed bugs:** +**Implemented enhancements:** -- Crash when generate keystore by mnemonics [\#62](https://github.com/BANKEX/web3swift/issues/62) +- Carthage support [\#44](https://github.com/matter-labs/web3swift/issues/44) +- How to get pending transactions by this framework [\#36](https://github.com/matter-labs/web3swift/issues/36) +- ENS for wallets [\#12](https://github.com/matter-labs/web3swift/issues/12) +- Recover passphrase from BIP32 store [\#5](https://github.com/matter-labs/web3swift/issues/5) +- ERC20 API Support [\#41](https://github.com/matter-labs/web3swift/issues/41) **Closed issues:** -- BIP39 Keystore not accessible from keystore parameter path [\#68](https://github.com/BANKEX/web3swift/issues/68) +- failed to send transaction due to known transaction [\#65](https://github.com/matter-labs/web3swift/issues/65) +- List of all transactions related to account \(private key\) [\#57](https://github.com/matter-labs/web3swift/issues/57) +- Make A README & doc [\#46](https://github.com/matter-labs/web3swift/issues/46) +- 'BigUInt' is ambiguous for type lookup in this conte [\#43](https://github.com/matter-labs/web3swift/issues/43) +- Migration to web3 format \(create account\) [\#40](https://github.com/matter-labs/web3swift/issues/40) +- Interface ideas are welcome for v2.0 [\#3](https://github.com/matter-labs/web3swift/issues/3) **Merged pull requests:** -- convenience methods in web3.eth to send ETH using either raw BigUInt value in Wei, or parsing a decimal string of arbitrary units [\#72](https://github.com/BANKEX/web3swift/pull/72) ([shamatar](https://github.com/shamatar)) -- improve BIP32 serialization to disk [\#71](https://github.com/BANKEX/web3swift/pull/71) ([shamatar](https://github.com/shamatar)) -- Fix BIP32 keystore when used through Manager [\#70](https://github.com/BANKEX/web3swift/pull/70) ([shamatar](https://github.com/shamatar)) -- add marshalling and unmarshalling signature as a part of Web3.Utils [\#69](https://github.com/BANKEX/web3swift/pull/69) ([shamatar](https://github.com/shamatar)) -- Event parsing example from user case [\#67](https://github.com/BANKEX/web3swift/pull/67) ([shamatar](https://github.com/shamatar)) - -## [0.5.5](https://github.com/bankex/web3swift/tree/0.5.5) (2018-04-18) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.5.4...0.5.5) +- Carthage [\#75](https://github.com/matter-labs/web3swift/pull/75) ([BaldyAsh](https://github.com/BaldyAsh)) +- Carthage fixes [\#74](https://github.com/matter-labs/web3swift/pull/74) ([BaldyAsh](https://github.com/BaldyAsh)) +- hotfix update pods [\#71](https://github.com/matter-labs/web3swift/pull/71) ([BaldyAsh](https://github.com/BaldyAsh)) -**Closed issues:** - -- Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value [\#57](https://github.com/BANKEX/web3swift/issues/57) +## [1.5.1](https://github.com/matter-labs/web3swift/tree/1.5.1) (2018-10-22) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.5...1.5.1) **Merged pull requests:** -- Solidity bound ECRecover test and example [\#66](https://github.com/BANKEX/web3swift/pull/66) ([shamatar](https://github.com/shamatar)) -- Fix BIP 32 derivation in release build \(with optimization\) [\#65](https://github.com/BANKEX/web3swift/pull/65) ([shamatar](https://github.com/shamatar)) -- Tests refactoring [\#61](https://github.com/BANKEX/web3swift/pull/61) ([skywinder](https://github.com/skywinder)) +- Function visibility fix [\#70](https://github.com/matter-labs/web3swift/pull/70) ([shamatar](https://github.com/shamatar)) -## [0.5.4](https://github.com/bankex/web3swift/tree/0.5.4) (2018-04-16) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.5.3...0.5.4) +## [1.5](https://github.com/matter-labs/web3swift/tree/1.5) (2018-10-18) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.10...1.5) -**Merged pull requests:** +**Implemented enhancements:** + +- Can you add support for ERC-721 tokens [\#7](https://github.com/matter-labs/web3swift/issues/7) -- fix regression of abi encoding [\#60](https://github.com/BANKEX/web3swift/pull/60) ([shamatar](https://github.com/shamatar)) +**Closed issues:** -## [0.5.3](https://github.com/bankex/web3swift/tree/0.5.3) (2018-04-16) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.5.2...0.5.3) +- Creating a new wallet is too slow [\#63](https://github.com/matter-labs/web3swift/issues/63) +- need to update for Xcode10 [\#49](https://github.com/matter-labs/web3swift/issues/49) +- Web3.Utils.formatToEthereumUnits [\#48](https://github.com/matter-labs/web3swift/issues/48) **Merged pull requests:** -- Wider range of parameter types as input to ABI encoder [\#59](https://github.com/BANKEX/web3swift/pull/59) ([shamatar](https://github.com/shamatar)) +- Add TxPool and ERC721 native class [\#68](https://github.com/matter-labs/web3swift/pull/68) ([shamatar](https://github.com/shamatar)) +- Feature/erc721 [\#67](https://github.com/matter-labs/web3swift/pull/67) ([BaldyAsh](https://github.com/BaldyAsh)) +- Feature/adding logo [\#66](https://github.com/matter-labs/web3swift/pull/66) ([BaldyAsh](https://github.com/BaldyAsh)) +- adds txpool function and its local node test [\#64](https://github.com/matter-labs/web3swift/pull/64) ([currybab](https://github.com/currybab)) +- License got reverted somewhere after PRs [\#60](https://github.com/matter-labs/web3swift/pull/60) ([shamatar](https://github.com/shamatar)) -## [0.5.2](https://github.com/bankex/web3swift/tree/0.5.2) (2018-04-16) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.5.1...0.5.2) +## [1.1.10](https://github.com/matter-labs/web3swift/tree/1.1.10) (2018-10-04) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.9...1.1.10) -**Implemented enhancements:** +**Merged pull requests:** -- Signing and unsigning. [\#52](https://github.com/BANKEX/web3swift/issues/52) +- Preliminary ENS support, start module splitting [\#59](https://github.com/matter-labs/web3swift/pull/59) ([shamatar](https://github.com/shamatar)) +- Feature/readme improvement [\#55](https://github.com/matter-labs/web3swift/pull/55) ([BaldyAsh](https://github.com/BaldyAsh)) +- Feature/support obj c [\#54](https://github.com/matter-labs/web3swift/pull/54) ([BaldyAsh](https://github.com/BaldyAsh)) +- Feature/ENSsupport [\#53](https://github.com/matter-labs/web3swift/pull/53) ([FesenkoG](https://github.com/FesenkoG)) +- Add Travis configuration [\#52](https://github.com/matter-labs/web3swift/pull/52) ([skywinder](https://github.com/skywinder)) +- Added ERC-20 token for testing web3swift lib [\#50](https://github.com/matter-labs/web3swift/pull/50) ([BaldyAsh](https://github.com/BaldyAsh)) + +## [1.1.9](https://github.com/matter-labs/web3swift/tree/1.1.9) (2018-09-18) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.7...1.1.9) **Fixed bugs:** -- Signing identical transaction results in different raw tx [\#53](https://github.com/BANKEX/web3swift/issues/53) -- I can not use my contract ? [\#43](https://github.com/BANKEX/web3swift/issues/43) -- Use of unresolved identifier 'EthereumAddress' [\#14](https://github.com/BANKEX/web3swift/issues/14) +- eth.getAccounts\(\) function returns an empty address Array [\#24](https://github.com/matter-labs/web3swift/issues/24) +- EIP681 bug fixes, accessibility in Function changed [\#35](https://github.com/matter-labs/web3swift/pull/35) ([FesenkoG](https://github.com/FesenkoG)) **Closed issues:** -- the method " web3.eth.getBlockByNumber\(\)" reseult fail? [\#54](https://github.com/BANKEX/web3swift/issues/54) -- the method"web3Main?.eth.getBalance\(\)" result is not correct? [\#50](https://github.com/BANKEX/web3swift/issues/50) -- Documentation, samples, comments [\#13](https://github.com/BANKEX/web3swift/issues/13) +- the version 1.1.6 couldn't from password and keystore to get the privateKey [\#32](https://github.com/matter-labs/web3swift/issues/32) +- Need implementation of EIP-681 parsing [\#25](https://github.com/matter-labs/web3swift/issues/25) **Merged pull requests:** -- add ECrecover, personal sign and unlock account methods [\#58](https://github.com/BANKEX/web3swift/pull/58) ([shamatar](https://github.com/shamatar)) -- Refactor secp256k1 part Slightly update an example Start working on web3.personal [\#56](https://github.com/BANKEX/web3swift/pull/56) ([shamatar](https://github.com/shamatar)) -- fix regression [\#55](https://github.com/BANKEX/web3swift/pull/55) ([shamatar](https://github.com/shamatar)) -- fix balance, provide better transaction receipt [\#51](https://github.com/BANKEX/web3swift/pull/51) ([shamatar](https://github.com/shamatar)) +- Update for XCode 10 [\#39](https://github.com/matter-labs/web3swift/pull/39) ([shamatar](https://github.com/shamatar)) +- Basic ENS support added, EIP681 parsing supports ENS from now. [\#38](https://github.com/matter-labs/web3swift/pull/38) ([FesenkoG](https://github.com/FesenkoG)) -## [0.5.1](https://github.com/bankex/web3swift/tree/0.5.1) (2018-04-11) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.5.0...0.5.1) +## [1.1.7](https://github.com/matter-labs/web3swift/tree/1.1.7) (2018-09-13) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.6...1.1.7) -**Merged pull requests:** +**Fixed bugs:** -- bump podspec and release 0.5.1 [\#49](https://github.com/BANKEX/web3swift/pull/49) ([shamatar](https://github.com/shamatar)) -- Contract deployment implementation [\#48](https://github.com/BANKEX/web3swift/pull/48) ([shamatar](https://github.com/shamatar)) +- Thread blocked [\#16](https://github.com/matter-labs/web3swift/issues/16) -## [0.5.0](https://github.com/bankex/web3swift/tree/0.5.0) (2018-04-10) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.4.1...0.5.0) +**Closed issues:** -**Implemented enhancements:** +- How to create same address and keystore by mnemonics? [\#22](https://github.com/matter-labs/web3swift/issues/22) -- Support returning structs from functions [\#33](https://github.com/BANKEX/web3swift/issues/33) -- Mnemonic account with five level derivation path like M/44'/60'/0'/0/1 [\#42](https://github.com/BANKEX/web3swift/issues/42) +**Merged pull requests:** -**Fixed bugs:** +- Fix ethereum address parsing, add readme [\#34](https://github.com/matter-labs/web3swift/pull/34) ([shamatar](https://github.com/shamatar)) +- complete EIP681, fix the most stupid Ethereum address parsing [\#33](https://github.com/matter-labs/web3swift/pull/33) ([shamatar](https://github.com/shamatar)) +- Add examples to readme, prettify formatting [\#31](https://github.com/matter-labs/web3swift/pull/31) ([skywinder](https://github.com/skywinder)) +- continue eip681 work [\#27](https://github.com/matter-labs/web3swift/pull/27) ([shamatar](https://github.com/shamatar)) +- Implement EIP681 parser \(untested\) [\#26](https://github.com/matter-labs/web3swift/pull/26) ([shamatar](https://github.com/shamatar)) +- Change access control of function fromRaw in struct EthereumTransaction [\#11](https://github.com/matter-labs/web3swift/pull/11) ([Plazmathron](https://github.com/Plazmathron)) -- Build error during archiving web3swift [\#15](https://github.com/BANKEX/web3swift/issues/15) +## [1.1.6](https://github.com/matter-labs/web3swift/tree/1.1.6) (2018-09-04) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.5...1.1.6) **Merged pull requests:** -- merge 0.5.0 [\#47](https://github.com/BANKEX/web3swift/pull/47) ([shamatar](https://github.com/shamatar)) -- cleanup to prevent Pod from panicking [\#45](https://github.com/BANKEX/web3swift/pull/45) ([shamatar](https://github.com/shamatar)) -- Fixes for external node work and more flexibility for BIP32 childs derivation [\#44](https://github.com/BANKEX/web3swift/pull/44) ([shamatar](https://github.com/shamatar)) +- Quick fix for scrypt performance [\#17](https://github.com/matter-labs/web3swift/pull/17) ([shamatar](https://github.com/shamatar)) +- adding description string to Web3Error [\#1](https://github.com/matter-labs/web3swift/pull/1) ([GabCas](https://github.com/GabCas)) -## [0.4.1](https://github.com/bankex/web3swift/tree/0.4.1) (2018-04-07) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.4.0...0.4.1) +## [1.1.5](https://github.com/matter-labs/web3swift/tree/1.1.5) (2018-08-10) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.1...1.1.5) -**Implemented enhancements:** +## [1.1.1](https://github.com/matter-labs/web3swift/tree/1.1.1) (2018-07-30) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.1.0...1.1.1) -- Password for every transaction [\#16](https://github.com/BANKEX/web3swift/issues/16) -- Concurrent batched requests [\#38](https://github.com/BANKEX/web3swift/pull/38) ([skywinder](https://github.com/skywinder)) +## [1.1.0](https://github.com/matter-labs/web3swift/tree/1.1.0) (2018-07-27) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.0.1...1.1.0) -**Closed issues:** +## [1.0.1](https://github.com/matter-labs/web3swift/tree/1.0.1) (2018-07-12) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/1.0.0...1.0.1) -- there is some error in example [\#27](https://github.com/BANKEX/web3swift/issues/27) -- EthereumKeystoreV3 constructor with KeystoreParamsV3 [\#17](https://github.com/BANKEX/web3swift/issues/17) -- Example and Code are different [\#9](https://github.com/BANKEX/web3swift/issues/9) +## [1.0.0](https://github.com/matter-labs/web3swift/tree/1.0.0) (2018-07-04) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.9.0...1.0.0) -**Merged pull requests:** +## [0.9.0](https://github.com/matter-labs/web3swift/tree/0.9.0) (2018-06-18) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.8.1...0.9.0) -- ABIv2 encoder now also works. Tested for most of the types, including string\[2\] and string\[\] [\#41](https://github.com/BANKEX/web3swift/pull/41) ([shamatar](https://github.com/shamatar)) -- Tested ABIv2 parser, with no regressions [\#40](https://github.com/BANKEX/web3swift/pull/40) ([shamatar](https://github.com/shamatar)) -- Streamlined concurrency, generic operations and fanout|join are available [\#39](https://github.com/BANKEX/web3swift/pull/39) ([shamatar](https://github.com/shamatar)) +## [0.8.1](https://github.com/matter-labs/web3swift/tree/0.8.1) (2018-06-10) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.8.0...0.8.1) -## [0.4.0](https://github.com/bankex/web3swift/tree/0.4.0) (2018-04-04) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.3.6...0.4.0) +## [0.8.0](https://github.com/matter-labs/web3swift/tree/0.8.0) (2018-05-31) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.7.9...0.8.0) -**Implemented enhancements:** +## [0.7.9](https://github.com/matter-labs/web3swift/tree/0.7.9) (2018-05-31) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.7.0...0.7.9) -- Struct encoder/decoder: Using a struct in a public function with ABIEncoderV2 [\#32](https://github.com/BANKEX/web3swift/issues/32) +## [0.7.0](https://github.com/matter-labs/web3swift/tree/0.7.0) (2018-05-11) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.6.0...0.7.0) -**Closed issues:** +## [0.6.0](https://github.com/matter-labs/web3swift/tree/0.6.0) (2018-04-24) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.5.6...0.6.0) -- BIP32Keystore and EthereumKeystoreV3 can't getPrivateKeyData [\#28](https://github.com/BANKEX/web3swift/issues/28) +## [0.5.6](https://github.com/matter-labs/web3swift/tree/0.5.6) (2018-04-20) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.5.5...0.5.6) -**Merged pull requests:** +## [0.5.5](https://github.com/matter-labs/web3swift/tree/0.5.5) (2018-04-18) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.5.4...0.5.5) -- ABIEncoderV2 implementation [\#34](https://github.com/BANKEX/web3swift/pull/34) ([shamatar](https://github.com/shamatar)) +## [0.5.4](https://github.com/matter-labs/web3swift/tree/0.5.4) (2018-04-16) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.5.3...0.5.4) -## [0.3.6](https://github.com/bankex/web3swift/tree/0.3.6) (2018-04-02) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.3.5...0.3.6) +## [0.5.3](https://github.com/matter-labs/web3swift/tree/0.5.3) (2018-04-16) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.5.2...0.5.3) -## [0.3.5](https://github.com/bankex/web3swift/tree/0.3.5) (2018-03-20) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.3.4...0.3.5) +## [0.5.2](https://github.com/matter-labs/web3swift/tree/0.5.2) (2018-04-16) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.5.1...0.5.2) -**Implemented enhancements:** +## [0.5.1](https://github.com/matter-labs/web3swift/tree/0.5.1) (2018-04-11) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.5.0...0.5.1) -- KeyStoreManger has only one constructor [\#20](https://github.com/BANKEX/web3swift/issues/20) +## [0.5.0](https://github.com/matter-labs/web3swift/tree/0.5.0) (2018-04-10) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.4.1...0.5.0) -**Closed issues:** +## [0.4.1](https://github.com/matter-labs/web3swift/tree/0.4.1) (2018-04-07) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.4.0...0.4.1) -- web3contract send function incorrect error [\#25](https://github.com/BANKEX/web3swift/issues/25) -- Develop branch 404 [\#24](https://github.com/BANKEX/web3swift/issues/24) -- AbiElement.decodeReturnData supports only dynamicTypes [\#23](https://github.com/BANKEX/web3swift/issues/23) +## [0.4.0](https://github.com/matter-labs/web3swift/tree/0.4.0) (2018-04-04) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.3.6...0.4.0) -## [0.3.4](https://github.com/bankex/web3swift/tree/0.3.4) (2018-03-18) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.3.3...0.3.4) +## [0.3.6](https://github.com/matter-labs/web3swift/tree/0.3.6) (2018-04-02) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.3.5...0.3.6) -## [0.3.3](https://github.com/bankex/web3swift/tree/0.3.3) (2018-03-05) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.3.2...0.3.3) +## [0.3.5](https://github.com/matter-labs/web3swift/tree/0.3.5) (2018-03-20) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.3.4...0.3.5) -## [0.3.2](https://github.com/bankex/web3swift/tree/0.3.2) (2018-03-03) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.3.1...0.3.2) +## [0.3.4](https://github.com/matter-labs/web3swift/tree/0.3.4) (2018-03-18) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.3.3...0.3.4) -**Closed issues:** +## [0.3.3](https://github.com/matter-labs/web3swift/tree/0.3.3) (2018-03-05) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.3.2...0.3.3) -- Signing transaction without connecting to web3 provider [\#22](https://github.com/BANKEX/web3swift/issues/22) -- Transaction Receipt [\#21](https://github.com/BANKEX/web3swift/issues/21) +## [0.3.2](https://github.com/matter-labs/web3swift/tree/0.3.2) (2018-03-03) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.3.1...0.3.2) -## [0.3.1](https://github.com/bankex/web3swift/tree/0.3.1) (2018-03-01) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.3.0...0.3.1) +## [0.3.1](https://github.com/matter-labs/web3swift/tree/0.3.1) (2018-03-01) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.3.0...0.3.1) -## [0.3.0](https://github.com/bankex/web3swift/tree/0.3.0) (2018-02-27) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.2.99...0.3.0) +## [0.3.0](https://github.com/matter-labs/web3swift/tree/0.3.0) (2018-02-27) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.99...0.3.0) -## [0.2.99](https://github.com/bankex/web3swift/tree/0.2.99) (2018-02-27) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.2.98...0.2.99) +## [0.2.99](https://github.com/matter-labs/web3swift/tree/0.2.99) (2018-02-27) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.98...0.2.99) -**Closed issues:** +## [0.2.98](https://github.com/matter-labs/web3swift/tree/0.2.98) (2018-02-27) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.12...0.2.98) -- Problem with signing/sending transactions [\#8](https://github.com/BANKEX/web3swift/issues/8) +## [0.2.12](https://github.com/matter-labs/web3swift/tree/0.2.12) (2018-02-01) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.11...0.2.12) -## [0.2.98](https://github.com/bankex/web3swift/tree/0.2.98) (2018-02-27) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.2.12...0.2.98) +## [0.2.11](https://github.com/matter-labs/web3swift/tree/0.2.11) (2018-02-01) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.10...0.2.11) -**Closed issues:** +## [0.2.10](https://github.com/matter-labs/web3swift/tree/0.2.10) (2018-01-31) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.9...0.2.10) -- Method eth\_getAccounts not supported [\#7](https://github.com/BANKEX/web3swift/issues/7) -- Would crash when trying to parse my abi data [\#6](https://github.com/BANKEX/web3swift/issues/6) -- Web3 Provider [\#5](https://github.com/BANKEX/web3swift/issues/5) -- Creating a new keystore using mnemonics [\#4](https://github.com/BANKEX/web3swift/issues/4) +## [0.2.9](https://github.com/matter-labs/web3swift/tree/0.2.9) (2018-01-29) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.8...0.2.9) -**Merged pull requests:** +## [0.2.8](https://github.com/matter-labs/web3swift/tree/0.2.8) (2018-01-18) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.7...0.2.8) -- Add support for macOS [\#10](https://github.com/BANKEX/web3swift/pull/10) ([dsemenovsky](https://github.com/dsemenovsky)) +## [0.2.7](https://github.com/matter-labs/web3swift/tree/0.2.7) (2018-01-15) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.5...0.2.7) -## [0.2.12](https://github.com/bankex/web3swift/tree/0.2.12) (2018-02-01) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.2.11...0.2.12) +## [0.2.5](https://github.com/matter-labs/web3swift/tree/0.2.5) (2018-01-12) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.2.0...0.2.5) -## [0.2.11](https://github.com/bankex/web3swift/tree/0.2.11) (2018-02-01) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.2.10...0.2.11) +## [0.2.0](https://github.com/matter-labs/web3swift/tree/0.2.0) (2017-12-30) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.1.2...0.2.0) -## [0.2.10](https://github.com/bankex/web3swift/tree/0.2.10) (2018-01-31) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.2.9...0.2.10) +## [0.1.2](https://github.com/matter-labs/web3swift/tree/0.1.2) (2017-12-27) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.1.1...0.1.2) -**Closed issues:** +## [0.1.1](https://github.com/matter-labs/web3swift/tree/0.1.1) (2017-12-26) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.1.0...0.1.1) -- How to pass parameters to Contract Method? [\#3](https://github.com/BANKEX/web3swift/issues/3) +## [0.1.0](https://github.com/matter-labs/web3swift/tree/0.1.0) (2017-12-26) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.0.6...0.1.0) -## [0.2.9](https://github.com/bankex/web3swift/tree/0.2.9) (2018-01-29) -[Full Changelog](https://github.com/bankex/web3swift/compare/0.2.8...0.2.9) +## [0.0.6](https://github.com/matter-labs/web3swift/tree/0.0.6) (2017-12-26) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.0.5...0.0.6) -**Closed issues:** +## [0.0.5](https://github.com/matter-labs/web3swift/tree/0.0.5) (2017-12-21) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.0.4...0.0.5) + +## [0.0.4](https://github.com/matter-labs/web3swift/tree/0.0.4) (2017-12-21) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.0.3...0.0.4) + +## [0.0.3](https://github.com/matter-labs/web3swift/tree/0.0.3) (2017-12-20) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.0.2...0.0.3) -- Wrong conversation of the Wei. [\#2](https://github.com/BANKEX/web3swift/issues/2) -- How to connect to a Localhost Node? [\#1](https://github.com/BANKEX/web3swift/issues/1) +## [0.0.2](https://github.com/matter-labs/web3swift/tree/0.0.2) (2017-12-20) +[Full Changelog](https://github.com/matter-labs/web3swift/compare/0.0.1...0.0.2) +## [0.0.1](https://github.com/matter-labs/web3swift/tree/0.0.1) (2017-12-19) \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/Documentation/AdvancedUsage.md b/Documentation/AdvancedUsage.md deleted file mode 100755 index 8b1378917..000000000 --- a/Documentation/AdvancedUsage.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Documentation/Usage.md b/Documentation/Usage.md index cde3cb161..64a8f3789 100755 --- a/Documentation/Usage.md +++ b/Documentation/Usage.md @@ -41,6 +41,11 @@ - [Get new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-new-pending-transactions) - [Create a new subscription over particular events](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-new-subscription-over-particular-events) - [Subscribe on new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#subscribe-on-new-pending-transactions) +- **[ENS](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ens)** + - [Registry](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#registry) + - [Resolver](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#resolver) + - [BaseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#baseregistrar) + - [RegistrarController](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#registrarcontroller) ## Introduction @@ -432,3 +437,66 @@ try! socketProvider.subscribe(params: <[Encodable]>) try! socketProvider.subscribeOnNewPendingTransactions() ``` +## ENS + +You need ENS instance for future actions: +```swift +let web = web3(provider: InfuraProvider(Networks.Mainnet)!) +let ens = ENS(web3: web)! +``` + +### Registry + +You can get/set owner, resolver, ttl via ENS property registry: +```swift +let owner = try! ens.registry.getOwner(node: node) +let resultSettingOwner = try! ens.registry.setOwner(node: node, owner: owner, options: options, password: password) +... +``` + +### Resolver + +You use convenient resolver methods from ENS instance: +```swift +let address = try! ens.getAddress(forNode: node) +let name = try! ens.getName(forNode: node) +let content = try! ens.getContent(forNode: node) +let abi = try! ens.getABI(forNode: node) +let pubkey = try! ens.getPublicKey(forNode: node) +let text = try! ens.getText(forNode: node, key: key) + +let result = try! ens.setAddress(forNode: node, address: address, options: options, password: password) +let result = try! ens.setName(forNode: node, name: name, options: options, password: password) +let result = try! ens.setContent(forNode: node, hash: hash, options: options, password: password) +let result = try! ens.setABI(forNode: node, contentType: .JSON, data: data, options: options, password: password) +let result = try! ens.setPublicKey(forNode: node, publicKey: publicKey, options: options, password: password) +let result = try! ens.setText(forNode: node, key: key, value: value, options: options, password: password) +``` +or you can get resolver to use its methods directly: +```swift +let resolver = try! ens.registry.getResolver(forDomain: domain) +let doSomething = try! resolver. ... +``` +or set it as ENS instance property and use its methods from it: +```swift +try! ens.setENSResolver(withDomain: domain) +let doSomething = try! ens.resolver!. ... +``` + +### BaseRegistrar +You can set BaseRegistrar as ENS instance property and use its methods from it: +```swift +ens.setBaseRegistrar(withAddress: address) +let doSomething = try! ens.baseRegistrar!. ... +``` + +### RegistrarController +You can set RegistrarController as ENS instance property and use its methods from it: +```swift +ens.setRegistrarController(withAddresss: address) +let doSomething = try! ens.registrarController!. ... +``` + + + + diff --git a/README.md b/README.md index bbd7e27d9..8f4be85b2 100755 --- a/README.md +++ b/README.md @@ -33,45 +33,50 @@ --- - [Usage Doc](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md) - **[Introduction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#introduction)** - - *[Preffered models](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-models)* - - [Preffered keys Wallet Model](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-keys-wallet-model-account) - - [Preffered ERC-20 Model](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-erc-20-model) -- **[Account Management](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#account-management)** - - *[Create Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account)* - - [Create Account With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account-with-private-key) - - [Create Account With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account-with-mnemonics-phrase) - - *[Import Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account)* - - [Import Account With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account-with-private-key) - - [Import Account With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account-with-mnemonics-phrase) - - [Get Keystore Manager from wallet data](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-keystore-manager-from-wallet-data) - - [Get wallet Private key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-wallet-private-key) -- **[Ethereum Endpoints interaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-endpoints-interaction)** - - [web3 instance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#web3-instance) - - [Ethereum Address](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-address) - - *[Get Balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-balance)* - - [Getting ETH balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#getting-eth-balance) - - [Getting ERC20 token balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#getting-erc20-token-balance) - - *[Transactions Operations](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#transactions-operations)* - - [Preparing Transaction For Sending Ether](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-transaction-for-sending-ether) - - [Preparing Transaction For Sending ERC-20 Tokens](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-transaction-for-sending-erc-20-tokens) - - [Preparing Write Transaction for sending to some Contract and use its method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-write-transaction-for-sending-to-some-contract-and-use-its-method) - - [Preparing Read Transaction to call some Contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-read-transaction-to-call-some-contract-method) - - [Send write transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#writing) - - [Send read transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reading) - - [Get Block number](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-block-number) -- **[Websockets](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#websockets)** - - [Web3socketDelegate](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#web3socketdelegate) - - [Get latest new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-latest-new-pending-transactions) - - *[Custom Websocket Provider](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#custom-websocket-provider)* - - [Connect to custom endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-endpoint) - - [Send message](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-message) - - *[Infura Websocket Provider](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#infura-websocket-provider)* - - [Connect to Infura endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-infura-endpoint) - - [Connect to custom endpoint with API similar to Infura WSS endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-endpoint-with-api-similar-to-infura-wss-endpoint) - - [Create a filter in the node to notify when something happened](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-filter-in-the-node-to-notify-when-something-happened) - - [Get new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-new-pending-transactions) - - [Create a new subscription over particular events](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-new-subscription-over-particular-events) - - [Subscribe on new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#subscribe-on-new-pending-transactions) + - *[Preffered models](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-models)* + - [Preffered keys Wallet Model](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-keys-wallet-model-account) + - [Preffered ERC-20 Model](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-erc-20-model) + - **[Account Management](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#account-management)** + - *[Create Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account)* + - [Create Account With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account-with-private-key) + - [Create Account With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account-with-mnemonics-phrase) + - *[Import Account](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-account)* + - [Import Account With Private Key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account-with-private-key) + - [Import Account With Mnemonics Phrase](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#import-account-with-mnemonics-phrase) + - [Get Keystore Manager from wallet data](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-keystore-manager-from-wallet-data) + - [Get wallet Private key](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-wallet-private-key) + - **[Ethereum Endpoints interaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-endpoints-interaction)** + - [web3 instance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#web3-instance) + - [Ethereum Address](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-address) + - *[Get Balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-balance)* + - [Getting ETH balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#getting-eth-balance) + - [Getting ERC20 token balance](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#getting-erc20-token-balance) + - *[Transactions Operations](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#transactions-operations)* + - [Preparing Transaction For Sending Ether](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-transaction-for-sending-ether) + - [Preparing Transaction For Sending ERC-20 Tokens](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-transaction-for-sending-erc-20-tokens) + - [Preparing Write Transaction for sending to some Contract and use its method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-write-transaction-for-sending-to-some-contract-and-use-its-method) + - [Preparing Read Transaction to call some Contract method](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preparing-read-transaction-to-call-some-contract-method) + - [Send write transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#writing) + - [Send read transaction](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#reading) + - [Get Block number](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-block-number) + - **[Websockets](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#websockets)** + - [Web3socketDelegate](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#web3socketdelegate) + - [Get latest new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-latest-new-pending-transactions) + - *[Custom Websocket Provider](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#custom-websocket-provider)* + - [Connect to custom endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-endpoint) + - [Send message](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#send-message) + - *[Infura Websocket Provider](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#infura-websocket-provider)* + - [Connect to Infura endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-infura-endpoint) + - [Connect to custom endpoint with API similar to Infura WSS endpoint](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#connect-to-custom-endpoint-with-api-similar-to-infura-wss-endpoint) + - [Create a filter in the node to notify when something happened](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-filter-in-the-node-to-notify-when-something-happened) + - [Get new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#get-new-pending-transactions) + - [Create a new subscription over particular events](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#create-a-new-subscription-over-particular-events) + - [Subscribe on new pending transactions](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#subscribe-on-new-pending-transactions) + - **[ENS](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ens)** + - [Registry](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#registry) + - [Resolver](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#resolver) + - [BaseRegistrar](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#baseregistrar) + - [RegistrarController](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#registrarcontroller) ## Ready Features - [x] Swift implementation of [web3.js](https://github.com/ethereum/web3.js/) functionality :zap: @@ -140,8 +145,8 @@ When using this lib, please make references to this repo and give your start! :) If you are using web3swift in your app or know of an app that uses it, please add it to [this list](https://github.com/matter-labs/web3swift/wiki/Apps-using-web3swift). -- If you **need help**, use [Stack Overflow](https://stackoverflow.com/questions/tagged/web3swift) and tag `web3swift`. -- If you need to **find or understand an API**, check [our documentation](http://web3swift.github.io/web3swift/). +- If you **need help**, [open an issue](https://github.com/matter-labs/web3swift/issues). +- If you need to **find or understand an API**, check [our documentation](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md). - If you'd like to **see web3swift best practices**, check [Apps using this library](https://github.com/matter-labs/web3swift/wiki/Apps-using-web3swift). - If you **found a bug**, [open an issue](https://github.com/matter-labs/web3swift/issues). - If you **have a feature request**, [open an issue](https://github.com/matter-labs/web3swift/issues). @@ -270,7 +275,6 @@ func setLocalNode(port: Int = 8545) -> Web3? { - [x] Complete Documentation (https://web3swift.github.io/web3swift) - [x] Modularity with the basic Web3 subspec/SPM (the most basic functions like transaction signing and interacting with an http rpc server) and other modules with additional functionality - [x] [R-Token](https://github.com/harborhq/r-token) - Smart Contracts for applying regulatory compliance to tokenized securities issuance and trading -- [x] Complete support Infura Websockets API - [x] Support IPFS via Infura public IPFS gateway - [x] Support more blockchains - Ripple, Bitcoin, EOS, etc. - [x] Performance Improvements diff --git a/web3swift.podspec b/web3swift.podspec index 2bdcd4bc3..fbb0fbe7c 100755 --- a/web3swift.podspec +++ b/web3swift.podspec @@ -17,7 +17,7 @@ s.swift_version = '5.0' s.module_name = 'Web3swift' s.ios.deployment_target = "9.0" s.osx.deployment_target = "10.11" -s.source_files = "web3swift/{Promises,Web3,Contract,KeystoreManager,Transaction,Convenience,HookedFunctions}/Classes/*.{h,swift}", "web3swift/Utils/Classes/{EIP67Code, EIP681, ENS, ENSResolver, NonceMiddleware}.swift", "web3swift/PrecompiledContracts/**/*.swift", "web3swift/web3swift.h" +s.source_files = "web3swift/{Promises,Web3,Contract,KeystoreManager,Transaction,Convenience,HookedFunctions}/*.{h,swift}", "web3swift/Utils/**/*.swift" "web3swift/PrecompiledContracts/**/*.swift", "web3swift/web3swift.h" s.public_header_files = "web3swift/web3swift.h" s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } diff --git a/web3swift.xcodeproj/project.pbxproj b/web3swift.xcodeproj/project.pbxproj index 9e7ed0962..2f05dba08 100755 --- a/web3swift.xcodeproj/project.pbxproj +++ b/web3swift.xcodeproj/project.pbxproj @@ -18,6 +18,16 @@ 3A3F59BD225931BE0075C9E7 /* NameHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81A7B2502143C3A8004CD2C7 /* NameHash.swift */; }; 3A3F59BE225931BE0075C9E7 /* ENS.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2E668CD214F8A7B00C3CC2D /* ENS.swift */; }; 3A3F59BF225931BE0075C9E7 /* ENSResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = B219DC162154F3EE0035BF94 /* ENSResolver.swift */; }; + 3A52CCB22264A6D4001C8D7A /* NonceMiddleware.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81ED4EA72190D922003E932E /* NonceMiddleware.swift */; }; + 3A52CCB32264A6DC001C8D7A /* NonceMiddleware.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81ED4EA72190D922003E932E /* NonceMiddleware.swift */; }; + 3A52CCB72264B712001C8D7A /* BaseRegistrar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A52CCB62264B712001C8D7A /* BaseRegistrar.swift */; }; + 3A52CCB82264B712001C8D7A /* BaseRegistrar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A52CCB62264B712001C8D7A /* BaseRegistrar.swift */; }; + 3A52CCBA2264B728001C8D7A /* ETHRegistrarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A52CCB92264B728001C8D7A /* ETHRegistrarController.swift */; }; + 3A52CCBB2264B728001C8D7A /* ETHRegistrarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A52CCB92264B728001C8D7A /* ETHRegistrarController.swift */; }; + 3A52CCBD226747EB001C8D7A /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A52CCBC226747EB001C8D7A /* PublicKey.swift */; }; + 3A52CCBE226747EB001C8D7A /* PublicKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A52CCBC226747EB001C8D7A /* PublicKey.swift */; }; + 3A52CCC022675CFC001C8D7A /* ENSRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A52CCBF22675CFC001C8D7A /* ENSRegistry.swift */; }; + 3A52CCC122675CFC001C8D7A /* ENSRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A52CCBF22675CFC001C8D7A /* ENSRegistry.swift */; }; 3AE8913C2256286C00D08E99 /* Web3+ERC1155.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE8911C2256286B00D08E99 /* Web3+ERC1155.swift */; }; 3AE8913D2256286C00D08E99 /* Web3+ERC1155.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE8911C2256286B00D08E99 /* Web3+ERC1155.swift */; }; 3AE8913E2256286C00D08E99 /* Web3+ERC1376.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE8911E2256286B00D08E99 /* Web3+ERC1376.swift */; }; @@ -258,6 +268,10 @@ 2B8FEFF3962166E1BEADC886 /* Pods_web3swift_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_web3swift_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 342700493511FEB189700D13 /* Pods-web3swift-iOS_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-web3swift-iOS_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-web3swift-iOS_Tests/Pods-web3swift-iOS_Tests.debug.xcconfig"; sourceTree = ""; }; 391A0D2EF42488E5C8AB2F71 /* Pods_web3swift_osx_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_web3swift_osx_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 3A52CCB62264B712001C8D7A /* BaseRegistrar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseRegistrar.swift; sourceTree = ""; }; + 3A52CCB92264B728001C8D7A /* ETHRegistrarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ETHRegistrarController.swift; sourceTree = ""; }; + 3A52CCBC226747EB001C8D7A /* PublicKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicKey.swift; sourceTree = ""; }; + 3A52CCBF22675CFC001C8D7A /* ENSRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ENSRegistry.swift; sourceTree = ""; }; 3AE8911C2256286B00D08E99 /* Web3+ERC1155.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3+ERC1155.swift"; sourceTree = ""; }; 3AE8911E2256286B00D08E99 /* Web3+ERC1376.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3+ERC1376.swift"; sourceTree = ""; }; 3AE891202256286B00D08E99 /* Web3+ERC888.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Web3+ERC888.swift"; sourceTree = ""; }; @@ -469,7 +483,7 @@ 1CD91AFE1FD76910007BFB45 /* web3swift */ = { isa = PBXGroup; children = ( - 8159C50921343EF900197B91 /* PrecompiledContracts */, + 8159C50921343EF900197B91 /* Tokens */, 81FECD43211ADE20006DA367 /* ObjectiveCbridge */, 81A1821220D5A2430016741F /* Promises */, 81C0FCED20440BDF00D82FAF /* HookedFunctions */, @@ -515,6 +529,29 @@ path = web3swiftTests; sourceTree = ""; }; + 3A52CCB42264A938001C8D7A /* ENS */ = { + isa = PBXGroup; + children = ( + 81A7B2502143C3A8004CD2C7 /* NameHash.swift */, + B2E668CD214F8A7B00C3CC2D /* ENS.swift */, + 3A52CCBC226747EB001C8D7A /* PublicKey.swift */, + B219DC162154F3EE0035BF94 /* ENSResolver.swift */, + 3A52CCBF22675CFC001C8D7A /* ENSRegistry.swift */, + 3A52CCB62264B712001C8D7A /* BaseRegistrar.swift */, + 3A52CCB92264B728001C8D7A /* ETHRegistrarController.swift */, + ); + path = ENS; + sourceTree = ""; + }; + 3A52CCB52264A9E1001C8D7A /* EIP */ = { + isa = PBXGroup; + children = ( + 81FB21F8207BA78B007F9A83 /* EIP67Code.swift */, + 81A7B2862143DBF6004CD2C7 /* EIP681.swift */, + ); + path = EIP; + sourceTree = ""; + }; 3AE8911B2256286B00D08E99 /* ERC1155 */ = { isa = PBXGroup; children = ( @@ -674,33 +711,22 @@ 8113D2AE1FD7E1590074282C /* Utils */ = { isa = PBXGroup; children = ( - 8113D2AF1FD7E1590074282C /* Classes */, + 3A52CCB52264A9E1001C8D7A /* EIP */, + 3A52CCB42264A938001C8D7A /* ENS */, + 8113D2AF1FD7E1590074282C /* Hooks */, ); path = Utils; sourceTree = ""; }; - 8113D2AF1FD7E1590074282C /* Classes */ = { + 8113D2AF1FD7E1590074282C /* Hooks */ = { isa = PBXGroup; children = ( - 81FB21F8207BA78B007F9A83 /* EIP67Code.swift */, - 81A7B2502143C3A8004CD2C7 /* NameHash.swift */, - 81A7B2862143DBF6004CD2C7 /* EIP681.swift */, - B2E668CD214F8A7B00C3CC2D /* ENS.swift */, - B219DC162154F3EE0035BF94 /* ENSResolver.swift */, 81ED4EA72190D922003E932E /* NonceMiddleware.swift */, ); - path = Classes; + path = Hooks; sourceTree = ""; }; 8113D2B51FD7E1590074282C /* KeystoreManager */ = { - isa = PBXGroup; - children = ( - 8113D2B71FD7E1590074282C /* Classes */, - ); - path = KeystoreManager; - sourceTree = ""; - }; - 8113D2B71FD7E1590074282C /* Classes */ = { isa = PBXGroup; children = ( 817EBB2420066E2B00E02EAA /* AbstractKeystore.swift */, @@ -715,28 +741,20 @@ 8103BBCB2077B84400499769 /* PlainKeystore.swift */, 8160E5CD20B8245A0070070B /* IBAN.swift */, ); - path = Classes; + path = KeystoreManager; sourceTree = ""; }; 8113D2C11FD7E1590074282C /* Transaction */ = { - isa = PBXGroup; - children = ( - 8113D2C21FD7E1590074282C /* Classes */, - ); - path = Transaction; - sourceTree = ""; - }; - 8113D2C21FD7E1590074282C /* Classes */ = { isa = PBXGroup; children = ( 8113D2C31FD7E1590074282C /* EthereumTransaction.swift */, 81C0FCF520440F9900D82FAF /* TransactionSigner.swift */, 8125F06820499AC300A0F2FE /* BloomFilter.swift */, ); - path = Classes; + path = Transaction; sourceTree = ""; }; - 8159C50921343EF900197B91 /* PrecompiledContracts */ = { + 8159C50921343EF900197B91 /* Tokens */ = { isa = PBXGroup; children = ( 3AE891262256286B00D08E99 /* ERC20 */, @@ -756,18 +774,10 @@ 3AE8912A2256286B00D08E99 /* ERC1644 */, 3AE891212256286B00D08E99 /* ST20 */, ); - path = PrecompiledContracts; + path = Tokens; sourceTree = ""; }; 818EABD71FDC9A3800E013FC /* Contract */ = { - isa = PBXGroup; - children = ( - 818EABD81FDC9A4800E013FC /* Classes */, - ); - path = Contract; - sourceTree = ""; - }; - 818EABD81FDC9A4800E013FC /* Classes */ = { isa = PBXGroup; children = ( 81C5DA2D2074EBF500424CD6 /* EthereumContract.swift */, @@ -776,18 +786,10 @@ 81D7D97420A3240900A193EC /* EthereumFilterEncodingExtensions.swift */, 81D7D97720A61E3800A193EC /* EventFiltering.swift */, ); - path = Classes; + path = Contract; sourceTree = ""; }; 81A1821220D5A2430016741F /* Promises */ = { - isa = PBXGroup; - children = ( - 81A1821320D5A24F0016741F /* Classes */, - ); - path = Promises; - sourceTree = ""; - }; - 81A1821320D5A24F0016741F /* Classes */ = { isa = PBXGroup; children = ( 81A1821720D5A3E70016741F /* Promise+HttpProvider.swift */, @@ -811,18 +813,10 @@ 81195AAF20D7FF8500ABC6B1 /* Promise+Web3+Contract+GetIndexedEvents.swift */, 985BFD4D216E2E0A00B28C14 /* Promise+Web3+TxPool.swift */, ); - path = Classes; + path = Promises; sourceTree = ""; }; 81C0FCEA20440BB400D82FAF /* Web3 */ = { - isa = PBXGroup; - children = ( - 81C0FCEB20440BBE00D82FAF /* Classes */, - ); - path = Web3; - sourceTree = ""; - }; - 81C0FCEB20440BBE00D82FAF /* Classes */ = { isa = PBXGroup; children = ( 81DDECCE1FDF004E0063684A /* Web3.swift */, @@ -846,24 +840,16 @@ 81909D1721862D5A007D2AE5 /* Web3+Eventloop.swift */, 3AE891602256611E00D08E99 /* Web3+Eth+Websocket.swift */, ); - path = Classes; + path = Web3; sourceTree = ""; }; 81C0FCED20440BDF00D82FAF /* HookedFunctions */ = { - isa = PBXGroup; - children = ( - 81C0FCEE20440BE900D82FAF /* Classes */, - ); - path = HookedFunctions; - sourceTree = ""; - }; - 81C0FCEE20440BE900D82FAF /* Classes */ = { isa = PBXGroup; children = ( 81C0FCEF20440C3600D82FAF /* Web3+Wallet.swift */, 81C0FCF8204456E600D82FAF /* Web3+BrowserFunctions.swift */, ); - path = Classes; + path = HookedFunctions; sourceTree = ""; }; 81FA43F42044097100EE14D5 /* web3swift-macOS_Tests */ = { @@ -876,14 +862,6 @@ sourceTree = ""; }; 81FB21F6207BA6DC007F9A83 /* Convenience */ = { - isa = PBXGroup; - children = ( - 81FB21F7207BA6EB007F9A83 /* Classes */, - ); - path = Convenience; - sourceTree = ""; - }; - 81FB21F7207BA6EB007F9A83 /* Classes */ = { isa = PBXGroup; children = ( 81C5DA272072E18200424CD6 /* NativeTypesEncoding+Extensions.swift */, @@ -897,7 +875,7 @@ 8113D2FF1FD7F30F0074282C /* String+Extension.swift */, 81909D2021884893007D2AE5 /* BigUInt+Extensions.swift */, ); - path = Classes; + path = Convenience; sourceTree = ""; }; 81FECD43211ADE20006DA367 /* ObjectiveCbridge */ = { @@ -1197,6 +1175,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3A52CCB22264A6D4001C8D7A /* NonceMiddleware.swift in Sources */, 3A3F59BC225931B00075C9E7 /* NameHash.swift in Sources */, 3A3F59BB225931780075C9E7 /* ENSResolver.swift in Sources */, 3A3F59BA225931710075C9E7 /* ENS.swift in Sources */, @@ -1213,6 +1192,7 @@ 810B0F9A1FEC446B00CF0DA2 /* Web3+JSONRPC.swift in Sources */, 3AE891642256620200D08E99 /* Web3+WebsocketProvider.swift in Sources */, 81195AB020D7FF8500ABC6B1 /* Promise+Web3+Contract+GetIndexedEvents.swift in Sources */, + 3A52CCBD226747EB001C8D7A /* PublicKey.swift in Sources */, 81EB1E4B208173D7003BD47F /* Web3+Personal.swift in Sources */, 81909D1821862D5A007D2AE5 /* Web3+Eventloop.swift in Sources */, 81A1824B20D7DF1B0016741F /* Promise+Web3+Personal+UnlockAccount.swift in Sources */, @@ -1248,6 +1228,7 @@ 3AE891612256611E00D08E99 /* Web3+Eth+Websocket.swift in Sources */, 81A1822520D678590016741F /* Promise+Web3+Eth+GetGasPrice.swift in Sources */, 8113DE7C1FD8514400CD8DF1 /* NSRegularExpressionExtension.swift in Sources */, + 3A52CCBA2264B728001C8D7A /* ETHRegistrarController.swift in Sources */, 81C5DA2E2074EBF500424CD6 /* EthereumContract.swift in Sources */, 810B0F9E1FEC5B9C00CF0DA2 /* Web3+Eth.swift in Sources */, 3AE891462256286C00D08E99 /* Web3+ERC165.swift in Sources */, @@ -1275,6 +1256,7 @@ 8103BBCC2077B84400499769 /* PlainKeystore.swift in Sources */, 81DFB3FF210775320011DC85 /* Web3+InfuraProviders.swift in Sources */, 81909D4A218864A8007D2AE5 /* EIP681.swift in Sources */, + 3A52CCC022675CFC001C8D7A /* ENSRegistry.swift in Sources */, 3AE891542256286C00D08E99 /* Web3+ERC1400.swift in Sources */, 3AE891522256286C00D08E99 /* Web3+ERC721x.swift in Sources */, 81C0FCF220440EB500D82FAF /* Web3+Protocols.swift in Sources */, @@ -1286,6 +1268,7 @@ 81A1822B20D67A1B0016741F /* Promise+Web3+Eth+GetTransactionDetails.swift in Sources */, 815630042007BC8F00A0EC2F /* BIP39+WordLists.swift in Sources */, 8113D2CE1FD7E1590074282C /* EthereumTransaction.swift in Sources */, + 3A52CCB72264B712001C8D7A /* BaseRegistrar.swift in Sources */, 3AE8914E2256286C00D08E99 /* Web3+ERC721.swift in Sources */, 81A1821F20D676BC0016741F /* Promise+Web3+Eth+GetTransactionCount.swift in Sources */, 81A1821520D5A2700016741F /* Promise+Web3+Eth+GetBalance.swift in Sources */, @@ -1321,6 +1304,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3A52CCB32264A6DC001C8D7A /* NonceMiddleware.swift in Sources */, 3A3F59BD225931BE0075C9E7 /* NameHash.swift in Sources */, 3A3F59BE225931BE0075C9E7 /* ENS.swift in Sources */, 3A3F59BF225931BE0075C9E7 /* ENSResolver.swift in Sources */, @@ -1337,6 +1321,7 @@ 41948121203630530065A83B /* Web3+Utils.swift in Sources */, 3AE891652256620200D08E99 /* Web3+WebsocketProvider.swift in Sources */, 81909D1921862D5A007D2AE5 /* Web3+Eventloop.swift in Sources */, + 3A52CCBE226747EB001C8D7A /* PublicKey.swift in Sources */, 8125F06A20499AC300A0F2FE /* BloomFilter.swift in Sources */, 81C0FD062044A8D100D82FAF /* TransactionSigner.swift in Sources */, 41948123203630530065A83B /* Web3+JSONRPC.swift in Sources */, @@ -1372,6 +1357,7 @@ 81A1824920D7DDA20016741F /* Promise+Web3+Personal+Sign.swift in Sources */, 81A1822620D678590016741F /* Promise+Web3+Eth+GetGasPrice.swift in Sources */, 81909D1621862D37007D2AE5 /* Web3+MutatingTransaction.swift in Sources */, + 3A52CCBB2264B728001C8D7A /* ETHRegistrarController.swift in Sources */, 41948133203630530065A83B /* BIP39.swift in Sources */, 3AE891472256286C00D08E99 /* Web3+ERC165.swift in Sources */, 3AE8913F2256286C00D08E99 /* Web3+ERC1376.swift in Sources */, @@ -1399,6 +1385,7 @@ 81A1823220D68A110016741F /* Promise+Batching.swift in Sources */, 4194813C203630530065A83B /* Base58.swift in Sources */, 81909D4B218864A9007D2AE5 /* EIP681.swift in Sources */, + 3A52CCC122675CFC001C8D7A /* ENSRegistry.swift in Sources */, 3AE891552256286C00D08E99 /* Web3+ERC1400.swift in Sources */, 3AE891532256286C00D08E99 /* Web3+ERC721x.swift in Sources */, 8103BBCD2077B84400499769 /* PlainKeystore.swift in Sources */, @@ -1410,6 +1397,7 @@ 81909D1321862D17007D2AE5 /* Web3+ReadingTransaction.swift in Sources */, 4194813F203630530065A83B /* Dictionary+Extension.swift in Sources */, 41948140203630530065A83B /* Array+Extension.swift in Sources */, + 3A52CCB82264B712001C8D7A /* BaseRegistrar.swift in Sources */, 3AE8914F2256286C00D08E99 /* Web3+ERC721.swift in Sources */, 81A1822020D676BC0016741F /* Promise+Web3+Eth+GetTransactionCount.swift in Sources */, 81A1821620D5A2700016741F /* Promise+Web3+Eth+GetBalance.swift in Sources */, diff --git a/web3swift/Contract/Classes/ComparisonExtensions.swift b/web3swift/Contract/ComparisonExtensions.swift similarity index 100% rename from web3swift/Contract/Classes/ComparisonExtensions.swift rename to web3swift/Contract/ComparisonExtensions.swift diff --git a/web3swift/Contract/Classes/ContractProtocol.swift b/web3swift/Contract/ContractProtocol.swift similarity index 100% rename from web3swift/Contract/Classes/ContractProtocol.swift rename to web3swift/Contract/ContractProtocol.swift diff --git a/web3swift/Contract/Classes/EthereumContract.swift b/web3swift/Contract/EthereumContract.swift similarity index 100% rename from web3swift/Contract/Classes/EthereumContract.swift rename to web3swift/Contract/EthereumContract.swift diff --git a/web3swift/Contract/Classes/EthereumFilterEncodingExtensions.swift b/web3swift/Contract/EthereumFilterEncodingExtensions.swift similarity index 100% rename from web3swift/Contract/Classes/EthereumFilterEncodingExtensions.swift rename to web3swift/Contract/EthereumFilterEncodingExtensions.swift diff --git a/web3swift/Contract/Classes/EventFiltering.swift b/web3swift/Contract/EventFiltering.swift similarity index 100% rename from web3swift/Contract/Classes/EventFiltering.swift rename to web3swift/Contract/EventFiltering.swift diff --git a/web3swift/Convenience/Classes/Array+Extension.swift b/web3swift/Convenience/Array+Extension.swift similarity index 100% rename from web3swift/Convenience/Classes/Array+Extension.swift rename to web3swift/Convenience/Array+Extension.swift diff --git a/web3swift/Convenience/Classes/Base58.swift b/web3swift/Convenience/Base58.swift similarity index 100% rename from web3swift/Convenience/Classes/Base58.swift rename to web3swift/Convenience/Base58.swift diff --git a/web3swift/Convenience/Classes/BigUInt+Extensions.swift b/web3swift/Convenience/BigUInt+Extensions.swift similarity index 100% rename from web3swift/Convenience/Classes/BigUInt+Extensions.swift rename to web3swift/Convenience/BigUInt+Extensions.swift diff --git a/web3swift/Convenience/Classes/CryptoExtensions.swift b/web3swift/Convenience/CryptoExtensions.swift similarity index 100% rename from web3swift/Convenience/Classes/CryptoExtensions.swift rename to web3swift/Convenience/CryptoExtensions.swift diff --git a/web3swift/Convenience/Classes/Data+Extension.swift b/web3swift/Convenience/Data+Extension.swift similarity index 100% rename from web3swift/Convenience/Classes/Data+Extension.swift rename to web3swift/Convenience/Data+Extension.swift diff --git a/web3swift/Convenience/Classes/Dictionary+Extension.swift b/web3swift/Convenience/Dictionary+Extension.swift similarity index 100% rename from web3swift/Convenience/Classes/Dictionary+Extension.swift rename to web3swift/Convenience/Dictionary+Extension.swift diff --git a/web3swift/Convenience/Classes/NSRegularExpressionExtension.swift b/web3swift/Convenience/NSRegularExpressionExtension.swift similarity index 100% rename from web3swift/Convenience/Classes/NSRegularExpressionExtension.swift rename to web3swift/Convenience/NSRegularExpressionExtension.swift diff --git a/web3swift/Convenience/Classes/NativeTypesEncoding+Extensions.swift b/web3swift/Convenience/NativeTypesEncoding+Extensions.swift similarity index 100% rename from web3swift/Convenience/Classes/NativeTypesEncoding+Extensions.swift rename to web3swift/Convenience/NativeTypesEncoding+Extensions.swift diff --git a/web3swift/Convenience/Classes/RIPEMD160+StackOveflow.swift b/web3swift/Convenience/RIPEMD160+StackOveflow.swift similarity index 100% rename from web3swift/Convenience/Classes/RIPEMD160+StackOveflow.swift rename to web3swift/Convenience/RIPEMD160+StackOveflow.swift diff --git a/web3swift/Convenience/Classes/String+Extension.swift b/web3swift/Convenience/String+Extension.swift similarity index 100% rename from web3swift/Convenience/Classes/String+Extension.swift rename to web3swift/Convenience/String+Extension.swift diff --git a/web3swift/HookedFunctions/Classes/Web3+BrowserFunctions.swift b/web3swift/HookedFunctions/Web3+BrowserFunctions.swift similarity index 100% rename from web3swift/HookedFunctions/Classes/Web3+BrowserFunctions.swift rename to web3swift/HookedFunctions/Web3+BrowserFunctions.swift diff --git a/web3swift/HookedFunctions/Classes/Web3+Wallet.swift b/web3swift/HookedFunctions/Web3+Wallet.swift similarity index 100% rename from web3swift/HookedFunctions/Classes/Web3+Wallet.swift rename to web3swift/HookedFunctions/Web3+Wallet.swift diff --git a/web3swift/KeystoreManager/Classes/AbstractKeystore.swift b/web3swift/KeystoreManager/AbstractKeystore.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/AbstractKeystore.swift rename to web3swift/KeystoreManager/AbstractKeystore.swift diff --git a/web3swift/KeystoreManager/Classes/BIP32HDNode.swift b/web3swift/KeystoreManager/BIP32HDNode.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/BIP32HDNode.swift rename to web3swift/KeystoreManager/BIP32HDNode.swift diff --git a/web3swift/KeystoreManager/Classes/BIP32Keystore.swift b/web3swift/KeystoreManager/BIP32Keystore.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/BIP32Keystore.swift rename to web3swift/KeystoreManager/BIP32Keystore.swift diff --git a/web3swift/KeystoreManager/Classes/BIP32KeystoreJSONStructure.swift b/web3swift/KeystoreManager/BIP32KeystoreJSONStructure.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/BIP32KeystoreJSONStructure.swift rename to web3swift/KeystoreManager/BIP32KeystoreJSONStructure.swift diff --git a/web3swift/KeystoreManager/Classes/BIP39+WordLists.swift b/web3swift/KeystoreManager/BIP39+WordLists.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/BIP39+WordLists.swift rename to web3swift/KeystoreManager/BIP39+WordLists.swift diff --git a/web3swift/KeystoreManager/Classes/BIP39.swift b/web3swift/KeystoreManager/BIP39.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/BIP39.swift rename to web3swift/KeystoreManager/BIP39.swift diff --git a/web3swift/KeystoreManager/Classes/EthereumKeystoreV3.swift b/web3swift/KeystoreManager/EthereumKeystoreV3.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/EthereumKeystoreV3.swift rename to web3swift/KeystoreManager/EthereumKeystoreV3.swift diff --git a/web3swift/KeystoreManager/Classes/IBAN.swift b/web3swift/KeystoreManager/IBAN.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/IBAN.swift rename to web3swift/KeystoreManager/IBAN.swift diff --git a/web3swift/KeystoreManager/Classes/KeystoreManager.swift b/web3swift/KeystoreManager/KeystoreManager.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/KeystoreManager.swift rename to web3swift/KeystoreManager/KeystoreManager.swift diff --git a/web3swift/KeystoreManager/Classes/KeystoreV3JSONStructure.swift b/web3swift/KeystoreManager/KeystoreV3JSONStructure.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/KeystoreV3JSONStructure.swift rename to web3swift/KeystoreManager/KeystoreV3JSONStructure.swift diff --git a/web3swift/KeystoreManager/Classes/PlainKeystore.swift b/web3swift/KeystoreManager/PlainKeystore.swift similarity index 100% rename from web3swift/KeystoreManager/Classes/PlainKeystore.swift rename to web3swift/KeystoreManager/PlainKeystore.swift diff --git a/web3swift/Promises/Classes/Promise+Batching.swift b/web3swift/Promises/Promise+Batching.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Batching.swift rename to web3swift/Promises/Promise+Batching.swift diff --git a/web3swift/Promises/Classes/Promise+HttpProvider.swift b/web3swift/Promises/Promise+HttpProvider.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+HttpProvider.swift rename to web3swift/Promises/Promise+HttpProvider.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Contract+GetIndexedEvents.swift b/web3swift/Promises/Promise+Web3+Contract+GetIndexedEvents.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Contract+GetIndexedEvents.swift rename to web3swift/Promises/Promise+Web3+Contract+GetIndexedEvents.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+Call.swift b/web3swift/Promises/Promise+Web3+Eth+Call.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+Call.swift rename to web3swift/Promises/Promise+Web3+Eth+Call.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+EstimateGas.swift b/web3swift/Promises/Promise+Web3+Eth+EstimateGas.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+EstimateGas.swift rename to web3swift/Promises/Promise+Web3+Eth+EstimateGas.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetAccounts.swift b/web3swift/Promises/Promise+Web3+Eth+GetAccounts.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetAccounts.swift rename to web3swift/Promises/Promise+Web3+Eth+GetAccounts.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetBalance.swift b/web3swift/Promises/Promise+Web3+Eth+GetBalance.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetBalance.swift rename to web3swift/Promises/Promise+Web3+Eth+GetBalance.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetBlockByHash.swift b/web3swift/Promises/Promise+Web3+Eth+GetBlockByHash.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetBlockByHash.swift rename to web3swift/Promises/Promise+Web3+Eth+GetBlockByHash.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetBlockByNumber.swift b/web3swift/Promises/Promise+Web3+Eth+GetBlockByNumber.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetBlockByNumber.swift rename to web3swift/Promises/Promise+Web3+Eth+GetBlockByNumber.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetBlockNumber.swift b/web3swift/Promises/Promise+Web3+Eth+GetBlockNumber.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetBlockNumber.swift rename to web3swift/Promises/Promise+Web3+Eth+GetBlockNumber.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetGasPrice.swift b/web3swift/Promises/Promise+Web3+Eth+GetGasPrice.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetGasPrice.swift rename to web3swift/Promises/Promise+Web3+Eth+GetGasPrice.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetTransactionCount.swift b/web3swift/Promises/Promise+Web3+Eth+GetTransactionCount.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetTransactionCount.swift rename to web3swift/Promises/Promise+Web3+Eth+GetTransactionCount.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetTransactionDetails.swift b/web3swift/Promises/Promise+Web3+Eth+GetTransactionDetails.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetTransactionDetails.swift rename to web3swift/Promises/Promise+Web3+Eth+GetTransactionDetails.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+GetTransactionReceipt.swift b/web3swift/Promises/Promise+Web3+Eth+GetTransactionReceipt.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+GetTransactionReceipt.swift rename to web3swift/Promises/Promise+Web3+Eth+GetTransactionReceipt.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+SendRawTransaction.swift b/web3swift/Promises/Promise+Web3+Eth+SendRawTransaction.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+SendRawTransaction.swift rename to web3swift/Promises/Promise+Web3+Eth+SendRawTransaction.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Eth+SendTransaction.swift b/web3swift/Promises/Promise+Web3+Eth+SendTransaction.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Eth+SendTransaction.swift rename to web3swift/Promises/Promise+Web3+Eth+SendTransaction.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Personal+CreateAccount.swift b/web3swift/Promises/Promise+Web3+Personal+CreateAccount.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Personal+CreateAccount.swift rename to web3swift/Promises/Promise+Web3+Personal+CreateAccount.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Personal+Sign.swift b/web3swift/Promises/Promise+Web3+Personal+Sign.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Personal+Sign.swift rename to web3swift/Promises/Promise+Web3+Personal+Sign.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+Personal+UnlockAccount.swift b/web3swift/Promises/Promise+Web3+Personal+UnlockAccount.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+Personal+UnlockAccount.swift rename to web3swift/Promises/Promise+Web3+Personal+UnlockAccount.swift diff --git a/web3swift/Promises/Classes/Promise+Web3+TxPool.swift b/web3swift/Promises/Promise+Web3+TxPool.swift similarity index 100% rename from web3swift/Promises/Classes/Promise+Web3+TxPool.swift rename to web3swift/Promises/Promise+Web3+TxPool.swift diff --git a/web3swift/PrecompiledContracts/ERC1155/Web3+ERC1155.swift b/web3swift/Tokens/ERC1155/Web3+ERC1155.swift similarity index 98% rename from web3swift/PrecompiledContracts/ERC1155/Web3+ERC1155.swift rename to web3swift/Tokens/ERC1155/Web3+ERC1155.swift index 7d129d82e..5c82ac8b9 100644 --- a/web3swift/PrecompiledContracts/ERC1155/Web3+ERC1155.swift +++ b/web3swift/Tokens/ERC1155/Web3+ERC1155.swift @@ -135,7 +135,7 @@ public class ERC1155: IERC1155 { return res } - func supportsInterface(interfaceID: [UInt8]) throws -> Bool { + func supportsInterface(interfaceID: String) throws -> Bool { let contract = self.contract var transactionOptions = TransactionOptions() transactionOptions.callOnBlock = .latest diff --git a/web3swift/PrecompiledContracts/ERC1376/Web3+ERC1376.swift b/web3swift/Tokens/ERC1376/Web3+ERC1376.swift similarity index 100% rename from web3swift/PrecompiledContracts/ERC1376/Web3+ERC1376.swift rename to web3swift/Tokens/ERC1376/Web3+ERC1376.swift diff --git a/web3swift/PrecompiledContracts/ERC1400/Web3+ERC1400.swift b/web3swift/Tokens/ERC1400/Web3+ERC1400.swift similarity index 99% rename from web3swift/PrecompiledContracts/ERC1400/Web3+ERC1400.swift rename to web3swift/Tokens/ERC1400/Web3+ERC1400.swift index ae51bf0ad..85f442a0a 100644 --- a/web3swift/PrecompiledContracts/ERC1400/Web3+ERC1400.swift +++ b/web3swift/Tokens/ERC1400/Web3+ERC1400.swift @@ -782,7 +782,7 @@ extension ERC1400: IERC777 { return tx } - public func supportsInterface(interfaceID: [UInt8]) throws -> Bool { + public func supportsInterface(interfaceID: String) throws -> Bool { let contract = self.contract var transactionOptions = TransactionOptions() transactionOptions.callOnBlock = .latest diff --git a/web3swift/PrecompiledContracts/ERC1410/Web3+ERC1410.swift b/web3swift/Tokens/ERC1410/Web3+ERC1410.swift similarity index 99% rename from web3swift/PrecompiledContracts/ERC1410/Web3+ERC1410.swift rename to web3swift/Tokens/ERC1410/Web3+ERC1410.swift index 8bdec4635..9a6ad04d3 100644 --- a/web3swift/PrecompiledContracts/ERC1410/Web3+ERC1410.swift +++ b/web3swift/Tokens/ERC1410/Web3+ERC1410.swift @@ -517,7 +517,7 @@ extension ERC1410: IERC777 { return tx } - public func supportsInterface(interfaceID: [UInt8]) throws -> Bool { + public func supportsInterface(interfaceID: String) throws -> Bool { let contract = self.contract var transactionOptions = TransactionOptions() transactionOptions.callOnBlock = .latest diff --git a/web3swift/PrecompiledContracts/ERC1594/Web3+ERC1594.swift b/web3swift/Tokens/ERC1594/Web3+ERC1594.swift similarity index 100% rename from web3swift/PrecompiledContracts/ERC1594/Web3+ERC1594.swift rename to web3swift/Tokens/ERC1594/Web3+ERC1594.swift diff --git a/web3swift/PrecompiledContracts/ERC1633/Web3+ERC1633.swift b/web3swift/Tokens/ERC1633/Web3+ERC1633.swift similarity index 99% rename from web3swift/PrecompiledContracts/ERC1633/Web3+ERC1633.swift rename to web3swift/Tokens/ERC1633/Web3+ERC1633.swift index a71e051b8..694821f32 100644 --- a/web3swift/PrecompiledContracts/ERC1633/Web3+ERC1633.swift +++ b/web3swift/Tokens/ERC1633/Web3+ERC1633.swift @@ -241,7 +241,7 @@ public class ERC1633: IERC1633 { return res } - public func supportsInterface(interfaceID: [UInt8]) throws -> Bool { + public func supportsInterface(interfaceID: String) throws -> Bool { let contract = self.contract var transactionOptions = TransactionOptions() transactionOptions.callOnBlock = .latest diff --git a/web3swift/PrecompiledContracts/ERC1643/Web3+ERC1643.swift b/web3swift/Tokens/ERC1643/Web3+ERC1643.swift similarity index 100% rename from web3swift/PrecompiledContracts/ERC1643/Web3+ERC1643.swift rename to web3swift/Tokens/ERC1643/Web3+ERC1643.swift diff --git a/web3swift/PrecompiledContracts/ERC1644/Web3+ERC1644.swift b/web3swift/Tokens/ERC1644/Web3+ERC1644.swift similarity index 100% rename from web3swift/PrecompiledContracts/ERC1644/Web3+ERC1644.swift rename to web3swift/Tokens/ERC1644/Web3+ERC1644.swift diff --git a/web3swift/PrecompiledContracts/ERC165/Web3+ERC165.swift b/web3swift/Tokens/ERC165/Web3+ERC165.swift similarity index 78% rename from web3swift/PrecompiledContracts/ERC165/Web3+ERC165.swift rename to web3swift/Tokens/ERC165/Web3+ERC165.swift index 6687e9c4e..5abd3e955 100644 --- a/web3swift/PrecompiledContracts/ERC165/Web3+ERC165.swift +++ b/web3swift/Tokens/ERC165/Web3+ERC165.swift @@ -11,6 +11,6 @@ import Foundation //Standard Interface Detection protocol IERC165 { - func supportsInterface(interfaceID: [UInt8]) throws -> Bool + func supportsInterface(interfaceID: String) throws -> Bool } diff --git a/web3swift/PrecompiledContracts/ERC20/Web3+ERC20.swift b/web3swift/Tokens/ERC20/Web3+ERC20.swift similarity index 100% rename from web3swift/PrecompiledContracts/ERC20/Web3+ERC20.swift rename to web3swift/Tokens/ERC20/Web3+ERC20.swift diff --git a/web3swift/PrecompiledContracts/ERC721/Web3+ERC721.swift b/web3swift/Tokens/ERC721/Web3+ERC721.swift similarity index 89% rename from web3swift/PrecompiledContracts/ERC721/Web3+ERC721.swift rename to web3swift/Tokens/ERC721/Web3+ERC721.swift index 1960b095a..9a2069130 100644 --- a/web3swift/PrecompiledContracts/ERC721/Web3+ERC721.swift +++ b/web3swift/Tokens/ERC721/Web3+ERC721.swift @@ -18,6 +18,10 @@ protocol IERC721: IERC165 { func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, tokenId: BigUInt) throws -> WriteTransaction + func safeTransferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, tokenId: BigUInt) throws -> WriteTransaction + + func safeTransferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, tokenId: BigUInt, data: [UInt8]) throws -> WriteTransaction + func transfer(from: EthereumAddress, to: EthereumAddress, tokenId: BigUInt) throws -> WriteTransaction func approve(from: EthereumAddress, approved: EthereumAddress, tokenId: BigUInt) throws -> WriteTransaction @@ -152,6 +156,26 @@ public class ERC721: IERC721 { return tx } + public func safeTransferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, tokenId: BigUInt) throws -> WriteTransaction { + let contract = self.contract + var basicOptions = TransactionOptions() + basicOptions.from = from + basicOptions.to = self.address + + let tx = contract.write("safeTransferFrom", parameters: [originalOwner, to, tokenId] as [AnyObject], transactionOptions: basicOptions)! + return tx + } + + public func safeTransferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, tokenId: BigUInt, data: [UInt8]) throws -> WriteTransaction { + let contract = self.contract + var basicOptions = TransactionOptions() + basicOptions.from = from + basicOptions.to = self.address + + let tx = contract.write("safeTransferFrom", parameters: [originalOwner, to, tokenId, data] as [AnyObject], transactionOptions: basicOptions)! + return tx + } + public func approve(from: EthereumAddress, approved: EthereumAddress, tokenId: BigUInt) throws -> WriteTransaction { let contract = self.contract var basicOptions = TransactionOptions() @@ -181,7 +205,7 @@ public class ERC721: IERC721 { return res } - public func supportsInterface(interfaceID: [UInt8]) throws -> Bool { + public func supportsInterface(interfaceID: String) throws -> Bool { let contract = self.contract var transactionOptions = TransactionOptions() transactionOptions.callOnBlock = .latest diff --git a/web3swift/PrecompiledContracts/ERC721x/Web3+ERC721x.swift b/web3swift/Tokens/ERC721x/Web3+ERC721x.swift similarity index 93% rename from web3swift/PrecompiledContracts/ERC721x/Web3+ERC721x.swift rename to web3swift/Tokens/ERC721x/Web3+ERC721x.swift index ccaff5438..31738165f 100644 --- a/web3swift/PrecompiledContracts/ERC721x/Web3+ERC721x.swift +++ b/web3swift/Tokens/ERC721x/Web3+ERC721x.swift @@ -140,6 +140,26 @@ public class ERC721x: IERC721x { return tx } + public func safeTransferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, tokenId: BigUInt) throws -> WriteTransaction { + let contract = self.contract + var basicOptions = TransactionOptions() + basicOptions.from = from + basicOptions.to = self.address + + let tx = contract.write("safeTransferFrom", parameters: [originalOwner, to, tokenId] as [AnyObject], transactionOptions: basicOptions)! + return tx + } + + public func safeTransferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, tokenId: BigUInt, data: [UInt8]) throws -> WriteTransaction { + let contract = self.contract + var basicOptions = TransactionOptions() + basicOptions.from = from + basicOptions.to = self.address + + let tx = contract.write("safeTransferFrom", parameters: [originalOwner, to, tokenId, data] as [AnyObject], transactionOptions: basicOptions)! + return tx + } + public func approve(from: EthereumAddress, approved: EthereumAddress, tokenId: BigUInt) throws -> WriteTransaction { let contract = self.contract var basicOptions = TransactionOptions() @@ -169,7 +189,7 @@ public class ERC721x: IERC721x { return res } - public func supportsInterface(interfaceID: [UInt8]) throws -> Bool { + public func supportsInterface(interfaceID: String) throws -> Bool { let contract = self.contract var transactionOptions = TransactionOptions() transactionOptions.callOnBlock = .latest diff --git a/web3swift/PrecompiledContracts/ERC777/Web3+ERC777.swift b/web3swift/Tokens/ERC777/Web3+ERC777.swift similarity index 99% rename from web3swift/PrecompiledContracts/ERC777/Web3+ERC777.swift rename to web3swift/Tokens/ERC777/Web3+ERC777.swift index 8127bf0fe..f13d7ce1a 100644 --- a/web3swift/PrecompiledContracts/ERC777/Web3+ERC777.swift +++ b/web3swift/Tokens/ERC777/Web3+ERC777.swift @@ -431,7 +431,7 @@ public class ERC777: IERC777 { return tx } - public func supportsInterface(interfaceID: [UInt8]) throws -> Bool { + public func supportsInterface(interfaceID: String) throws -> Bool { let contract = self.contract var transactionOptions = TransactionOptions() transactionOptions.callOnBlock = .latest diff --git a/web3swift/PrecompiledContracts/ERC820/Web3+ERC820.swift b/web3swift/Tokens/ERC820/Web3+ERC820.swift similarity index 100% rename from web3swift/PrecompiledContracts/ERC820/Web3+ERC820.swift rename to web3swift/Tokens/ERC820/Web3+ERC820.swift diff --git a/web3swift/PrecompiledContracts/ERC888/Web3+ERC888.swift b/web3swift/Tokens/ERC888/Web3+ERC888.swift similarity index 100% rename from web3swift/PrecompiledContracts/ERC888/Web3+ERC888.swift rename to web3swift/Tokens/ERC888/Web3+ERC888.swift diff --git a/web3swift/PrecompiledContracts/ST20/Web3+ST20.swift b/web3swift/Tokens/ST20/Web3+ST20.swift similarity index 100% rename from web3swift/PrecompiledContracts/ST20/Web3+ST20.swift rename to web3swift/Tokens/ST20/Web3+ST20.swift diff --git a/web3swift/PrecompiledContracts/ST20/Web3+SecurityToken.swift b/web3swift/Tokens/ST20/Web3+SecurityToken.swift similarity index 100% rename from web3swift/PrecompiledContracts/ST20/Web3+SecurityToken.swift rename to web3swift/Tokens/ST20/Web3+SecurityToken.swift diff --git a/web3swift/Transaction/Classes/BloomFilter.swift b/web3swift/Transaction/BloomFilter.swift similarity index 100% rename from web3swift/Transaction/Classes/BloomFilter.swift rename to web3swift/Transaction/BloomFilter.swift diff --git a/web3swift/Transaction/Classes/EthereumTransaction.swift b/web3swift/Transaction/EthereumTransaction.swift similarity index 100% rename from web3swift/Transaction/Classes/EthereumTransaction.swift rename to web3swift/Transaction/EthereumTransaction.swift diff --git a/web3swift/Transaction/Classes/TransactionSigner.swift b/web3swift/Transaction/TransactionSigner.swift similarity index 100% rename from web3swift/Transaction/Classes/TransactionSigner.swift rename to web3swift/Transaction/TransactionSigner.swift diff --git a/web3swift/Utils/Classes/ENS.swift b/web3swift/Utils/Classes/ENS.swift deleted file mode 100755 index 6181c81a8..000000000 --- a/web3swift/Utils/Classes/ENS.swift +++ /dev/null @@ -1,161 +0,0 @@ -// web3swift -// -// Created by Alex Vlasov. -// Copyright © 2018 Alex Vlasov. All rights reserved. -// - -import Foundation -import BigInt -import EthereumAddress - -public class ENS { - - let web3: web3 - let ensContractAddress: EthereumAddress? - - init(web3: web3) { - self.web3 = web3 - switch web3.provider.network { - case .Mainnet?: - ensContractAddress = EthereumAddress("0x314159265dd8dbb310642f98f50c066173c1259b") - case .Rinkeby?: - ensContractAddress = EthereumAddress("0xe7410170f87102df0055eb195163a03b7f2bff4a") - case .Ropsten?: - ensContractAddress = EthereumAddress("0x112234455c3a32fd11230c42e7bccd4a84e02010") - default: - ensContractAddress = nil - } - } - - lazy var registryContract: web3.web3contract = { - let contract = self.web3.contract(Web3.Utils.ensRegistryABI, at: self.ensContractAddress, abiVersion: 2) - precondition(contract != nil) - return contract! - }() - - lazy var defaultOptions: TransactionOptions = { - return TransactionOptions.defaultOptions - }() - - //MARK: - Convenience methods - public func getAddress(_ domain: String) throws -> EthereumAddress { - guard var resolver = try? self.resolver(forDomain: domain) else {throw Web3Error.processingError(desc: "Failed to get resolver for domain")} - guard let isAddrSupports = try? resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.addr.hash()) else {throw Web3Error.processingError(desc: "Resolver don't support interface with this ID")} - guard isAddrSupports else {throw Web3Error.processingError(desc: "Address isn't supported")} - guard let addr = try? resolver.addr(forDomain: domain) else {throw Web3Error.processingError(desc: "Can't get address")} - return addr - } - - - public func setAddress(domain: String, address: EthereumAddress, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - guard var resolver = try? self.resolver(forDomain: domain) else {throw Web3Error.processingError(desc: "Failed to get resolver for domain")} - guard let isAddrSupports = try? resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.addr.hash()) else {throw Web3Error.processingError(desc: "Resolver don't support interface with this ID")} - guard isAddrSupports else {throw Web3Error.processingError(desc: "Address isn't supported")} - guard let result = try? resolver.setAddr(node: domain, address: address, options: options, password: password) else {throw Web3Error.processingError(desc: "Can't get result")} - return result - } - - public func getPubkey(domain: String) throws -> PublicKey { - guard var resolver = try? self.resolver(forDomain: domain) else {throw Web3Error.processingError(desc: "Failed to get resolver for domain")} - guard let isPubkeySupports = try? resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.pubkey.hash()) else {throw Web3Error.processingError(desc: "Resolver don't support interface with this ID")} - guard isPubkeySupports else {throw Web3Error.processingError(desc: "Pubkey isn't supported")} - guard let pubkey = try? resolver.pubkey(node: domain) else {throw Web3Error.processingError(desc: "Can't get pubkey")} - return pubkey - } - - public func setPubkey(domain: String, x: String, y: String, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - guard var resolver = try? self.resolver(forDomain: domain) else {throw Web3Error.processingError(desc: "Failed to get resolver for domain")} - guard let result = try? resolver.setPubkey(node: domain, x: x, y: y, options: options, password: password) else {throw Web3Error.processingError(desc: "Can't get result")} - return result - } - - public func getContent(domain: String) throws -> String { - guard var resolver = try? self.resolver(forDomain: domain) else {throw Web3Error.processingError(desc: "Failed to get resolver for domain")} - guard let content = try? resolver.content(node: domain) else {throw Web3Error.processingError(desc: "Can't get content")} - return content - } - - public func setContent(domain: String, hash: String, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - guard var resolver = try? self.resolver(forDomain: domain) else {throw Web3Error.processingError(desc: "Failed to get resolver for domain")} - guard let result = try? resolver.setContent(node: domain, hash: hash, options: options, password: password) else {throw Web3Error.processingError(desc: "Can't get result")} - return result - } - - public func getMultihash(domain: String) throws -> Data { - guard var resolver = try? self.resolver(forDomain: domain) else {throw Web3Error.processingError(desc: "Failed to get resolver for domain")} - guard let multihash = try? resolver.multihash(node: domain) else {throw Web3Error.processingError(desc: "Can't get multihash")} - return multihash - } - - - //MARK: - Returns resolver for the given domain - public func resolver(forDomain domain: String) throws -> ResolverENS { - guard let nameHash = NameHash.nameHash(domain) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.read("resolver", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let resolverAddress = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "No address in result")} - return ResolverENS(web3: self.web3, resolverAddress: resolverAddress) - } - - //Returns node's owner address - public func owner(node: String) throws -> EthereumAddress { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.read("owner", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "No address in result")} - return address - } - - //Untested - public func ttl(node: String) throws -> BigUInt { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.read("ttl", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let ans = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "No answer in result")} - return ans - } - - // function setOwner(bytes32 node, address owner); - public func setOwner(node: String, owner: EthereumAddress, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.write("setOwner", parameters: [nameHash, owner] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - - // function setSubnodeOwner(bytes32 node, bytes32 label, address owner); - public func setSubnodeOwner(node: String, label: String, owner: EthereumAddress, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let labelHash = NameHash.nameHash(label) else {throw Web3Error.processingError(desc: "Failed to get label hash")} - guard let transaction = self.registryContract.write("setSubnodeOwner", parameters: [nameHash, labelHash, owner] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - - // function setResolver(bytes32 node, address resolver); - public func setResolver(node: String, resolver: EthereumAddress, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.write("setResolver", parameters: [nameHash, resolver] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - - // function setTTL(bytes32 node, uint64 ttl); - public func setTTL(node: String, ttl: BigUInt, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.registryContract.write("setTTL", parameters: [nameHash, ttl] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - - private func getOptions(_ options: TransactionOptions) -> TransactionOptions { - var options = options - options.to = self.ensContractAddress - return options - } -} - diff --git a/web3swift/Utils/Classes/ENSResolver.swift b/web3swift/Utils/Classes/ENSResolver.swift deleted file mode 100755 index fdad551a1..000000000 --- a/web3swift/Utils/Classes/ENSResolver.swift +++ /dev/null @@ -1,200 +0,0 @@ -// web3swift -// -// Created by Alex Vlasov. -// Copyright © 2018 Alex Vlasov. All rights reserved. -// - -import Foundation -import BigInt -import EthereumAddress - -public struct ResolverENS { - let web3: web3 - let resolverAddress: EthereumAddress - - public enum InterfaceName { - case addr - case name - case ABI - case pubkey - case content - case multihash - case text - - func hash() -> String { - switch self { - case .ABI: - return "0x2203ab56" - case .addr: - return "0x3b3b57de" - case .name: - return "0x691f3431" - case .pubkey: - return "0xc8690233" - case .content: - return "0xd8389dc5" - case .multihash: - return "0xe89401a1" - case .text: - return "0x59d1d43c" - } - } - } - - lazy var resolverContract: web3.web3contract = { - let contract = self.web3.contract(Web3.Utils.resolverABI, at: self.resolverAddress, abiVersion: 2) - precondition(contract != nil) - return contract! - }() - - lazy var defaultOptions: TransactionOptions = { - return TransactionOptions.defaultOptions - }() - - init(web3: web3, resolverAddress: EthereumAddress) { - self.web3 = web3 - self.resolverAddress = resolverAddress - } - - mutating public func supportsInterface(interfaceID: Data) throws -> Bool { - guard let supports = try? supportsInterface(interfaceID: interfaceID.toHexString()) else {throw Web3Error.processingError(desc: "Can't get answer")} - return supports - } - - //MARK: - returns true if the contract supports given interface - mutating public func supportsInterface(interfaceID: String) throws -> Bool { - guard let transaction = self.resolverContract.read("supportsInterface", parameters: [interfaceID as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let supports = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} - return supports - } - - //MARK: - returns address for the given domain at given resolver - mutating public func addr(forDomain domain: String) throws -> EthereumAddress { - guard let nameHash = NameHash.nameHash(domain) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.read("addr", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Can't get address")} - return address - } - - //function setAddr(bytes32 node, address addr) - mutating public func setAddr(node: String, address: EthereumAddress, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.write("setAddr", parameters: [nameHash, address] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - - //MARK: - returns corresponding ENS to the requested node - mutating public func name(node: String) throws -> String { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.read("name", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let name = result["0"] as? String else {throw Web3Error.processingError(desc: "Can't get name")} - return name - } - - mutating func setName(node: String, name: String, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.write("setName", parameters: [nameHash, name] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - - //MARK: - returns ABI in the requested encodings - mutating public func ABI(node: String, contentType: BigUInt) throws -> (BigUInt, Data) { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.read("ABI", parameters: [nameHash, contentType] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let encoding = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Can't get encoding")} - guard let data = result["1"] as? Data else {throw Web3Error.processingError(desc: "Can't get data")} - return (encoding, data) - } - - mutating func setABI(node: String, contentType: BigUInt, data: Data, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.write("setABI", parameters: [nameHash, contentType, data] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - - //MARK: - returns x and y coordinates - mutating public func pubkey(node: String) throws -> PublicKey { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.read("pubkey", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let x = result["x"] as? Data else {throw Web3Error.processingError(desc: "Can't get x")} - guard let y = result["y"] as? Data else {throw Web3Error.processingError(desc: "Can't get y")} - let pubkey = PublicKey(x: "0x" + x.toHexString(), y: "0x" + y.toHexString()) - return pubkey - } - - mutating public func setPubkey(node: String, x: String, y: String, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.write("setPubkey", parameters: [nameHash, x, y] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - - mutating func content(node: String) throws -> String { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.read("content", parameters: [nameHash] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let content = result["0"] as? String else {throw Web3Error.processingError(desc: "Can't get content")} - return content - } - - mutating func setContent(node: String, hash: String, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.write("setContent", parameters: [nameHash, hash] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - //function multihash(bytes32 node) public view returns (bytes) - mutating public func multihash(node: String) throws -> Data { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.read("multihash", parameters: [nameHash] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let multihash = result["0"] as? Data else {throw Web3Error.processingError(desc: "Can't get multihash")} - return multihash - } - //function setMultihash(bytes32 node, bytes hash) public only_owner(node) - mutating public func setMultihash(node: String, hash: Data, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - let options = getOptions(options) - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.write("setMultihash", parameters: [nameHash, hash] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - //function text(bytes32 node, string key) public view returns (string) - mutating public func text(node: String, key: String) throws -> String { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.read("text", parameters: [nameHash, key] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} - guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} - guard let text = result["0"] as? String else {throw Web3Error.processingError(desc: "Can't get text")} - return text - } - //function setText(bytes32 node, string key, string value) public only_owner(node) - mutating public func setText(node: String, key: String, value: String, options: TransactionOptions, password: String? = nil) throws -> TransactionSendingResult { - guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} - guard let transaction = self.resolverContract.write("setText", parameters: [nameHash, key, value] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} - guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} - return result - } - private func getOptions(_ options: TransactionOptions) -> TransactionOptions { - var options = options - options.to = self.resolverAddress - return options - } -} - -public struct PublicKey { - let x: String - let y: String -} diff --git a/web3swift/Utils/Classes/EIP67Code.swift b/web3swift/Utils/EIP/EIP67Code.swift similarity index 100% rename from web3swift/Utils/Classes/EIP67Code.swift rename to web3swift/Utils/EIP/EIP67Code.swift diff --git a/web3swift/Utils/Classes/EIP681.swift b/web3swift/Utils/EIP/EIP681.swift similarity index 98% rename from web3swift/Utils/Classes/EIP681.swift rename to web3swift/Utils/EIP/EIP681.swift index 64729f7f7..24f2b907d 100755 --- a/web3swift/Utils/Classes/EIP681.swift +++ b/web3swift/Utils/EIP/EIP681.swift @@ -126,8 +126,8 @@ extension Web3 { do { let web = web3(provider: InfuraProvider(Networks.fromInt(Int(code.chainID ?? 1)) ?? Networks.Mainnet)!) let ensModel = ENS(web3: web) - var resolver = try ensModel.resolver(forDomain: ens) - let address = try resolver.addr(forDomain: ens) + try ensModel?.setENSResolver(withDomain: ens) + let address = try ensModel?.getAddress(forNode: ens) nativeValue = address as AnyObject } catch { return nil diff --git a/web3swift/Utils/ENS/BaseRegistrar.swift b/web3swift/Utils/ENS/BaseRegistrar.swift new file mode 100644 index 000000000..f9f651c08 --- /dev/null +++ b/web3swift/Utils/ENS/BaseRegistrar.swift @@ -0,0 +1,82 @@ +// +// BaseRegistrar.swift +// web3swift +// +// Created by Anton on 15/04/2019. +// Copyright © 2019 The Matter Inc. All rights reserved. +// + +import Foundation +import BigInt +import EthereumAddress + +public extension ENS { + class BaseRegistrar: ERC721 { + lazy var defaultOptions: TransactionOptions = { + return TransactionOptions.defaultOptions + }() + + public init(web3: web3, address: EthereumAddress) { + super.init(web3: web3, provider: web3.provider, address: address) + guard let contract = self.web3.contract(Web3.Utils.baseRegistrarABI, at: self.address, abiVersion: 2) else { + return + } + self.contract = contract + } + + override public init(web3: web3, provider: Web3Provider, address: EthereumAddress) { + super.init(web3: web3, provider: provider, address: address) + guard let contract = self.web3.contract(Web3.Utils.baseRegistrarABI, at: self.address, abiVersion: 2) else { + return + } + self.contract = contract + } + + @available(*, message: "Available for only owner") + public func addController(from: EthereumAddress, controllerAddress: EthereumAddress) throws -> WriteTransaction { + defaultOptions.from = from + defaultOptions.to = self.address + guard let transaction = self.contract.write("addController", parameters: [controllerAddress as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + return transaction + } + + @available(*, message: "Available for only owner") + public func removeController(from: EthereumAddress, controllerAddress: EthereumAddress) throws -> WriteTransaction { + defaultOptions.from = from + defaultOptions.to = self.address + guard let transaction = self.contract.write("removeController", parameters: [controllerAddress as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + return transaction + } + + @available(*, message: "Available for only owner") + public func setResolver(from: EthereumAddress, resolverAddress: EthereumAddress) throws -> WriteTransaction { + defaultOptions.from = from + defaultOptions.to = self.address + guard let transaction = self.contract.write("setResolver", parameters: [resolverAddress as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + return transaction + } + + public func getNameExpirity(name: BigUInt) throws -> UInt { + guard let transaction = self.contract.read("nameExpires", parameters: [name as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let expirity = result["0"] as? UInt else {throw Web3Error.processingError(desc: "Can't get answer")} + return expirity + } + + @available(*, message: "This function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, check name availablility via the controller") + public func isNameAvailable(name: BigUInt) throws -> Bool { + guard let transaction = self.contract.read("available", parameters: [name as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let available = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} + return available + } + + public func reclaim(from: EthereumAddress, record: BigUInt) throws -> WriteTransaction { + defaultOptions.from = from + defaultOptions.to = self.address + guard let transaction = self.contract.write("reclaim", parameters: [record as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + return transaction + } + + } +} diff --git a/web3swift/Utils/ENS/ENS.swift b/web3swift/Utils/ENS/ENS.swift new file mode 100755 index 000000000..085412347 --- /dev/null +++ b/web3swift/Utils/ENS/ENS.swift @@ -0,0 +1,273 @@ +// web3swift +// +// Created by Alex Vlasov. +// Copyright © 2018 Alex Vlasov. All rights reserved. +// + +import Foundation +import BigInt +import EthereumAddress + +public class ENS { + + let web3: web3 + var registry: Registry + var resolver: Resolver? = nil + var baseRegistrar: BaseRegistrar? = nil + var registrarController: ETHRegistrarController? = nil + + init?(web3: web3) { + self.web3 = web3 + guard let registry = Registry(web3: web3) else { + return nil + } + self.registry = registry + } + + func setENSResolver(_ resolver: Resolver) throws { + guard resolver.web3.provider.url == self.web3.provider.url else { + throw Web3Error.processingError(desc: "Resolver should use same provider as ENS") + } + self.resolver = resolver + } + + func setENSResolver(withDomain domain: String) throws { + guard let resolver = try? self.registry.getResolver(forDomain: domain) else { + throw Web3Error.processingError(desc: "No resolver for this domain") + } + self.resolver = resolver + } + + func setBaseRegistrar(_ baseRegistrar: BaseRegistrar) throws { + guard baseRegistrar.web3.provider.url == self.web3.provider.url else { + throw Web3Error.processingError(desc: "Base registrar should use same provider as ENS") + } + self.baseRegistrar = baseRegistrar + } + + func setBaseRegistrar(withAddress address: EthereumAddress) { + let baseRegistrar = BaseRegistrar(web3: web3, address: address) + self.baseRegistrar = baseRegistrar + } + + func setRegistrarController(_ registrarController: ETHRegistrarController) throws { + guard registrarController.web3.provider.url == self.web3.provider.url else { + throw Web3Error.processingError(desc: "Registrar controller should use same provider as ENS") + } + self.registrarController = registrarController + } + + func setRegistrarController(withAddress address: EthereumAddress) { + let registrarController = ETHRegistrarController(web3: web3, address: address) + self.registrarController = registrarController + } + + lazy var defaultOptions: TransactionOptions = { + return TransactionOptions.defaultOptions + }() + + //MARK: - Convenience resolver methods + public func getAddress(forNode node: String) throws -> EthereumAddress { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isAddrSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.addr.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isAddrSupports else { + throw Web3Error.processingError(desc: "Address isn't supported") + } + guard let addr = try? resolver.getAddress(forNode: node) else { + throw Web3Error.processingError(desc: "Can't get address") + } + return addr + } + + public func setAddress(forNode node: String, address: EthereumAddress, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isAddrSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.addr.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isAddrSupports else { + throw Web3Error.processingError(desc: "Address isn't supported") + } + var options = options ?? defaultOptions + options.to = resolver.resolverContractAddress + guard let result = try? resolver.setAddress(forNode: node, address: address, options: options, password: password) else { + throw Web3Error.processingError(desc: "Can't get result") + } + return result + } + + public func getName(forNode node: String) throws -> String { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isNameSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.name.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isNameSupports else { + throw Web3Error.processingError(desc: "Name isn't supported") + } + guard let name = try? resolver.getCanonicalName(forNode: node) else { + throw Web3Error.processingError(desc: "Can't get name") + } + return name + } + + public func setName(forNode node: String, name: String, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isNameSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.name.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isNameSupports else { + throw Web3Error.processingError(desc: "Name isn't supported") + } + var options = options ?? defaultOptions + options.to = resolver.resolverContractAddress + guard let result = try? resolver.setCanonicalName(forNode: node, name: name, options: options, password: password) else { + throw Web3Error.processingError(desc: "Can't get result") + } + return result + } + + public func getContent(forNode node: String) throws -> String { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isContentSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.content.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isContentSupports else { + throw Web3Error.processingError(desc: "Content isn't supported") + } + guard let content = try? resolver.getContentHash(forNode: node) else { + throw Web3Error.processingError(desc: "Can't get content") + } + return content + } + + public func setContent(forNode node: String, hash: String, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isContentSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.content.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isContentSupports else { + throw Web3Error.processingError(desc: "Content isn't supported") + } + var options = options ?? defaultOptions + options.to = resolver.resolverContractAddress + guard let result = try? resolver.setContentHash(forNode: node, hash: hash, options: options, password: password) else { + throw Web3Error.processingError(desc: "Can't get result") + } + return result + } + + public func getABI(forNode node: String, contentType: ENS.Resolver.ContentType) throws -> (BigUInt, Data) { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isABISupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.ABI.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isABISupports else { + throw Web3Error.processingError(desc: "ABI isn't supported") + } + guard let abi = try? resolver.getContractABI(forNode: node, contentType: contentType) else { + throw Web3Error.processingError(desc: "Can't get ABI") + } + return abi + } + + public func setABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isABISupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.ABI.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isABISupports else { + throw Web3Error.processingError(desc: "ABI isn't supported") + } + var options = options ?? defaultOptions + options.to = resolver.resolverContractAddress + guard let result = try? resolver.setContractABI(forNode: node, contentType: contentType, data: data, options: options, password: password) else { + throw Web3Error.processingError(desc: "Can't get result") + } + return result + } + + public func getPublicKey(forNode node: String) throws -> PublicKey { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isPKSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.pubkey.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isPKSupports else { + throw Web3Error.processingError(desc: "Public Key isn't supported") + } + guard let pk = try? resolver.getPublicKey(forNode: node) else { + throw Web3Error.processingError(desc: "Can't get Public Key") + } + return pk + } + + public func setPublicKey(forNode node: String, publicKey: PublicKey, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isPKSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.pubkey.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isPKSupports else { + throw Web3Error.processingError(desc: "Public Key isn't supported") + } + var options = options ?? defaultOptions + options.to = resolver.resolverContractAddress + guard let result = try? resolver.setPublicKey(forNode: node, publicKey: publicKey, options: options, password: password) else { + throw Web3Error.processingError(desc: "Can't get result") + } + return result + } + + public func getText(forNode node: String, key: String) throws -> String { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isTextSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.text.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isTextSupports else { + throw Web3Error.processingError(desc: "Text isn't supported") + } + guard let text = try? resolver.getTextData(forNode: node, key: key) else { + throw Web3Error.processingError(desc: "Can't get text") + } + return text + } + + public func setText(forNode node: String, key: String, value: String, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + guard let resolver = try? self.registry.getResolver(forDomain: node) else { + throw Web3Error.processingError(desc: "Failed to get resolver for domain") + } + guard let isTextSupports = try? resolver.supportsInterface(interfaceID: Resolver.InterfaceName.text.hash()) else { + throw Web3Error.processingError(desc: "Resolver don't support interface with this ID") + } + guard isTextSupports else { + throw Web3Error.processingError(desc: "Text isn't supported") + } + var options = options ?? defaultOptions + options.to = resolver.resolverContractAddress + guard let result = try? resolver.setTextData(forNode: node, key: key, value: value, options: options, password: password) else { + throw Web3Error.processingError(desc: "Can't get result") + } + return result + } +} diff --git a/web3swift/Utils/ENS/ENSRegistry.swift b/web3swift/Utils/ENS/ENSRegistry.swift new file mode 100644 index 000000000..3a7fac16f --- /dev/null +++ b/web3swift/Utils/ENS/ENSRegistry.swift @@ -0,0 +1,110 @@ +// +// ENSRegistry.swift +// web3swift +// +// Created by Anton on 17/04/2019. +// Copyright © 2019 The Matter Inc. All rights reserved. +// + +import Foundation +import BigInt +import EthereumAddress + +public extension ENS { + class Registry { + let web3: web3 + let registryContractAddress: EthereumAddress? + + init?(web3: web3) { + self.web3 = web3 + switch web3.provider.network { + case .Mainnet?: + registryContractAddress = EthereumAddress("0x314159265dd8dbb310642f98f50c066173c1259b") + case .Rinkeby?: + registryContractAddress = EthereumAddress("0xe7410170f87102df0055eb195163a03b7f2bff4a") + case .Ropsten?: + registryContractAddress = EthereumAddress("0x112234455c3a32fd11230c42e7bccd4a84e02010") + default: + let url = web3.provider.url.absoluteString + if url.contains("https://rpc.goerli.mudit.blog") + || url.contains("http://goerli.blockscout.com") + || url.contains("http://goerli.prylabs.net") + || url.contains("https://rpc.slock.it/goerli") { + registryContractAddress = EthereumAddress("0x112234455c3a32fd11230c42e7bccd4a84e02010") + } + return nil + } + } + + lazy var defaultOptions: TransactionOptions = { + return TransactionOptions.defaultOptions + }() + + lazy var registryContract: web3.web3contract = { + let contract = self.web3.contract(Web3.Utils.ensRegistryABI, at: self.registryContractAddress, abiVersion: 2) + precondition(contract != nil) + return contract! + }() + + public func getOwner(node: String) throws -> EthereumAddress { + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.registryContract.read("owner", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "No address in result")} + return address + } + + public func getResolver(forDomain domain: String) throws -> Resolver { + guard let nameHash = NameHash.nameHash(domain) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.registryContract.read("resolver", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let resolverAddress = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "No address in result")} + return Resolver(web3: self.web3, resolverContractAddress: resolverAddress) + } + + public func getTTL(node: String) throws -> BigUInt { + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.registryContract.read("ttl", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let ans = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "No answer in result")} + return ans + } + + public func setOwner(node: String, owner: EthereumAddress, options: TransactionOptions?, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.registryContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.registryContract.write("setOwner", parameters: [nameHash, owner] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + + public func setSubnodeOwner(node: String, label: String, owner: EthereumAddress, options: TransactionOptions?, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.registryContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let labelHash = NameHash.nameHash(label) else {throw Web3Error.processingError(desc: "Failed to get label hash")} + guard let transaction = self.registryContract.write("setSubnodeOwner", parameters: [nameHash, labelHash, owner] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + + public func setResolver(node: String, resolver: EthereumAddress, options: TransactionOptions?, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.registryContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.registryContract.write("setResolver", parameters: [nameHash, resolver] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + + public func setTTL(node: String, ttl: BigUInt, options: TransactionOptions?, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.registryContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.registryContract.write("setTTL", parameters: [nameHash, ttl] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + } +} diff --git a/web3swift/Utils/ENS/ENSResolver.swift b/web3swift/Utils/ENS/ENSResolver.swift new file mode 100755 index 000000000..fa011fe0f --- /dev/null +++ b/web3swift/Utils/ENS/ENSResolver.swift @@ -0,0 +1,188 @@ +// web3swift +// +// Created by Alex Vlasov. +// Copyright © 2018 Alex Vlasov. All rights reserved. +// + +import Foundation +import BigInt +import EthereumAddress + +public extension ENS { + class Resolver { + let web3: web3 + let resolverContractAddress: EthereumAddress + + public enum ContentType: BigUInt { + case JSON = 1 + case zlibCompressedJSON = 2 + case CBOR = 4 + case URI = 8 + } + + public enum InterfaceName { + case addr + case name + case content + case ABI + case pubkey + case text + + func hash() -> String { + switch self { + case .addr: + return "0x3b3b57de" + case .name: + return "0x691f3431" + case .content: + return "0xbc1c58d1" + case .ABI: + return "0x2203ab56" + case .pubkey: + return "0xc8690233" + case .text: + return "0x59d1d43c" + } + } + } + + lazy var resolverContract: web3.web3contract = { + let contract = self.web3.contract(Web3.Utils.resolverABI, at: self.resolverContractAddress, abiVersion: 2) + precondition(contract != nil) + return contract! + }() + + lazy var defaultOptions: TransactionOptions = { + return TransactionOptions.defaultOptions + }() + + init(web3: web3, resolverContractAddress: EthereumAddress) { + self.web3 = web3 + self.resolverContractAddress = resolverContractAddress + } + + public func supportsInterface(interfaceID: Data) throws -> Bool { + guard let supports = try? supportsInterface(interfaceID: interfaceID.toHexString()) else {throw Web3Error.processingError(desc: "Can't get answer")} + return supports + } + + public func supportsInterface(interfaceID: String) throws -> Bool { + guard let transaction = self.resolverContract.read("supportsInterface", parameters: [interfaceID as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let supports = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} + return supports + } + + public func getAddress(forNode node: String) throws -> EthereumAddress { + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.read("addr", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let address = result["0"] as? EthereumAddress else {throw Web3Error.processingError(desc: "Can't get address")} + return address + } + + @available(*, message: "Available for only owner") + public func setAddress(forNode node: String, address: EthereumAddress, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.resolverContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.write("setAddr", parameters: [nameHash, address] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + + public func getCanonicalName(forNode node: String) throws -> String { + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.read("name", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let name = result["0"] as? String else {throw Web3Error.processingError(desc: "Can't get name")} + return name + } + + @available(*, message: "Available for only owner") + func setCanonicalName(forNode node: String, name: String, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.resolverContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.write("setName", parameters: [nameHash, name] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + + func getContentHash(forNode node: String) throws -> String { + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.read("contenthash", parameters: [nameHash] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let content = result["0"] as? String else {throw Web3Error.processingError(desc: "Can't get content")} + return content + } + + @available(*, message: "Available for only owner") + func setContentHash(forNode node: String, hash: String, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.resolverContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.write("setContenthash", parameters: [nameHash, hash] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + + public func getContractABI(forNode node: String, contentType: ENS.Resolver.ContentType) throws -> (BigUInt, Data) { + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.read("ABI", parameters: [nameHash, contentType.rawValue] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let encoding = result["0"] as? BigUInt else {throw Web3Error.processingError(desc: "Can't get encoding")} + guard let data = result["1"] as? Data else {throw Web3Error.processingError(desc: "Can't get data")} + return (encoding, data) + } + + @available(*, message: "Available for only owner") + func setContractABI(forNode node: String, contentType: ENS.Resolver.ContentType, data: Data, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.resolverContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.write("setABI", parameters: [nameHash, contentType.rawValue, data] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + + public func getPublicKey(forNode node: String) throws -> PublicKey { + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.read("pubkey", parameters: [nameHash as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let x = result["x"] as? Data else {throw Web3Error.processingError(desc: "Can't get x")} + guard let y = result["y"] as? Data else {throw Web3Error.processingError(desc: "Can't get y")} + let pubkey = PublicKey(x: "0x" + x.toHexString(), y: "0x" + y.toHexString()) + return pubkey + } + + @available(*, message: "Available for only owner") + public func setPublicKey(forNode node: String, publicKey: PublicKey, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.resolverContractAddress + let pubkeyWithoutPrefix = publicKey.getComponentsWithoutPrefix() + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.write("setPubkey", parameters: [nameHash, pubkeyWithoutPrefix.x, pubkeyWithoutPrefix.y] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + + public func getTextData(forNode node: String, key: String) throws -> String { + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.read("text", parameters: [nameHash, key] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let text = result["0"] as? String else {throw Web3Error.processingError(desc: "Can't get text")} + return text + } + + @available(*, message: "Available for only owner") + public func setTextData(forNode node: String, key: String, value: String, options: TransactionOptions? = nil, password: String? = nil) throws -> TransactionSendingResult { + var options = options ?? defaultOptions + options.to = self.resolverContractAddress + guard let nameHash = NameHash.nameHash(node) else {throw Web3Error.processingError(desc: "Failed to get name hash")} + guard let transaction = self.resolverContract.write("setText", parameters: [nameHash, key, value] as [AnyObject], extraData: Data(), transactionOptions: options) else {throw Web3Error.transactionSerializationError} + guard let result = password == nil ? try? transaction.send() : try? transaction.send(password: password!, transactionOptions: options) else {throw Web3Error.processingError(desc: "Can't send transaction")} + return result + } + } +} diff --git a/web3swift/Utils/ENS/ETHRegistrarController.swift b/web3swift/Utils/ENS/ETHRegistrarController.swift new file mode 100644 index 000000000..39fd936c0 --- /dev/null +++ b/web3swift/Utils/ENS/ETHRegistrarController.swift @@ -0,0 +1,94 @@ +// +// RegistrarController.swift +// web3swift +// +// Created by Anton on 15/04/2019. +// Copyright © 2019 The Matter Inc. All rights reserved. +// + +import Foundation +import BigInt +import EthereumAddress + +public extension ENS { + class ETHRegistrarController { + let web3: web3 + let address: EthereumAddress + + lazy var contract: web3.web3contract = { + let contract = self.web3.contract(Web3.Utils.ethRegistrarControllerABI, at: self.address, abiVersion: 2) + precondition(contract != nil) + return contract! + }() + + lazy var defaultOptions: TransactionOptions = { + return TransactionOptions.defaultOptions + }() + + init(web3: web3, address: EthereumAddress) { + self.web3 = web3 + self.address = address + } + + public func getRentPrice(name: String, duration: UInt) throws -> UInt { + guard let transaction = self.contract.read("rentPrice", parameters: [name, duration] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let price = result["0"] as? UInt else {throw Web3Error.processingError(desc: "Can't get answer")} + return price + } + + public func checkNameValidity(name: String) throws -> Bool { + guard let transaction = self.contract.read("valid", parameters: [name] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let valid = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} + return valid + } + + public func isNameAvailable(name: String) throws -> Bool { + guard let transaction = self.contract.read("available", parameters: [name as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let available = result["0"] as? Bool else {throw Web3Error.processingError(desc: "Can't get answer")} + return available + } + + public func calculateCommitmentHash(name: String, owner: EthereumAddress, secret: [UInt32]) throws -> [UInt32] { + guard let transaction = self.contract.read("makeCommitment", parameters: [name, owner, secret] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + guard let result = try? transaction.call(transactionOptions: defaultOptions) else {throw Web3Error.processingError(desc: "Can't call transaction")} + guard let hash = result["0"] as? [UInt32] else {throw Web3Error.processingError(desc: "Can't get answer")} + return hash + } + + public func sumbitCommitment(from: EthereumAddress, commitment: [UInt32]) throws -> WriteTransaction { + defaultOptions.from = from + defaultOptions.to = self.address + guard let transaction = self.contract.write("commit", parameters: [commitment as AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + return transaction + } + + public func registerName(from: EthereumAddress, name: String, owner: EthereumAddress, duration: UInt32, secret: [UInt32], price: String) throws -> WriteTransaction { + guard let amount = Web3.Utils.parseToBigUInt(price, units: .eth) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")} + defaultOptions.value = amount + defaultOptions.from = from + defaultOptions.to = self.address + guard let transaction = self.contract.write("register", parameters: [name, owner, duration, secret] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + return transaction + } + + public func extendNameRegistration(from: EthereumAddress, name: String, duration: UInt32, price: String) throws -> WriteTransaction { + guard let amount = Web3.Utils.parseToBigUInt(price, units: .eth) else {throw Web3Error.inputError(desc: "Wrong price: no way for parsing to ether units")} + defaultOptions.value = amount + defaultOptions.from = from + defaultOptions.to = self.address + guard let transaction = self.contract.write("renew", parameters: [name, duration] as [AnyObject], extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + return transaction + } + + @available(*, message: "Available for only owner") + public func withdraw(from: EthereumAddress) throws -> WriteTransaction { + defaultOptions.from = from + defaultOptions.to = self.address + guard let transaction = self.contract.write("withdraw", parameters: [AnyObject](), extraData: Data(), transactionOptions: defaultOptions) else {throw Web3Error.transactionSerializationError} + return transaction + } + } +} diff --git a/web3swift/Utils/Classes/NameHash.swift b/web3swift/Utils/ENS/NameHash.swift similarity index 100% rename from web3swift/Utils/Classes/NameHash.swift rename to web3swift/Utils/ENS/NameHash.swift diff --git a/web3swift/Utils/ENS/PublicKey.swift b/web3swift/Utils/ENS/PublicKey.swift new file mode 100644 index 000000000..f7b000d40 --- /dev/null +++ b/web3swift/Utils/ENS/PublicKey.swift @@ -0,0 +1,26 @@ +// +// PublicKey.swift +// web3swift +// +// Created by Anton on 17/04/2019. +// Copyright © 2019 The Matter Inc. All rights reserved. +// + +import Foundation + +public struct PublicKey { + public let x: String + public let y: String + + public func getComponentsWithoutPrefix() -> PublicKey { + var x = self.x + var y = self.y + if x.hasHexPrefix() { + x.removeFirst(2) + } + if y.hasHexPrefix() { + y.removeFirst(2) + } + return PublicKey(x: x, y: y) + } +} diff --git a/web3swift/Utils/Classes/NonceMiddleware.swift b/web3swift/Utils/Hooks/NonceMiddleware.swift similarity index 100% rename from web3swift/Utils/Classes/NonceMiddleware.swift rename to web3swift/Utils/Hooks/NonceMiddleware.swift diff --git a/web3swift/Web3/Classes/Web3+Contract.swift b/web3swift/Web3/Web3+Contract.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Contract.swift rename to web3swift/Web3/Web3+Contract.swift diff --git a/web3swift/Web3/Classes/Web3+Eth+Websocket.swift b/web3swift/Web3/Web3+Eth+Websocket.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Eth+Websocket.swift rename to web3swift/Web3/Web3+Eth+Websocket.swift diff --git a/web3swift/Web3/Classes/Web3+Eth.swift b/web3swift/Web3/Web3+Eth.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Eth.swift rename to web3swift/Web3/Web3+Eth.swift diff --git a/web3swift/Web3/Classes/Web3+EventParser.swift b/web3swift/Web3/Web3+EventParser.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+EventParser.swift rename to web3swift/Web3/Web3+EventParser.swift diff --git a/web3swift/Web3/Classes/Web3+Eventloop.swift b/web3swift/Web3/Web3+Eventloop.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Eventloop.swift rename to web3swift/Web3/Web3+Eventloop.swift diff --git a/web3swift/Web3/Classes/Web3+HttpProvider.swift b/web3swift/Web3/Web3+HttpProvider.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+HttpProvider.swift rename to web3swift/Web3/Web3+HttpProvider.swift diff --git a/web3swift/Web3/Classes/Web3+InfuraProviders.swift b/web3swift/Web3/Web3+InfuraProviders.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+InfuraProviders.swift rename to web3swift/Web3/Web3+InfuraProviders.swift diff --git a/web3swift/Web3/Classes/Web3+Instance.swift b/web3swift/Web3/Web3+Instance.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Instance.swift rename to web3swift/Web3/Web3+Instance.swift diff --git a/web3swift/Web3/Classes/Web3+JSONRPC.swift b/web3swift/Web3/Web3+JSONRPC.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+JSONRPC.swift rename to web3swift/Web3/Web3+JSONRPC.swift diff --git a/web3swift/Web3/Classes/Web3+Methods.swift b/web3swift/Web3/Web3+Methods.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Methods.swift rename to web3swift/Web3/Web3+Methods.swift diff --git a/web3swift/Web3/Classes/Web3+MutatingTransaction.swift b/web3swift/Web3/Web3+MutatingTransaction.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+MutatingTransaction.swift rename to web3swift/Web3/Web3+MutatingTransaction.swift diff --git a/web3swift/Web3/Classes/Web3+Options.swift b/web3swift/Web3/Web3+Options.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Options.swift rename to web3swift/Web3/Web3+Options.swift diff --git a/web3swift/Web3/Classes/Web3+Personal.swift b/web3swift/Web3/Web3+Personal.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Personal.swift rename to web3swift/Web3/Web3+Personal.swift diff --git a/web3swift/Web3/Classes/Web3+Protocols.swift b/web3swift/Web3/Web3+Protocols.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Protocols.swift rename to web3swift/Web3/Web3+Protocols.swift diff --git a/web3swift/Web3/Classes/Web3+ReadingTransaction.swift b/web3swift/Web3/Web3+ReadingTransaction.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+ReadingTransaction.swift rename to web3swift/Web3/Web3+ReadingTransaction.swift diff --git a/web3swift/Web3/Classes/Web3+Structures.swift b/web3swift/Web3/Web3+Structures.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+Structures.swift rename to web3swift/Web3/Web3+Structures.swift diff --git a/web3swift/Web3/Classes/Web3+TxPool.swift b/web3swift/Web3/Web3+TxPool.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+TxPool.swift rename to web3swift/Web3/Web3+TxPool.swift diff --git a/web3swift/Web3/Classes/Web3+Utils.swift b/web3swift/Web3/Web3+Utils.swift similarity index 86% rename from web3swift/Web3/Classes/Web3+Utils.swift rename to web3swift/Web3/Web3+Utils.swift index 3365f294e..c5875de4e 100755 --- a/web3swift/Web3/Classes/Web3+Utils.swift +++ b/web3swift/Web3/Web3+Utils.swift @@ -3589,6 +3589,1161 @@ extension Web3.Utils { [{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"releaseDeed","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"getAllowedTime","outputs":[{"name":"timestamp","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"unhashedName","type":"string"}],"name":"invalidateName","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"hash","type":"bytes32"},{"name":"owner","type":"address"},{"name":"value","type":"uint256"},{"name":"salt","type":"bytes32"}],"name":"shaBid","outputs":[{"name":"sealedBid","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"bidder","type":"address"},{"name":"seal","type":"bytes32"}],"name":"cancelBid","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"entries","outputs":[{"name":"","type":"uint8"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"},{"name":"_value","type":"uint256"},{"name":"_salt","type":"bytes32"}],"name":"unsealBid","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"transferRegistrars","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"bytes32"}],"name":"sealedBids","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"state","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"},{"name":"newOwner","type":"address"}],"name":"transfer","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_hash","type":"bytes32"},{"name":"_timestamp","type":"uint256"}],"name":"isAllowed","outputs":[{"name":"allowed","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"finalizeAuction","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"registryStarted","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"sealedBid","type":"bytes32"}],"name":"newBid","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"labels","type":"bytes32[]"}],"name":"eraseNode","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_hashes","type":"bytes32[]"}],"name":"startAuctions","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"hash","type":"bytes32"},{"name":"deed","type":"address"},{"name":"registrationDate","type":"uint256"}],"name":"acceptRegistrarTransfer","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_hash","type":"bytes32"}],"name":"startAuction","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"rootNode","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"hashes","type":"bytes32[]"},{"name":"sealedBid","type":"bytes32"}],"name":"startAuctionsAndBid","outputs":[],"payable":true,"type":"function"},{"inputs":[{"name":"_ens","type":"address"},{"name":"_rootNode","type":"bytes32"},{"name":"_startDate","type":"uint256"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":false,"name":"registrationDate","type":"uint256"}],"name":"AuctionStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"bidder","type":"address"},{"indexed":false,"name":"deposit","type":"uint256"}],"name":"NewBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"status","type":"uint8"}],"name":"BidRevealed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"registrationDate","type":"uint256"}],"name":"HashRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":false,"name":"value","type":"uint256"}],"name":"HashReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"hash","type":"bytes32"},{"indexed":true,"name":"name","type":"string"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"registrationDate","type":"uint256"}],"name":"HashInvalidated","type":"event"}] """ + public static var ethRegistrarControllerABI = """ +[ + { + "constant": true, + "inputs": [ + { + "name": "interfaceID", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_prices", + "type": "address" + } + ], + "name": "setPriceOracle", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_minCommitmentAge", + "type": "uint256" + }, + { + "name": "_maxCommitmentAge", + "type": "uint256" + } + ], + "name": "setCommitmentAges", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "name": "commitments", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "name", + "type": "string" + }, + { + "name": "duration", + "type": "uint256" + } + ], + "name": "rentPrice", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "name", + "type": "string" + }, + { + "name": "owner", + "type": "address" + }, + { + "name": "duration", + "type": "uint256" + }, + { + "name": "secret", + "type": "bytes32" + } + ], + "name": "register", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIN_REGISTRATION_DURATION", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "minCommitmentAge", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "name", + "type": "string" + } + ], + "name": "valid", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "name", + "type": "string" + }, + { + "name": "duration", + "type": "uint256" + } + ], + "name": "renew", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "name", + "type": "string" + } + ], + "name": "available", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "maxCommitmentAge", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "commitment", + "type": "bytes32" + } + ], + "name": "commit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "name", + "type": "string" + }, + { + "name": "owner", + "type": "address" + }, + { + "name": "secret", + "type": "bytes32" + } + ], + "name": "makeCommitment", + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "name": "_base", + "type": "address" + }, + { + "name": "_prices", + "type": "address" + }, + { + "name": "_minCommitmentAge", + "type": "uint256" + }, + { + "name": "_maxCommitmentAge", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "name", + "type": "string" + }, + { + "indexed": true, + "name": "label", + "type": "bytes32" + }, + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "name": "cost", + "type": "uint256" + }, + { + "indexed": false, + "name": "expires", + "type": "uint256" + } + ], + "name": "NameRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "name": "name", + "type": "string" + }, + { + "indexed": true, + "name": "label", + "type": "bytes32" + }, + { + "indexed": false, + "name": "cost", + "type": "uint256" + }, + { + "indexed": false, + "name": "expires", + "type": "uint256" + } + ], + "name": "NameRenewed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "oracle", + "type": "address" + } + ], + "name": "NewPriceOracle", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + } +] +""" + + public static var baseRegistrarABI = """ +[ + { + "constant": true, + "inputs": [ + { + "name": "interfaceID", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getApproved", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "to", + "type": "address" + }, + { + "name": "tokenId", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "from", + "type": "address" + }, + { + "name": "to", + "type": "address" + }, + { + "name": "tokenId", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "id", + "type": "uint256" + } + ], + "name": "reclaim", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "ens", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "from", + "type": "address" + }, + { + "name": "to", + "type": "address" + }, + { + "name": "tokenId", + "type": "uint256" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "transferPeriodEnds", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "resolver", + "type": "address" + } + ], + "name": "setResolver", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "MIGRATION_LOCK_PERIOD", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isOwner", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "id", + "type": "uint256" + } + ], + "name": "available", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "to", + "type": "address" + }, + { + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "controller", + "type": "address" + } + ], + "name": "addController", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "previousRegistrar", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "from", + "type": "address" + }, + { + "name": "to", + "type": "address" + }, + { + "name": "tokenId", + "type": "uint256" + }, + { + "name": "_data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "GRACE_PERIOD", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "id", + "type": "uint256" + }, + { + "name": "duration", + "type": "uint256" + } + ], + "name": "renew", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "id", + "type": "uint256" + } + ], + "name": "nameExpires", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "controllers", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "baseNode", + "outputs": [ + { + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "label", + "type": "bytes32" + }, + { + "name": "deed", + "type": "address" + }, + { + "name": "", + "type": "uint256" + } + ], + "name": "acceptRegistrarTransfer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "controller", + "type": "address" + } + ], + "name": "removeController", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "id", + "type": "uint256" + }, + { + "name": "owner", + "type": "address" + }, + { + "name": "duration", + "type": "uint256" + } + ], + "name": "register", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "name": "_ens", + "type": "address" + }, + { + "name": "_previousRegistrar", + "type": "address" + }, + { + "name": "_baseNode", + "type": "bytes32" + }, + { + "name": "_transferPeriodEnds", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "controller", + "type": "address" + } + ], + "name": "ControllerAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "controller", + "type": "address" + } + ], + "name": "ControllerRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "id", + "type": "uint256" + }, + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "name": "expires", + "type": "uint256" + } + ], + "name": "NameMigrated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "id", + "type": "uint256" + }, + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "name": "expires", + "type": "uint256" + } + ], + "name": "NameRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "id", + "type": "uint256" + }, + { + "indexed": false, + "name": "expires", + "type": "uint256" + } + ], + "name": "NameRenewed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": true, + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "approved", + "type": "address" + }, + { + "indexed": true, + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + } +] +""" + //function setAddr(bytes32 node, address addr) public static var resolverABI = """ [ diff --git a/web3swift/Web3/Classes/Web3+WebsocketProvider.swift b/web3swift/Web3/Web3+WebsocketProvider.swift similarity index 100% rename from web3swift/Web3/Classes/Web3+WebsocketProvider.swift rename to web3swift/Web3/Web3+WebsocketProvider.swift diff --git a/web3swift/Web3/Classes/Web3.swift b/web3swift/Web3/Web3.swift similarity index 100% rename from web3swift/Web3/Classes/Web3.swift rename to web3swift/Web3/Web3.swift diff --git a/web3swiftTests/web3swift_ENS_Tests.swift b/web3swiftTests/web3swift_ENS_Tests.swift index bf78562cc..865b8652a 100755 --- a/web3swiftTests/web3swift_ENS_Tests.swift +++ b/web3swiftTests/web3swift_ENS_Tests.swift @@ -26,8 +26,8 @@ class web3swift_ENS_Tests: XCTestCase { let web = web3(provider: InfuraProvider(Networks.Mainnet)!) let ens = ENS(web3: web) let domain = "somename.eth" - let resolver = try ens.resolver(forDomain: domain) - XCTAssertEqual(resolver.resolverAddress.address.lowercased(), "0x5ffc014343cd971b7eb70732021e26c35b744cc4") + let address = try ens?.registry.getResolver(forDomain: domain).resolverContractAddress + XCTAssertEqual(address?.address.lowercased(), "0x5ffc014343cd971b7eb70732021e26c35b744cc4") } catch { XCTFail() } @@ -38,9 +38,8 @@ class web3swift_ENS_Tests: XCTestCase { let web = web3(provider: InfuraProvider(Networks.Mainnet)!) let ens = ENS(web3: web) let domain = "somename.eth" - var resolver = try ens.resolver(forDomain: domain) - let address = try resolver.addr(forDomain: domain) - XCTAssertEqual(address.address.lowercased(), "0x3487acfb1479ad1df6c0eb56ae743d34897798ac") + let address = try ens?.getAddress(forNode: domain) + XCTAssertEqual(address?.address.lowercased(), "0x3487acfb1479ad1df6c0eb56ae743d34897798ac") } catch { XCTFail() } @@ -51,11 +50,11 @@ class web3swift_ENS_Tests: XCTestCase { let web = web3(provider: InfuraProvider(Networks.Mainnet)!) let ens = ENS(web3: web) let domain = "somename.eth" - var resolver = try ens.resolver(forDomain: domain) - let isAddrSupports = try resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.addr.hash()) - let isNameSupports = try resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.name.hash()) - let isABIsupports = try resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.ABI.hash()) - let isPubkeySupports = try resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.pubkey.hash()) + let resolver = try ens?.registry.getResolver(forDomain: domain) + let isAddrSupports = try resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.addr.hash()) + let isNameSupports = try resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.name.hash()) + let isABIsupports = try resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.ABI.hash()) + let isPubkeySupports = try resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.pubkey.hash()) XCTAssertEqual(isAddrSupports, true) XCTAssertEqual(isNameSupports, true) XCTAssertEqual(isABIsupports, true) @@ -70,12 +69,12 @@ class web3swift_ENS_Tests: XCTestCase { let web = web3(provider: InfuraProvider(Networks.Mainnet)!) let ens = ENS(web3: web) let domain = "somename.eth" - var resolver = try ens.resolver(forDomain: domain) - let isABIsupported = try resolver.supportsInterface(interfaceID: ResolverENS.InterfaceName.ABI.hash()) - if isABIsupported { - let res = try resolver.ABI(node: domain, contentType: 2) - XCTAssert(res.0 == 0) - XCTAssert(res.1.count == 0) + let resolver = try ens?.registry.getResolver(forDomain: domain) + if let isABIsupported = try resolver?.supportsInterface(interfaceID: ENS.Resolver.InterfaceName.ABI.hash()), + isABIsupported { + let res = try resolver?.getContractABI(forNode: domain, contentType: .zlibCompressedJSON) + XCTAssert(res?.0 == 0) + XCTAssert(res?.1.count == 0) } else { XCTFail() } @@ -89,8 +88,8 @@ class web3swift_ENS_Tests: XCTestCase { let web = web3(provider: InfuraProvider(Networks.Mainnet)!) let ens = ENS(web3: web) let domain = "somename.eth" - let owner = try ens.owner(node: domain) - XCTAssertEqual("0xc67247454e720328714c4e17bec7640572657bee", owner.address.lowercased()) + let owner = try ens?.registry.getOwner(node: domain) + XCTAssertEqual("0xc67247454e720328714c4e17bec7640572657bee", owner?.address.lowercased()) } catch { XCTFail() } @@ -101,7 +100,7 @@ class web3swift_ENS_Tests: XCTestCase { let web = web3(provider: InfuraProvider(Networks.Mainnet)!) let ens = ENS(web3: web) let domain = "somename.eth" - let ttl = try ens.ttl(node: domain) + let ttl = try ens?.registry.getTTL(node: domain) print(ttl) } catch { XCTFail() @@ -113,8 +112,9 @@ class web3swift_ENS_Tests: XCTestCase { let web = web3(provider: InfuraProvider(Networks.Mainnet)!) let ens = ENS(web3: web) let domain = "somename.eth" - let address = try ens.getAddress(domain) - XCTAssertEqual(address.address.lowercased(), "0x3487acfb1479ad1df6c0eb56ae743d34897798ac") + let resolver = try ens?.registry.getResolver(forDomain: domain) + let address = try resolver?.getAddress(forNode: domain) + XCTAssertEqual(address?.address.lowercased(), "0x3487acfb1479ad1df6c0eb56ae743d34897798ac") } catch { XCTFail() } @@ -125,9 +125,10 @@ class web3swift_ENS_Tests: XCTestCase { let web = web3(provider: InfuraProvider(Networks.Mainnet)!) let ens = ENS(web3: web) let domain = "somename.eth" - let pubkey = try ens.getPubkey(domain: domain) - XCTAssert(pubkey.x == "0x0000000000000000000000000000000000000000000000000000000000000000") - XCTAssert(pubkey.y == "0x0000000000000000000000000000000000000000000000000000000000000000") + let resolver = try ens?.registry.getResolver(forDomain: domain) + let pubkey = try resolver?.getPublicKey(forNode: domain) + XCTAssert(pubkey?.x == "0x0000000000000000000000000000000000000000000000000000000000000000") + XCTAssert(pubkey?.y == "0x0000000000000000000000000000000000000000000000000000000000000000") } catch { XCTFail() }