├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .swiftlint.yml ├── Cartfile ├── Cartfile.resolved ├── Example ├── Podfile ├── Podfile.lock ├── Tests │ ├── Info.plist │ ├── WCBinanceTradePairTests.swift │ ├── WCEncryptorTests.swift │ ├── WCEthereumSignPayloadTests.swift │ ├── WCEthereumTransactionTests.swift │ ├── WCPeerMetaMock.swift │ ├── WCSessionManagerTests.swift │ ├── WCSessionTests.swift │ └── test_data │ │ ├── defisaver_send.json │ │ ├── eth_sign.json │ │ ├── peer_meta.json │ │ ├── personal_sign.json │ │ ├── sign_typed.json │ │ └── sign_typed_string.json ├── WalletConnect.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── WalletConnect-Example.xcscheme ├── WalletConnect.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDETemplateMacros.plist │ │ └── IDEWorkspaceChecks.plist └── WalletConnect │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard │ ├── Images.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-1024.png │ │ ├── Icon-120.png │ │ ├── Icon-121.png │ │ ├── Icon-180.png │ │ ├── Icon-40.png │ │ ├── Icon-58.png │ │ ├── Icon-60.png │ │ ├── Icon-80.png │ │ └── Icon-87.png │ ├── Info.plist │ └── WCSessionViewController.swift ├── LICENSE ├── Package.resolved ├── Package.swift ├── README.md ├── WalletConnect.podspec ├── WalletConnect.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── WalletConnect.xcscheme ├── WalletConnect ├── Assets │ └── .gitkeep ├── Extensions │ ├── Data+Hex.swift │ └── Encodable+Extension.swift ├── Info.plist ├── JSONRPC │ └── JSONRPC.swift ├── Models │ ├── Binance │ │ ├── WCBinanceCancelOrder.swift │ │ ├── WCBinanceOrder.swift │ │ ├── WCBinanceTradeOrder.swift │ │ ├── WCBinanceTradePair.swift │ │ └── WCBinanceTransferOrder.swift │ ├── Ethereum │ │ ├── AnyDecodable.swift │ │ ├── WCEthereumSignPayload.swift │ │ └── WCEthereumTransaction.swift │ ├── OKExChain │ │ └── WCOKExChainTransaction.swift │ ├── Trust │ │ ├── WCTrustAccount.swift │ │ └── WCTrustTransaction.swift │ ├── WCEvent.swift │ ├── WCPeerMeta.swift │ ├── WCSessionModels.swift │ └── WCSocketMessage.swift ├── SubInteractor │ ├── WCBinanceInteractor.swift │ ├── WCEthereumInteractor.swift │ ├── WCOKExChainInteractor.swift │ └── WCTrustInteractor.swift ├── WCEncryptor.swift ├── WCError.swift ├── WCInteractor.swift ├── WCLog.swift ├── WCSession.swift ├── WCSessionStore.swift └── WalletConnect.h ├── _Pods.xcodeproj └── codecov.yml /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | test: 11 | runs-on: macos-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Pod install 15 | run: pod install --repo-update 16 | working-directory: Example 17 | - name: Run tests 18 | run: | 19 | fastlane scan 20 | working-directory: Example 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Ignore when build 10 | .DS_Store 11 | 12 | ## Various settings 13 | *.pbxuser 14 | !default.pbxuser 15 | *.mode1v3 16 | !default.mode1v3 17 | *.mode2v3 18 | !default.mode2v3 19 | *.perspectivev3 20 | !default.perspectivev3 21 | xcuserdata/ 22 | 23 | ## Other 24 | *.moved-aside 25 | *.xccheckout 26 | *.xcscmblueprint 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | ## Playgrounds 35 | timeline.xctimeline 36 | playground.xcworkspace 37 | 38 | # Swift Package Manager 39 | # 40 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 41 | # Packages/ 42 | # Package.pins 43 | # Package.resolved 44 | .build/ 45 | 46 | # CocoaPods 47 | # 48 | # We recommend against adding the Pods directory to your .gitignore. However 49 | # you should judge for yourself, the pros and cons are mentioned at: 50 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 51 | # 52 | Pods/ 53 | 54 | # Carthage 55 | 56 | Carthage/ 57 | 58 | #R 59 | *.generated.swift 60 | 61 | *.mobileprovision 62 | *.cer 63 | 64 | # VIM 65 | *.swp 66 | *.swo 67 | *~ 68 | *.orig 69 | .vscode/ 70 | 71 | # node 72 | node_modules 73 | JS/staging 74 | 75 | # codecov 76 | *.coverage.txt 77 | *.zip 78 | 79 | # fastlane 80 | test_output/ 81 | -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | disabled_rules: 2 | - cyclomatic_complexity 3 | - force_cast 4 | - force_try 5 | - identifier_name 6 | - nesting 7 | - redundant_discardable_let 8 | - todo 9 | - type_name 10 | - xctfail_message 11 | opt_in_rules: 12 | - closure_end_indentation 13 | - closure_spacing 14 | - empty_count 15 | - multiline_parameters 16 | - vertical_parameter_alignment_on_call 17 | excluded: 18 | - Pods/ 19 | function_parameter_count: 20 | warning: 20 21 | error: 25 22 | line_length: 23 | warning: 250 24 | error: 450 25 | large_tuple: 26 | warning: 4 27 | type_body_length: 28 | warning: 450 29 | error: 650 30 | function_body_length: 80 31 | file_length: 32 | warning: 600 33 | error: 1200 34 | trailing_comma: 35 | mandatory_comma: true 36 | superfluous_disable_command: warning 37 | reporter: "xcode" 38 | -------------------------------------------------------------------------------- /Cartfile: -------------------------------------------------------------------------------- 1 | github "krzyzanowskim/CryptoSwift" 2 | github "daltoniam/Starscream" 3 | github "mxcl/PromiseKit" 4 | -------------------------------------------------------------------------------- /Cartfile.resolved: -------------------------------------------------------------------------------- 1 | github "daltoniam/Starscream" "3.1.1" 2 | github "krzyzanowskim/CryptoSwift" "1.1.3" 3 | github "mxcl/PromiseKit" "6.11.0" 4 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '11.0' 2 | inhibit_all_warnings! 3 | use_frameworks! 4 | 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | install! 'cocoapods', :generate_multiple_pod_projects => true 8 | 9 | target 'WalletConnect_Example' do 10 | pod 'WalletConnect', :path => '../' 11 | pod 'TrustWalletCore' 12 | pod 'SwiftLint' 13 | target 'WalletConnect_Tests' do 14 | inherit! :search_paths 15 | end 16 | end 17 | 18 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CryptoSwift (1.1.3) 3 | - PromiseKit (6.11.0): 4 | - PromiseKit/CorePromise (= 6.11.0) 5 | - PromiseKit/Foundation (= 6.11.0) 6 | - PromiseKit/UIKit (= 6.11.0) 7 | - PromiseKit/CorePromise (6.11.0) 8 | - PromiseKit/Foundation (6.11.0): 9 | - PromiseKit/CorePromise 10 | - PromiseKit/UIKit (6.11.0): 11 | - PromiseKit/CorePromise 12 | - Starscream (3.1.1) 13 | - SwiftLint (0.36.0) 14 | - SwiftProtobuf (1.5.0) 15 | - TrustWalletCore (0.12.25): 16 | - SwiftProtobuf (~> 1.5.0) 17 | - WalletConnect (0.1.0): 18 | - CryptoSwift 19 | - PromiseKit 20 | - Starscream 21 | 22 | DEPENDENCIES: 23 | - SwiftLint 24 | - TrustWalletCore 25 | - WalletConnect (from `../`) 26 | 27 | SPEC REPOS: 28 | trunk: 29 | - CryptoSwift 30 | - PromiseKit 31 | - Starscream 32 | - SwiftLint 33 | - SwiftProtobuf 34 | - TrustWalletCore 35 | 36 | EXTERNAL SOURCES: 37 | WalletConnect: 38 | :path: "../" 39 | 40 | SPEC CHECKSUMS: 41 | CryptoSwift: 6b6e488df0598b3e9fa49254ed1a65e8c1b1e10b 42 | PromiseKit: e4863d06976e7dee5e41c04fc7371c16b3600292 43 | Starscream: 4bb2f9942274833f7b4d296a55504dcfc7edb7b0 44 | SwiftLint: fc9859e4e1752340664851f667bb1898b9c90114 45 | SwiftProtobuf: 241400280f912735c1e1b9fe675fdd2c6c4d42e2 46 | TrustWalletCore: c5e7f4c875b9e68203ee2b0312272dd7dd32ce98 47 | WalletConnect: c5be4e3ed9efbefb8480ab27e1766d4549a92709 48 | 49 | PODFILE CHECKSUM: f8fe63c2c817ca4c3ecd0ded9c92a7efc585b40e 50 | 51 | COCOAPODS: 1.9.3 52 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/WCBinanceTradePairTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import XCTest 8 | import WalletConnect 9 | 10 | class WCBinanceTradePairTests: XCTestCase { 11 | 12 | func testParsing() { 13 | let symbol = "BNB_ETH.B-261" 14 | let pair = WCBinanceTradePair.from(symbol) 15 | 16 | XCTAssertEqual(pair?.from, "BNB") 17 | XCTAssertEqual(pair?.to, "ETH.B") 18 | 19 | let symbol2 = "000-0E1_BNB" 20 | let pair2 = WCBinanceTradePair.from(symbol2) 21 | 22 | XCTAssertEqual(pair2?.from, "000") 23 | XCTAssertEqual(pair2?.to, "BNB") 24 | 25 | let symbol3 = "CRYPRICE-150_BTC.B-918" 26 | let pair3 = WCBinanceTradePair.from(symbol3) 27 | 28 | XCTAssertEqual(pair3?.from, "CRYPRICE") 29 | XCTAssertEqual(pair3?.to, "BTC.B") 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/Tests/WCEncryptorTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import XCTest 8 | @testable import WalletConnect 9 | 10 | // swiftlint:disable line_length 11 | class WCEncryptorTests: XCTestCase { 12 | func testDecrypt() throws { 13 | let data = "1b3db3674de082d65455eba0ae61cfe7e681c8ef1132e60c8dbd8e52daf18f4fea42cc76366c83351dab6dca52682ff81f828753f89a21e1cc46587ca51ccd353914ffdd3b0394acfee392be6c22b3db9237d3f717a3777e3577dd70408c089a4c9c85130a68c43b0a8aadb00f1b8a8558798104e67aa4ff027b35d4b989e7fd3988d5dcdd563105767670be735b21c4" 14 | let hmac = "a33f868e793ca4fcca964bcb64430f65e2f1ca7a779febeaf94c5373d6df48b3" 15 | let iv = "89ef1d6728bac2f1dcde2ef9330d2bb8" 16 | let key = Data(hex: "5caa3a74154cee16bd1b570a1330be46e086474ac2f4720530662ef1a469662c") 17 | let payload = WCEncryptionPayload(data: data, hmac: hmac, iv: iv) 18 | let decrypted = try WCEncryptor.decrypt(payload: payload, with: key) 19 | let request = try JSONDecoder().decode(JSONRPCRequest<[WCSessionUpdateParam]>.self, from: decrypted) 20 | 21 | let expect = """ 22 | {"id":1554098597199736,"jsonrpc":"2.0","method":"wc_sessionUpdate","params":[{"approved":false,"chainId":null,"accounts":null}]} 23 | """ 24 | XCTAssertEqual(expect, String(data: decrypted, encoding: .utf8)!) 25 | XCTAssertEqual(request.method, "wc_sessionUpdate") 26 | XCTAssertEqual(request.params[0].approved, false) 27 | } 28 | 29 | func testDecryptSessionRequest() throws { 30 | // wc:a87335bc-0c1d-4c2e-ac12-1cf4fc003563@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=8c146479c3c9c387b848db8d0eb09145f17c88c86453c10b2963a74d6f916868 31 | let data = "5d2e92b0b64a014eef5bf3637ddbc66a70a6bd48630234dc02f1256089e8e6f50a014518e9f1a79c52f22eeda3821bfad1b2cc13ef905360a25b9573a1ed236d6cf9cd5c6b835a9272fca8ba24ce34b7842620dfd4cbe215443a17555f70dadc4831f3b87776e18b05c5204f6c93a20060a818b3fd809c1353f394dc78e4138e4c4e300740bbd7e62b453b76446f49dcbed329a1f0a7a5b7f4505735bd5488dd0aecb54d204797351166634c483431555fe212d56b83dcb1cb709da824f50fe62dcffa05116ba3b7cc82d72649135255bb88f5c99aacc526e5e40b135db7d65cc3b034cdc46c305ba10498d8967a4525243cbb6a6f7cc9c7c7ded4546c2a0aa5eb82b80121e314493ac897304cfb1d7ac491d54ea728c5e99bffee379369ca2a" 32 | let hmac = "34079117b417d80d7bef3c95b2affe0bfcd82435afc484e7826275f780885369" 33 | let iv = "7ba596e01aa6695a410320b372e8695b" 34 | let key = Data(hex: "8c146479c3c9c387b848db8d0eb09145f17c88c86453c10b2963a74d6f916868") 35 | let payload = WCEncryptionPayload(data: data, hmac: hmac, iv: iv) 36 | let decrypted = try WCEncryptor.decrypt(payload: payload, with: key) 37 | let request: JSONRPCRequest<[WCSessionRequestParam]> = try WCEvent.sessionRequest.decode(decrypted) 38 | XCTAssertNotNil(request.params.first) 39 | XCTAssertNil(request.params.first?.chainId) 40 | } 41 | 42 | func testDecryptSessionRequestChainId() throws { 43 | // wc:d3175406-811b-4463-bcfd-0570481c8d7f@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=6a91eb9cc4322209224b97e81894bcec7474712659dd1bd26d72841065684706 44 | let data = "36ec99546b080c3d49762fde911818e1804e861b5bccfd02c66191fd97ff56afb7bc3d73d7441f7e5587b24674e8c5b9bd963aa2645be137d961cb40f5222440d184e1f1da5a546f3b70f8d26083a6355c0af3b544a8b21d7bbf1353a77ff44078ad84167fc8747fc187a8b4c56034321c76c6fe5637622dc412407bfa6f198b9bc6d7cac8d89833de8a9edf7ad69e40004c5af5cfaae8aae2787132cbfab22ae2481f16a9b6af96a67f54c5d5868219d809197acd6c5b6c944c8617cce80d7ed45db6a8d78a8a4bd047652047c85985682f7c47e588348a492a11aa0ea5f287b5c6b796bf3c51465eef9ed3723555d0765d5116f87f987d2838fc54731d3f9e43dd4d82e7c043df31a358a6dce8715459681277c6cb097e1faf2e24735c8689e7caa5b29f155c552e7f86e7ddd23fff0ce95839f757f9dc244272f75e3cdd5cda209bff64d8ff2c770fa692964468ef5cea6ba3e9943acbbf133e18de242565864666b2f5341b5dae9a716568d4ad39b5be851e834a51473ad79ac7f737d1e9025314066c13f0ddec851f5d0bc5121c94727e823edfa423e43f9a9d59bfe86f07500375b33650acb2ef0668670169f59585f7ee12be42094d2279e2a1064f56bedf4ecb59099f8cb7a0d19fa150e7aff83566dd74deaec8fc1726a8b11ae14d23d977256896e1f801a6ad77b097aa7ec2c86b252893c181aff9edf9c58740fb" 45 | let hmac = "86a2b0425f7c84337d9639f8ca07de0a67b2fc1e65bc5cd88fc3739c0693738e" 46 | let iv = "b2560b9f092ee90afd492c8b900f5835" 47 | let key = Data(hex: "6a91eb9cc4322209224b97e81894bcec7474712659dd1bd26d72841065684706") 48 | let payload = WCEncryptionPayload(data: data, hmac: hmac, iv: iv) 49 | let decrypted = try WCEncryptor.decrypt(payload: payload, with: key) 50 | let request: JSONRPCRequest<[WCSessionRequestParam]> = try WCEvent.sessionRequest.decode(decrypted) 51 | XCTAssertNotNil(request.params.first) 52 | XCTAssertEqual(request.params.first?.chainId, 1) 53 | } 54 | 55 | func testDecryptRejectSession() throws { 56 | // wc:3c5318c3-fba2-4e57-bca3-854e7ac9c51e@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=bbc82a01ebdb14698faee4a9e5038de72c995a9f6bcdb21903d62408b0c5ca96 57 | let data = "e7df9810ce66defcc03023ee945f5958c1d4697bf97945daeab5059c2bc6262642cbca82982ac690e77e16671770c200f348f743a7c6e5df5c74eb892ef9b45a9b5ddf0f08fa60c49e5b694688d1b0b521b43975e65b4e8d557a83f4d1aab0af" 58 | let hmac = "ffcf0f43aeb0ef36dd2ea641ab7f48b9abbf2d9f65354aefc7faf530d318a9fe" 59 | let iv = "debb62725b21c7577e4e498e10f096c7" 60 | let key = Data(hex: "bbc82a01ebdb14698faee4a9e5038de72c995a9f6bcdb21903d62408b0c5ca96") 61 | let payload = WCEncryptionPayload(data: data, hmac: hmac, iv: iv) 62 | let decrypted = try WCEncryptor.decrypt(payload: payload, with: key) 63 | let rpcError = try JSONDecoder().decode(JSONRPCErrorResponse.self, from: decrypted) 64 | 65 | let expect = """ 66 | {"jsonrpc":"2.0","id":1554343834752446,"error":{"code":-32000,"message":"Session Rejected"}} 67 | """ 68 | XCTAssertEqual(expect, String(data: decrypted, encoding: .utf8)!) 69 | XCTAssertEqual(rpcError.error.code, -32000) 70 | } 71 | 72 | func testDecryptBnbSign() throws { 73 | // topic: e7f48633-b2d5-43de-ab0a-f83a451a079c 74 | // key: 10b653558be908057c2584b93d27cb0a6d020aa4520af9fef036dd0fec324668 75 | let data = "9e3a3590371e27596745ac4665d4e50d148804413b7fc1ea2b7f4866562ce7c61d5cd21e7c442edd41f20de891a87988c89e28458cba5051aabd74cab0e700fffcd9a383e05292c2053eb256a4e98c435b72359e189f6a9374489a6e6aef6d8356d183cf358c81ce532a21dd27f594981ab0e1f1d8fb0545a4dc6fa626bc891590d4d673e7d876b7684913c9134fb52870c4beb057a55deb7c8e7b3d237ff4b41287744d8f41fa74ee253d0d1a7833965191172ae2cc814dda53e599eb4dbb41c1c60416c2385af38f0093a9dec97e4892a9f7793d24b43d087fa1ee549bc7037269cb19f68e32dae38ac695197c389c04fa043273f29abe0d0aee6933f237488361e0a4415e2e41541dd068304bd6051e099d3fbc909d9c237694c858080e461ceceabb3cb06048b5ac9b2944a28b7a516308f2e1ff9089bbcd3ead12066edcabc8fb8b28e40fa6ffb7943bfbb9fa8695324104798489724e1328d3000cb7bb0518f64117c5b871b282ac6bb3d1e213f4e82137402e6fd69478b145a5b5f059" 76 | let hmac = "d910de5672d1506129ad35709fa0d7c4618814605e8529385b089f899a99b574" 77 | let iv = "7cfdc41e3b2bee432a196770bb644865" 78 | let key = Data(hex: "10b653558be908057c2584b93d27cb0a6d020aa4520af9fef036dd0fec324668") 79 | 80 | let payload = WCEncryptionPayload(data: data, hmac: hmac, iv: iv) 81 | let decrypted = try WCEncryptor.decrypt(payload: payload, with: key) 82 | let request: JSONRPCRequest<[WCBinanceTradeOrder]> = try WCEvent.bnbSign.decode(decrypted) 83 | 84 | let expected = """ 85 | {"id":1,"jsonrpc":"2.0","method":"bnb_sign","params":[{"account_number":"666682","chain_id":"Binance-Chain-Nile","data":null,"memo":"","msgs":[{"id":"A9241D9CDC41DBFF587A236047D5836EDA6C7345-1","ordertype":2,"price":401180,"quantity":2500000000,"sender":"tbnb14yjpm8xug8dl7kr6ydsy04vrdmdxcu69kwrw78","side":2,"symbol":"BNB_BTC.B-918","timeinforce":1}],"sequence":"0","source":"1"}]} 86 | """ 87 | XCTAssertEqual(request.encodedString, expected) 88 | } 89 | } 90 | // swiftlint:enable line_length 91 | -------------------------------------------------------------------------------- /Example/Tests/WCEthereumSignPayloadTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import XCTest 8 | import WalletConnect 9 | import CryptoSwift 10 | 11 | class WCEthereumSignPayloadTests: XCTestCase { 12 | 13 | func testDecodeSign() throws { 14 | let data = try loadJSON(filename: "eth_sign") 15 | let payload = try JSONDecoder().decode(WCEthereumSignPayload.self, from: data) 16 | if case .sign(let data, let raw) = payload { 17 | let messageData = Data(hex: "6dee0d861fb7e0da1b3cd046816981b1150b60f409d648a5b6d85d3fce00642c") 18 | XCTAssertEqual(payload.method, "eth_sign") 19 | XCTAssertEqual(Data(hex: payload.message), messageData) 20 | XCTAssertEqual(data, messageData) 21 | XCTAssertEqual(raw[0], "0xD432C5910f626dD21bE918D782facB38BDaE3296") 22 | } else { 23 | XCTFail("faild to decode eth sign data") 24 | } 25 | } 26 | 27 | func testDecodePersonal() throws { 28 | let data = try loadJSON(filename: "personal_sign") 29 | let payload = try JSONDecoder().decode(WCEthereumSignPayload.self, from: data) 30 | if case .personalSign(let data, let raw) = payload { 31 | XCTAssertEqual(payload.method, "personal_sign") 32 | XCTAssertEqual(payload.message, "My email is john@doe.com - 1537836206101") 33 | XCTAssertEqual(data.toHexString(), "4d7920656d61696c206973206a6f686e40646f652e636f6d202d2031353337383336323036313031") 34 | XCTAssertEqual(raw[1], "0xD432C5910f626dD21bE918D782facB38BDaE3296") 35 | } else { 36 | XCTFail("faild to decode eth sign data") 37 | } 38 | } 39 | 40 | // swiftlint:disable line_length 41 | func testDecodeTypedData() throws { 42 | let data = try loadJSON(filename: "sign_typed") 43 | let payload = try JSONDecoder().decode(WCEthereumSignPayload.self, from: data) 44 | if case .signTypeData(let id, let data, let raw) = payload { 45 | XCTAssertEqual(id, 1572863361304726) 46 | XCTAssertEqual(payload.method, "eth_signTypedData") 47 | XCTAssertEqual(raw[0], "0x7d8bf18C7cE84b3E175b339c4Ca93aEd1dD166F1") 48 | guard let json = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else { 49 | return XCTFail("fail to decode eth sign typed data") 50 | } 51 | XCTAssertEqual(json["primaryType"] as? String, "Mail") 52 | } else { 53 | XCTFail("faild to decode eth sign typed data") 54 | } 55 | } 56 | 57 | func testDecodeTypedDataString() throws { 58 | let data = try loadJSON(filename: "sign_typed_string") 59 | let payload = try JSONDecoder().decode(WCEthereumSignPayload.self, from: data) 60 | if case .signTypeData(_, let data, let raw) = payload { 61 | XCTAssertEqual(payload.method, "eth_signTypedData") 62 | XCTAssertEqual(data.toHexString(), "7b227479706573223a7b22454950373132446f6d61696e223a5b7b226e616d65223a226e616d65222c2274797065223a22737472696e67227d2c7b226e616d65223a2276657273696f6e222c2274797065223a22737472696e67227d2c7b226e616d65223a22636861696e4964222c2274797065223a2275696e74323536227d2c7b226e616d65223a22766572696679696e67436f6e7472616374222c2274797065223a2261646472657373227d5d2c22506572736f6e223a5b7b226e616d65223a226e616d65222c2274797065223a22737472696e67227d2c7b226e616d65223a226163636f756e74222c2274797065223a2261646472657373227d5d2c224d61696c223a5b7b226e616d65223a2266726f6d222c2274797065223a22506572736f6e227d2c7b226e616d65223a22746f222c2274797065223a22506572736f6e227d2c7b226e616d65223a22636f6e74656e7473222c2274797065223a22737472696e67227d5d7d2c227072696d61727954797065223a224d61696c222c22646f6d61696e223a7b226e616d65223a224578616d706c652044617070222c2276657273696f6e223a22312e302e302d62657461222c22636861696e4964223a312c22766572696679696e67436f6e7472616374223a22307830303030303030303030303030303030303030303030303030303030303030303030303030303030227d2c226d657373616765223a7b2266726f6d223a7b226e616d65223a22416c696365222c226163636f756e74223a22307861616161616161616161616161616161616161616161616161616161616161616161616161616161227d2c22746f223a7b226e616d65223a22426f62222c226163636f756e74223a22307862626262626262626262626262626262626262626262626262626262626262626262626262626262227d2c22636f6e74656e7473223a224865792c20426f6221227d7d") 63 | XCTAssertEqual(raw[0], "0x7d8bf18C7cE84b3E175b339c4Ca93aEd1dD166F1") 64 | } else { 65 | XCTFail("faild to decode eth sign typed data") 66 | } 67 | } 68 | // swiftlint:enable line_length 69 | } 70 | -------------------------------------------------------------------------------- /Example/Tests/WCEthereumTransactionTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import XCTest 8 | @testable import WalletConnect 9 | 10 | class WCEthereumTransactionTests: XCTestCase { 11 | func testSendTransaction() throws { 12 | let data = try loadJSON(filename: "defisaver_send") 13 | let request = try JSONDecoder().decode(JSONRPCRequest<[WCEthereumTransaction]>.self, from: data) 14 | let tx = request.params.first! 15 | 16 | XCTAssertEqual(tx.from, "0x7d8bf18c7ce84b3e175b339c4ca93aed1dd166f1") 17 | XCTAssertEqual(tx.to, "0xb1ff153f0ecbd12433000314e2c9d2c6b9f9c214") 18 | XCTAssertEqual(tx.gasPrice, "0x10642ace9") 19 | XCTAssertEqual(tx.data.count, 458) 20 | } 21 | 22 | func testDecodeGas() throws { 23 | let jsonString = """ 24 | { 25 | "from": "0xc36edf48e21cf395b206352a1819de658fd7f988", 26 | "gas": "0x77fb", 27 | "gasPrice": "0xb2d05e00", 28 | "nonce": "0x64", 29 | "to": "0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e", 30 | "value": "0x0", 31 | "data": "" 32 | } 33 | """ 34 | let tx = try JSONDecoder().decode(WCEthereumTransaction.self, from: jsonString.data(using: .utf8)!) 35 | XCTAssertEqual(tx.gas, "0x77fb") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Example/Tests/WCPeerMetaMock.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | import WalletConnect 9 | 10 | func loadJSON(filename: String, extension: String? = "json", subdirectory: String? = "test_data") throws -> Data { 11 | let dataUrl = Bundle(for: WCSessionStoreTests.self).url(forResource: filename, withExtension: `extension`, subdirectory: subdirectory)! 12 | let data = try Data(contentsOf: dataUrl) 13 | return data 14 | } 15 | 16 | extension WCPeerMeta { 17 | static func mock() -> WCPeerMeta { 18 | let data = try! loadJSON(filename: "peer_meta") 19 | let peerMeta = try! JSONDecoder().decode(WCPeerMeta.self, from: data) 20 | return peerMeta 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Tests/WCSessionManagerTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import XCTest 8 | import WalletConnect 9 | 10 | class WCSessionStoreTests: XCTestCase { 11 | 12 | override func setUp() { 13 | let wcUri = "wc:f7fddc39-e4ab-4071-b51e-1b669244f516@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=65253a9f194c3eaa9c823f8db07736817a0b024db5b00eb2d7da58d59c1e1376" 14 | let session = WCSession.from(string: wcUri)! 15 | let peerId = "779ee67f-6dbf-4c47-8589-16f1bcdd8e68" 16 | 17 | WCSessionStore.store(session, peerId: peerId, peerMeta: .mock()) 18 | } 19 | 20 | func testStore() { 21 | let wcUri = "wc:fcfecccf-4930-46b9-9f42-5648579c1658@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=4941e24abe9cce7822c17ebeadcd2f25a96b6e6904b9e4ec0942446ad5de8a18" 22 | let peerId = "309dc3d2-1d15-49fe-bef4-f708eb8c45de" 23 | let session = WCSession.from(string: wcUri)! 24 | 25 | WCSessionStore.store(session, peerId: peerId, peerMeta: .mock()) 26 | XCTAssertNotNil(WCSessionStore.load(session.topic)) 27 | 28 | WCSessionStore.clear(session.topic) 29 | XCTAssertNil(WCSessionStore.load(session.topic)) 30 | } 31 | 32 | func testLoad() { 33 | let topic = "f7fddc39-e4ab-4071-b51e-1b669244f516" 34 | let item = WCSessionStore.load(topic)! 35 | 36 | XCTAssertEqual(item.session.topic, topic) 37 | XCTAssertEqual(item.peerId, "779ee67f-6dbf-4c47-8589-16f1bcdd8e68") 38 | XCTAssertEqual(item.peerMeta.name, "WalletConnect Example") 39 | XCTAssertEqual(item.peerMeta.url, "https://example.walletconnect.org") 40 | } 41 | 42 | func testClearAll() { 43 | let expect = self.expectation(description: "clear all sessions") 44 | 45 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) { 46 | WCSessionStore.clearAll() 47 | XCTAssertNil(WCSessionStore.load("f7fddc39-e4ab-4071-b51e-1b669244f516")) 48 | expect.fulfill() 49 | } 50 | 51 | waitForExpectations(timeout: 3, handler: nil) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/Tests/WCSessionTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import XCTest 8 | import WalletConnect 9 | 10 | class WCSessionTests: XCTestCase { 11 | 12 | func testParse() { 13 | let uri = "wc:217374f6-8735-472d-a743-23bd7d26d106@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=d565a3e6cc792fa789bbea26b3f257fb436cfba2de48d2490b3e0248168d4b6b" 14 | 15 | let session = WCSession.from(string: uri) 16 | 17 | XCTAssertNotNil(session) 18 | XCTAssertEqual(session?.topic, "217374f6-8735-472d-a743-23bd7d26d106") 19 | XCTAssertEqual(session?.version, "1") 20 | XCTAssertEqual(session?.bridge.description, "https://bridge.walletconnect.org") 21 | XCTAssertEqual(session?.key, Data(hex: "d565a3e6cc792fa789bbea26b3f257fb436cfba2de48d2490b3e0248168d4b6b") ) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Example/Tests/test_data/defisaver_send.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1587005423352714, 3 | "jsonrpc": "2.0", 4 | "method": "eth_sendTransaction", 5 | "params": [{ 6 | "from": "0x7d8bf18c7ce84b3e175b339c4ca93aed1dd166f1", 7 | "to": "0xb1ff153f0ecbd12433000314e2c9d2c6b9f9c214", 8 | "gasPrice": "0x10642ace9", 9 | "data": "0x1cff79cd000000000000000000000000190c2cfc69e68a8e8d5e2b9e2b9cc3332caff77b00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064f9ef04be000000000000000000000000448a5065aebb8e423f0896e6c5d525c040f59af3000000000000000000000000000000000000000000000000000000000001136d0000000000000000000000000000000000000000000000000003ba0bc061ac5500000000000000000000000000000000000000000000000000000000" 10 | }] 11 | } -------------------------------------------------------------------------------- /Example/Tests/test_data/eth_sign.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1562814913374218, 3 | "jsonrpc": "2.0", 4 | "method": "eth_sign", 5 | "params": ["0xD432C5910f626dD21bE918D782facB38BDaE3296", "0x6dee0d861fb7e0da1b3cd046816981b1150b60f409d648a5b6d85d3fce00642c"] 6 | } 7 | -------------------------------------------------------------------------------- /Example/Tests/test_data/peer_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "", 3 | "url": "https://example.walletconnect.org", 4 | "icons": ["https://example.walletconnect.org/favicon.ico"], 5 | "name": "WalletConnect Example" 6 | } 7 | -------------------------------------------------------------------------------- /Example/Tests/test_data/personal_sign.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1562814868292270, 3 | "jsonrpc": "2.0", 4 | "method": "personal_sign", 5 | "params": ["0x4d7920656d61696c206973206a6f686e40646f652e636f6d202d2031353337383336323036313031", "0xD432C5910f626dD21bE918D782facB38BDaE3296"] 6 | } 7 | -------------------------------------------------------------------------------- /Example/Tests/test_data/sign_typed.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1572863361304726, 3 | "jsonrpc": "2.0", 4 | "method": "eth_signTypedData", 5 | "params": ["0x7d8bf18C7cE84b3E175b339c4Ca93aEd1dD166F1", { 6 | "types": { 7 | "EIP712Domain": [{ 8 | "name": "name", 9 | "type": "string" 10 | }, { 11 | "name": "version", 12 | "type": "string" 13 | }, { 14 | "name": "chainId", 15 | "type": "uint256" 16 | }, { 17 | "name": "verifyingContract", 18 | "type": "address" 19 | }], 20 | "Person": [{ 21 | "name": "name", 22 | "type": "string" 23 | }, { 24 | "name": "account", 25 | "type": "address" 26 | }], 27 | "Mail": [{ 28 | "name": "from", 29 | "type": "Person" 30 | }, { 31 | "name": "to", 32 | "type": "Person" 33 | }, { 34 | "name": "contents", 35 | "type": "string" 36 | }] 37 | }, 38 | "primaryType": "Mail", 39 | "domain": { 40 | "name": "Example Dapp", 41 | "version": "1.0.0-beta", 42 | "chainId": 1, 43 | "verifyingContract": "0x0000000000000000000000000000000000000000" 44 | }, 45 | "message": { 46 | "from": { 47 | "name": "Alice", 48 | "account": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 49 | }, 50 | "to": { 51 | "name": null, 52 | "account": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 53 | }, 54 | "contents": "Hey, Bob!" 55 | } 56 | }] 57 | } -------------------------------------------------------------------------------- /Example/Tests/test_data/sign_typed_string.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1572864672471409, 3 | "jsonrpc": "2.0", 4 | "method": "eth_signTypedData", 5 | "params": ["0x7d8bf18C7cE84b3E175b339c4Ca93aEd1dD166F1", "{\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Person\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"account\",\"type\":\"address\"}],\"Mail\":[{\"name\":\"from\",\"type\":\"Person\"},{\"name\":\"to\",\"type\":\"Person\"},{\"name\":\"contents\",\"type\":\"string\"}]},\"primaryType\":\"Mail\",\"domain\":{\"name\":\"Example Dapp\",\"version\":\"1.0.0-beta\",\"chainId\":1,\"verifyingContract\":\"0x0000000000000000000000000000000000000000\"},\"message\":{\"from\":{\"name\":\"Alice\",\"account\":\"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},\"to\":{\"name\":\"Bob\",\"account\":\"0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"},\"contents\":\"Hey, Bob!\"}}"] 6 | } -------------------------------------------------------------------------------- /Example/WalletConnect.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5944A2D390134C9FF57ED3E8 /* Pods_WalletConnect_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E343012D932C98B685E7EFB2 /* Pods_WalletConnect_Tests.framework */; }; 11 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 12 | 607FACD81AFB9204008FA782 /* WCSessionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* WCSessionViewController.swift */; }; 13 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 14 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 15 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 16 | 95B629BC9AE35AF7FECB685A /* Pods_WalletConnect_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58018BFAC1E050DECC1E3B9B /* Pods_WalletConnect_Example.framework */; }; 17 | BB3C46572257496400966B16 /* WCEncryptorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3C46552257496400966B16 /* WCEncryptorTests.swift */; }; 18 | BB3C46582257496400966B16 /* WCSessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3C46562257496400966B16 /* WCSessionTests.swift */; }; 19 | BB7DE7812448013D00C4F207 /* WCEthereumTransactionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7DE7802448013D00C4F207 /* WCEthereumTransactionTests.swift */; }; 20 | BBC3209222D6D6AC000D5A77 /* WCSessionManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBC3209122D6D6AC000D5A77 /* WCSessionManagerTests.swift */; }; 21 | BBC3209622D6D994000D5A77 /* test_data in Resources */ = {isa = PBXBuildFile; fileRef = BBC3209522D6D994000D5A77 /* test_data */; }; 22 | BBC3209822D6DDC1000D5A77 /* WCPeerMetaMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBC3209722D6DDC1000D5A77 /* WCPeerMetaMock.swift */; }; 23 | BBC3209A22D6F9DE000D5A77 /* WCEthereumSignPayloadTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBC3209922D6F9DE000D5A77 /* WCEthereumSignPayloadTests.swift */; }; 24 | BBFB765822681B18008CBC32 /* WCBinanceTradePairTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFB765722681B18008CBC32 /* WCBinanceTradePairTests.swift */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 33 | remoteInfo = WalletConnect; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 3CAB43573298CF6540303C70 /* Pods-WalletConnect_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WalletConnect_Example.debug.xcconfig"; path = "Target Support Files/Pods-WalletConnect_Example/Pods-WalletConnect_Example.debug.xcconfig"; sourceTree = ""; }; 39 | 58018BFAC1E050DECC1E3B9B /* Pods_WalletConnect_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WalletConnect_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 607FACD01AFB9204008FA782 /* WalletConnect_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WalletConnect_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 43 | 607FACD71AFB9204008FA782 /* WCSessionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCSessionViewController.swift; sourceTree = ""; }; 44 | 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 45 | 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 46 | 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 47 | 607FACE51AFB9204008FA782 /* WalletConnect_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WalletConnect_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 7B51907CCB4908B80495A7C7 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 50 | 898BD455BC548305184BF04B /* Pods-WalletConnect_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WalletConnect_Tests.release.xcconfig"; path = "Target Support Files/Pods-WalletConnect_Tests/Pods-WalletConnect_Tests.release.xcconfig"; sourceTree = ""; }; 51 | 9FE02F50BAA093A28A16E601 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 52 | AF6FEF50E52A07BBD8821D45 /* Pods-WalletConnect_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WalletConnect_Tests.debug.xcconfig"; path = "Target Support Files/Pods-WalletConnect_Tests/Pods-WalletConnect_Tests.debug.xcconfig"; sourceTree = ""; }; 53 | BB3C46552257496400966B16 /* WCEncryptorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCEncryptorTests.swift; sourceTree = ""; }; 54 | BB3C46562257496400966B16 /* WCSessionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCSessionTests.swift; sourceTree = ""; }; 55 | BB7DE7802448013D00C4F207 /* WCEthereumTransactionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCEthereumTransactionTests.swift; sourceTree = ""; }; 56 | BBC3209122D6D6AC000D5A77 /* WCSessionManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCSessionManagerTests.swift; sourceTree = ""; }; 57 | BBC3209522D6D994000D5A77 /* test_data */ = {isa = PBXFileReference; lastKnownFileType = folder; path = test_data; sourceTree = ""; }; 58 | BBC3209722D6DDC1000D5A77 /* WCPeerMetaMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCPeerMetaMock.swift; sourceTree = ""; }; 59 | BBC3209922D6F9DE000D5A77 /* WCEthereumSignPayloadTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCEthereumSignPayloadTests.swift; sourceTree = ""; }; 60 | BBFB765722681B18008CBC32 /* WCBinanceTradePairTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WCBinanceTradePairTests.swift; sourceTree = ""; }; 61 | C5AB14183732ECC55F0DC926 /* Pods-WalletConnect_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WalletConnect_Example.release.xcconfig"; path = "Target Support Files/Pods-WalletConnect_Example/Pods-WalletConnect_Example.release.xcconfig"; sourceTree = ""; }; 62 | E343012D932C98B685E7EFB2 /* Pods_WalletConnect_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WalletConnect_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | FF54DC7F0D5E8367EB168F5A /* WalletConnect.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = WalletConnect.podspec; path = ../WalletConnect.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 64 | /* End PBXFileReference section */ 65 | 66 | /* Begin PBXFrameworksBuildPhase section */ 67 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | 95B629BC9AE35AF7FECB685A /* Pods_WalletConnect_Example.framework in Frameworks */, 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | 5944A2D390134C9FF57ED3E8 /* Pods_WalletConnect_Tests.framework in Frameworks */, 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 35A375D8C1409D77CED68BD2 /* Pods */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 3CAB43573298CF6540303C70 /* Pods-WalletConnect_Example.debug.xcconfig */, 90 | C5AB14183732ECC55F0DC926 /* Pods-WalletConnect_Example.release.xcconfig */, 91 | AF6FEF50E52A07BBD8821D45 /* Pods-WalletConnect_Tests.debug.xcconfig */, 92 | 898BD455BC548305184BF04B /* Pods-WalletConnect_Tests.release.xcconfig */, 93 | ); 94 | path = Pods; 95 | sourceTree = ""; 96 | }; 97 | 607FACC71AFB9204008FA782 = { 98 | isa = PBXGroup; 99 | children = ( 100 | 607FACF51AFB993E008FA782 /* Podspec */, 101 | 607FACD21AFB9204008FA782 /* WalletConnectApp */, 102 | 607FACE81AFB9204008FA782 /* Tests */, 103 | 607FACD11AFB9204008FA782 /* Products */, 104 | 35A375D8C1409D77CED68BD2 /* Pods */, 105 | F19FF873C1B246C950BCFCE4 /* Frameworks */, 106 | ); 107 | sourceTree = ""; 108 | }; 109 | 607FACD11AFB9204008FA782 /* Products */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 607FACD01AFB9204008FA782 /* WalletConnect_Example.app */, 113 | 607FACE51AFB9204008FA782 /* WalletConnect_Tests.xctest */, 114 | ); 115 | name = Products; 116 | sourceTree = ""; 117 | }; 118 | 607FACD21AFB9204008FA782 /* WalletConnectApp */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 122 | 607FACD71AFB9204008FA782 /* WCSessionViewController.swift */, 123 | 607FACD91AFB9204008FA782 /* Main.storyboard */, 124 | 607FACDC1AFB9204008FA782 /* Images.xcassets */, 125 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 126 | 607FACD31AFB9204008FA782 /* Supporting Files */, 127 | ); 128 | name = WalletConnectApp; 129 | path = WalletConnect; 130 | sourceTree = ""; 131 | }; 132 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 607FACD41AFB9204008FA782 /* Info.plist */, 136 | ); 137 | name = "Supporting Files"; 138 | sourceTree = ""; 139 | }; 140 | 607FACE81AFB9204008FA782 /* Tests */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | BBC3209522D6D994000D5A77 /* test_data */, 144 | BBFB765722681B18008CBC32 /* WCBinanceTradePairTests.swift */, 145 | BB3C46552257496400966B16 /* WCEncryptorTests.swift */, 146 | BB3C46562257496400966B16 /* WCSessionTests.swift */, 147 | BBC3209122D6D6AC000D5A77 /* WCSessionManagerTests.swift */, 148 | BBC3209722D6DDC1000D5A77 /* WCPeerMetaMock.swift */, 149 | BBC3209922D6F9DE000D5A77 /* WCEthereumSignPayloadTests.swift */, 150 | BB7DE7802448013D00C4F207 /* WCEthereumTransactionTests.swift */, 151 | 607FACE91AFB9204008FA782 /* Supporting Files */, 152 | ); 153 | path = Tests; 154 | sourceTree = ""; 155 | }; 156 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | 607FACEA1AFB9204008FA782 /* Info.plist */, 160 | ); 161 | name = "Supporting Files"; 162 | sourceTree = ""; 163 | }; 164 | 607FACF51AFB993E008FA782 /* Podspec */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | FF54DC7F0D5E8367EB168F5A /* WalletConnect.podspec */, 168 | 9FE02F50BAA093A28A16E601 /* README.md */, 169 | 7B51907CCB4908B80495A7C7 /* LICENSE */, 170 | ); 171 | name = Podspec; 172 | sourceTree = ""; 173 | }; 174 | F19FF873C1B246C950BCFCE4 /* Frameworks */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | 58018BFAC1E050DECC1E3B9B /* Pods_WalletConnect_Example.framework */, 178 | E343012D932C98B685E7EFB2 /* Pods_WalletConnect_Tests.framework */, 179 | ); 180 | name = Frameworks; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXGroup section */ 184 | 185 | /* Begin PBXNativeTarget section */ 186 | 607FACCF1AFB9204008FA782 /* WalletConnect_Example */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "WalletConnect_Example" */; 189 | buildPhases = ( 190 | C1B9F7991B6113D359A1D332 /* [CP] Check Pods Manifest.lock */, 191 | 607FACCC1AFB9204008FA782 /* Sources */, 192 | 607FACCD1AFB9204008FA782 /* Frameworks */, 193 | 607FACCE1AFB9204008FA782 /* Resources */, 194 | A97A052E375912909E5670CC /* [CP] Embed Pods Frameworks */, 195 | BB8E3A0D22A74A0D00791D71 /* SwiftLint */, 196 | ); 197 | buildRules = ( 198 | ); 199 | dependencies = ( 200 | ); 201 | name = WalletConnect_Example; 202 | productName = WalletConnect; 203 | productReference = 607FACD01AFB9204008FA782 /* WalletConnect_Example.app */; 204 | productType = "com.apple.product-type.application"; 205 | }; 206 | 607FACE41AFB9204008FA782 /* WalletConnect_Tests */ = { 207 | isa = PBXNativeTarget; 208 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "WalletConnect_Tests" */; 209 | buildPhases = ( 210 | F52DAAE2B440AE5152878E22 /* [CP] Check Pods Manifest.lock */, 211 | 607FACE11AFB9204008FA782 /* Sources */, 212 | 607FACE21AFB9204008FA782 /* Frameworks */, 213 | 607FACE31AFB9204008FA782 /* Resources */, 214 | ); 215 | buildRules = ( 216 | ); 217 | dependencies = ( 218 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 219 | ); 220 | name = WalletConnect_Tests; 221 | productName = Tests; 222 | productReference = 607FACE51AFB9204008FA782 /* WalletConnect_Tests.xctest */; 223 | productType = "com.apple.product-type.bundle.unit-test"; 224 | }; 225 | /* End PBXNativeTarget section */ 226 | 227 | /* Begin PBXProject section */ 228 | 607FACC81AFB9204008FA782 /* Project object */ = { 229 | isa = PBXProject; 230 | attributes = { 231 | LastSwiftUpdateCheck = 0830; 232 | LastUpgradeCheck = 1020; 233 | ORGANIZATIONNAME = CocoaPods; 234 | TargetAttributes = { 235 | 607FACCF1AFB9204008FA782 = { 236 | CreatedOnToolsVersion = 6.3.1; 237 | DevelopmentTeam = FH9QG7ZJR9; 238 | LastSwiftMigration = 1020; 239 | ProvisioningStyle = Automatic; 240 | SystemCapabilities = { 241 | com.apple.BackgroundModes = { 242 | enabled = 1; 243 | }; 244 | }; 245 | }; 246 | 607FACE41AFB9204008FA782 = { 247 | CreatedOnToolsVersion = 6.3.1; 248 | LastSwiftMigration = 1020; 249 | TestTargetID = 607FACCF1AFB9204008FA782; 250 | }; 251 | }; 252 | }; 253 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "WalletConnect" */; 254 | compatibilityVersion = "Xcode 3.2"; 255 | developmentRegion = English; 256 | hasScannedForEncodings = 0; 257 | knownRegions = ( 258 | English, 259 | en, 260 | Base, 261 | ); 262 | mainGroup = 607FACC71AFB9204008FA782; 263 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 264 | projectDirPath = ""; 265 | projectRoot = ""; 266 | targets = ( 267 | 607FACCF1AFB9204008FA782 /* WalletConnect_Example */, 268 | 607FACE41AFB9204008FA782 /* WalletConnect_Tests */, 269 | ); 270 | }; 271 | /* End PBXProject section */ 272 | 273 | /* Begin PBXResourcesBuildPhase section */ 274 | 607FACCE1AFB9204008FA782 /* Resources */ = { 275 | isa = PBXResourcesBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, 279 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 280 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | }; 284 | 607FACE31AFB9204008FA782 /* Resources */ = { 285 | isa = PBXResourcesBuildPhase; 286 | buildActionMask = 2147483647; 287 | files = ( 288 | BBC3209622D6D994000D5A77 /* test_data in Resources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | /* End PBXResourcesBuildPhase section */ 293 | 294 | /* Begin PBXShellScriptBuildPhase section */ 295 | A97A052E375912909E5670CC /* [CP] Embed Pods Frameworks */ = { 296 | isa = PBXShellScriptBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | ); 300 | inputPaths = ( 301 | "${PODS_ROOT}/Target Support Files/Pods-WalletConnect_Example/Pods-WalletConnect_Example-frameworks.sh", 302 | "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework", 303 | "${BUILT_PRODUCTS_DIR}/PromiseKit/PromiseKit.framework", 304 | "${BUILT_PRODUCTS_DIR}/Starscream/Starscream.framework", 305 | "${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework", 306 | "${BUILT_PRODUCTS_DIR}/TrustWalletCore/TrustWalletCore.framework", 307 | "${BUILT_PRODUCTS_DIR}/WalletConnect/WalletConnect.framework", 308 | ); 309 | name = "[CP] Embed Pods Frameworks"; 310 | outputPaths = ( 311 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework", 312 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PromiseKit.framework", 313 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Starscream.framework", 314 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework", 315 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TrustWalletCore.framework", 316 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WalletConnect.framework", 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | shellPath = /bin/sh; 320 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-WalletConnect_Example/Pods-WalletConnect_Example-frameworks.sh\"\n"; 321 | showEnvVarsInLog = 0; 322 | }; 323 | BB8E3A0D22A74A0D00791D71 /* SwiftLint */ = { 324 | isa = PBXShellScriptBuildPhase; 325 | buildActionMask = 2147483647; 326 | files = ( 327 | ); 328 | inputFileListPaths = ( 329 | ); 330 | inputPaths = ( 331 | ); 332 | name = SwiftLint; 333 | outputFileListPaths = ( 334 | ); 335 | outputPaths = ( 336 | ); 337 | runOnlyForDeploymentPostprocessing = 0; 338 | shellPath = /bin/sh; 339 | shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\" --config ../.swiftlint.yml\n"; 340 | }; 341 | C1B9F7991B6113D359A1D332 /* [CP] Check Pods Manifest.lock */ = { 342 | isa = PBXShellScriptBuildPhase; 343 | buildActionMask = 2147483647; 344 | files = ( 345 | ); 346 | inputFileListPaths = ( 347 | ); 348 | inputPaths = ( 349 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 350 | "${PODS_ROOT}/Manifest.lock", 351 | ); 352 | name = "[CP] Check Pods Manifest.lock"; 353 | outputFileListPaths = ( 354 | ); 355 | outputPaths = ( 356 | "$(DERIVED_FILE_DIR)/Pods-WalletConnect_Example-checkManifestLockResult.txt", 357 | ); 358 | runOnlyForDeploymentPostprocessing = 0; 359 | shellPath = /bin/sh; 360 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 361 | showEnvVarsInLog = 0; 362 | }; 363 | F52DAAE2B440AE5152878E22 /* [CP] Check Pods Manifest.lock */ = { 364 | isa = PBXShellScriptBuildPhase; 365 | buildActionMask = 2147483647; 366 | files = ( 367 | ); 368 | inputFileListPaths = ( 369 | ); 370 | inputPaths = ( 371 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 372 | "${PODS_ROOT}/Manifest.lock", 373 | ); 374 | name = "[CP] Check Pods Manifest.lock"; 375 | outputFileListPaths = ( 376 | ); 377 | outputPaths = ( 378 | "$(DERIVED_FILE_DIR)/Pods-WalletConnect_Tests-checkManifestLockResult.txt", 379 | ); 380 | runOnlyForDeploymentPostprocessing = 0; 381 | shellPath = /bin/sh; 382 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 383 | showEnvVarsInLog = 0; 384 | }; 385 | /* End PBXShellScriptBuildPhase section */ 386 | 387 | /* Begin PBXSourcesBuildPhase section */ 388 | 607FACCC1AFB9204008FA782 /* Sources */ = { 389 | isa = PBXSourcesBuildPhase; 390 | buildActionMask = 2147483647; 391 | files = ( 392 | 607FACD81AFB9204008FA782 /* WCSessionViewController.swift in Sources */, 393 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 394 | ); 395 | runOnlyForDeploymentPostprocessing = 0; 396 | }; 397 | 607FACE11AFB9204008FA782 /* Sources */ = { 398 | isa = PBXSourcesBuildPhase; 399 | buildActionMask = 2147483647; 400 | files = ( 401 | BB3C46582257496400966B16 /* WCSessionTests.swift in Sources */, 402 | BBFB765822681B18008CBC32 /* WCBinanceTradePairTests.swift in Sources */, 403 | BBC3209822D6DDC1000D5A77 /* WCPeerMetaMock.swift in Sources */, 404 | BBC3209222D6D6AC000D5A77 /* WCSessionManagerTests.swift in Sources */, 405 | BBC3209A22D6F9DE000D5A77 /* WCEthereumSignPayloadTests.swift in Sources */, 406 | BB7DE7812448013D00C4F207 /* WCEthereumTransactionTests.swift in Sources */, 407 | BB3C46572257496400966B16 /* WCEncryptorTests.swift in Sources */, 408 | ); 409 | runOnlyForDeploymentPostprocessing = 0; 410 | }; 411 | /* End PBXSourcesBuildPhase section */ 412 | 413 | /* Begin PBXTargetDependency section */ 414 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 415 | isa = PBXTargetDependency; 416 | target = 607FACCF1AFB9204008FA782 /* WalletConnect_Example */; 417 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 418 | }; 419 | /* End PBXTargetDependency section */ 420 | 421 | /* Begin PBXVariantGroup section */ 422 | 607FACD91AFB9204008FA782 /* Main.storyboard */ = { 423 | isa = PBXVariantGroup; 424 | children = ( 425 | 607FACDA1AFB9204008FA782 /* Base */, 426 | ); 427 | name = Main.storyboard; 428 | sourceTree = ""; 429 | }; 430 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { 431 | isa = PBXVariantGroup; 432 | children = ( 433 | 607FACDF1AFB9204008FA782 /* Base */, 434 | ); 435 | name = LaunchScreen.xib; 436 | sourceTree = ""; 437 | }; 438 | /* End PBXVariantGroup section */ 439 | 440 | /* Begin XCBuildConfiguration section */ 441 | 607FACED1AFB9204008FA782 /* Debug */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ALWAYS_SEARCH_USER_PATHS = NO; 445 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 446 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 447 | CLANG_CXX_LIBRARY = "libc++"; 448 | CLANG_ENABLE_MODULES = YES; 449 | CLANG_ENABLE_OBJC_ARC = YES; 450 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 451 | CLANG_WARN_BOOL_CONVERSION = YES; 452 | CLANG_WARN_COMMA = YES; 453 | CLANG_WARN_CONSTANT_CONVERSION = YES; 454 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 455 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 456 | CLANG_WARN_EMPTY_BODY = YES; 457 | CLANG_WARN_ENUM_CONVERSION = YES; 458 | CLANG_WARN_INFINITE_RECURSION = YES; 459 | CLANG_WARN_INT_CONVERSION = YES; 460 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 461 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 462 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 463 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 464 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 465 | CLANG_WARN_STRICT_PROTOTYPES = YES; 466 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 467 | CLANG_WARN_UNREACHABLE_CODE = YES; 468 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 469 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 470 | COPY_PHASE_STRIP = NO; 471 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 472 | ENABLE_STRICT_OBJC_MSGSEND = YES; 473 | ENABLE_TESTABILITY = YES; 474 | GCC_C_LANGUAGE_STANDARD = gnu99; 475 | GCC_DYNAMIC_NO_PIC = NO; 476 | GCC_NO_COMMON_BLOCKS = YES; 477 | GCC_OPTIMIZATION_LEVEL = 0; 478 | GCC_PREPROCESSOR_DEFINITIONS = ( 479 | "DEBUG=1", 480 | "$(inherited)", 481 | ); 482 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 483 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 484 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 485 | GCC_WARN_UNDECLARED_SELECTOR = YES; 486 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 487 | GCC_WARN_UNUSED_FUNCTION = YES; 488 | GCC_WARN_UNUSED_VARIABLE = YES; 489 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 490 | MTL_ENABLE_DEBUG_INFO = YES; 491 | ONLY_ACTIVE_ARCH = YES; 492 | SDKROOT = iphoneos; 493 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 494 | }; 495 | name = Debug; 496 | }; 497 | 607FACEE1AFB9204008FA782 /* Release */ = { 498 | isa = XCBuildConfiguration; 499 | buildSettings = { 500 | ALWAYS_SEARCH_USER_PATHS = NO; 501 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 502 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 503 | CLANG_CXX_LIBRARY = "libc++"; 504 | CLANG_ENABLE_MODULES = YES; 505 | CLANG_ENABLE_OBJC_ARC = YES; 506 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 507 | CLANG_WARN_BOOL_CONVERSION = YES; 508 | CLANG_WARN_COMMA = YES; 509 | CLANG_WARN_CONSTANT_CONVERSION = YES; 510 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 511 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 512 | CLANG_WARN_EMPTY_BODY = YES; 513 | CLANG_WARN_ENUM_CONVERSION = YES; 514 | CLANG_WARN_INFINITE_RECURSION = YES; 515 | CLANG_WARN_INT_CONVERSION = YES; 516 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 517 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 518 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 519 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 520 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 521 | CLANG_WARN_STRICT_PROTOTYPES = YES; 522 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 523 | CLANG_WARN_UNREACHABLE_CODE = YES; 524 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 525 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 526 | COPY_PHASE_STRIP = NO; 527 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 528 | ENABLE_NS_ASSERTIONS = NO; 529 | ENABLE_STRICT_OBJC_MSGSEND = YES; 530 | GCC_C_LANGUAGE_STANDARD = gnu99; 531 | GCC_NO_COMMON_BLOCKS = YES; 532 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 533 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 534 | GCC_WARN_UNDECLARED_SELECTOR = YES; 535 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 536 | GCC_WARN_UNUSED_FUNCTION = YES; 537 | GCC_WARN_UNUSED_VARIABLE = YES; 538 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 539 | MTL_ENABLE_DEBUG_INFO = NO; 540 | SDKROOT = iphoneos; 541 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 542 | VALIDATE_PRODUCT = YES; 543 | }; 544 | name = Release; 545 | }; 546 | 607FACF01AFB9204008FA782 /* Debug */ = { 547 | isa = XCBuildConfiguration; 548 | baseConfigurationReference = 3CAB43573298CF6540303C70 /* Pods-WalletConnect_Example.debug.xcconfig */; 549 | buildSettings = { 550 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 551 | CODE_SIGN_IDENTITY = "iPhone Developer"; 552 | CODE_SIGN_STYLE = Automatic; 553 | DEVELOPMENT_TEAM = FH9QG7ZJR9; 554 | INFOPLIST_FILE = WalletConnect/Info.plist; 555 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 556 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 557 | MODULE_NAME = ExampleApp; 558 | PRODUCT_BUNDLE_IDENTIFIER = "org.walletconnect.WalletConnect-Example"; 559 | PRODUCT_NAME = "$(TARGET_NAME)"; 560 | PROVISIONING_PROFILE_SPECIFIER = ""; 561 | SWIFT_VERSION = 5.0; 562 | }; 563 | name = Debug; 564 | }; 565 | 607FACF11AFB9204008FA782 /* Release */ = { 566 | isa = XCBuildConfiguration; 567 | baseConfigurationReference = C5AB14183732ECC55F0DC926 /* Pods-WalletConnect_Example.release.xcconfig */; 568 | buildSettings = { 569 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 570 | CODE_SIGN_IDENTITY = "iPhone Developer"; 571 | CODE_SIGN_STYLE = Automatic; 572 | DEVELOPMENT_TEAM = FH9QG7ZJR9; 573 | INFOPLIST_FILE = WalletConnect/Info.plist; 574 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 575 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 576 | MODULE_NAME = ExampleApp; 577 | PRODUCT_BUNDLE_IDENTIFIER = "org.walletconnect.WalletConnect-Example"; 578 | PRODUCT_NAME = "$(TARGET_NAME)"; 579 | PROVISIONING_PROFILE_SPECIFIER = ""; 580 | SWIFT_VERSION = 5.0; 581 | }; 582 | name = Release; 583 | }; 584 | 607FACF31AFB9204008FA782 /* Debug */ = { 585 | isa = XCBuildConfiguration; 586 | baseConfigurationReference = AF6FEF50E52A07BBD8821D45 /* Pods-WalletConnect_Tests.debug.xcconfig */; 587 | buildSettings = { 588 | CLANG_ENABLE_MODULES = YES; 589 | DEVELOPMENT_TEAM = ""; 590 | GCC_PREPROCESSOR_DEFINITIONS = ( 591 | "DEBUG=1", 592 | "$(inherited)", 593 | ); 594 | INFOPLIST_FILE = Tests/Info.plist; 595 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 596 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 597 | PRODUCT_NAME = "$(TARGET_NAME)"; 598 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 599 | SWIFT_VERSION = 5.0; 600 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WalletConnect_Example.app/WalletConnect_Example"; 601 | }; 602 | name = Debug; 603 | }; 604 | 607FACF41AFB9204008FA782 /* Release */ = { 605 | isa = XCBuildConfiguration; 606 | baseConfigurationReference = 898BD455BC548305184BF04B /* Pods-WalletConnect_Tests.release.xcconfig */; 607 | buildSettings = { 608 | CLANG_ENABLE_MODULES = YES; 609 | DEVELOPMENT_TEAM = ""; 610 | INFOPLIST_FILE = Tests/Info.plist; 611 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 612 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 613 | PRODUCT_NAME = "$(TARGET_NAME)"; 614 | SWIFT_VERSION = 5.0; 615 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WalletConnect_Example.app/WalletConnect_Example"; 616 | }; 617 | name = Release; 618 | }; 619 | /* End XCBuildConfiguration section */ 620 | 621 | /* Begin XCConfigurationList section */ 622 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "WalletConnect" */ = { 623 | isa = XCConfigurationList; 624 | buildConfigurations = ( 625 | 607FACED1AFB9204008FA782 /* Debug */, 626 | 607FACEE1AFB9204008FA782 /* Release */, 627 | ); 628 | defaultConfigurationIsVisible = 0; 629 | defaultConfigurationName = Release; 630 | }; 631 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "WalletConnect_Example" */ = { 632 | isa = XCConfigurationList; 633 | buildConfigurations = ( 634 | 607FACF01AFB9204008FA782 /* Debug */, 635 | 607FACF11AFB9204008FA782 /* Release */, 636 | ); 637 | defaultConfigurationIsVisible = 0; 638 | defaultConfigurationName = Release; 639 | }; 640 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "WalletConnect_Tests" */ = { 641 | isa = XCConfigurationList; 642 | buildConfigurations = ( 643 | 607FACF31AFB9204008FA782 /* Debug */, 644 | 607FACF41AFB9204008FA782 /* Release */, 645 | ); 646 | defaultConfigurationIsVisible = 0; 647 | defaultConfigurationName = Release; 648 | }; 649 | /* End XCConfigurationList section */ 650 | }; 651 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 652 | } 653 | -------------------------------------------------------------------------------- /Example/WalletConnect.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/WalletConnect.xcodeproj/xcshareddata/xcschemes/WalletConnect-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 46 | 47 | 53 | 54 | 55 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 74 | 75 | 76 | 77 | 78 | 79 | 89 | 91 | 97 | 98 | 99 | 100 | 101 | 102 | 108 | 110 | 116 | 117 | 118 | 119 | 121 | 122 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /Example/WalletConnect.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/WalletConnect.xcworkspace/xcshareddata/IDETemplateMacros.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | FILEHEADER 6 | Copyright © 2017-2019 Trust Wallet. 7 | // 8 | // This file is part of Trust. The full Trust copyright notice, including 9 | // terms governing use, modification, and redistribution, is contained in the 10 | // file LICENSE at the root of the source code distribution tree. 11 | 12 | 13 | -------------------------------------------------------------------------------- /Example/WalletConnect.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/WalletConnect/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import UIKit 8 | 9 | @UIApplicationMain 10 | class AppDelegate: UIResponder, UIApplicationDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | var rootViewController: WCSessionViewController? { 15 | return window?.rootViewController as? WCSessionViewController 16 | } 17 | 18 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 19 | return true 20 | } 21 | 22 | func applicationWillEnterForeground(_ application: UIApplication) { 23 | rootViewController?.applicationWillEnterForeground(application) 24 | } 25 | 26 | func applicationDidEnterBackground(_ application: UIApplication) { 27 | rootViewController?.applicationDidEnterBackground(application) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Example/WalletConnect/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Example/WalletConnect/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 36 | 43 | 50 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-40.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-60.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-58.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-87.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-80.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-121.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-120.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-180.png", 49 | "scale" : "3x" 50 | }, 51 | { 52 | "size" : "1024x1024", 53 | "idiom" : "ios-marketing", 54 | "filename" : "Icon-1024.png", 55 | "scale" : "1x" 56 | } 57 | ], 58 | "info" : { 59 | "version" : 1, 60 | "author" : "xcode" 61 | } 62 | } -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-1024.png -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-120.png -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-121.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-121.png -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-180.png -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-58.png -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-60.png -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-80.png -------------------------------------------------------------------------------- /Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/Example/WalletConnect/Images.xcassets/AppIcon.appiconset/Icon-87.png -------------------------------------------------------------------------------- /Example/WalletConnect/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIBackgroundModes 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/WalletConnect/WCSessionViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import UIKit 8 | import WalletConnect 9 | import PromiseKit 10 | import TrustWalletCore 11 | import UserNotifications 12 | 13 | class WCSessionViewController: UIViewController { 14 | 15 | @IBOutlet weak var uriField: UITextField! 16 | @IBOutlet weak var addressField: UITextField! 17 | @IBOutlet weak var chainIdField: UITextField! 18 | @IBOutlet weak var connectButton: UIButton! 19 | @IBOutlet weak var approveButton: UIButton! 20 | 21 | var interactor: WCInteractor? 22 | let clientMeta = WCPeerMeta(name: "WalletConnect SDK", url: "https://github.com/TrustWallet/wallet-connect-swift") 23 | 24 | let privateKey = PrivateKey(data: Data(hexString: "ba005cd605d8a02e3d5dfd04234cef3a3ee4f76bfbad2722d1fb5af8e12e6764")!)! 25 | 26 | var defaultAddress: String = "" 27 | var defaultChainId: Int = 1 28 | var recoverSession: Bool = false 29 | var notificationGranted: Bool = false 30 | 31 | private var backgroundTaskId: UIBackgroundTaskIdentifier? 32 | private weak var backgroundTimer: Timer? 33 | 34 | override func viewDidLoad() { 35 | super.viewDidLoad() 36 | 37 | // let string = "wc:fcfecccf-4930-46b9-9f42-5648579c1658@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=4941e24abe9cce7822c17ebeadcd2f25a96b6e6904b9e4ec0942446ad5de8a18" 38 | let string = "wc:6087eb23-a8ac-4270-9f48-99cf86e56dd0@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=228a5cfa700aa907a32c97568163d7a95d911fc56fe2ffcbe93b4199a2bcbc3a" 39 | defaultAddress = CoinType.ethereum.deriveAddress(privateKey: privateKey) 40 | uriField.text = string 41 | addressField.text = defaultAddress 42 | chainIdField.text = "1" 43 | chainIdField.textAlignment = .center 44 | approveButton.isEnabled = false 45 | 46 | UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { (granted, error) in 47 | print("<== notification permission: \(granted)") 48 | if let error = error { 49 | print(error) 50 | } 51 | self.notificationGranted = granted 52 | } 53 | } 54 | 55 | func connect(session: WCSession) { 56 | print("==> session", session) 57 | let interactor = WCInteractor(session: session, meta: clientMeta, uuid: UIDevice.current.identifierForVendor ?? UUID()) 58 | 59 | configure(interactor: interactor) 60 | 61 | interactor.connect().done { [weak self] connected in 62 | self?.connectionStatusUpdated(connected) 63 | }.catch { [weak self] error in 64 | self?.present(error: error) 65 | } 66 | 67 | self.interactor = interactor 68 | } 69 | 70 | func configure(interactor: WCInteractor) { 71 | let accounts = [defaultAddress] 72 | let chainId = defaultChainId 73 | 74 | interactor.onError = { [weak self] error in 75 | self?.present(error: error) 76 | } 77 | 78 | interactor.onSessionRequest = { [weak self] (id, peerParam) in 79 | let peer = peerParam.peerMeta 80 | let message = [peer.description, peer.url].joined(separator: "\n") 81 | let alert = UIAlertController(title: peer.name, message: message, preferredStyle: .alert) 82 | alert.addAction(UIAlertAction(title: "Reject", style: .destructive, handler: { _ in 83 | self?.interactor?.rejectSession().cauterize() 84 | })) 85 | alert.addAction(UIAlertAction(title: "Approve", style: .default, handler: { _ in 86 | self?.interactor?.approveSession(accounts: accounts, chainId: chainId).cauterize() 87 | })) 88 | self?.show(alert, sender: nil) 89 | } 90 | 91 | interactor.onDisconnect = { [weak self] (error) in 92 | if let error = error { 93 | print(error) 94 | } 95 | self?.connectionStatusUpdated(false) 96 | } 97 | 98 | interactor.eth.onSign = { [weak self] (id, payload) in 99 | let alert = UIAlertController(title: payload.method, message: payload.message, preferredStyle: .alert) 100 | alert.addAction(UIAlertAction(title: "Cancel", style: .destructive, handler: { _ in 101 | self?.interactor?.rejectRequest(id: id, message: "User canceled").cauterize() 102 | })) 103 | alert.addAction(UIAlertAction(title: "Sign", style: .default, handler: { _ in 104 | self?.signEth(id: id, payload: payload) 105 | })) 106 | self?.show(alert, sender: nil) 107 | } 108 | 109 | interactor.eth.onTransaction = { [weak self] (id, event, transaction) in 110 | let data = try! JSONEncoder().encode(transaction) 111 | let message = String(data: data, encoding: .utf8) 112 | let alert = UIAlertController(title: event.rawValue, message: message, preferredStyle: .alert) 113 | alert.addAction(UIAlertAction(title: "Reject", style: .destructive, handler: { _ in 114 | self?.interactor?.rejectRequest(id: id, message: "I don't have ethers").cauterize() 115 | })) 116 | self?.show(alert, sender: nil) 117 | } 118 | 119 | interactor.bnb.onSign = { [weak self] (id, order) in 120 | let message = order.encodedString 121 | let alert = UIAlertController(title: "bnb_sign", message: message, preferredStyle: .alert) 122 | alert.addAction(UIAlertAction(title: "Cancel", style: .destructive, handler: { [weak self] _ in 123 | self?.interactor?.rejectRequest(id: id, message: "User canceled").cauterize() 124 | })) 125 | alert.addAction(UIAlertAction(title: "Sign", style: .default, handler: { [weak self] _ in 126 | self?.signBnbOrder(id: id, order: order) 127 | })) 128 | self?.show(alert, sender: nil) 129 | } 130 | 131 | interactor.okt.onTransaction = { [weak self] (id, event, transaction) in 132 | let data = try! JSONEncoder().encode(transaction) 133 | let message = String(data: data, encoding: .utf8) 134 | let alert = UIAlertController(title: event.rawValue, message: message, preferredStyle: .alert) 135 | alert.addAction(UIAlertAction(title: "Reject", style: .destructive, handler: { _ in 136 | self?.interactor?.rejectRequest(id: id, message: "I don't have okt").cauterize() 137 | })) 138 | alert.addAction(UIAlertAction(title: "Approve", style: .default, handler: { (_) in 139 | self?.interactor?.approveRequest(id: id, result: "This is the signed data").cauterize() 140 | })) 141 | self?.show(alert, sender: nil) 142 | } 143 | } 144 | 145 | func approve(accounts: [String], chainId: Int) { 146 | interactor?.approveSession(accounts: accounts, chainId: chainId).done { 147 | print("<== approveSession done") 148 | }.catch { [weak self] error in 149 | self?.present(error: error) 150 | } 151 | } 152 | 153 | func signEth(id: Int64, payload: WCEthereumSignPayload) { 154 | let data: Data = { 155 | switch payload { 156 | case .sign(let data, _): 157 | return data 158 | case .personalSign(let data, _): 159 | let prefix = "\u{19}Ethereum Signed Message:\n\(data)".data(using: .utf8)! 160 | return prefix + data 161 | case .signTypeData(_, let data, _): 162 | // FIXME 163 | return data 164 | } 165 | }() 166 | 167 | var result = privateKey.sign(digest: Hash.keccak256(data: data), curve: .secp256k1)! 168 | result[64] += 27 169 | self.interactor?.approveRequest(id: id, result: "0x" + result.hexString).cauterize() 170 | } 171 | 172 | func signBnbOrder(id: Int64, order: WCBinanceOrder) { 173 | let data = order.encoded 174 | print("==> signbnbOrder", String(data: data, encoding: .utf8)!) 175 | let signature = privateKey.sign(digest: Hash.sha256(data: data), curve: .secp256k1)! 176 | let signed = WCBinanceOrderSignature( 177 | signature: signature.dropLast().hexString, 178 | publicKey: privateKey.getPublicKeySecp256k1(compressed: false).data.hexString 179 | ) 180 | interactor?.approveBnbOrder(id: id, signed: signed).done({ confirm in 181 | print("<== approveBnbOrder", confirm) 182 | }).catch { [weak self] error in 183 | self?.present(error: error) 184 | } 185 | } 186 | 187 | func connectionStatusUpdated(_ connected: Bool) { 188 | self.approveButton.isEnabled = connected 189 | self.connectButton.setTitle(!connected ? "Connect" : "Kill Session", for: .normal) 190 | } 191 | 192 | func present(error: Error) { 193 | let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert) 194 | alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) 195 | self.show(alert, sender: nil) 196 | } 197 | 198 | @IBAction func connectTapped() { 199 | guard let string = uriField.text, let session = WCSession.from(string: string) else { 200 | print("invalid uri: \(String(describing: uriField.text))") 201 | return 202 | } 203 | if let i = interactor, i.state == .connected { 204 | i.killSession().done { [weak self] in 205 | self?.approveButton.isEnabled = false 206 | self?.connectButton.setTitle("Connect", for: .normal) 207 | }.cauterize() 208 | } else { 209 | connect(session: session) 210 | } 211 | } 212 | 213 | @IBAction func approveTapped() { 214 | guard let address = addressField.text, 215 | let chainIdString = chainIdField.text else { 216 | print("empty address or chainId") 217 | return 218 | } 219 | guard let chainId = Int(chainIdString) else { 220 | print("invalid chainId") 221 | return 222 | } 223 | guard EthereumAddress.isValidString(string: address) || CosmosAddress.isValidString(string: address) else { 224 | print("invalid eth or bnb address") 225 | return 226 | } 227 | approve(accounts: [address], chainId: chainId) 228 | } 229 | } 230 | 231 | extension WCSessionViewController { 232 | func applicationDidEnterBackground(_ application: UIApplication) { 233 | print("<== applicationDidEnterBackground") 234 | 235 | if interactor?.state != .connected { 236 | return 237 | } 238 | 239 | if notificationGranted { 240 | pauseInteractor() 241 | } else { 242 | startBackgroundTask(application) 243 | } 244 | } 245 | 246 | func applicationWillEnterForeground(_ application: UIApplication) { 247 | print("==> applicationWillEnterForeground") 248 | if let id = backgroundTaskId { 249 | application.endBackgroundTask(id) 250 | } 251 | backgroundTimer?.invalidate() 252 | 253 | if recoverSession { 254 | DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) { 255 | self.interactor?.resume() 256 | } 257 | } 258 | } 259 | 260 | func startBackgroundTask(_ application: UIApplication) { 261 | backgroundTaskId = application.beginBackgroundTask(withName: "WalletConnect", expirationHandler: { 262 | self.backgroundTimer?.invalidate() 263 | print("<== background task expired") 264 | }) 265 | 266 | var alerted = false 267 | backgroundTimer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in 268 | print("<== background time remainning: ", application.backgroundTimeRemaining) 269 | if application.backgroundTimeRemaining < 15 { 270 | self.pauseInteractor() 271 | } else if application.backgroundTimeRemaining < 120 && !alerted { 272 | let notification = self.createWarningNotification() 273 | UNUserNotificationCenter.current().add(notification, withCompletionHandler: { error in 274 | alerted = true 275 | if let error = error { 276 | print("post error \(error.localizedDescription)") 277 | } 278 | }) 279 | } 280 | } 281 | } 282 | 283 | func pauseInteractor() { 284 | recoverSession = true 285 | interactor?.pause() 286 | } 287 | 288 | func createWarningNotification() -> UNNotificationRequest { 289 | let content = UNMutableNotificationContent() 290 | content.title = "WC session will be interrupted" 291 | content.sound = UNNotificationSound.default 292 | 293 | let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) 294 | 295 | return UNNotificationRequest(identifier: "session.warning", content: content, trigger: trigger) 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 hewigovens <360470+hewigovens@users.noreply.github.com> 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "CryptoSwift", 6 | "repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift", 7 | "state": { 8 | "branch": null, 9 | "revision": "90e5b7af823d869fa8dea5a3abc7d95b6cb04c8c", 10 | "version": "1.1.3" 11 | } 12 | }, 13 | { 14 | "package": "PromiseKit", 15 | "repositoryURL": "https://github.com/mxcl/PromiseKit", 16 | "state": { 17 | "branch": null, 18 | "revision": "4d8d1287d2e50c53a9f8430ffe88925292838c57", 19 | "version": "6.11.0" 20 | } 21 | }, 22 | { 23 | "package": "Starscream", 24 | "repositoryURL": "https://github.com/daltoniam/Starscream", 25 | "state": { 26 | "branch": null, 27 | "revision": "e6b65c6d9077ea48b4a7bdda8994a1d3c6969c8d", 28 | "version": "3.1.1" 29 | } 30 | }, 31 | { 32 | "package": "swift-nio-zlib-support", 33 | "repositoryURL": "https://github.com/apple/swift-nio-zlib-support.git", 34 | "state": { 35 | "branch": null, 36 | "revision": "37760e9a52030bb9011972c5213c3350fa9d41fd", 37 | "version": "1.0.0" 38 | } 39 | } 40 | ] 41 | }, 42 | "version": 1 43 | } 44 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.0 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "WalletConnect", 6 | platforms: [ 7 | .iOS(.v11), 8 | .macOS(.v10_13), 9 | ], 10 | products: [ 11 | .library(name: "WalletConnect", targets: ["WalletConnect"]), 12 | ], 13 | dependencies: [ 14 | .package(url: "https://github.com/krzyzanowskim/CryptoSwift", from: "1.1.0"), 15 | .package(url: "https://github.com/mxcl/PromiseKit", from: "6.8.0"), 16 | .package(url: "https://github.com/daltoniam/Starscream", from: "3.0.0"), 17 | ], 18 | targets: [ 19 | .target( 20 | name: "WalletConnect", 21 | dependencies: ["CryptoSwift", "PromiseKit", "Starscream"], 22 | path: "WalletConnect" 23 | ), 24 | ] 25 | ) 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WalletConnect 2 | 3 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/44d202d68ed244878f955c03ad710f50)](https://www.codacy.com/app/TrustWallet/wallet-connect-swift?utm_source=github.com&utm_medium=referral&utm_content=TrustWallet/wallet-connect-swift&utm_campaign=Badge_Grade) 4 | ![CI](https://github.com/trustwallet/wallet-connect-swift/workflows/CI/badge.svg) 5 | 6 | [WalletConnect](https://walletconnect.org/) Swift SDK, implements 1.0.0 websocket based protocol. 7 | 8 | Demo video 9 | 10 | 11 | 12 | ## Requirements 13 | 14 | - iOS 11 15 | - Xcode 10.2 16 | - Swift 5 17 | 18 | ## Features 19 | 20 | - [x] Connect and disconnect 21 | - [x] Approve / Reject / Kill session 22 | - [x] Approve and reject `eth_sign` / `personal_sign` / `eth_signTypedData` 23 | - [x] Approve and reject `eth_signTransaction` / `eth_sendTransaction` 24 | - [x] Approve and reject `bnb_sign` (binance dex orders) 25 | - [x] session persistent / recovery 26 | 27 | Todo: 28 | 29 | - [ ] push notification (APNS) 30 | 31 | ## Example 32 | 33 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 34 | 35 | ## Installation 36 | 37 | WalletConnect is available through [CocoaPods](https://cocoapods.org), [Carthage](https://github.com/Carthage/Carthage) and [Swift Package Manager](https://swift.org/package-manager/). 38 | 39 | ### CocoaPods 40 | 41 | To install it, simply add the following line to your `Podfile`: 42 | 43 | ```ruby 44 | pod 'WalletConnect', git: 'https://github.com/trustwallet/wallet-connect-swift', branch: 'master' 45 | ``` 46 | 47 | ### Carthage 48 | 49 | Add following line to your `Cartfile`: 50 | 51 | ```ruby 52 | github "trustwallet/wallet-connect-swift" 53 | ``` 54 | ### Swift Package Manager 55 | 56 | Add `.package(url:_:)` to your `Package.swift`: 57 | 58 | ```swift 59 | dependencies: [ 60 | .package(url: "https://github.com/trustwallet/wallet-connect-swift", .branch("master")), 61 | ], 62 | ``` 63 | 64 | ## Usage 65 | 66 | parse session from scanned QR code: 67 | 68 | ```swift 69 | let string = "wc:..." 70 | guard let session = WCSession.from(string: string) else { 71 | // invalid session 72 | return 73 | } 74 | // handle session 75 | ``` 76 | 77 | configure and handle incoming message: 78 | 79 | ```swift 80 | let interactor = WCInteractor(session: session, meta: clientMeta) 81 | interactor.onSessionRequest = { [weak self] (id, peer) in 82 | // ask for user consent 83 | } 84 | 85 | interactor.onDisconnect = { [weak self] (error) in 86 | // handle disconnect 87 | } 88 | 89 | interactor.eth.onSign = { [weak self] (id, payload) in 90 | // handle eth_sign, personal_sign, eth_signTypedData 91 | } 92 | 93 | interactor.eth.onTransaction = { [weak self] (id, event, transaction) in 94 | // handle eth_signTransaction / eth_sendTransaction 95 | } 96 | 97 | interactor.bnb.onSign = { [weak self] (id, order) in 98 | // handle bnb_sign 99 | } 100 | ``` 101 | 102 | approve session 103 | 104 | ```swift 105 | interactor.approveSession(accounts: accounts, chainId: chainId).done { 106 | print("<== approveSession done") 107 | }.cauterize() 108 | ``` 109 | 110 | approve request 111 | 112 | ```swift 113 | interactor.approveRequest(id: id, result: result.hexString).done { 114 | print("<== approveRequest done") 115 | }.cauterize() 116 | ``` 117 | 118 | approve binance dex orders 119 | 120 | ```swift 121 | interactor?.approveBnbOrder(id: id, signed: signed).done({ confirm in 122 | print("<== approveBnbOrder", confirm) 123 | }).cauterize() 124 | ``` 125 | 126 | ## Author 127 | 128 | hewigovens 129 | 130 | ## License 131 | 132 | WalletConnect is available under the MIT license. See the LICENSE file for more info. 133 | -------------------------------------------------------------------------------- /WalletConnect.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'WalletConnect' 3 | s.version = '0.1.0' 4 | s.summary = 'WalletConnect Swift SDK' 5 | s.description = 'WalletConnect Swift SDK' 6 | 7 | s.homepage = 'https://github.com/hewigovens/wallet-connect-swift' 8 | s.license = { :type => 'MIT', :file => 'LICENSE' } 9 | s.author = { 'hewigovens' => '360470+hewigovens@users.noreply.github.com' } 10 | s.source = { :git => 'https://github.com/hewigovens/WalletConnect.git', :tag => s.version.to_s } 11 | 12 | s.ios.deployment_target = '11.0' 13 | s.source_files = 'WalletConnect/**/*' 14 | s.exclude_files = ["WalletConnect/Info.plist"] 15 | s.swift_version = '5.0' 16 | 17 | s.dependency 'CryptoSwift' 18 | s.dependency 'Starscream' 19 | s.dependency 'PromiseKit' 20 | end 21 | -------------------------------------------------------------------------------- /WalletConnect.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BB47674F236BB93600A9A9AF /* WalletConnect.h in Headers */ = {isa = PBXBuildFile; fileRef = BB47674D236BB93600A9A9AF /* WalletConnect.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | BB476775236BB98400A9A9AF /* WCInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476755236BB98300A9A9AF /* WCInteractor.swift */; }; 12 | BB476776236BB98400A9A9AF /* JSONRPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476757236BB98300A9A9AF /* JSONRPC.swift */; }; 13 | BB476777236BB98400A9A9AF /* WCSessionStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476758236BB98300A9A9AF /* WCSessionStore.swift */; }; 14 | BB476778236BB98400A9A9AF /* WCBinanceInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47675A236BB98300A9A9AF /* WCBinanceInteractor.swift */; }; 15 | BB476779236BB98400A9A9AF /* WCTrustInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47675B236BB98300A9A9AF /* WCTrustInteractor.swift */; }; 16 | BB47677A236BB98400A9A9AF /* WCEthereumInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47675C236BB98300A9A9AF /* WCEthereumInteractor.swift */; }; 17 | BB47677B236BB98400A9A9AF /* WCEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47675E236BB98300A9A9AF /* WCEvent.swift */; }; 18 | BB47677C236BB98400A9A9AF /* WCSessionModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47675F236BB98300A9A9AF /* WCSessionModels.swift */; }; 19 | BB47677D236BB98400A9A9AF /* WCPeerMeta.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476760236BB98300A9A9AF /* WCPeerMeta.swift */; }; 20 | BB47677E236BB98400A9A9AF /* WCSocketMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476761236BB98300A9A9AF /* WCSocketMessage.swift */; }; 21 | BB47677F236BB98400A9A9AF /* WCTrustAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476763236BB98300A9A9AF /* WCTrustAccount.swift */; }; 22 | BB476780236BB98400A9A9AF /* WCTrustTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476764236BB98300A9A9AF /* WCTrustTransaction.swift */; }; 23 | BB476781236BB98400A9A9AF /* WCEthereumSignPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476766236BB98300A9A9AF /* WCEthereumSignPayload.swift */; }; 24 | BB476782236BB98400A9A9AF /* WCEthereumTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476767236BB98300A9A9AF /* WCEthereumTransaction.swift */; }; 25 | BB476783236BB98400A9A9AF /* WCBinanceTradePair.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476769236BB98300A9A9AF /* WCBinanceTradePair.swift */; }; 26 | BB476784236BB98400A9A9AF /* WCBinanceCancelOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47676A236BB98300A9A9AF /* WCBinanceCancelOrder.swift */; }; 27 | BB476785236BB98400A9A9AF /* WCBinanceOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47676B236BB98300A9A9AF /* WCBinanceOrder.swift */; }; 28 | BB476786236BB98400A9A9AF /* WCBinanceTradeOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47676C236BB98300A9A9AF /* WCBinanceTradeOrder.swift */; }; 29 | BB476787236BB98400A9A9AF /* WCBinanceTransferOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47676D236BB98300A9A9AF /* WCBinanceTransferOrder.swift */; }; 30 | BB476788236BB98400A9A9AF /* Data+Hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB47676F236BB98300A9A9AF /* Data+Hex.swift */; }; 31 | BB476789236BB98400A9A9AF /* Encodable+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476770236BB98300A9A9AF /* Encodable+Extension.swift */; }; 32 | BB47678A236BB98400A9A9AF /* WCLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476771236BB98300A9A9AF /* WCLog.swift */; }; 33 | BB47678B236BB98400A9A9AF /* WCSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476772236BB98300A9A9AF /* WCSession.swift */; }; 34 | BB47678C236BB98400A9A9AF /* WCEncryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476773236BB98300A9A9AF /* WCEncryptor.swift */; }; 35 | BB47678D236BB98400A9A9AF /* WCError.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB476774236BB98300A9A9AF /* WCError.swift */; }; 36 | BB476792236BCCC300A9A9AF /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB47678F236BCCC300A9A9AF /* Starscream.framework */; }; 37 | BB476794236BCCC300A9A9AF /* PromiseKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB476790236BCCC300A9A9AF /* PromiseKit.framework */; }; 38 | BB476796236BCCC300A9A9AF /* CryptoSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB476791236BCCC300A9A9AF /* CryptoSwift.framework */; }; 39 | /* End PBXBuildFile section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | BB47674A236BB93600A9A9AF /* WalletConnect.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WalletConnect.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | BB47674D236BB93600A9A9AF /* WalletConnect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WalletConnect.h; sourceTree = ""; }; 44 | BB47674E236BB93600A9A9AF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | BB476755236BB98300A9A9AF /* WCInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCInteractor.swift; sourceTree = ""; }; 46 | BB476757236BB98300A9A9AF /* JSONRPC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONRPC.swift; sourceTree = ""; }; 47 | BB476758236BB98300A9A9AF /* WCSessionStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCSessionStore.swift; sourceTree = ""; }; 48 | BB47675A236BB98300A9A9AF /* WCBinanceInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCBinanceInteractor.swift; sourceTree = ""; }; 49 | BB47675B236BB98300A9A9AF /* WCTrustInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCTrustInteractor.swift; sourceTree = ""; }; 50 | BB47675C236BB98300A9A9AF /* WCEthereumInteractor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCEthereumInteractor.swift; sourceTree = ""; }; 51 | BB47675E236BB98300A9A9AF /* WCEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCEvent.swift; sourceTree = ""; }; 52 | BB47675F236BB98300A9A9AF /* WCSessionModels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCSessionModels.swift; sourceTree = ""; }; 53 | BB476760236BB98300A9A9AF /* WCPeerMeta.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCPeerMeta.swift; sourceTree = ""; }; 54 | BB476761236BB98300A9A9AF /* WCSocketMessage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCSocketMessage.swift; sourceTree = ""; }; 55 | BB476763236BB98300A9A9AF /* WCTrustAccount.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCTrustAccount.swift; sourceTree = ""; }; 56 | BB476764236BB98300A9A9AF /* WCTrustTransaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCTrustTransaction.swift; sourceTree = ""; }; 57 | BB476766236BB98300A9A9AF /* WCEthereumSignPayload.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCEthereumSignPayload.swift; sourceTree = ""; }; 58 | BB476767236BB98300A9A9AF /* WCEthereumTransaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCEthereumTransaction.swift; sourceTree = ""; }; 59 | BB476769236BB98300A9A9AF /* WCBinanceTradePair.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCBinanceTradePair.swift; sourceTree = ""; }; 60 | BB47676A236BB98300A9A9AF /* WCBinanceCancelOrder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCBinanceCancelOrder.swift; sourceTree = ""; }; 61 | BB47676B236BB98300A9A9AF /* WCBinanceOrder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCBinanceOrder.swift; sourceTree = ""; }; 62 | BB47676C236BB98300A9A9AF /* WCBinanceTradeOrder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCBinanceTradeOrder.swift; sourceTree = ""; }; 63 | BB47676D236BB98300A9A9AF /* WCBinanceTransferOrder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCBinanceTransferOrder.swift; sourceTree = ""; }; 64 | BB47676F236BB98300A9A9AF /* Data+Hex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Data+Hex.swift"; sourceTree = ""; }; 65 | BB476770236BB98300A9A9AF /* Encodable+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Encodable+Extension.swift"; sourceTree = ""; }; 66 | BB476771236BB98300A9A9AF /* WCLog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCLog.swift; sourceTree = ""; }; 67 | BB476772236BB98300A9A9AF /* WCSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCSession.swift; sourceTree = ""; }; 68 | BB476773236BB98300A9A9AF /* WCEncryptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCEncryptor.swift; sourceTree = ""; }; 69 | BB476774236BB98300A9A9AF /* WCError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WCError.swift; sourceTree = ""; }; 70 | BB47678F236BCCC300A9A9AF /* Starscream.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Starscream.framework; path = Carthage/Build/iOS/Starscream.framework; sourceTree = ""; }; 71 | BB476790236BCCC300A9A9AF /* PromiseKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PromiseKit.framework; path = Carthage/Build/iOS/PromiseKit.framework; sourceTree = ""; }; 72 | BB476791236BCCC300A9A9AF /* CryptoSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CryptoSwift.framework; path = Carthage/Build/iOS/CryptoSwift.framework; sourceTree = ""; }; 73 | BB476799236BD18100A9A9AF /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; 74 | BB4767E9236BFDF800A9A9AF /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 75 | /* End PBXFileReference section */ 76 | 77 | /* Begin PBXFrameworksBuildPhase section */ 78 | BB476747236BB93600A9A9AF /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | BB476796236BCCC300A9A9AF /* CryptoSwift.framework in Frameworks */, 83 | BB476792236BCCC300A9A9AF /* Starscream.framework in Frameworks */, 84 | BB476794236BCCC300A9A9AF /* PromiseKit.framework in Frameworks */, 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | /* End PBXFrameworksBuildPhase section */ 89 | 90 | /* Begin PBXGroup section */ 91 | BB476740236BB93600A9A9AF = { 92 | isa = PBXGroup; 93 | children = ( 94 | BB4767E9236BFDF800A9A9AF /* README.md */, 95 | BB476799236BD18100A9A9AF /* Package.swift */, 96 | BB47674C236BB93600A9A9AF /* WalletConnect */, 97 | BB47674B236BB93600A9A9AF /* Products */, 98 | BB47678E236BCCC200A9A9AF /* Frameworks */, 99 | ); 100 | sourceTree = ""; 101 | }; 102 | BB47674B236BB93600A9A9AF /* Products */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | BB47674A236BB93600A9A9AF /* WalletConnect.framework */, 106 | ); 107 | name = Products; 108 | sourceTree = ""; 109 | }; 110 | BB47674C236BB93600A9A9AF /* WalletConnect */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | BB47676E236BB98300A9A9AF /* Extensions */, 114 | BB476756236BB98300A9A9AF /* JSONRPC */, 115 | BB47675D236BB98300A9A9AF /* Models */, 116 | BB476759236BB98300A9A9AF /* SubInteractor */, 117 | BB476773236BB98300A9A9AF /* WCEncryptor.swift */, 118 | BB476774236BB98300A9A9AF /* WCError.swift */, 119 | BB476755236BB98300A9A9AF /* WCInteractor.swift */, 120 | BB476771236BB98300A9A9AF /* WCLog.swift */, 121 | BB476772236BB98300A9A9AF /* WCSession.swift */, 122 | BB476758236BB98300A9A9AF /* WCSessionStore.swift */, 123 | BB47674D236BB93600A9A9AF /* WalletConnect.h */, 124 | BB47674E236BB93600A9A9AF /* Info.plist */, 125 | ); 126 | path = WalletConnect; 127 | sourceTree = ""; 128 | }; 129 | BB476756236BB98300A9A9AF /* JSONRPC */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | BB476757236BB98300A9A9AF /* JSONRPC.swift */, 133 | ); 134 | path = JSONRPC; 135 | sourceTree = ""; 136 | }; 137 | BB476759236BB98300A9A9AF /* SubInteractor */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | BB47675A236BB98300A9A9AF /* WCBinanceInteractor.swift */, 141 | BB47675B236BB98300A9A9AF /* WCTrustInteractor.swift */, 142 | BB47675C236BB98300A9A9AF /* WCEthereumInteractor.swift */, 143 | ); 144 | path = SubInteractor; 145 | sourceTree = ""; 146 | }; 147 | BB47675D236BB98300A9A9AF /* Models */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | BB47675E236BB98300A9A9AF /* WCEvent.swift */, 151 | BB47675F236BB98300A9A9AF /* WCSessionModels.swift */, 152 | BB476760236BB98300A9A9AF /* WCPeerMeta.swift */, 153 | BB476761236BB98300A9A9AF /* WCSocketMessage.swift */, 154 | BB476762236BB98300A9A9AF /* Trust */, 155 | BB476765236BB98300A9A9AF /* Ethereum */, 156 | BB476768236BB98300A9A9AF /* Binance */, 157 | ); 158 | path = Models; 159 | sourceTree = ""; 160 | }; 161 | BB476762236BB98300A9A9AF /* Trust */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | BB476763236BB98300A9A9AF /* WCTrustAccount.swift */, 165 | BB476764236BB98300A9A9AF /* WCTrustTransaction.swift */, 166 | ); 167 | path = Trust; 168 | sourceTree = ""; 169 | }; 170 | BB476765236BB98300A9A9AF /* Ethereum */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | BB476766236BB98300A9A9AF /* WCEthereumSignPayload.swift */, 174 | BB476767236BB98300A9A9AF /* WCEthereumTransaction.swift */, 175 | ); 176 | path = Ethereum; 177 | sourceTree = ""; 178 | }; 179 | BB476768236BB98300A9A9AF /* Binance */ = { 180 | isa = PBXGroup; 181 | children = ( 182 | BB476769236BB98300A9A9AF /* WCBinanceTradePair.swift */, 183 | BB47676A236BB98300A9A9AF /* WCBinanceCancelOrder.swift */, 184 | BB47676B236BB98300A9A9AF /* WCBinanceOrder.swift */, 185 | BB47676C236BB98300A9A9AF /* WCBinanceTradeOrder.swift */, 186 | BB47676D236BB98300A9A9AF /* WCBinanceTransferOrder.swift */, 187 | ); 188 | path = Binance; 189 | sourceTree = ""; 190 | }; 191 | BB47676E236BB98300A9A9AF /* Extensions */ = { 192 | isa = PBXGroup; 193 | children = ( 194 | BB47676F236BB98300A9A9AF /* Data+Hex.swift */, 195 | BB476770236BB98300A9A9AF /* Encodable+Extension.swift */, 196 | ); 197 | path = Extensions; 198 | sourceTree = ""; 199 | }; 200 | BB47678E236BCCC200A9A9AF /* Frameworks */ = { 201 | isa = PBXGroup; 202 | children = ( 203 | BB476791236BCCC300A9A9AF /* CryptoSwift.framework */, 204 | BB476790236BCCC300A9A9AF /* PromiseKit.framework */, 205 | BB47678F236BCCC300A9A9AF /* Starscream.framework */, 206 | ); 207 | name = Frameworks; 208 | sourceTree = ""; 209 | }; 210 | /* End PBXGroup section */ 211 | 212 | /* Begin PBXHeadersBuildPhase section */ 213 | BB476745236BB93600A9A9AF /* Headers */ = { 214 | isa = PBXHeadersBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | BB47674F236BB93600A9A9AF /* WalletConnect.h in Headers */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | /* End PBXHeadersBuildPhase section */ 222 | 223 | /* Begin PBXNativeTarget section */ 224 | BB476749236BB93600A9A9AF /* WalletConnect */ = { 225 | isa = PBXNativeTarget; 226 | buildConfigurationList = BB476752236BB93600A9A9AF /* Build configuration list for PBXNativeTarget "WalletConnect" */; 227 | buildPhases = ( 228 | BB476745236BB93600A9A9AF /* Headers */, 229 | BB476746236BB93600A9A9AF /* Sources */, 230 | BB476747236BB93600A9A9AF /* Frameworks */, 231 | BB476748236BB93600A9A9AF /* Resources */, 232 | ); 233 | buildRules = ( 234 | ); 235 | dependencies = ( 236 | ); 237 | name = WalletConnect; 238 | productName = WalletConnect; 239 | productReference = BB47674A236BB93600A9A9AF /* WalletConnect.framework */; 240 | productType = "com.apple.product-type.framework"; 241 | }; 242 | /* End PBXNativeTarget section */ 243 | 244 | /* Begin PBXProject section */ 245 | BB476741236BB93600A9A9AF /* Project object */ = { 246 | isa = PBXProject; 247 | attributes = { 248 | LastUpgradeCheck = 1110; 249 | ORGANIZATIONNAME = "Trust Wallet"; 250 | TargetAttributes = { 251 | BB476749236BB93600A9A9AF = { 252 | CreatedOnToolsVersion = 11.1; 253 | LastSwiftMigration = 1110; 254 | }; 255 | }; 256 | }; 257 | buildConfigurationList = BB476744236BB93600A9A9AF /* Build configuration list for PBXProject "WalletConnect" */; 258 | compatibilityVersion = "Xcode 9.3"; 259 | developmentRegion = en; 260 | hasScannedForEncodings = 0; 261 | knownRegions = ( 262 | en, 263 | Base, 264 | ); 265 | mainGroup = BB476740236BB93600A9A9AF; 266 | productRefGroup = BB47674B236BB93600A9A9AF /* Products */; 267 | projectDirPath = ""; 268 | projectRoot = ""; 269 | targets = ( 270 | BB476749236BB93600A9A9AF /* WalletConnect */, 271 | ); 272 | }; 273 | /* End PBXProject section */ 274 | 275 | /* Begin PBXResourcesBuildPhase section */ 276 | BB476748236BB93600A9A9AF /* Resources */ = { 277 | isa = PBXResourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXResourcesBuildPhase section */ 284 | 285 | /* Begin PBXSourcesBuildPhase section */ 286 | BB476746236BB93600A9A9AF /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | BB47677E236BB98400A9A9AF /* WCSocketMessage.swift in Sources */, 291 | BB476784236BB98400A9A9AF /* WCBinanceCancelOrder.swift in Sources */, 292 | BB476780236BB98400A9A9AF /* WCTrustTransaction.swift in Sources */, 293 | BB47677D236BB98400A9A9AF /* WCPeerMeta.swift in Sources */, 294 | BB47678C236BB98400A9A9AF /* WCEncryptor.swift in Sources */, 295 | BB476787236BB98400A9A9AF /* WCBinanceTransferOrder.swift in Sources */, 296 | BB476786236BB98400A9A9AF /* WCBinanceTradeOrder.swift in Sources */, 297 | BB476781236BB98400A9A9AF /* WCEthereumSignPayload.swift in Sources */, 298 | BB476785236BB98400A9A9AF /* WCBinanceOrder.swift in Sources */, 299 | BB47678B236BB98400A9A9AF /* WCSession.swift in Sources */, 300 | BB476775236BB98400A9A9AF /* WCInteractor.swift in Sources */, 301 | BB476783236BB98400A9A9AF /* WCBinanceTradePair.swift in Sources */, 302 | BB47677B236BB98400A9A9AF /* WCEvent.swift in Sources */, 303 | BB476788236BB98400A9A9AF /* Data+Hex.swift in Sources */, 304 | BB47677C236BB98400A9A9AF /* WCSessionModels.swift in Sources */, 305 | BB476782236BB98400A9A9AF /* WCEthereumTransaction.swift in Sources */, 306 | BB47677F236BB98400A9A9AF /* WCTrustAccount.swift in Sources */, 307 | BB47677A236BB98400A9A9AF /* WCEthereumInteractor.swift in Sources */, 308 | BB476779236BB98400A9A9AF /* WCTrustInteractor.swift in Sources */, 309 | BB476789236BB98400A9A9AF /* Encodable+Extension.swift in Sources */, 310 | BB476778236BB98400A9A9AF /* WCBinanceInteractor.swift in Sources */, 311 | BB476777236BB98400A9A9AF /* WCSessionStore.swift in Sources */, 312 | BB47678A236BB98400A9A9AF /* WCLog.swift in Sources */, 313 | BB47678D236BB98400A9A9AF /* WCError.swift in Sources */, 314 | BB476776236BB98400A9A9AF /* JSONRPC.swift in Sources */, 315 | ); 316 | runOnlyForDeploymentPostprocessing = 0; 317 | }; 318 | /* End PBXSourcesBuildPhase section */ 319 | 320 | /* Begin XCBuildConfiguration section */ 321 | BB476750236BB93600A9A9AF /* Debug */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 327 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 328 | CLANG_CXX_LIBRARY = "libc++"; 329 | CLANG_ENABLE_MODULES = YES; 330 | CLANG_ENABLE_OBJC_ARC = YES; 331 | CLANG_ENABLE_OBJC_WEAK = YES; 332 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 333 | CLANG_WARN_BOOL_CONVERSION = YES; 334 | CLANG_WARN_COMMA = YES; 335 | CLANG_WARN_CONSTANT_CONVERSION = YES; 336 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 339 | CLANG_WARN_EMPTY_BODY = YES; 340 | CLANG_WARN_ENUM_CONVERSION = YES; 341 | CLANG_WARN_INFINITE_RECURSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 345 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 346 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 347 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 348 | CLANG_WARN_STRICT_PROTOTYPES = YES; 349 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 350 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | COPY_PHASE_STRIP = NO; 354 | CURRENT_PROJECT_VERSION = 1; 355 | DEBUG_INFORMATION_FORMAT = dwarf; 356 | ENABLE_STRICT_OBJC_MSGSEND = YES; 357 | ENABLE_TESTABILITY = YES; 358 | GCC_C_LANGUAGE_STANDARD = gnu11; 359 | GCC_DYNAMIC_NO_PIC = NO; 360 | GCC_NO_COMMON_BLOCKS = YES; 361 | GCC_OPTIMIZATION_LEVEL = 0; 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 367 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 368 | GCC_WARN_UNDECLARED_SELECTOR = YES; 369 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 370 | GCC_WARN_UNUSED_FUNCTION = YES; 371 | GCC_WARN_UNUSED_VARIABLE = YES; 372 | IPHONEOS_DEPLOYMENT_TARGET = 13.1; 373 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 374 | MTL_FAST_MATH = YES; 375 | ONLY_ACTIVE_ARCH = YES; 376 | SDKROOT = iphoneos; 377 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 378 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 379 | VERSIONING_SYSTEM = "apple-generic"; 380 | VERSION_INFO_PREFIX = ""; 381 | }; 382 | name = Debug; 383 | }; 384 | BB476751236BB93600A9A9AF /* Release */ = { 385 | isa = XCBuildConfiguration; 386 | buildSettings = { 387 | ALWAYS_SEARCH_USER_PATHS = NO; 388 | CLANG_ANALYZER_NONNULL = YES; 389 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 390 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 391 | CLANG_CXX_LIBRARY = "libc++"; 392 | CLANG_ENABLE_MODULES = YES; 393 | CLANG_ENABLE_OBJC_ARC = YES; 394 | CLANG_ENABLE_OBJC_WEAK = YES; 395 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 396 | CLANG_WARN_BOOL_CONVERSION = YES; 397 | CLANG_WARN_COMMA = YES; 398 | CLANG_WARN_CONSTANT_CONVERSION = YES; 399 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 400 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 401 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INFINITE_RECURSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 407 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 408 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 409 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 410 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 411 | CLANG_WARN_STRICT_PROTOTYPES = YES; 412 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 413 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 414 | CLANG_WARN_UNREACHABLE_CODE = YES; 415 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 416 | COPY_PHASE_STRIP = NO; 417 | CURRENT_PROJECT_VERSION = 1; 418 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 419 | ENABLE_NS_ASSERTIONS = NO; 420 | ENABLE_STRICT_OBJC_MSGSEND = YES; 421 | GCC_C_LANGUAGE_STANDARD = gnu11; 422 | GCC_NO_COMMON_BLOCKS = YES; 423 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 424 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 425 | GCC_WARN_UNDECLARED_SELECTOR = YES; 426 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 427 | GCC_WARN_UNUSED_FUNCTION = YES; 428 | GCC_WARN_UNUSED_VARIABLE = YES; 429 | IPHONEOS_DEPLOYMENT_TARGET = 13.1; 430 | MTL_ENABLE_DEBUG_INFO = NO; 431 | MTL_FAST_MATH = YES; 432 | SDKROOT = iphoneos; 433 | SWIFT_COMPILATION_MODE = wholemodule; 434 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 435 | VALIDATE_PRODUCT = YES; 436 | VERSIONING_SYSTEM = "apple-generic"; 437 | VERSION_INFO_PREFIX = ""; 438 | }; 439 | name = Release; 440 | }; 441 | BB476753236BB93600A9A9AF /* Debug */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | BUILD_LIBRARY_FOR_DISTRIBUTION = NO; 445 | CLANG_ENABLE_MODULES = YES; 446 | CODE_SIGN_STYLE = Automatic; 447 | DEFINES_MODULE = YES; 448 | DYLIB_COMPATIBILITY_VERSION = 1; 449 | DYLIB_CURRENT_VERSION = 1; 450 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 451 | FRAMEWORK_SEARCH_PATHS = ( 452 | "$(inherited)", 453 | "$(PROJECT_DIR)/Carthage/Build/iOS", 454 | ); 455 | INFOPLIST_FILE = WalletConnect/Info.plist; 456 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 457 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 458 | LD_RUNPATH_SEARCH_PATHS = ( 459 | "$(inherited)", 460 | "@executable_path/Frameworks", 461 | "@loader_path/Frameworks", 462 | ); 463 | PRODUCT_BUNDLE_IDENTIFIER = com.trustwallet.WalletConnect; 464 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 465 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 466 | SWIFT_VERSION = 5.0; 467 | TARGETED_DEVICE_FAMILY = "1,2"; 468 | }; 469 | name = Debug; 470 | }; 471 | BB476754236BB93600A9A9AF /* Release */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | BUILD_LIBRARY_FOR_DISTRIBUTION = NO; 475 | CLANG_ENABLE_MODULES = YES; 476 | CODE_SIGN_STYLE = Automatic; 477 | DEFINES_MODULE = YES; 478 | DYLIB_COMPATIBILITY_VERSION = 1; 479 | DYLIB_CURRENT_VERSION = 1; 480 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 481 | FRAMEWORK_SEARCH_PATHS = ( 482 | "$(inherited)", 483 | "$(PROJECT_DIR)/Carthage/Build/iOS", 484 | ); 485 | INFOPLIST_FILE = WalletConnect/Info.plist; 486 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 487 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 488 | LD_RUNPATH_SEARCH_PATHS = ( 489 | "$(inherited)", 490 | "@executable_path/Frameworks", 491 | "@loader_path/Frameworks", 492 | ); 493 | PRODUCT_BUNDLE_IDENTIFIER = com.trustwallet.WalletConnect; 494 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 495 | SWIFT_VERSION = 5.0; 496 | TARGETED_DEVICE_FAMILY = "1,2"; 497 | }; 498 | name = Release; 499 | }; 500 | /* End XCBuildConfiguration section */ 501 | 502 | /* Begin XCConfigurationList section */ 503 | BB476744236BB93600A9A9AF /* Build configuration list for PBXProject "WalletConnect" */ = { 504 | isa = XCConfigurationList; 505 | buildConfigurations = ( 506 | BB476750236BB93600A9A9AF /* Debug */, 507 | BB476751236BB93600A9A9AF /* Release */, 508 | ); 509 | defaultConfigurationIsVisible = 0; 510 | defaultConfigurationName = Release; 511 | }; 512 | BB476752236BB93600A9A9AF /* Build configuration list for PBXNativeTarget "WalletConnect" */ = { 513 | isa = XCConfigurationList; 514 | buildConfigurations = ( 515 | BB476753236BB93600A9A9AF /* Debug */, 516 | BB476754236BB93600A9A9AF /* Release */, 517 | ); 518 | defaultConfigurationIsVisible = 0; 519 | defaultConfigurationName = Release; 520 | }; 521 | /* End XCConfigurationList section */ 522 | }; 523 | rootObject = BB476741236BB93600A9A9AF /* Project object */; 524 | } 525 | -------------------------------------------------------------------------------- /WalletConnect.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WalletConnect.xcodeproj/xcshareddata/xcschemes/WalletConnect.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 57 | 58 | 59 | 60 | 62 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /WalletConnect/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WalletConnect/wallet-connect-swift/d4d45e1d94a2b96fb5c2831a1e9d23390f5ac09e/WalletConnect/Assets/.gitkeep -------------------------------------------------------------------------------- /WalletConnect/Extensions/Data+Hex.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | import CryptoSwift 9 | 10 | extension Data { 11 | var hex: String { 12 | return self.toHexString() 13 | } 14 | } 15 | 16 | extension JSONEncoder { 17 | func encodeAsUTF8(_ value: T) -> String where T : Encodable { 18 | guard let data = try? self.encode(value), 19 | let string = String(data: data, encoding: .utf8) else { 20 | return "" 21 | } 22 | return string 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /WalletConnect/Extensions/Encodable+Extension.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | extension Encodable { 10 | public var encoded: Data { 11 | let encoder = JSONEncoder() 12 | encoder.outputFormatting = [.sortedKeys] 13 | return try! encoder.encode(self) 14 | } 15 | public var encodedString: String { 16 | return String(data: encoded, encoding: .utf8)! 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /WalletConnect/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /WalletConnect/JSONRPC/JSONRPC.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | let JSONRPCVersion = "2.0" 10 | 11 | struct JSONRPCError: Error, Codable { 12 | let code: Int 13 | let message: String 14 | } 15 | 16 | struct JSONRPCRequest: Codable { 17 | let id: Int64 18 | let jsonrpc = JSONRPCVersion 19 | let method: String 20 | let params: T 21 | } 22 | 23 | struct JSONRPCResponse: Codable { 24 | let jsonrpc = JSONRPCVersion 25 | let id: Int64 26 | let result: T 27 | 28 | enum CodingKeys: String, CodingKey { 29 | case jsonrpc 30 | case id 31 | case result 32 | case error 33 | } 34 | 35 | init(id: Int64, result: T) { 36 | self.id = id 37 | self.result = result 38 | } 39 | } 40 | 41 | struct JSONRPCErrorResponse: Codable { 42 | let jsonrpc = JSONRPCVersion 43 | let id: Int64 44 | let error: JSONRPCError 45 | } 46 | 47 | extension JSONRPCResponse { 48 | func encode(to encoder: Encoder) throws { 49 | var container = encoder.container(keyedBy: CodingKeys.self) 50 | try container.encode(id, forKey: .id) 51 | try container.encode(jsonrpc, forKey: .jsonrpc) 52 | try container.encode(result, forKey: .result) 53 | } 54 | 55 | init(from decoder: Decoder) throws { 56 | let values = try decoder.container(keyedBy: CodingKeys.self) 57 | if let error = try values.decodeIfPresent(JSONRPCError.self, forKey: .error) { 58 | throw error 59 | } 60 | self.id = try values.decode(Int64.self, forKey: .id) 61 | self.result = try values.decode(T.self, forKey: .result) 62 | } 63 | } 64 | 65 | public func generateId() -> Int64 { 66 | return Int64(Date().timeIntervalSince1970) * 1000 67 | } 68 | -------------------------------------------------------------------------------- /WalletConnect/Models/Binance/WCBinanceCancelOrder.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCBinanceCancelOrder: WCBinanceOrderMessage, Codable { 10 | public struct Message: Codable { 11 | public let refid: String 12 | public let sender: String 13 | public let symbol: String 14 | } 15 | public let account_number: String 16 | public let chain_id: String 17 | public let data: String? 18 | public let memo: String 19 | public let msgs: [Message] 20 | public let sequence: String 21 | public let source: String 22 | 23 | public func encode(to encoder: Encoder) throws { 24 | var container = encoder.container(keyedBy: CodingKeys.self) 25 | try container.encode(account_number, forKey: .account_number) 26 | try container.encode(chain_id, forKey: .chain_id) 27 | try container.encode(data, forKey: .data) 28 | try container.encode(memo, forKey: .memo) 29 | try container.encode(msgs, forKey: .msgs) 30 | try container.encode(sequence, forKey: .sequence) 31 | try container.encode(source, forKey: .source) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /WalletConnect/Models/Binance/WCBinanceOrder.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public protocol WCBinanceOrder { 10 | var encoded: Data { get } 11 | var encodedString: String { get } 12 | } 13 | 14 | public protocol WCBinanceOrderMessage: WCBinanceOrder { 15 | associatedtype Message 16 | var account_number: String { get } 17 | var chain_id: String { get } 18 | var data: String? { get } 19 | var memo: String { get } 20 | var msgs: [Message] { get } 21 | var sequence: String { get } 22 | var source: String { get } 23 | } 24 | 25 | public struct WCBinanceOrderSignature: Codable { 26 | public let signature: String 27 | public let publicKey: String 28 | 29 | public init(signature: String, publicKey: String) { 30 | self.signature = signature 31 | self.publicKey = publicKey 32 | } 33 | } 34 | 35 | public struct WCBinanceTxConfirmParam: Codable { 36 | public let ok: Bool 37 | public let errorMsg: String? 38 | } 39 | -------------------------------------------------------------------------------- /WalletConnect/Models/Binance/WCBinanceTradeOrder.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCBinanceTradeOrder: WCBinanceOrderMessage, Codable { 10 | public struct Message: Codable { 11 | public let id: String 12 | public let ordertype: Int 13 | public let price: Int 14 | public let quantity: Int64 15 | public let sender: String 16 | public let side: Int 17 | public let symbol: String 18 | public let timeinforce: Int 19 | } 20 | public let account_number: String 21 | public let chain_id: String 22 | public let data: String? 23 | public let memo: String 24 | public let msgs: [Message] 25 | public let sequence: String 26 | public let source: String 27 | 28 | public func encode(to encoder: Encoder) throws { 29 | var container = encoder.container(keyedBy: CodingKeys.self) 30 | try container.encode(account_number, forKey: .account_number) 31 | try container.encode(chain_id, forKey: .chain_id) 32 | try container.encode(data, forKey: .data) 33 | try container.encode(memo, forKey: .memo) 34 | try container.encode(msgs, forKey: .msgs) 35 | try container.encode(sequence, forKey: .sequence) 36 | try container.encode(source, forKey: .source) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WalletConnect/Models/Binance/WCBinanceTradePair.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCBinanceTradePair { 10 | public let from: String 11 | public let to: String 12 | 13 | public static func from(_ symbol: String) -> WCBinanceTradePair? { 14 | let pair = symbol.split(separator: "_") 15 | guard pair.count > 1 else { return nil } 16 | let first_parts = pair[0].split(separator: "-") 17 | let second_parts = pair[1].split(separator: "-") 18 | return WCBinanceTradePair(from: String(first_parts[0]), to: String(second_parts[0])) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /WalletConnect/Models/Binance/WCBinanceTransferOrder.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCBinanceTransferOrder: WCBinanceOrderMessage, Codable { 10 | public struct Message: Codable { 11 | public struct Coin: Codable { 12 | public let amount: Int64 13 | public let denom: String 14 | } 15 | public struct Item: Codable { 16 | public let address: String 17 | public let coins: [Coin] 18 | } 19 | public let inputs: [Item] 20 | public let outputs: [Item] 21 | } 22 | 23 | public let account_number: String 24 | public let chain_id: String 25 | public let data: String? 26 | public let memo: String 27 | public let msgs: [Message] 28 | public let sequence: String 29 | public let source: String 30 | 31 | public func encode(to encoder: Encoder) throws { 32 | var container = encoder.container(keyedBy: CodingKeys.self) 33 | try container.encode(account_number, forKey: .account_number) 34 | try container.encode(chain_id, forKey: .chain_id) 35 | try container.encode(data, forKey: .data) 36 | try container.encode(memo, forKey: .memo) 37 | try container.encode(msgs, forKey: .msgs) 38 | try container.encode(sequence, forKey: .sequence) 39 | try container.encode(source, forKey: .source) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /WalletConnect/Models/Ethereum/AnyDecodable.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | import Foundation 7 | 8 | public struct AnyDecodable: Decodable { 9 | public var value: Any 10 | 11 | private struct CodingKeys: CodingKey { 12 | var stringValue: String 13 | var intValue: Int? 14 | init?(intValue: Int) { 15 | self.stringValue = "\(intValue)" 16 | self.intValue = intValue 17 | } 18 | init?(stringValue: String) { 19 | self.stringValue = stringValue 20 | } 21 | } 22 | 23 | public init(from decoder: Decoder) throws { 24 | if let container = try? decoder.container(keyedBy: CodingKeys.self) { 25 | var result = [String: Any]() 26 | try container.allKeys.forEach { (key) throws in 27 | result[key.stringValue] = try container.decode(AnyDecodable.self, forKey: key).value 28 | } 29 | value = result 30 | } else if var container = try? decoder.unkeyedContainer() { 31 | var result = [Any]() 32 | while !container.isAtEnd { 33 | result.append(try container.decode(AnyDecodable.self).value) 34 | } 35 | value = result 36 | } else if let container = try? decoder.singleValueContainer() { 37 | if let intVal = try? container.decode(Int.self) { 38 | value = intVal 39 | } else if let doubleVal = try? container.decode(Double.self) { 40 | value = doubleVal 41 | } else if let boolVal = try? container.decode(Bool.self) { 42 | value = boolVal 43 | } else if let stringVal = try? container.decode(String.self) { 44 | value = stringVal 45 | } else if container.decodeNil() { 46 | value = NSNull() 47 | } else { 48 | throw DecodingError.dataCorruptedError(in: container, debugDescription: "the container contains nothing decodable") 49 | } 50 | } else { 51 | throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Could not decode")) 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /WalletConnect/Models/Ethereum/WCEthereumSignPayload.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public enum WCEthereumSignPayload { 10 | case sign(data: Data, raw: [String]) 11 | case personalSign(data: Data, raw: [String]) 12 | case signTypeData(id: Int64, data: Data, raw: [String]) 13 | } 14 | 15 | extension WCEthereumSignPayload: Decodable { 16 | private enum Method: String, Decodable { 17 | case eth_sign 18 | case personal_sign 19 | case eth_signTypedData 20 | } 21 | 22 | private enum CodingKeys: String, CodingKey { 23 | case id 24 | case method 25 | case params 26 | } 27 | 28 | public init(from decoder: Decoder) throws { 29 | let container = try decoder.container(keyedBy: CodingKeys.self) 30 | let method = try container.decode(Method.self, forKey: .method) 31 | let params = try container.decode([AnyDecodable].self, forKey: .params) 32 | guard params.count > 1 else { throw WCError.badJSONRPCRequest } 33 | let strings = params.compactMap { $0.value as? String } 34 | switch method { 35 | case .eth_sign: 36 | self = .sign(data: Data(hex: strings[1]), raw: strings) 37 | case .personal_sign: 38 | self = .personalSign(data: Data(hex: strings[0]), raw: strings) 39 | case .eth_signTypedData: 40 | let id = try container.decode(Int64.self, forKey: .id) 41 | let address = params[0].value as? String ?? "" 42 | if let string = params[1].value as? String, 43 | let data = string.data(using: .utf8) { 44 | self = .signTypeData(id: id, data: data, raw: [address, string]) 45 | } else if let dict = params[1].value as? [String: Any] { 46 | let data = try JSONSerialization.data(withJSONObject: dict, options: []) 47 | let json = String(data: data, encoding: .utf8) ?? "" 48 | self = .signTypeData(id: id, data: data, raw: [address, json]) 49 | } else { 50 | throw WCError.badJSONRPCRequest 51 | } 52 | } 53 | } 54 | 55 | public var method: String { 56 | switch self { 57 | case .sign: return Method.eth_sign.rawValue 58 | case .personalSign: return Method.personal_sign.rawValue 59 | case .signTypeData: return Method.eth_signTypedData.rawValue 60 | } 61 | } 62 | 63 | public var message: String { 64 | switch self { 65 | case .sign(_, let raw): 66 | return raw[1] 67 | case .personalSign(let data, let raw): 68 | return String(data: data, encoding: .utf8) ?? raw[0] 69 | case .signTypeData(_, _, let raw): 70 | return raw[1] 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /WalletConnect/Models/Ethereum/WCEthereumTransaction.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCEthereumTransaction: Codable { 10 | public let from: String 11 | public let to: String? 12 | public let nonce: String? 13 | public let gasPrice: String? 14 | public let gas: String? 15 | public let gasLimit: String? // legacy gas limit 16 | public let value: String? 17 | public let data: String 18 | } 19 | -------------------------------------------------------------------------------- /WalletConnect/Models/OKExChain/WCOKExChainTransaction.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCOKExChainTransaction: Codable { 10 | public let from: String? 11 | public let to: String? 12 | public let value: String? 13 | public let gasLimit: String? 14 | public let gasPrice: String? 15 | public let accountNumber: String? 16 | public let sequenceNumber: String? 17 | public let symbol: String? 18 | public let memo: String? 19 | public let decimalNum: String? 20 | public let contractAddress: String? 21 | public let data: String? 22 | } 23 | -------------------------------------------------------------------------------- /WalletConnect/Models/Trust/WCTrustAccount.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCTrustAccount: Codable { 10 | public let network: UInt32 11 | public let address: String 12 | 13 | public init(network: UInt32, address: String) { 14 | self.network = network 15 | self.address = address 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WalletConnect/Models/Trust/WCTrustTransaction.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCTrustTransaction: Codable { 10 | public let network: UInt32 11 | public let transaction: String 12 | 13 | public init(network: UInt32, transaction: String) { 14 | self.network = network 15 | self.transaction = transaction 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WalletConnect/Models/WCEvent.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public enum WCEvent: String { 10 | case sessionRequest = "wc_sessionRequest" 11 | case sessionUpdate = "wc_sessionUpdate" 12 | 13 | case ethSign = "eth_sign" 14 | case ethPersonalSign = "personal_sign" 15 | case ethSignTypeData = "eth_signTypedData" 16 | 17 | case ethSignTransaction = "eth_signTransaction" 18 | case ethSendTransaction = "eth_sendTransaction" 19 | 20 | case bnbSign = "bnb_sign" 21 | case bnbTransactionConfirm = "bnb_tx_confirmation" 22 | case trustSignTransacation = "trust_signTransaction" 23 | case getAccounts = "get_accounts" 24 | 25 | case oktSignTransaction = "okt_signTransaction" 26 | case oktSendTransaction = "okt_sendTransaction" 27 | } 28 | 29 | extension WCEvent { 30 | 31 | static let eth = Set([.ethSign, .ethPersonalSign, .ethSignTypeData, .ethSignTransaction, .ethSendTransaction]) 32 | static let bnb = Set([.bnbSign, .bnbTransactionConfirm]) 33 | static let trust = Set([.trustSignTransacation, .getAccounts]) 34 | static let okt = Set([.oktSignTransaction, .oktSendTransaction]) 35 | 36 | func decode(_ data: Data) throws -> JSONRPCRequest { 37 | return try JSONDecoder().decode(JSONRPCRequest.self, from: data) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /WalletConnect/Models/WCPeerMeta.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCPeerMeta: Codable { 10 | public let name: String 11 | public let url: String 12 | public let description: String 13 | public let icons: [String] 14 | 15 | public init(name: String, url: String, description: String = "", icons: [String] = []) { 16 | self.name = name 17 | self.url = url 18 | self.description = description 19 | self.icons = icons 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /WalletConnect/Models/WCSessionModels.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCSessionRequestParam: Codable { 10 | public let peerId: String 11 | public let peerMeta: WCPeerMeta 12 | public let chainId: Int? 13 | } 14 | 15 | public struct WCSessionUpdateParam: Codable { 16 | public let approved: Bool 17 | public let chainId: Int? 18 | public let accounts: [String]? 19 | 20 | public func encode(to encoder: Encoder) throws { 21 | var container = encoder.container(keyedBy: CodingKeys.self) 22 | try container.encode(approved, forKey: .approved) 23 | try container.encode(chainId, forKey: .chainId) 24 | try container.encode(accounts, forKey: .accounts) 25 | } 26 | } 27 | 28 | public struct WCApproveSessionResponse: Codable { 29 | public let approved: Bool 30 | public let chainId: Int 31 | public let accounts: [String] 32 | 33 | public let peerId: String? 34 | public let peerMeta: WCPeerMeta? 35 | } 36 | -------------------------------------------------------------------------------- /WalletConnect/Models/WCSocketMessage.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCEncryptionPayload: Codable { 10 | public let data: String 11 | public let hmac: String 12 | public let iv: String 13 | 14 | public init(data: String, hmac: String, iv: String) { 15 | self.data = data 16 | self.hmac = hmac 17 | self.iv = iv 18 | } 19 | } 20 | 21 | public struct WCSocketMessage: Codable { 22 | public enum MessageType: String, Codable { 23 | case pub 24 | case sub 25 | } 26 | public let topic: String 27 | public let type: MessageType 28 | public let payload: T 29 | } 30 | 31 | public extension WCEncryptionPayload { 32 | static func extract(_ string: String) -> (topic: String, payload: WCEncryptionPayload)? { 33 | guard let data = string.data(using: .utf8) else { 34 | return nil 35 | } 36 | do { 37 | let decoder = JSONDecoder() 38 | if let message = try? decoder.decode(WCSocketMessage.self, from: data) { 39 | return (message.topic, message.payload) 40 | } else { 41 | let message = try decoder.decode(WCSocketMessage.self, from: data) 42 | let payloadData = message.payload.data(using: .utf8) 43 | return (message.topic, try decoder.decode(WCEncryptionPayload.self, from: payloadData!)) 44 | } 45 | } catch let error { 46 | print(error) 47 | } 48 | return nil 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /WalletConnect/SubInteractor/WCBinanceInteractor.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | import PromiseKit 9 | 10 | public typealias BnbSignClosure = (_ id: Int64, _ order: WCBinanceOrder) -> Void 11 | 12 | public struct WCBinanceInteractor { 13 | public var onSign: BnbSignClosure? 14 | 15 | var confirmResolvers: [Int64: Resolver] = [:] 16 | 17 | mutating func handleEvent(_ event: WCEvent, topic: String, decrypted: Data) throws { 18 | switch event { 19 | case .bnbSign: 20 | if let request: JSONRPCRequest<[WCBinanceTradeOrder]> = try? event.decode(decrypted) { 21 | onSign?(request.id, request.params[0]) 22 | } else if let request: JSONRPCRequest<[WCBinanceCancelOrder]> = try? event.decode(decrypted) { 23 | onSign?(request.id, request.params[0]) 24 | } else if let request: JSONRPCRequest<[WCBinanceTransferOrder]> = try? event.decode(decrypted) { 25 | onSign?(request.id, request.params[0]) 26 | } 27 | case .bnbTransactionConfirm: 28 | let request: JSONRPCRequest<[WCBinanceTxConfirmParam]> = try event.decode(decrypted) 29 | guard !request.params.isEmpty else { throw WCError.badJSONRPCRequest } 30 | self.confirmResolvers[request.id]?.fulfill(request.params[0]) 31 | self.confirmResolvers[request.id] = nil 32 | default: 33 | break 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /WalletConnect/SubInteractor/WCEthereumInteractor.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public typealias EthSignClosure = (_ id: Int64, _ payload: WCEthereumSignPayload) -> Void 10 | public typealias EthTransactionClosure = (_ id: Int64, _ event: WCEvent, _ transaction: WCEthereumTransaction) -> Void 11 | 12 | public struct WCEthereumInteractor { 13 | public var onSign: EthSignClosure? 14 | public var onTransaction: EthTransactionClosure? 15 | 16 | func handleEvent(_ event: WCEvent, topic: String, decrypted: Data) throws { 17 | switch event { 18 | case .ethSign, .ethPersonalSign: 19 | let request: JSONRPCRequest<[String]> = try event.decode(decrypted) 20 | let payload = try JSONDecoder().decode(WCEthereumSignPayload.self, from: decrypted) 21 | onSign?(request.id, payload) 22 | case .ethSignTypeData: 23 | let payload = try JSONDecoder().decode(WCEthereumSignPayload.self, from: decrypted) 24 | guard case .signTypeData(let id, _, _) = payload else { 25 | return 26 | } 27 | onSign?(id, payload) 28 | case .ethSendTransaction, .ethSignTransaction: 29 | let request: JSONRPCRequest<[WCEthereumTransaction]> = try event.decode(decrypted) 30 | guard !request.params.isEmpty else { throw WCError.badJSONRPCRequest } 31 | onTransaction?(request.id, event, request.params[0]) 32 | default: 33 | break 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /WalletConnect/SubInteractor/WCOKExChainInteractor.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public typealias OktTransactionClosure = (_ id: Int64, _ event: WCEvent, _ transaction: WCOKExChainTransaction) -> Void 10 | 11 | public struct WCOKExChainInteractor { 12 | public var onTransaction: OktTransactionClosure? 13 | 14 | func handleEvent(_ event: WCEvent, topic: String, decrypted: Data) throws { 15 | switch event { 16 | case .oktSignTransaction, .oktSendTransaction: 17 | let request: JSONRPCRequest<[WCOKExChainTransaction]> = try event.decode(decrypted) 18 | guard !request.params.isEmpty else { throw WCError.badJSONRPCRequest } 19 | onTransaction?(request.id, event, request.params[0]) 20 | default: 21 | break 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /WalletConnect/SubInteractor/WCTrustInteractor.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public typealias TransactionSignClosure = (_ id: Int64, _ transaction: WCTrustTransaction) -> Void 10 | public typealias GetAccountsClosure = (_ id: Int64) -> Void 11 | 12 | public struct WCTrustInteractor { 13 | public var onTransactionSign: TransactionSignClosure? 14 | public var onGetAccounts: GetAccountsClosure? 15 | 16 | func handleEvent(_ event: WCEvent, topic: String, decrypted: Data) throws { 17 | switch event { 18 | case .trustSignTransacation: 19 | let request: JSONRPCRequest<[WCTrustTransaction]> = try event.decode(decrypted) 20 | guard !request.params.isEmpty else { throw WCError.badJSONRPCRequest } 21 | onTransactionSign?(request.id, request.params[0]) 22 | case .getAccounts: 23 | let request: JSONRPCRequest<[String]> = try event.decode(decrypted) 24 | onGetAccounts?(request.id) 25 | default: 26 | break 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /WalletConnect/WCEncryptor.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | import CryptoSwift 9 | import Security 10 | 11 | public struct WCEncryptor { 12 | public static func encrypt(data: Data, with key: Data) throws -> WCEncryptionPayload { 13 | let ivBytes = randomBytes(16) 14 | let keyBytes = key.bytes 15 | let aesCipher = try AES(key: keyBytes, blockMode: CBC(iv: ivBytes)) 16 | let cipherInput = data.bytes 17 | let encryptedBytes = try aesCipher.encrypt(cipherInput) 18 | 19 | let data = encryptedBytes.toHexString() 20 | let iv = ivBytes.toHexString() 21 | let hmac = try computeHMAC(payload: data, iv: iv, key: keyBytes) 22 | 23 | return WCEncryptionPayload(data: data, hmac: hmac, iv: iv) 24 | } 25 | 26 | public static func decrypt(payload: WCEncryptionPayload, with key: Data) throws -> Data { 27 | let keyBytes = key.bytes 28 | let computedHmac = try computeHMAC(payload: payload.data, iv: payload.iv, key: keyBytes) 29 | 30 | guard computedHmac == payload.hmac else { 31 | throw WCError.badServerResponse 32 | } 33 | 34 | let dataBytes = Data(hex: payload.data).bytes 35 | let ivBytes = Data(hex: payload.iv).bytes 36 | let aesCipher = try AES(key: keyBytes, blockMode: CBC(iv: ivBytes)) 37 | let decryptedBytes = try aesCipher.decrypt(dataBytes) 38 | 39 | return Data(decryptedBytes) 40 | } 41 | 42 | static func computeHMAC(payload: String, iv: String, key: [UInt8]) throws -> String { 43 | let payloadBytes = Data(hex: payload) 44 | let ivBytes = Data(hex: iv) 45 | 46 | let data = payloadBytes + ivBytes 47 | let hmacBytes = try HMAC(key: key, variant: .sha256).authenticate(data.bytes) 48 | let hmac = Data(hmacBytes).hex 49 | return hmac 50 | } 51 | 52 | static func randomBytes(_ n: Int) -> [UInt8] { 53 | var bytes = [UInt8].init(repeating: 0, count: n) 54 | let status = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes) 55 | if status != errSecSuccess { 56 | for i in 1...bytes.count { 57 | bytes[i] = UInt8(arc4random_uniform(256)) 58 | } 59 | } 60 | return bytes 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /WalletConnect/WCError.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public enum WCError: LocalizedError { 10 | case badServerResponse 11 | case badJSONRPCRequest 12 | case sessionInvalid 13 | case sessionRequestTimeout 14 | case unknown 15 | } 16 | -------------------------------------------------------------------------------- /WalletConnect/WCInteractor.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | import Starscream 9 | import PromiseKit 10 | 11 | public typealias SessionRequestClosure = (_ id: Int64, _ peerParam: WCSessionRequestParam) -> Void 12 | public typealias DisconnectClosure = (Error?) -> Void 13 | public typealias CustomRequestClosure = (_ id: Int64, _ request: [String: Any]) -> Void 14 | public typealias ErrorClosure = (Error) -> Void 15 | 16 | public enum WCInteractorState { 17 | case connected 18 | case connecting 19 | case paused 20 | case disconnected 21 | } 22 | 23 | open class WCInteractor { 24 | public let session: WCSession 25 | 26 | public private(set) var state: WCInteractorState 27 | 28 | public let clientId: String 29 | public let clientMeta: WCPeerMeta 30 | 31 | public var eth: WCEthereumInteractor 32 | public var bnb: WCBinanceInteractor 33 | public var trust: WCTrustInteractor 34 | public var okt: WCOKExChainInteractor 35 | 36 | // incoming event handlers 37 | public var onSessionRequest: SessionRequestClosure? 38 | public var onDisconnect: DisconnectClosure? 39 | public var onError: ErrorClosure? 40 | public var onCustomRequest: CustomRequestClosure? 41 | 42 | // outgoing promise resolvers 43 | private var connectResolver: Resolver? 44 | 45 | private let socket: WebSocket 46 | private var handshakeId: Int64 = -1 47 | private weak var pingTimer: Timer? 48 | private weak var sessionTimer: Timer? 49 | private let sessionRequestTimeout: TimeInterval 50 | 51 | private var peerId: String? 52 | private var peerMeta: WCPeerMeta? 53 | 54 | public init(session: WCSession, meta: WCPeerMeta, uuid: UUID, sessionRequestTimeout: TimeInterval = 20) { 55 | self.session = session 56 | self.clientId = uuid.description.lowercased() 57 | self.clientMeta = meta 58 | self.sessionRequestTimeout = sessionRequestTimeout 59 | self.state = .disconnected 60 | 61 | var request = URLRequest(url: session.bridge) 62 | request.timeoutInterval = sessionRequestTimeout 63 | self.socket = WebSocket(request: request) 64 | 65 | self.eth = WCEthereumInteractor() 66 | self.bnb = WCBinanceInteractor() 67 | self.trust = WCTrustInteractor() 68 | self.okt = WCOKExChainInteractor() 69 | 70 | socket.onConnect = { [weak self] in self?.onConnect() } 71 | socket.onDisconnect = { [weak self] error in self?.onDisconnect(error: error) } 72 | socket.onText = { [weak self] text in self?.onReceiveMessage(text: text) } 73 | socket.onPong = { _ in WCLog("<== pong") } 74 | socket.onData = { data in WCLog("<== websocketDidReceiveData: \(data.toHexString())") } 75 | } 76 | 77 | deinit { 78 | disconnect() 79 | } 80 | 81 | open func connect() -> Promise { 82 | if socket.isConnected { 83 | return Promise.value(true) 84 | } 85 | socket.connect() 86 | state = .connecting 87 | return Promise { [weak self] seal in 88 | self?.connectResolver = seal 89 | } 90 | } 91 | 92 | open func pause() { 93 | state = .paused 94 | socket.disconnect(forceTimeout: nil, closeCode: CloseCode.goingAway.rawValue) 95 | } 96 | 97 | open func resume() { 98 | socket.connect() 99 | state = .connecting 100 | } 101 | 102 | open func disconnect() { 103 | stopTimers() 104 | 105 | socket.disconnect() 106 | state = .disconnected 107 | 108 | connectResolver = nil 109 | handshakeId = -1 110 | 111 | WCSessionStore.clear(session.topic) 112 | } 113 | 114 | open func approveSession(accounts: [String], chainId: Int) -> Promise { 115 | guard handshakeId > 0 else { 116 | return Promise(error: WCError.sessionInvalid) 117 | } 118 | let result = WCApproveSessionResponse( 119 | approved: true, 120 | chainId: chainId, 121 | accounts: accounts, 122 | peerId: clientId, 123 | peerMeta: clientMeta 124 | ) 125 | let response = JSONRPCResponse(id: handshakeId, result: result) 126 | return encryptAndSend(data: response.encoded) 127 | } 128 | 129 | open func rejectSession(_ message: String = "Session Rejected") -> Promise { 130 | guard handshakeId > 0 else { 131 | return Promise(error: WCError.sessionInvalid) 132 | } 133 | let response = JSONRPCErrorResponse(id: handshakeId, error: JSONRPCError(code: -32000, message: message)) 134 | return encryptAndSend(data: response.encoded) 135 | } 136 | 137 | open func killSession() -> Promise { 138 | let result = WCSessionUpdateParam(approved: false, chainId: nil, accounts: nil) 139 | let response = JSONRPCRequest(id: generateId(), method: WCEvent.sessionUpdate.rawValue, params: [result]) 140 | return encryptAndSend(data: response.encoded) 141 | .map { [weak self] in 142 | self?.disconnect() 143 | } 144 | } 145 | 146 | open func approveBnbOrder(id: Int64, signed: WCBinanceOrderSignature) -> Promise { 147 | let result = signed.encodedString 148 | return approveRequest(id: id, result: result) 149 | .then { _ -> Promise in 150 | return Promise { [weak self] seal in 151 | self?.bnb.confirmResolvers[id] = seal 152 | } 153 | } 154 | } 155 | 156 | open func approveRequest(id: Int64, result: T) -> Promise { 157 | let response = JSONRPCResponse(id: id, result: result) 158 | return encryptAndSend(data: response.encoded) 159 | } 160 | 161 | open func rejectRequest(id: Int64, message: String) -> Promise { 162 | let response = JSONRPCErrorResponse(id: id, error: JSONRPCError(code: -32000, message: message)) 163 | return encryptAndSend(data: response.encoded) 164 | } 165 | } 166 | 167 | // MARK: internal funcs 168 | extension WCInteractor { 169 | private func subscribe(topic: String) { 170 | let message = WCSocketMessage(topic: topic, type: .sub, payload: "") 171 | let data = try! JSONEncoder().encode(message) 172 | socket.write(data: data) 173 | WCLog("==> subscribe: \(String(data: data, encoding: .utf8)!)") 174 | } 175 | 176 | private func encryptAndSend(data: Data) -> Promise { 177 | WCLog("==> encrypt: \(String(data: data, encoding: .utf8)!) ") 178 | let encoder = JSONEncoder() 179 | let payload = try! WCEncryptor.encrypt(data: data, with: session.key) 180 | let payloadString = encoder.encodeAsUTF8(payload) 181 | let message = WCSocketMessage(topic: peerId ?? session.topic, type: .pub, payload: payloadString) 182 | let data = message.encoded 183 | return Promise { seal in 184 | socket.write(data: data) { 185 | WCLog("==> sent \(String(data: data, encoding: .utf8)!) ") 186 | seal.fulfill(()) 187 | } 188 | } 189 | } 190 | 191 | private func handleEvent(_ event: WCEvent, topic: String, decrypted: Data) throws { 192 | switch event { 193 | case .sessionRequest: 194 | // topic == session.topic 195 | let request: JSONRPCRequest<[WCSessionRequestParam]> = try event.decode(decrypted) 196 | guard let params = request.params.first else { throw WCError.badJSONRPCRequest } 197 | handshakeId = request.id 198 | peerId = params.peerId 199 | peerMeta = params.peerMeta 200 | sessionTimer?.invalidate() 201 | onSessionRequest?(request.id, params) 202 | case .sessionUpdate: 203 | // topic == clientId 204 | let request: JSONRPCRequest<[WCSessionUpdateParam]> = try event.decode(decrypted) 205 | guard let param = request.params.first else { throw WCError.badJSONRPCRequest } 206 | if param.approved == false { 207 | disconnect() 208 | } 209 | default: 210 | if WCEvent.eth.contains(event) { 211 | try eth.handleEvent(event, topic: topic, decrypted: decrypted) 212 | } else if WCEvent.bnb.contains(event) { 213 | try bnb.handleEvent(event, topic: topic, decrypted: decrypted) 214 | } else if WCEvent.trust.contains(event) { 215 | try trust.handleEvent(event, topic: topic, decrypted: decrypted) 216 | }else if WCEvent.okt.contains(event) { 217 | try okt.handleEvent(event, topic: topic, decrypted: decrypted) 218 | } 219 | } 220 | } 221 | 222 | private func setupPingTimer() { 223 | pingTimer = Timer.scheduledTimer(withTimeInterval: 15, repeats: true) { [weak socket] _ in 224 | WCLog("==> ping") 225 | socket?.write(ping: Data()) 226 | } 227 | } 228 | 229 | private func checkExistingSession() { 230 | // check if it's an existing session 231 | if let existing = WCSessionStore.load(session.topic), existing.session == session { 232 | peerId = existing.peerId 233 | peerMeta = existing.peerMeta 234 | return 235 | } 236 | 237 | // we only setup timer for new sessions 238 | sessionTimer = Timer.scheduledTimer(withTimeInterval: sessionRequestTimeout, repeats: false) { [weak self] _ in 239 | self?.onSessionRequestTimeout() 240 | } 241 | } 242 | 243 | private func stopTimers() { 244 | pingTimer?.invalidate() 245 | sessionTimer?.invalidate() 246 | } 247 | 248 | private func onSessionRequestTimeout() { 249 | onDisconnect(error: WCError.sessionRequestTimeout) 250 | } 251 | } 252 | 253 | // MARK: WebSocket event handler 254 | extension WCInteractor { 255 | private func onConnect() { 256 | WCLog("<== websocketDidConnect") 257 | 258 | setupPingTimer() 259 | checkExistingSession() 260 | 261 | subscribe(topic: session.topic) 262 | subscribe(topic: clientId) 263 | 264 | connectResolver?.fulfill(true) 265 | connectResolver = nil 266 | 267 | state = .connected 268 | } 269 | 270 | private func onDisconnect(error: Error?) { 271 | WCLog("<== websocketDidDisconnect, error: \(error.debugDescription)") 272 | 273 | stopTimers() 274 | 275 | if let error = error { 276 | connectResolver?.reject(error) 277 | } else { 278 | connectResolver?.fulfill(false) 279 | } 280 | 281 | connectResolver = nil 282 | onDisconnect?(error) 283 | 284 | state = .disconnected 285 | } 286 | 287 | private func onReceiveMessage(text: String) { 288 | WCLog("<== receive: \(text)") 289 | // handle ping in text format :( 290 | if text == "ping" { return socket.write(pong: Data()) } 291 | guard let (topic, payload) = WCEncryptionPayload.extract(text) else { return } 292 | do { 293 | let decrypted = try WCEncryptor.decrypt(payload: payload, with: session.key) 294 | guard let json = try JSONSerialization.jsonObject(with: decrypted, options: []) 295 | as? [String: Any] else { 296 | throw WCError.badJSONRPCRequest 297 | } 298 | WCLog("<== decrypted: \(String(data: decrypted, encoding: .utf8)!)") 299 | if let method = json["method"] as? String { 300 | if let event = WCEvent(rawValue: method) { 301 | try handleEvent(event, topic: topic, decrypted: decrypted) 302 | } else if let id = json["id"] as? Int64 { 303 | onCustomRequest?(id, json) 304 | } 305 | } 306 | } catch let error { 307 | onError?(error) 308 | WCLog("==> onReceiveMessage error: \(error.localizedDescription)") 309 | } 310 | } 311 | } 312 | -------------------------------------------------------------------------------- /WalletConnect/WCLog.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public func WCLog(_ items: Any..., separator: String = " ", terminator: String = "\n") { 10 | #if DEBUG 11 | items.forEach { 12 | Swift.print($0, separator: separator, terminator: terminator) 13 | } 14 | #endif 15 | } 16 | -------------------------------------------------------------------------------- /WalletConnect/WCSession.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | import CryptoSwift 9 | 10 | public struct WCSession: Codable, Equatable { 11 | public let topic: String 12 | public let version: String 13 | public let bridge: URL 14 | public let key: Data 15 | 16 | public static func from(string: String) -> WCSession? { 17 | guard string .hasPrefix("wc:") else { 18 | return nil 19 | } 20 | 21 | let urlString = string.replacingOccurrences(of: "wc:", with: "wc://") 22 | guard let url = URL(string: urlString), 23 | let topic = url.user, 24 | let version = url.host, 25 | let components = NSURLComponents(url: url, resolvingAgainstBaseURL: false) else { 26 | return nil 27 | } 28 | 29 | var dicts = [String: String]() 30 | for query in components.queryItems ?? [] { 31 | if let value = query.value { 32 | dicts[query.name] = value 33 | } 34 | } 35 | guard let bridge = dicts["bridge"], 36 | let bridgeUrl = URL(string: bridge), 37 | let key = dicts["key"] else { 38 | return nil 39 | } 40 | 41 | return WCSession(topic: topic, version: version, bridge: bridgeUrl, key: Data(hex: key)) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /WalletConnect/WCSessionStore.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2017-2019 Trust Wallet. 2 | // 3 | // This file is part of Trust. The full Trust copyright notice, including 4 | // terms governing use, modification, and redistribution, is contained in the 5 | // file LICENSE at the root of the source code distribution tree. 6 | 7 | import Foundation 8 | 9 | public struct WCSessionStoreItem: Codable { 10 | public let session: WCSession 11 | public let peerId: String 12 | public let peerMeta: WCPeerMeta 13 | public let autoSign: Bool 14 | public let date: Date 15 | } 16 | 17 | public struct WCSessionStore { 18 | 19 | static let prefix = "org.walletconnect.sessions" 20 | 21 | public static var allSessions: [String: WCSessionStoreItem] { 22 | let sessions: [String: WCSessionStoreItem] = UserDefaults.standard.codableValue(forKey: prefix) ?? [:] 23 | return sessions 24 | } 25 | 26 | public static func store(_ session: WCSession, peerId: String, peerMeta: WCPeerMeta, autoSign: Bool = false, date: Date = Date()) { 27 | let item = WCSessionStoreItem( 28 | session: session, 29 | peerId: peerId, 30 | peerMeta: peerMeta, 31 | autoSign: autoSign, 32 | date: date 33 | ) 34 | store(item) 35 | } 36 | 37 | public static func store(_ item: WCSessionStoreItem) { 38 | var sessions = allSessions 39 | sessions[item.session.topic] = item 40 | store(sessions) 41 | } 42 | 43 | public static func load(_ topic: String) -> WCSessionStoreItem? { 44 | guard let item = allSessions[topic] else { return nil } 45 | return item 46 | } 47 | 48 | public static func clear( _ topic: String) { 49 | var sessions = allSessions 50 | sessions.removeValue(forKey: topic) 51 | store(sessions) 52 | } 53 | 54 | public static func clearAll() { 55 | store([:]) 56 | } 57 | 58 | private static func store(_ sessions: [String: WCSessionStoreItem]) { 59 | UserDefaults.standard.setCodable(sessions, forKey: prefix) 60 | } 61 | } 62 | 63 | extension UserDefaults { 64 | func setCodable(_ value: T, forKey: String) { 65 | let data = try? JSONEncoder().encode(value) 66 | set(data, forKey: forKey) 67 | } 68 | 69 | func codableValue(forKey: String) -> T? { 70 | guard let data = data(forKey: forKey), 71 | let value = try? JSONDecoder().decode(T.self, from: data) else { 72 | return nil 73 | } 74 | return value 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /WalletConnect/WalletConnect.h: -------------------------------------------------------------------------------- 1 | // 2 | // WalletConnect.h 3 | // WalletConnect 4 | // 5 | // Created by Tao X on 11/1/19. 6 | // Copyright © 2019 Trust Wallet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for WalletConnect. 12 | FOUNDATION_EXPORT double WalletConnectVersionNumber; 13 | 14 | //! Project version string for WalletConnect. 15 | FOUNDATION_EXPORT const unsigned char WalletConnectVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "Example/WalletConnect/" 3 | --------------------------------------------------------------------------------