From 869663948dfec945dd5c21d6c015cbbf31ffbce1 Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Tue, 26 Oct 2021 14:34:04 +0200
Subject: [PATCH 01/13] Update Starscream dependency to Major 4.x.x version.
swift-nio-zlib-support subdependency removed.
Public WC interface was not affected.
---
Cartfile | 2 +-
Package.resolved | 13 +----
Package.swift | 2 +-
Sources/Internal/WebSocketConnection.swift | 49 +++++++++++--------
WalletConnectSwift.podspec | 4 +-
WalletConnectSwift.xcodeproj/project.pbxproj | 2 +-
.../xcshareddata/swiftpm/Package.resolved | 13 +----
WalletConnectSwift/Info.plist | 2 +-
WalletConnectSwiftTests/Info.plist | 2 +-
9 files changed, 39 insertions(+), 50 deletions(-)
diff --git a/Cartfile b/Cartfile
index 06a437e6f..c584c72c2 100644
--- a/Cartfile
+++ b/Cartfile
@@ -1,2 +1,2 @@
github "krzyzanowskim/CryptoSwift" ~> 1.4.0
-github "daltoniam/Starscream" ~> 3.1.0
+github "daltoniam/Starscream" ~> 4.0.0
diff --git a/Package.resolved b/Package.resolved
index 0583fbb43..027804cda 100644
--- a/Package.resolved
+++ b/Package.resolved
@@ -15,17 +15,8 @@
"repositoryURL": "https://github.com/daltoniam/Starscream.git",
"state": {
"branch": null,
- "revision": "e6b65c6d9077ea48b4a7bdda8994a1d3c6969c8d",
- "version": "3.1.1"
- }
- },
- {
- "package": "swift-nio-zlib-support",
- "repositoryURL": "https://github.com/apple/swift-nio-zlib-support.git",
- "state": {
- "branch": null,
- "revision": "37760e9a52030bb9011972c5213c3350fa9d41fd",
- "version": "1.0.0"
+ "revision": "df8d82047f6654d8e4b655d1b1525c64e1059d21",
+ "version": "4.0.4"
}
}
]
diff --git a/Package.swift b/Package.swift
index 26ca86fec..2f70469bf 100644
--- a/Package.swift
+++ b/Package.swift
@@ -13,7 +13,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.4.0")),
- .package(url: "https://github.com/daltoniam/Starscream.git", .upToNextMinor(from: "3.1.0"))
+ .package(url: "https://github.com/daltoniam/Starscream.git", .upToNextMinor(from: "4.0.0"))
],
targets: [
.target(
diff --git a/Sources/Internal/WebSocketConnection.swift b/Sources/Internal/WebSocketConnection.swift
index cbf9ccee9..f334b720f 100644
--- a/Sources/Internal/WebSocketConnection.swift
+++ b/Sources/Internal/WebSocketConnection.swift
@@ -8,6 +8,8 @@ import Starscream
class WebSocketConnection {
let url: WCURL
private let socket: WebSocket
+ private var isConnected: Bool = false
+
private let onConnect: (() -> Void)?
private let onDisconnect: ((Error?) -> Void)?
private let onTextReceive: ((String) -> Void)?
@@ -23,7 +25,7 @@ class WebSocketConnection {
private let serialCallbackQueue: DispatchQueue
var isOpen: Bool {
- return socket.isConnected
+ return isConnected
}
init(url: WCURL,
@@ -35,7 +37,7 @@ class WebSocketConnection {
self.onDisconnect = onDisconnect
self.onTextReceive = onTextReceive
serialCallbackQueue = DispatchQueue(label: "org.walletconnect.swift.connection-\(url.bridgeURL)-\(url.topic)")
- socket = WebSocket(url: url.bridgeURL)
+ socket = WebSocket(request: URLRequest(url: url.bridgeURL))
socket.delegate = self
socket.callbackQueue = serialCallbackQueue
}
@@ -49,7 +51,7 @@ class WebSocketConnection {
}
func send(_ text: String) {
- guard socket.isConnected else { return }
+ guard isConnected else { return }
socket.write(string: text)
log(text)
}
@@ -66,24 +68,29 @@ class WebSocketConnection {
}
extension WebSocketConnection: WebSocketDelegate {
- func websocketDidConnect(socket: WebSocketClient) {
- pingTimer = Timer.scheduledTimer(withTimeInterval: pingInterval, repeats: true) { [weak self] _ in
- LogService.shared.log("WC: ==> ping")
- self?.socket.write(ping: Data())
+ func didReceive(event: WebSocketEvent, client: WebSocket) {
+ switch event {
+ case .connected:
+ pingTimer = Timer.scheduledTimer(withTimeInterval: pingInterval, repeats: true) { [weak self] _ in
+ LogService.shared.log("WC: ==> ping")
+ self?.socket.write(ping: Data())
+ }
+ isConnected = true
+ onConnect?()
+ case .disconnected:
+ isConnected = false
+ pingTimer?.invalidate()
+ onDisconnect?(nil)
+ case .error(let error):
+ isConnected = false
+ pingTimer?.invalidate()
+ onDisconnect?(error)
+ case .cancelled:
+ isConnected = false
+ case .text(let string):
+ onTextReceive?(string)
+ case .binary, .pong, .ping, .viabilityChanged, .reconnectSuggested:
+ break
}
- onConnect?()
- }
-
- func websocketDidDisconnect(socket: WebSocketClient, error: Error?) {
- pingTimer?.invalidate()
- onDisconnect?(error)
- }
-
- func websocketDidReceiveMessage(socket: WebSocketClient, text: String) {
- onTextReceive?(text)
- }
-
- func websocketDidReceiveData(socket: WebSocketClient, data: Data) {
- // no-op
}
}
diff --git a/WalletConnectSwift.podspec b/WalletConnectSwift.podspec
index 4f7f1ab62..83c549b34 100644
--- a/WalletConnectSwift.podspec
+++ b/WalletConnectSwift.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "WalletConnectSwift"
- spec.version = "1.6.0"
+ spec.version = "1.6.1"
spec.summary = "A delightful way to integrate WalletConnect into your app."
spec.description = <<-DESC
WalletConnect protocol implementation for enabling communication between dapps and
@@ -17,5 +17,5 @@ Pod::Spec.new do |spec|
spec.source_files = "Sources/**/*.swift"
spec.requires_arc = true
spec.dependency "CryptoSwift", "~> 1.4"
- spec.dependency "Starscream", "~> 3.1"
+ spec.dependency "Starscream", "~> 4.0"
end
diff --git a/WalletConnectSwift.xcodeproj/project.pbxproj b/WalletConnectSwift.xcodeproj/project.pbxproj
index 91b5d649d..88615cc21 100644
--- a/WalletConnectSwift.xcodeproj/project.pbxproj
+++ b/WalletConnectSwift.xcodeproj/project.pbxproj
@@ -625,7 +625,7 @@
repositoryURL = "https://github.com/daltoniam/Starscream.git";
requirement = {
kind = upToNextMinorVersion;
- minimumVersion = 3.1.0;
+ minimumVersion = 4.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */
diff --git a/WalletConnectSwift.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/WalletConnectSwift.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
index 0583fbb43..027804cda 100644
--- a/WalletConnectSwift.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/WalletConnectSwift.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -15,17 +15,8 @@
"repositoryURL": "https://github.com/daltoniam/Starscream.git",
"state": {
"branch": null,
- "revision": "e6b65c6d9077ea48b4a7bdda8994a1d3c6969c8d",
- "version": "3.1.1"
- }
- },
- {
- "package": "swift-nio-zlib-support",
- "repositoryURL": "https://github.com/apple/swift-nio-zlib-support.git",
- "state": {
- "branch": null,
- "revision": "37760e9a52030bb9011972c5213c3350fa9d41fd",
- "version": "1.0.0"
+ "revision": "df8d82047f6654d8e4b655d1b1525c64e1059d21",
+ "version": "4.0.4"
}
}
]
diff --git a/WalletConnectSwift/Info.plist b/WalletConnectSwift/Info.plist
index 98b1ede8f..c0fcf6c3e 100644
--- a/WalletConnectSwift/Info.plist
+++ b/WalletConnectSwift/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.6.0
+ 1.6.1
CFBundleVersion
$(CURRENT_PROJECT_VERSION)
diff --git a/WalletConnectSwiftTests/Info.plist b/WalletConnectSwiftTests/Info.plist
index 70308fe25..120b91dd6 100644
--- a/WalletConnectSwiftTests/Info.plist
+++ b/WalletConnectSwiftTests/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
BNDL
CFBundleShortVersionString
- 1.6.0
+ 1.6.1
CFBundleVersion
1
From 32b871a6a1f9aa7b6d3ef4e61cb1d56575b79709 Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Tue, 26 Oct 2021 22:43:08 +0200
Subject: [PATCH 02/13] Prevent multiple delegate calls of didScan
---
ExampleApps/ServerApp/ScannerViewController.swift | 1 +
1 file changed, 1 insertion(+)
diff --git a/ExampleApps/ServerApp/ScannerViewController.swift b/ExampleApps/ServerApp/ScannerViewController.swift
index 6a2470bc4..06e64e01a 100644
--- a/ExampleApps/ServerApp/ScannerViewController.swift
+++ b/ExampleApps/ServerApp/ScannerViewController.swift
@@ -58,6 +58,7 @@ extension ScannerViewController: AVCaptureMetadataOutputObjectsDelegate {
let metadata = metadataObjects[0] as! AVMetadataMachineReadableCodeObject
if metadata.type == .qr && metadata.stringValue != nil {
delegate.didScan(metadata.stringValue!)
+ captureSession.stopRunning()
}
}
}
From a17519571d962197ae096e647a5c534755ab47b8 Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Tue, 26 Oct 2021 22:44:52 +0200
Subject: [PATCH 03/13] Fix typo
---
ExampleApps/ClientApp/WalletConnect.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ExampleApps/ClientApp/WalletConnect.swift b/ExampleApps/ClientApp/WalletConnect.swift
index 178a766e5..43941a4f7 100644
--- a/ExampleApps/ClientApp/WalletConnect.swift
+++ b/ExampleApps/ClientApp/WalletConnect.swift
@@ -29,7 +29,7 @@ class WalletConnect {
bridgeURL: URL(string: "https://safe-walletconnect.gnosis.io/")!,
key: try! randomKey())
let clientMeta = Session.ClientMeta(name: "ExampleDApp",
- description: "WalletConnectSwift ",
+ description: "WalletConnectSwift",
icons: [],
url: URL(string: "https://safe.gnosis.io")!)
let dAppInfo = Session.DAppInfo(peerId: UUID().uuidString, peerMeta: clientMeta)
From 0e378f7a1f25c25a29e1982156be9c26f2febdcf Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Tue, 26 Oct 2021 22:46:51 +0200
Subject: [PATCH 04/13] Give a bit of a time to make sure everything properly
connected and request for session have been sent
---
ExampleApps/ClientApp/MainViewController.swift | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/ExampleApps/ClientApp/MainViewController.swift b/ExampleApps/ClientApp/MainViewController.swift
index 9c4b71dc7..765e58507 100644
--- a/ExampleApps/ClientApp/MainViewController.swift
+++ b/ExampleApps/ClientApp/MainViewController.swift
@@ -17,12 +17,15 @@ class MainViewController: UIViewController {
/// Here deep link provided for integration with server test app only
let deepLinkUrl = "wc://wc?uri=\(connectionUrl)"
- if let url = URL(string: deepLinkUrl), UIApplication.shared.canOpenURL(url) {
- UIApplication.shared.open(url, options: [:], completionHandler: nil)
- } else {
- handshakeController = HandshakeViewController.create(code: connectionUrl)
- present(handshakeController, animated: true)
+ DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
+ if let url = URL(string: deepLinkUrl), UIApplication.shared.canOpenURL(url) {
+ UIApplication.shared.open(url, options: [:], completionHandler: nil)
+ } else {
+ self.handshakeController = HandshakeViewController.create(code: connectionUrl)
+ self.present(self.handshakeController, animated: true)
+ }
}
+
}
override func viewDidLoad() {
From 2120d1b954f685a0b8b2cd3026a1b7bfac7c3421 Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Tue, 26 Oct 2021 22:49:25 +0200
Subject: [PATCH 05/13] Adjust demo app just to find out that there are
multiple strong memory cycles inside of Client -> onCallback ->
WebSocketConnection -> Client. Still this gives a better control for demo
apps to do intended job.
---
ExampleApps/ClientApp/ActionsViewController.swift | 3 +++
ExampleApps/ServerApp/MainViewController.swift | 8 ++++++++
2 files changed, 11 insertions(+)
diff --git a/ExampleApps/ClientApp/ActionsViewController.swift b/ExampleApps/ClientApp/ActionsViewController.swift
index 020e744e4..cea5a886b 100644
--- a/ExampleApps/ClientApp/ActionsViewController.swift
+++ b/ExampleApps/ClientApp/ActionsViewController.swift
@@ -94,6 +94,9 @@ class ActionsViewController: UIViewController {
}
@IBAction func close(_ sender: Any) {
+ for session in client.openSessions() {
+ try? client.disconnect(from: session)
+ }
dismiss(animated: true)
}
diff --git a/ExampleApps/ServerApp/MainViewController.swift b/ExampleApps/ServerApp/MainViewController.swift
index 21738f9ef..191098eff 100644
--- a/ExampleApps/ServerApp/MainViewController.swift
+++ b/ExampleApps/ServerApp/MainViewController.swift
@@ -163,6 +163,9 @@ extension Response {
extension MainViewController: ServerDelegate {
func server(_ server: Server, didFailToConnect url: WCURL) {
onMainThread {
+ self.scanQRCodeButton.isEnabled = true
+ self.scanQRCodeButton.isHidden = false
+ self.disconnectButton.isHidden = true
UIAlertController.showFailedToConnect(from: self)
}
}
@@ -188,6 +191,11 @@ extension MainViewController: ServerDelegate {
}
func server(_ server: Server, didConnect session: Session) {
+ if let currentSession = self.session,
+ currentSession.url.key != session.url.key {
+ print("Test app only supports 1 session atm, cleaning...")
+ try? self.server.disconnect(from: currentSession)
+ }
self.session = session
let sessionData = try! JSONEncoder().encode(session)
UserDefaults.standard.set(sessionData, forKey: sessionKey)
From 27c9adb884c8cd8d2705a5aec7e25e777e84c607 Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Tue, 26 Oct 2021 23:46:27 +0200
Subject: [PATCH 06/13] Proof of work 4.0.x Starscream with TCPTransport(non
Native iOS Engine). Additional tests required for NativeEngine Hacked in
solution for iOS platform.
---
Sources/Internal/WebSocketConnection.swift | 139 +++++++++++++++++----
1 file changed, 114 insertions(+), 25 deletions(-)
diff --git a/Sources/Internal/WebSocketConnection.swift b/Sources/Internal/WebSocketConnection.swift
index f334b720f..c62941da9 100644
--- a/Sources/Internal/WebSocketConnection.swift
+++ b/Sources/Internal/WebSocketConnection.swift
@@ -4,10 +4,17 @@
import Foundation
import Starscream
+import Network
+
+#if os(iOS)
+import UIKit
+#endif
+
class WebSocketConnection {
let url: WCURL
private let socket: WebSocket
+
private var isConnected: Bool = false
private let onConnect: (() -> Void)?
@@ -17,17 +24,22 @@ class WebSocketConnection {
private var pingTimer: Timer?
// TODO: make injectable on server creation
private let pingInterval: TimeInterval = 30
-
+
private var requestSerializer: RequestSerializer = JSONRPCSerializer()
private var responseSerializer: ResponseSerializer = JSONRPCSerializer()
-
+
// serial queue for receiving the calls.
private let serialCallbackQueue: DispatchQueue
-
+
+#if os(iOS)
+ private var backgroundNotificationObserver: Any?
+ private var foregroundNotificationObserver: Any?
+#endif
+
var isOpen: Bool {
return isConnected
}
-
+
init(url: WCURL,
onConnect: (() -> Void)?,
onDisconnect: ((Error?) -> Void)?,
@@ -37,25 +49,59 @@ class WebSocketConnection {
self.onDisconnect = onDisconnect
self.onTextReceive = onTextReceive
serialCallbackQueue = DispatchQueue(label: "org.walletconnect.swift.connection-\(url.bridgeURL)-\(url.topic)")
- socket = WebSocket(request: URLRequest(url: url.bridgeURL))
- socket.delegate = self
- socket.callbackQueue = serialCallbackQueue
+
+ self.socket = WebSocket(request: URLRequest(url: url.bridgeURL))
+ self.socket.callbackQueue = serialCallbackQueue
+ self.socket.delegate = self
}
-
+
+ deinit {
+#if os(iOS)
+ if let observer = self.backgroundNotificationObserver {
+ NotificationCenter.default.removeObserver(observer)
+ }
+ if let observer = self.foregroundNotificationObserver {
+ NotificationCenter.default.removeObserver(observer)
+ }
+#endif
+ }
+
func open() {
- socket.connect()
+ self.socket.connect()
+#if os(iOS)
+ self.backgroundNotificationObserver = NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification,
+ object: nil, queue: nil) { [weak self] notification in
+ self?.close(closeCode: CloseCode.goingAway.rawValue)
+ }
+ if let observer = self.foregroundNotificationObserver {
+ NotificationCenter.default.removeObserver(observer)
+ }
+ self.foregroundNotificationObserver = nil
+#endif
}
-
- func close() {
- socket.disconnect()
+
+ func close(closeCode: UInt16 = CloseCode.normal.rawValue) {
+ self.socket.disconnect(closeCode: closeCode)
+ self.pingTimer?.invalidate()
+ self.pingTimer = nil
+#if os(iOS)
+ self.foregroundNotificationObserver = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification,
+ object: nil, queue: nil) { [weak self] notification in
+ self?.open()
+ }
+ if let observer = self.backgroundNotificationObserver {
+ NotificationCenter.default.removeObserver(observer)
+ }
+ self.backgroundNotificationObserver = nil
+#endif
}
-
+
func send(_ text: String) {
guard isConnected else { return }
socket.write(string: text)
log(text)
}
-
+
private func log(_ text: String) {
if let request = try? requestSerializer.deserialize(text, url: url).json().string {
LogService.shared.log("WC: ==> \(request)")
@@ -71,26 +117,69 @@ extension WebSocketConnection: WebSocketDelegate {
func didReceive(event: WebSocketEvent, client: WebSocket) {
switch event {
case .connected:
- pingTimer = Timer.scheduledTimer(withTimeInterval: pingInterval, repeats: true) { [weak self] _ in
- LogService.shared.log("WC: ==> ping")
- self?.socket.write(ping: Data())
+ DispatchQueue.main.sync {
+ self.pingTimer = Timer.scheduledTimer(withTimeInterval: self.pingInterval,
+ repeats: true) { [weak self] _ in
+ LogService.shared.log("WC: ==> ping")
+ self?.socket.write(ping: Data())
+ }
}
isConnected = true
onConnect?()
+#if os(iOS)
case .disconnected:
- isConnected = false
- pingTimer?.invalidate()
- onDisconnect?(nil)
+ DispatchQueue.main.sync {
+ if UIApplication.shared.applicationState != .background {
+ didDisconnect(with: nil)
+ }
+ }
case .error(let error):
- isConnected = false
- pingTimer?.invalidate()
- onDisconnect?(error)
+ DispatchQueue.main.sync {
+ if UIApplication.shared.applicationState != .background {
+ didDisconnect(with: error)
+ }
+ }
+ break
case .cancelled:
- isConnected = false
+ DispatchQueue.main.sync {
+ if UIApplication.shared.applicationState != .background {
+ LogService.shared.log("WC: <== connection terminated from internal call. Disconnecting...")
+ self.didDisconnect(with: nil)
+ } else {
+ LogService.shared.log("WC: <== connection cancelled in background. Will re-activate when possible.")
+ }
+ }
+#else
+ case .disconnected:
+ didDisconnect(with: nil)
+ case .error(let error):
+ didDisconnect(with: error)
+ break
+ case .cancelled:
+ didDisconnect(with: nil)
+#endif
case .text(let string):
onTextReceive?(string)
- case .binary, .pong, .ping, .viabilityChanged, .reconnectSuggested:
+ case .ping:
+ LogService.shared.log("WC: <== ping")
+ LogService.shared.log("WC: ==> pong client.respondToPingWithPong: \(client.respondToPingWithPong == true)")
break
+ case .pong:
+ LogService.shared.log("WC: <== pong")
+ case .reconnectSuggested:
+ LogService.shared.log("WC: <== reconnectSuggested") //TODO: Should we?
+ case .binary, .viabilityChanged:
+ break
+ }
+ }
+
+ private func didDisconnect(with error: Error? = nil) {
+ LogService.shared.log("WC: <== disconnected")
+ if let error = error {
+ LogService.shared.log("^------ with error: \(error)")
}
+ self.isConnected = false
+ self.pingTimer?.invalidate()
+ onDisconnect?(error)
}
}
From 5496fc0b63cff01fbeff5b83182936c96ffe357b Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Tue, 26 Oct 2021 23:46:49 +0200
Subject: [PATCH 07/13] Fix invocation out of main queue
---
.../ClientApp/ActionsViewController.swift | 28 +++++++++----------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/ExampleApps/ClientApp/ActionsViewController.swift b/ExampleApps/ClientApp/ActionsViewController.swift
index cea5a886b..9fb5339e6 100644
--- a/ExampleApps/ClientApp/ActionsViewController.swift
+++ b/ExampleApps/ClientApp/ActionsViewController.swift
@@ -101,25 +101,25 @@ class ActionsViewController: UIViewController {
}
private func handleReponse(_ response: Response, expecting: String) {
- if let error = response.error {
- show(UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert))
- return
- }
- do {
- let result = try response.result(as: String.self)
- show(UIAlertController(title: expecting, message: result, preferredStyle: .alert))
- } catch {
- show(UIAlertController(title: "Error",
- message: "Unexpected response type error: \(error)",
- preferredStyle: .alert))
+ DispatchQueue.main.async {
+ if let error = response.error {
+ self.show(UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert))
+ return
+ }
+ do {
+ let result = try response.result(as: String.self)
+ self.show(UIAlertController(title: expecting, message: result, preferredStyle: .alert))
+ } catch {
+ self.show(UIAlertController(title: "Error",
+ message: "Unexpected response type error: \(error)",
+ preferredStyle: .alert))
+ }
}
}
private func show(_ alert: UIAlertController) {
alert.addAction(UIAlertAction(title: "Close", style: .cancel))
- DispatchQueue.main.async {
- self.present(alert, animated: true)
- }
+ self.present(alert, animated: true)
}
private func nonceRequest() -> Request {
From 23abe05524a8793a04140751ada7ec8e5b44477f Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Fri, 29 Oct 2021 21:54:47 +0200
Subject: [PATCH 08/13] Fallback to old Foundation Transport to get reliable
result from Starscream library
---
Sources/Internal/WebSocketConnection.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Sources/Internal/WebSocketConnection.swift b/Sources/Internal/WebSocketConnection.swift
index c62941da9..370bb81d0 100644
--- a/Sources/Internal/WebSocketConnection.swift
+++ b/Sources/Internal/WebSocketConnection.swift
@@ -50,7 +50,7 @@ class WebSocketConnection {
self.onTextReceive = onTextReceive
serialCallbackQueue = DispatchQueue(label: "org.walletconnect.swift.connection-\(url.bridgeURL)-\(url.topic)")
- self.socket = WebSocket(request: URLRequest(url: url.bridgeURL))
+ self.socket = WebSocket(request: URLRequest(url: url.bridgeURL), engine: WSEngine(transport: FoundationTransport(), certPinner: FoundationSecurity()))
self.socket.callbackQueue = serialCallbackQueue
self.socket.delegate = self
}
From 8313c81e447cb1d79eccfa81a072220ac87a8ec5 Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Fri, 29 Oct 2021 21:56:00 +0200
Subject: [PATCH 09/13] Allow disconnect only during active state of the app to
control work of the sockets without background capabilities
---
Sources/Internal/WebSocketConnection.swift | 62 +++++++++++++---------
1 file changed, 37 insertions(+), 25 deletions(-)
diff --git a/Sources/Internal/WebSocketConnection.swift b/Sources/Internal/WebSocketConnection.swift
index 370bb81d0..3b7572d0c 100644
--- a/Sources/Internal/WebSocketConnection.swift
+++ b/Sources/Internal/WebSocketConnection.swift
@@ -53,9 +53,36 @@ class WebSocketConnection {
self.socket = WebSocket(request: URLRequest(url: url.bridgeURL), engine: WSEngine(transport: FoundationTransport(), certPinner: FoundationSecurity()))
self.socket.callbackQueue = serialCallbackQueue
self.socket.delegate = self
+
+#if os(iOS)
+ var didBecomeActiveName: NSNotification.Name
+ if #available(iOS 13.0, *) {
+ didBecomeActiveName = UIScene.didActivateNotification
+ } else {
+ didBecomeActiveName = UIApplication.didBecomeActiveNotification
+ }
+ self.foregroundNotificationObserver = NotificationCenter.default.addObserver(forName: didBecomeActiveName,
+ object: nil,
+ queue: OperationQueue.main) { [weak self] notification in
+ self?.open()
+ }
+ var willResignActiveName: NSNotification.Name
+ if #available(iOS 13.0, *) {
+ willResignActiveName = UIScene.willDeactivateNotification
+ } else {
+ willResignActiveName = UIApplication.willResignActiveNotification
+ }
+ self.backgroundNotificationObserver = NotificationCenter.default.addObserver(forName: willResignActiveName,
+ object: nil,
+ queue: OperationQueue.main) { [weak self] notification in
+ print("WebSocketConnect: ==> Shotting down socket before background")
+ self?.close(closeCode: CloseCode.protocolError.rawValue)
+ }
+#endif
}
deinit {
+ LogService.shared.log("WebSocketConnect: ==> deinit")
#if os(iOS)
if let observer = self.backgroundNotificationObserver {
NotificationCenter.default.removeObserver(observer)
@@ -64,36 +91,16 @@ class WebSocketConnection {
NotificationCenter.default.removeObserver(observer)
}
#endif
+ self.pingTimer?.invalidate()
}
func open() {
self.socket.connect()
-#if os(iOS)
- self.backgroundNotificationObserver = NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification,
- object: nil, queue: nil) { [weak self] notification in
- self?.close(closeCode: CloseCode.goingAway.rawValue)
- }
- if let observer = self.foregroundNotificationObserver {
- NotificationCenter.default.removeObserver(observer)
- }
- self.foregroundNotificationObserver = nil
-#endif
}
func close(closeCode: UInt16 = CloseCode.normal.rawValue) {
self.socket.disconnect(closeCode: closeCode)
self.pingTimer?.invalidate()
- self.pingTimer = nil
-#if os(iOS)
- self.foregroundNotificationObserver = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification,
- object: nil, queue: nil) { [weak self] notification in
- self?.open()
- }
- if let observer = self.backgroundNotificationObserver {
- NotificationCenter.default.removeObserver(observer)
- }
- self.backgroundNotificationObserver = nil
-#endif
}
func send(_ text: String) {
@@ -124,27 +131,32 @@ extension WebSocketConnection: WebSocketDelegate {
self?.socket.write(ping: Data())
}
}
+ LogService.shared.log("WC: <== connected")
isConnected = true
onConnect?()
#if os(iOS)
case .disconnected:
DispatchQueue.main.sync {
- if UIApplication.shared.applicationState != .background {
+ if UIApplication.shared.applicationState == .active {
didDisconnect(with: nil)
+ } else {
+ LogService.shared.log("WC: <== connection disconnected in background. Will re-activate when possible.")
}
}
case .error(let error):
DispatchQueue.main.sync {
- if UIApplication.shared.applicationState != .background {
+ if UIApplication.shared.applicationState == .active {
didDisconnect(with: error)
+ } else {
+ LogService.shared.log("WC: <== connection error in background. Will re-activate when possible.")
}
}
break
case .cancelled:
DispatchQueue.main.sync {
- if UIApplication.shared.applicationState != .background {
+ if UIApplication.shared.applicationState == .active {
LogService.shared.log("WC: <== connection terminated from internal call. Disconnecting...")
- self.didDisconnect(with: nil)
+ didDisconnect(with: nil)
} else {
LogService.shared.log("WC: <== connection cancelled in background. Will re-activate when possible.")
}
From 916a4399a960ae824ad2719479f4beb80a49a44c Mon Sep 17 00:00:00 2001
From: Aleksei Minaev <1472675+zulkis@users.noreply.github.com>
Date: Fri, 29 Oct 2021 21:58:46 +0200
Subject: [PATCH 10/13] Fix retain cycle where lambda syntax used to pass
functions which are retained by WalletConnect class.
That would not allow to follow RAII principle. So if I release WalletConnect instance - my sockets would still remain active, which is not expected
---
Sources/PublicInterface/WalletConnect.swift | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/Sources/PublicInterface/WalletConnect.swift b/Sources/PublicInterface/WalletConnect.swift
index 6873047d6..5b6947b54 100644
--- a/Sources/PublicInterface/WalletConnect.swift
+++ b/Sources/PublicInterface/WalletConnect.swift
@@ -58,10 +58,19 @@ open class WalletConnect {
}
private func listen(on url: WCURL) {
+ let onConnect: ((WCURL) -> Void) = { [weak self] url in
+ self?.onConnect(to: url)
+ }
+ let onDisconnect: ((WCURL, Error?) -> Void) = { [weak self] (url, error) in
+ self?.onDisconnect(from: url, error: error)
+ }
+ let onTextReceive: ((String, WCURL) -> Void) = { [weak self] (text, url) in
+ self?.onTextReceive(text, from: url)
+ }
communicator.listen(on: url,
- onConnect: onConnect(to:),
- onDisconnect: onDisconnect(from:error:),
- onTextReceive: onTextReceive(_:from:))
+ onConnect: onConnect,
+ onDisconnect: onDisconnect,
+ onTextReceive: onTextReceive)
}
/// Confirmation from Transport layer that connection was successfully established.
From a5f30848cb62f1633a14421a1ef7904bf96a714b Mon Sep 17 00:00:00 2001
From: Dmitry Bespalov
Date: Wed, 10 Nov 2021 17:54:35 +0100
Subject: [PATCH 11/13] Removed uikit code from transport layer
---
Sources/Internal/JSONRPC_2_0.swift | 4 +-
Sources/Internal/WebSocketConnection.swift | 77 +---------------------
2 files changed, 3 insertions(+), 78 deletions(-)
diff --git a/Sources/Internal/JSONRPC_2_0.swift b/Sources/Internal/JSONRPC_2_0.swift
index 6bb2f07ad..2c9dcca2d 100644
--- a/Sources/Internal/JSONRPC_2_0.swift
+++ b/Sources/Internal/JSONRPC_2_0.swift
@@ -171,7 +171,7 @@ enum JSONRPC_2_0 {
/// https://www.jsonrpc.org/specification#request_object
struct Request: Hashable, Codable {
- let jsonrpc = "2.0"
+ var jsonrpc = "2.0"
var method: String
var params: Params?
var id: IDType?
@@ -242,7 +242,7 @@ enum JSONRPC_2_0 {
/// https://www.jsonrpc.org/specification#response_object
struct Response: Hashable, Codable {
- let jsonrpc = "2.0"
+ var jsonrpc = "2.0"
var result: Payload
var id: IDType
diff --git a/Sources/Internal/WebSocketConnection.swift b/Sources/Internal/WebSocketConnection.swift
index 3b7572d0c..6024ecf04 100644
--- a/Sources/Internal/WebSocketConnection.swift
+++ b/Sources/Internal/WebSocketConnection.swift
@@ -6,11 +6,6 @@ import Foundation
import Starscream
import Network
-#if os(iOS)
-import UIKit
-#endif
-
-
class WebSocketConnection {
let url: WCURL
private let socket: WebSocket
@@ -30,12 +25,7 @@ class WebSocketConnection {
// serial queue for receiving the calls.
private let serialCallbackQueue: DispatchQueue
-
-#if os(iOS)
- private var backgroundNotificationObserver: Any?
- private var foregroundNotificationObserver: Any?
-#endif
-
+
var isOpen: Bool {
return isConnected
}
@@ -53,44 +43,9 @@ class WebSocketConnection {
self.socket = WebSocket(request: URLRequest(url: url.bridgeURL), engine: WSEngine(transport: FoundationTransport(), certPinner: FoundationSecurity()))
self.socket.callbackQueue = serialCallbackQueue
self.socket.delegate = self
-
-#if os(iOS)
- var didBecomeActiveName: NSNotification.Name
- if #available(iOS 13.0, *) {
- didBecomeActiveName = UIScene.didActivateNotification
- } else {
- didBecomeActiveName = UIApplication.didBecomeActiveNotification
- }
- self.foregroundNotificationObserver = NotificationCenter.default.addObserver(forName: didBecomeActiveName,
- object: nil,
- queue: OperationQueue.main) { [weak self] notification in
- self?.open()
- }
- var willResignActiveName: NSNotification.Name
- if #available(iOS 13.0, *) {
- willResignActiveName = UIScene.willDeactivateNotification
- } else {
- willResignActiveName = UIApplication.willResignActiveNotification
- }
- self.backgroundNotificationObserver = NotificationCenter.default.addObserver(forName: willResignActiveName,
- object: nil,
- queue: OperationQueue.main) { [weak self] notification in
- print("WebSocketConnect: ==> Shotting down socket before background")
- self?.close(closeCode: CloseCode.protocolError.rawValue)
- }
-#endif
}
deinit {
- LogService.shared.log("WebSocketConnect: ==> deinit")
-#if os(iOS)
- if let observer = self.backgroundNotificationObserver {
- NotificationCenter.default.removeObserver(observer)
- }
- if let observer = self.foregroundNotificationObserver {
- NotificationCenter.default.removeObserver(observer)
- }
-#endif
self.pingTimer?.invalidate()
}
@@ -134,42 +89,12 @@ extension WebSocketConnection: WebSocketDelegate {
LogService.shared.log("WC: <== connected")
isConnected = true
onConnect?()
-#if os(iOS)
- case .disconnected:
- DispatchQueue.main.sync {
- if UIApplication.shared.applicationState == .active {
- didDisconnect(with: nil)
- } else {
- LogService.shared.log("WC: <== connection disconnected in background. Will re-activate when possible.")
- }
- }
- case .error(let error):
- DispatchQueue.main.sync {
- if UIApplication.shared.applicationState == .active {
- didDisconnect(with: error)
- } else {
- LogService.shared.log("WC: <== connection error in background. Will re-activate when possible.")
- }
- }
- break
- case .cancelled:
- DispatchQueue.main.sync {
- if UIApplication.shared.applicationState == .active {
- LogService.shared.log("WC: <== connection terminated from internal call. Disconnecting...")
- didDisconnect(with: nil)
- } else {
- LogService.shared.log("WC: <== connection cancelled in background. Will re-activate when possible.")
- }
- }
-#else
case .disconnected:
didDisconnect(with: nil)
case .error(let error):
didDisconnect(with: error)
- break
case .cancelled:
didDisconnect(with: nil)
-#endif
case .text(let string):
onTextReceive?(string)
case .ping:
From ccff3484741afde7500217f1cdfe2354dab42443 Mon Sep 17 00:00:00 2001
From: Dmitry Bespalov
Date: Fri, 12 Nov 2021 12:03:22 +0100
Subject: [PATCH 12/13] Moved ExampleApps to a separate repo
New repo: https://github.com/WalletConnect/WalletConnectSwift-Example.git
---
.../ClientApp/ActionsViewController.swift | 232 -------
ExampleApps/ClientApp/AppDelegate.swift | 41 --
.../AppIcon.appiconset/Contents.json | 98 ---
.../ClientApp/Assets.xcassets/Contents.json | 6 -
.../Base.lproj/LaunchScreen.storyboard | 25 -
.../ClientApp/Base.lproj/Main.storyboard | 190 ------
.../ClientApp/HandshakeViewController.swift | 38 --
ExampleApps/ClientApp/Info.plist | 52 --
.../ClientApp/MainViewController.swift | 96 ---
ExampleApps/ClientApp/WalletConnect.swift | 92 ---
.../ExampleApps.xcodeproj/project.pbxproj | 564 ------------------
.../contents.xcworkspacedata | 7 -
.../xcshareddata/IDEWorkspaceChecks.plist | 8 -
ExampleApps/ServerApp/AppDelegate.swift | 51 --
.../AppIcon.appiconset/Contents.json | 98 ---
.../ServerApp/Assets.xcassets/Contents.json | 6 -
.../Base.lproj/LaunchScreen.storyboard | 25 -
.../ServerApp/Base.lproj/Main.storyboard | 117 ----
ExampleApps/ServerApp/Info.plist | 61 --
.../ServerApp/MainViewController.swift | 279 ---------
.../ServerApp/ScannerViewController.swift | 64 --
21 files changed, 2150 deletions(-)
delete mode 100644 ExampleApps/ClientApp/ActionsViewController.swift
delete mode 100644 ExampleApps/ClientApp/AppDelegate.swift
delete mode 100644 ExampleApps/ClientApp/Assets.xcassets/AppIcon.appiconset/Contents.json
delete mode 100644 ExampleApps/ClientApp/Assets.xcassets/Contents.json
delete mode 100644 ExampleApps/ClientApp/Base.lproj/LaunchScreen.storyboard
delete mode 100644 ExampleApps/ClientApp/Base.lproj/Main.storyboard
delete mode 100644 ExampleApps/ClientApp/HandshakeViewController.swift
delete mode 100644 ExampleApps/ClientApp/Info.plist
delete mode 100644 ExampleApps/ClientApp/MainViewController.swift
delete mode 100644 ExampleApps/ClientApp/WalletConnect.swift
delete mode 100644 ExampleApps/ExampleApps.xcodeproj/project.pbxproj
delete mode 100644 ExampleApps/ExampleApps.xcodeproj/project.xcworkspace/contents.xcworkspacedata
delete mode 100644 ExampleApps/ExampleApps.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
delete mode 100644 ExampleApps/ServerApp/AppDelegate.swift
delete mode 100644 ExampleApps/ServerApp/Assets.xcassets/AppIcon.appiconset/Contents.json
delete mode 100644 ExampleApps/ServerApp/Assets.xcassets/Contents.json
delete mode 100644 ExampleApps/ServerApp/Base.lproj/LaunchScreen.storyboard
delete mode 100644 ExampleApps/ServerApp/Base.lproj/Main.storyboard
delete mode 100644 ExampleApps/ServerApp/Info.plist
delete mode 100644 ExampleApps/ServerApp/MainViewController.swift
delete mode 100644 ExampleApps/ServerApp/ScannerViewController.swift
diff --git a/ExampleApps/ClientApp/ActionsViewController.swift b/ExampleApps/ClientApp/ActionsViewController.swift
deleted file mode 100644
index 9fb5339e6..000000000
--- a/ExampleApps/ClientApp/ActionsViewController.swift
+++ /dev/null
@@ -1,232 +0,0 @@
-//
-// Copyright © 2019 Gnosis Ltd. All rights reserved.
-//
-
-import UIKit
-import WalletConnectSwift
-
-/// For testing we recommend to use Rainbow Wallet
-/// MetaMask does not support `eth_gasPrice` and `eth_getTransactionCount` at the moment of testing 01.09.2021
-class ActionsViewController: UIViewController {
- @IBOutlet weak var disconnectButton: UIButton!
- @IBOutlet weak var personalSignButton: UIButton!
- @IBOutlet weak var ethSignButton: UIButton!
- @IBOutlet weak var ethSignTypedDataButton: UIButton!
- @IBOutlet weak var ethSendTransactionButton: UIButton!
- @IBOutlet weak var ethSignTransactionButton: UIButton!
- @IBOutlet weak var ethSendRawTransactionButton: UIButton!
- @IBOutlet weak var ethCustomRequestButton: UIButton!
-
- var client: Client!
- var session: Session!
-
- static func create(walletConnect: WalletConnect) -> ActionsViewController {
- let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
- let controller = storyboard.instantiateViewController(withIdentifier: "ActionsViewController") as! ActionsViewController
- controller.client = walletConnect.client
- controller.session = walletConnect.session
- return controller
- }
-
- var walletAccount: String {
- return session.walletInfo!.accounts[0]
- }
-
- @IBAction func disconnect(_ sender: Any) {
- guard let session = session else { return }
- try? client.disconnect(from: session)
- }
-
- // personal_sign should send a human readable message
- @IBAction func personal_sign(_ sender: Any) {
- try? client.personal_sign(url: session.url, message: "Hi there!", account: session.walletInfo!.accounts[0]) {
- [weak self] response in
- self?.handleReponse(response, expecting: "Signature")
- }
- }
-
- // eth_sign should send a properly formed hash: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))
- @IBAction func eth_sign(_ sender: Any) {
- try? client.eth_sign(url: session.url, account: session.walletInfo!.accounts[0], message: "0x0123") {
- [weak self] response in
- self?.handleReponse(response, expecting: "Signature")
- }
- }
-
- @IBAction func eth_signTypedData(_ sender: Any) {
- try? client.eth_signTypedData(url: session.url,
- account: session.walletInfo!.accounts[0],
- message: Stub.typedData) {
- [weak self] response in
- self?.handleReponse(response, expecting: "Signature") }
- }
-
- @IBAction func eth_sendTransaction(_ sender: Any) {
- // example when we make 2 chained requests: 1) get nonce 2) sendTransaction
- // We recommend to use Rainbow Wallet to test this reques
- try? client.send(nonceRequest()) { [weak self] response in
- guard let self = self, let nonce = self.nonce(from: response) else { return }
- let transaction = Stub.transaction(from: self.walletAccount, nonce: nonce)
- try? self.client.eth_sendTransaction(url: response.url, transaction: transaction) { [weak self] response in
- self?.handleReponse(response, expecting: "Hash")
- }
- }
- }
-
- @IBAction func eth_signTransaction(_ sender: Any) {
- let transaction = Stub.transaction(from: self.walletAccount, nonce: "0x0")
- try? self.client.eth_signTransaction(url: session.url, transaction: transaction) { [weak self] response in
- self?.handleReponse(response, expecting: "Signature")
- }
- }
-
- @IBAction func eth_sendRawTransaction(_ sender: Any) {
- try? client.eth_sendRawTransaction(url: session.url, data: Stub.data) { [weak self] response in
- self?.handleReponse(response, expecting: "Hash")
- }
- }
-
- @IBAction func customRequest(_ sender: Any) {
- // We recommend to use Rainbow Wallet to test this reques
- try? client.send(.eth_gasPrice(url: session.url)) { [weak self] response in
- self?.handleReponse(response, expecting: "Gas Price")
- }
- }
-
- @IBAction func close(_ sender: Any) {
- for session in client.openSessions() {
- try? client.disconnect(from: session)
- }
- dismiss(animated: true)
- }
-
- private func handleReponse(_ response: Response, expecting: String) {
- DispatchQueue.main.async {
- if let error = response.error {
- self.show(UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert))
- return
- }
- do {
- let result = try response.result(as: String.self)
- self.show(UIAlertController(title: expecting, message: result, preferredStyle: .alert))
- } catch {
- self.show(UIAlertController(title: "Error",
- message: "Unexpected response type error: \(error)",
- preferredStyle: .alert))
- }
- }
- }
-
- private func show(_ alert: UIAlertController) {
- alert.addAction(UIAlertAction(title: "Close", style: .cancel))
- self.present(alert, animated: true)
- }
-
- private func nonceRequest() -> Request {
- return .eth_getTransactionCount(url: session.url, account: session.walletInfo!.accounts[0])
- }
-
- private func nonce(from response: Response) -> String? {
- return try? response.result(as: String.self)
- }
-}
-
-extension Request {
- static func eth_getTransactionCount(url: WCURL, account: String) -> Request {
- return try! Request(url: url, method: "eth_getTransactionCount", params: [account, "latest"])
- }
-
- static func eth_gasPrice(url: WCURL) -> Request {
- return Request(url: url, method: "eth_gasPrice")
- }
-}
-
-fileprivate enum Stub {
- /// https://docs.walletconnect.org/json-rpc-api-methods/ethereum#example-parameters
- static let typedData = """
-{
- "types": {
- "EIP712Domain": [
- {
- "name": "name",
- "type": "string"
- },
- {
- "name": "version",
- "type": "string"
- },
- {
- "name": "chainId",
- "type": "uint256"
- },
- {
- "name": "verifyingContract",
- "type": "address"
- }
- ],
- "Person": [
- {
- "name": "name",
- "type": "string"
- },
- {
- "name": "wallet",
- "type": "address"
- }
- ],
- "Mail": [
- {
- "name": "from",
- "type": "Person"
- },
- {
- "name": "to",
- "type": "Person"
- },
- {
- "name": "contents",
- "type": "string"
- }
- ]
- },
- "primaryType": "Mail",
- "domain": {
- "name": "Ether Mail",
- "version": "1",
- "chainId": 1,
- "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
- },
- "message": {
- "from": {
- "name": "Cow",
- "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
- },
- "to": {
- "name": "Bob",
- "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
- },
- "contents": "Hello, Bob!"
- }
-}
-"""
-
- /// https://docs.walletconnect.org/json-rpc-api-methods/ethereum#example-parameters-1
- static func transaction(from address: String, nonce: String) -> Client.Transaction {
- return Client.Transaction(from: address,
- to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
- data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
- gas: "0x76c0", // 30400
- gasPrice: "0x9184e72a000", // 10000000000000
- value: "0x9184e72a", // 2441406250
- nonce: nonce,
- type: nil,
- accessList: nil,
- chainId: nil,
- maxPriorityFeePerGas: nil,
- maxFeePerGas: nil)
- }
-
- /// https://docs.walletconnect.org/json-rpc-api-methods/ethereum#example-5
- static let data = "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f07244567"
-
-}
diff --git a/ExampleApps/ClientApp/AppDelegate.swift b/ExampleApps/ClientApp/AppDelegate.swift
deleted file mode 100644
index 9e4edc1d1..000000000
--- a/ExampleApps/ClientApp/AppDelegate.swift
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Copyright © 2019 Gnosis Ltd. All rights reserved.
-//
-
-import UIKit
-
-@UIApplicationMain
-class AppDelegate: UIResponder, UIApplicationDelegate {
-
- var window: UIWindow?
-
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- // Override point for customization after application launch.
- return true
- }
-
- func applicationWillResignActive(_ application: UIApplication) {
- // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
- // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
- }
-
- func applicationDidEnterBackground(_ application: UIApplication) {
- // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
- }
-
- func applicationWillEnterForeground(_ application: UIApplication) {
- // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
- }
-
- func applicationDidBecomeActive(_ application: UIApplication) {
- // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
- }
-
- func applicationWillTerminate(_ application: UIApplication) {
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
- }
-
-
-}
-
diff --git a/ExampleApps/ClientApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/ExampleApps/ClientApp/Assets.xcassets/AppIcon.appiconset/Contents.json
deleted file mode 100644
index 9221b9bb1..000000000
--- a/ExampleApps/ClientApp/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "images" : [
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "20x20"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "20x20"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "29x29"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "29x29"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "40x40"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "40x40"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "60x60"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "60x60"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "20x20"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "20x20"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "29x29"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "29x29"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "40x40"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "40x40"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "76x76"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "76x76"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "83.5x83.5"
- },
- {
- "idiom" : "ios-marketing",
- "scale" : "1x",
- "size" : "1024x1024"
- }
- ],
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/ExampleApps/ClientApp/Assets.xcassets/Contents.json b/ExampleApps/ClientApp/Assets.xcassets/Contents.json
deleted file mode 100644
index 73c00596a..000000000
--- a/ExampleApps/ClientApp/Assets.xcassets/Contents.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/ExampleApps/ClientApp/Base.lproj/LaunchScreen.storyboard b/ExampleApps/ClientApp/Base.lproj/LaunchScreen.storyboard
deleted file mode 100644
index 865e9329f..000000000
--- a/ExampleApps/ClientApp/Base.lproj/LaunchScreen.storyboard
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ExampleApps/ClientApp/Base.lproj/Main.storyboard b/ExampleApps/ClientApp/Base.lproj/Main.storyboard
deleted file mode 100644
index eecef49a3..000000000
--- a/ExampleApps/ClientApp/Base.lproj/Main.storyboard
+++ /dev/null
@@ -1,190 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ExampleApps/ClientApp/HandshakeViewController.swift b/ExampleApps/ClientApp/HandshakeViewController.swift
deleted file mode 100644
index af435ce42..000000000
--- a/ExampleApps/ClientApp/HandshakeViewController.swift
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright © 2019 Gnosis Ltd. All rights reserved.
-//
-
-import UIKit
-import CoreImage.CIFilterBuiltins
-
-class HandshakeViewController: UIViewController {
- @IBOutlet weak var qrCodeImageView: UIImageView!
-
- var code: String!
-
- static func create(code: String) -> HandshakeViewController {
- let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
- let controller = storyboard.instantiateViewController(withIdentifier: "HandshakeViewController") as! HandshakeViewController
- controller.code = code
- return controller
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- let data = Data(code.utf8)
- let context = CIContext()
- let filter = CIFilter.qrCodeGenerator()
- filter.setValue(data, forKey: "inputMessage")
-
- let outputImage = filter.outputImage!
- let scaledImage = outputImage.transformed(by: CGAffineTransform(scaleX: 3, y: 3))
- let cgImage = context.createCGImage(scaledImage, from: scaledImage.extent)!
-
- qrCodeImageView.image = UIImage(cgImage: cgImage)
- }
-
- @IBAction func close(_ sender: Any) {
- dismiss(animated: true)
- }
-}
diff --git a/ExampleApps/ClientApp/Info.plist b/ExampleApps/ClientApp/Info.plist
deleted file mode 100644
index fd4cda1a4..000000000
--- a/ExampleApps/ClientApp/Info.plist
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- $(DEVELOPMENT_LANGUAGE)
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- $(PRODUCT_BUNDLE_PACKAGE_TYPE)
- CFBundleShortVersionString
- 1.0
- CFBundleVersion
- 1
- LSApplicationQueriesSchemes
-
- wc
-
- LSRequiresIPhoneOS
-
- UIApplicationSceneManifest
-
- UIApplicationSupportsMultipleScenes
-
-
- UILaunchStoryboardName
- LaunchScreen
- UIMainStoryboardFile
- Main
- UIRequiredDeviceCapabilities
-
- armv7
-
- UISupportedInterfaceOrientations
-
- UIInterfaceOrientationPortrait
-
- UISupportedInterfaceOrientations~ipad
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
-
-
diff --git a/ExampleApps/ClientApp/MainViewController.swift b/ExampleApps/ClientApp/MainViewController.swift
deleted file mode 100644
index 765e58507..000000000
--- a/ExampleApps/ClientApp/MainViewController.swift
+++ /dev/null
@@ -1,96 +0,0 @@
-//
-// Copyright © 2019 Gnosis Ltd. All rights reserved.
-//
-
-import UIKit
-
-class MainViewController: UIViewController {
- var handshakeController: HandshakeViewController!
- var actionsController: ActionsViewController!
- var walletConnect: WalletConnect!
-
- @IBAction func connect(_ sender: Any) {
- let connectionUrl = walletConnect.connect()
-
- /// https://docs.walletconnect.org/mobile-linking#for-ios
- /// **NOTE**: Majority of wallets support universal links that you should normally use in production application
- /// Here deep link provided for integration with server test app only
- let deepLinkUrl = "wc://wc?uri=\(connectionUrl)"
-
- DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
- if let url = URL(string: deepLinkUrl), UIApplication.shared.canOpenURL(url) {
- UIApplication.shared.open(url, options: [:], completionHandler: nil)
- } else {
- self.handshakeController = HandshakeViewController.create(code: connectionUrl)
- self.present(self.handshakeController, animated: true)
- }
- }
-
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- walletConnect = WalletConnect(delegate: self)
- walletConnect.reconnectIfNeeded()
- }
-
- func onMainThread(_ closure: @escaping () -> Void) {
- if Thread.isMainThread {
- closure()
- } else {
- DispatchQueue.main.async {
- closure()
- }
- }
- }
-}
-
-extension MainViewController: WalletConnectDelegate {
- func failedToConnect() {
- onMainThread { [unowned self] in
- if let handshakeController = self.handshakeController {
- handshakeController.dismiss(animated: true)
- }
- UIAlertController.showFailedToConnect(from: self)
- }
- }
-
- func didConnect() {
- onMainThread { [unowned self] in
- self.actionsController = ActionsViewController.create(walletConnect: self.walletConnect)
- if let handshakeController = self.handshakeController {
- handshakeController.dismiss(animated: false) { [unowned self] in
- self.present(self.actionsController, animated: false)
- }
- } else if self.presentedViewController == nil {
- self.present(self.actionsController, animated: false)
- }
- }
- }
-
- func didDisconnect() {
- onMainThread { [unowned self] in
- if let presented = self.presentedViewController {
- presented.dismiss(animated: false)
- }
- UIAlertController.showDisconnected(from: self)
- }
- }
-}
-
-extension UIAlertController {
- func withCloseButton() -> UIAlertController {
- addAction(UIAlertAction(title: "Close", style: .cancel))
- return self
- }
-
- static func showFailedToConnect(from controller: UIViewController) {
- let alert = UIAlertController(title: "Failed to connect", message: nil, preferredStyle: .alert)
- controller.present(alert.withCloseButton(), animated: true)
- }
-
- static func showDisconnected(from controller: UIViewController) {
- let alert = UIAlertController(title: "Did disconnect", message: nil, preferredStyle: .alert)
- controller.present(alert.withCloseButton(), animated: true)
- }
-}
diff --git a/ExampleApps/ClientApp/WalletConnect.swift b/ExampleApps/ClientApp/WalletConnect.swift
deleted file mode 100644
index 43941a4f7..000000000
--- a/ExampleApps/ClientApp/WalletConnect.swift
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// Copyright © 2019 Gnosis Ltd. All rights reserved.
-//
-
-import Foundation
-import WalletConnectSwift
-
-protocol WalletConnectDelegate {
- func failedToConnect()
- func didConnect()
- func didDisconnect()
-}
-
-class WalletConnect {
- var client: Client!
- var session: Session!
- var delegate: WalletConnectDelegate
-
- let sessionKey = "sessionKey"
-
- init(delegate: WalletConnectDelegate) {
- self.delegate = delegate
- }
-
- func connect() -> String {
- // gnosis wc bridge: https://safe-walletconnect.gnosis.io/
- // test bridge with latest protocol version: https://bridge.walletconnect.org
- let wcUrl = WCURL(topic: UUID().uuidString,
- bridgeURL: URL(string: "https://safe-walletconnect.gnosis.io/")!,
- key: try! randomKey())
- let clientMeta = Session.ClientMeta(name: "ExampleDApp",
- description: "WalletConnectSwift",
- icons: [],
- url: URL(string: "https://safe.gnosis.io")!)
- let dAppInfo = Session.DAppInfo(peerId: UUID().uuidString, peerMeta: clientMeta)
- client = Client(delegate: self, dAppInfo: dAppInfo)
-
- print("WalletConnect URL: \(wcUrl.absoluteString)")
-
- try! client.connect(to: wcUrl)
- return wcUrl.absoluteString
- }
-
- func reconnectIfNeeded() {
- if let oldSessionObject = UserDefaults.standard.object(forKey: sessionKey) as? Data,
- let session = try? JSONDecoder().decode(Session.self, from: oldSessionObject) {
- client = Client(delegate: self, dAppInfo: session.dAppInfo)
- try? client.reconnect(to: session)
- }
- }
-
- // https://developer.apple.com/documentation/security/1399291-secrandomcopybytes
- private func randomKey() throws -> String {
- var bytes = [Int8](repeating: 0, count: 32)
- let status = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes)
- if status == errSecSuccess {
- return Data(bytes: bytes, count: 32).toHexString()
- } else {
- // we don't care in the example app
- enum TestError: Error {
- case unknown
- }
- throw TestError.unknown
- }
- }
-}
-
-extension WalletConnect: ClientDelegate {
- func client(_ client: Client, didFailToConnect url: WCURL) {
- delegate.failedToConnect()
- }
-
- func client(_ client: Client, didConnect url: WCURL) {
- // do nothing
- }
-
- func client(_ client: Client, didConnect session: Session) {
- self.session = session
- let sessionData = try! JSONEncoder().encode(session)
- UserDefaults.standard.set(sessionData, forKey: sessionKey)
- delegate.didConnect()
- }
-
- func client(_ client: Client, didDisconnect session: Session) {
- UserDefaults.standard.removeObject(forKey: sessionKey)
- delegate.didDisconnect()
- }
-
- func client(_ client: Client, didUpdate session: Session) {
- // do nothing
- }
-}
diff --git a/ExampleApps/ExampleApps.xcodeproj/project.pbxproj b/ExampleApps/ExampleApps.xcodeproj/project.pbxproj
deleted file mode 100644
index dbfaff660..000000000
--- a/ExampleApps/ExampleApps.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,564 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 52;
- objects = {
-
-/* Begin PBXBuildFile section */
- 555DE0B324BC3516002714B9 /* Web3 in Frameworks */ = {isa = PBXBuildFile; productRef = 555DE0B224BC3516002714B9 /* Web3 */; };
- 55B781C624A619A80036F8E5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B781C524A619A80036F8E5 /* AppDelegate.swift */; };
- 55B781CD24A619A80036F8E5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 55B781CB24A619A80036F8E5 /* Main.storyboard */; };
- 55B781CF24A619A90036F8E5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 55B781CE24A619A90036F8E5 /* Assets.xcassets */; };
- 55B781D224A619A90036F8E5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 55B781D024A619A90036F8E5 /* LaunchScreen.storyboard */; };
- 55B781D924A61A3C0036F8E5 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B781D724A61A3C0036F8E5 /* MainViewController.swift */; };
- 55B781DA24A61A3C0036F8E5 /* ScannerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B781D824A61A3C0036F8E5 /* ScannerViewController.swift */; };
- 55B781DD24A61B0D0036F8E5 /* WalletConnectSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 55B781DC24A61B0D0036F8E5 /* WalletConnectSwift */; };
- 55B781E824A61CE60036F8E5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B781E724A61CE60036F8E5 /* AppDelegate.swift */; };
- 55B781EF24A61CE60036F8E5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 55B781ED24A61CE60036F8E5 /* Main.storyboard */; };
- 55B781F124A61CE70036F8E5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 55B781F024A61CE70036F8E5 /* Assets.xcassets */; };
- 55B781F424A61CE70036F8E5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 55B781F224A61CE70036F8E5 /* LaunchScreen.storyboard */; };
- 55B781FD24A61D480036F8E5 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B781F924A61D480036F8E5 /* MainViewController.swift */; };
- 55B781FE24A61D480036F8E5 /* WalletConnect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B781FA24A61D480036F8E5 /* WalletConnect.swift */; };
- 55B781FF24A61D480036F8E5 /* HandshakeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B781FB24A61D480036F8E5 /* HandshakeViewController.swift */; };
- 55B7820024A61D480036F8E5 /* ActionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B781FC24A61D480036F8E5 /* ActionsViewController.swift */; };
- 55B7820324A61D600036F8E5 /* WalletConnectSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 55B7820224A61D600036F8E5 /* WalletConnectSwift */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
- 55B781C324A619A80036F8E5 /* ServerApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ServerApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 55B781C524A619A80036F8E5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
- 55B781CC24A619A80036F8E5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
- 55B781CE24A619A90036F8E5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
- 55B781D124A619A90036F8E5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
- 55B781D324A619A90036F8E5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- 55B781D724A61A3C0036F8E5 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; };
- 55B781D824A61A3C0036F8E5 /* ScannerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScannerViewController.swift; sourceTree = ""; };
- 55B781E524A61CE60036F8E5 /* ClientApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ClientApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 55B781E724A61CE60036F8E5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
- 55B781EE24A61CE60036F8E5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
- 55B781F024A61CE70036F8E5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
- 55B781F324A61CE70036F8E5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
- 55B781F524A61CE70036F8E5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- 55B781F924A61D480036F8E5 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; };
- 55B781FA24A61D480036F8E5 /* WalletConnect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletConnect.swift; sourceTree = ""; };
- 55B781FB24A61D480036F8E5 /* HandshakeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HandshakeViewController.swift; sourceTree = ""; };
- 55B781FC24A61D480036F8E5 /* ActionsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionsViewController.swift; sourceTree = ""; };
- 55D2F76F26DF861C00E8E80F /* WalletConnectSwift */ = {isa = PBXFileReference; lastKnownFileType = folder; name = WalletConnectSwift; path = ..; sourceTree = ""; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- 55B781C024A619A80036F8E5 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 55B781DD24A61B0D0036F8E5 /* WalletConnectSwift in Frameworks */,
- 555DE0B324BC3516002714B9 /* Web3 in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 55B781E224A61CE60036F8E5 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 55B7820324A61D600036F8E5 /* WalletConnectSwift in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 55B7819F24A616A20036F8E5 = {
- isa = PBXGroup;
- children = (
- 55D2F76F26DF861C00E8E80F /* WalletConnectSwift */,
- 55B781C424A619A80036F8E5 /* ServerApp */,
- 55B781E624A61CE60036F8E5 /* ClientApp */,
- 55B781A924A616A20036F8E5 /* Products */,
- 55B7820124A61D600036F8E5 /* Frameworks */,
- );
- sourceTree = "";
- };
- 55B781A924A616A20036F8E5 /* Products */ = {
- isa = PBXGroup;
- children = (
- 55B781C324A619A80036F8E5 /* ServerApp.app */,
- 55B781E524A61CE60036F8E5 /* ClientApp.app */,
- );
- name = Products;
- sourceTree = "";
- };
- 55B781C424A619A80036F8E5 /* ServerApp */ = {
- isa = PBXGroup;
- children = (
- 55B781D724A61A3C0036F8E5 /* MainViewController.swift */,
- 55B781D824A61A3C0036F8E5 /* ScannerViewController.swift */,
- 55B781C524A619A80036F8E5 /* AppDelegate.swift */,
- 55B781CB24A619A80036F8E5 /* Main.storyboard */,
- 55B781CE24A619A90036F8E5 /* Assets.xcassets */,
- 55B781D024A619A90036F8E5 /* LaunchScreen.storyboard */,
- 55B781D324A619A90036F8E5 /* Info.plist */,
- );
- path = ServerApp;
- sourceTree = "";
- };
- 55B781E624A61CE60036F8E5 /* ClientApp */ = {
- isa = PBXGroup;
- children = (
- 55B781FC24A61D480036F8E5 /* ActionsViewController.swift */,
- 55B781FB24A61D480036F8E5 /* HandshakeViewController.swift */,
- 55B781F924A61D480036F8E5 /* MainViewController.swift */,
- 55B781FA24A61D480036F8E5 /* WalletConnect.swift */,
- 55B781E724A61CE60036F8E5 /* AppDelegate.swift */,
- 55B781ED24A61CE60036F8E5 /* Main.storyboard */,
- 55B781F024A61CE70036F8E5 /* Assets.xcassets */,
- 55B781F224A61CE70036F8E5 /* LaunchScreen.storyboard */,
- 55B781F524A61CE70036F8E5 /* Info.plist */,
- );
- path = ClientApp;
- sourceTree = "";
- };
- 55B7820124A61D600036F8E5 /* Frameworks */ = {
- isa = PBXGroup;
- children = (
- );
- name = Frameworks;
- sourceTree = "";
- };
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
- 55B781C224A619A80036F8E5 /* ServerApp */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 55B781D424A619A90036F8E5 /* Build configuration list for PBXNativeTarget "ServerApp" */;
- buildPhases = (
- 55B781BF24A619A80036F8E5 /* Sources */,
- 55B781C024A619A80036F8E5 /* Frameworks */,
- 55B781C124A619A80036F8E5 /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = ServerApp;
- packageProductDependencies = (
- 55B781DC24A61B0D0036F8E5 /* WalletConnectSwift */,
- 555DE0B224BC3516002714B9 /* Web3 */,
- );
- productName = ServerApp;
- productReference = 55B781C324A619A80036F8E5 /* ServerApp.app */;
- productType = "com.apple.product-type.application";
- };
- 55B781E424A61CE60036F8E5 /* ClientApp */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 55B781F624A61CE70036F8E5 /* Build configuration list for PBXNativeTarget "ClientApp" */;
- buildPhases = (
- 55B781E124A61CE60036F8E5 /* Sources */,
- 55B781E224A61CE60036F8E5 /* Frameworks */,
- 55B781E324A61CE60036F8E5 /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = ClientApp;
- packageProductDependencies = (
- 55B7820224A61D600036F8E5 /* WalletConnectSwift */,
- );
- productName = ClientApp;
- productReference = 55B781E524A61CE60036F8E5 /* ClientApp.app */;
- productType = "com.apple.product-type.application";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 55B781A024A616A20036F8E5 /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastSwiftUpdateCheck = 1150;
- LastUpgradeCheck = 1250;
- ORGANIZATIONNAME = Gnosis;
- TargetAttributes = {
- 55B781C224A619A80036F8E5 = {
- CreatedOnToolsVersion = 11.5;
- };
- 55B781E424A61CE60036F8E5 = {
- CreatedOnToolsVersion = 11.5;
- };
- };
- };
- buildConfigurationList = 55B781A324A616A20036F8E5 /* Build configuration list for PBXProject "ExampleApps" */;
- compatibilityVersion = "Xcode 9.3";
- developmentRegion = en;
- hasScannedForEncodings = 0;
- knownRegions = (
- en,
- Base,
- );
- mainGroup = 55B7819F24A616A20036F8E5;
- packageReferences = (
- 55B781DB24A61B0D0036F8E5 /* XCRemoteSwiftPackageReference "WalletConnectSwift" */,
- 555DE0B124BC3516002714B9 /* XCRemoteSwiftPackageReference "Web3.swift" */,
- );
- productRefGroup = 55B781A924A616A20036F8E5 /* Products */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- 55B781C224A619A80036F8E5 /* ServerApp */,
- 55B781E424A61CE60036F8E5 /* ClientApp */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
- 55B781C124A619A80036F8E5 /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 55B781D224A619A90036F8E5 /* LaunchScreen.storyboard in Resources */,
- 55B781CF24A619A90036F8E5 /* Assets.xcassets in Resources */,
- 55B781CD24A619A80036F8E5 /* Main.storyboard in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 55B781E324A61CE60036F8E5 /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 55B781F424A61CE70036F8E5 /* LaunchScreen.storyboard in Resources */,
- 55B781F124A61CE70036F8E5 /* Assets.xcassets in Resources */,
- 55B781EF24A61CE60036F8E5 /* Main.storyboard in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
- 55B781BF24A619A80036F8E5 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 55B781C624A619A80036F8E5 /* AppDelegate.swift in Sources */,
- 55B781DA24A61A3C0036F8E5 /* ScannerViewController.swift in Sources */,
- 55B781D924A61A3C0036F8E5 /* MainViewController.swift in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 55B781E124A61CE60036F8E5 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 55B781E824A61CE60036F8E5 /* AppDelegate.swift in Sources */,
- 55B781FD24A61D480036F8E5 /* MainViewController.swift in Sources */,
- 55B781FF24A61D480036F8E5 /* HandshakeViewController.swift in Sources */,
- 55B7820024A61D480036F8E5 /* ActionsViewController.swift in Sources */,
- 55B781FE24A61D480036F8E5 /* WalletConnect.swift in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXVariantGroup section */
- 55B781CB24A619A80036F8E5 /* Main.storyboard */ = {
- isa = PBXVariantGroup;
- children = (
- 55B781CC24A619A80036F8E5 /* Base */,
- );
- name = Main.storyboard;
- sourceTree = "";
- };
- 55B781D024A619A90036F8E5 /* LaunchScreen.storyboard */ = {
- isa = PBXVariantGroup;
- children = (
- 55B781D124A619A90036F8E5 /* Base */,
- );
- name = LaunchScreen.storyboard;
- sourceTree = "";
- };
- 55B781ED24A61CE60036F8E5 /* Main.storyboard */ = {
- isa = PBXVariantGroup;
- children = (
- 55B781EE24A61CE60036F8E5 /* Base */,
- );
- name = Main.storyboard;
- sourceTree = "";
- };
- 55B781F224A61CE70036F8E5 /* LaunchScreen.storyboard */ = {
- isa = PBXVariantGroup;
- children = (
- 55B781F324A61CE70036F8E5 /* Base */,
- );
- name = LaunchScreen.storyboard;
- sourceTree = "";
- };
-/* End PBXVariantGroup section */
-
-/* Begin XCBuildConfiguration section */
- 55B781BA24A616A30036F8E5 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ANALYZER_NONNULL = YES;
- CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
- CLANG_ENABLE_OBJC_ARC = YES;
- CLANG_ENABLE_OBJC_WEAK = YES;
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_COMMA = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
- CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INFINITE_RECURSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
- CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
- CLANG_WARN_STRICT_PROTOTYPES = YES;
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
- CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- COPY_PHASE_STRIP = NO;
- DEBUG_INFORMATION_FORMAT = dwarf;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- ENABLE_TESTABILITY = YES;
- GCC_C_LANGUAGE_STANDARD = gnu11;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 13.5;
- MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
- MTL_FAST_MATH = YES;
- ONLY_ACTIVE_ARCH = YES;
- SDKROOT = iphoneos;
- SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
- SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- };
- name = Debug;
- };
- 55B781BB24A616A30036F8E5 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ANALYZER_NONNULL = YES;
- CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
- CLANG_CXX_LIBRARY = "libc++";
- CLANG_ENABLE_MODULES = YES;
- CLANG_ENABLE_OBJC_ARC = YES;
- CLANG_ENABLE_OBJC_WEAK = YES;
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_COMMA = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
- CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INFINITE_RECURSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
- CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
- CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
- CLANG_WARN_STRICT_PROTOTYPES = YES;
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
- CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
- CLANG_WARN_UNREACHABLE_CODE = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- COPY_PHASE_STRIP = NO;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- ENABLE_NS_ASSERTIONS = NO;
- ENABLE_STRICT_OBJC_MSGSEND = YES;
- GCC_C_LANGUAGE_STANDARD = gnu11;
- GCC_NO_COMMON_BLOCKS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 13.5;
- MTL_ENABLE_DEBUG_INFO = NO;
- MTL_FAST_MATH = YES;
- SDKROOT = iphoneos;
- SWIFT_COMPILATION_MODE = wholemodule;
- SWIFT_OPTIMIZATION_LEVEL = "-O";
- VALIDATE_PRODUCT = YES;
- };
- name = Release;
- };
- 55B781D524A619A90036F8E5 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CODE_SIGN_IDENTITY = "Apple Development";
- CODE_SIGN_STYLE = Automatic;
- DEVELOPMENT_TEAM = ZKG876RKJ8;
- INFOPLIST_FILE = ServerApp/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 13.4;
- LD_RUNPATH_SEARCH_PATHS = (
- "$(inherited)",
- "@executable_path/Frameworks",
- );
- PRODUCT_BUNDLE_IDENTIFIER = io.gnosis.WalletConnectSwift.ServerApp;
- PRODUCT_NAME = "$(TARGET_NAME)";
- PROVISIONING_PROFILE_SPECIFIER = "";
- SWIFT_VERSION = 5.0;
- TARGETED_DEVICE_FAMILY = "1,2";
- };
- name = Debug;
- };
- 55B781D624A619A90036F8E5 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CODE_SIGN_IDENTITY = "Apple Development";
- CODE_SIGN_STYLE = Automatic;
- DEVELOPMENT_TEAM = ZKG876RKJ8;
- INFOPLIST_FILE = ServerApp/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 13.4;
- LD_RUNPATH_SEARCH_PATHS = (
- "$(inherited)",
- "@executable_path/Frameworks",
- );
- PRODUCT_BUNDLE_IDENTIFIER = io.gnosis.WalletConnectSwift.ServerApp;
- PRODUCT_NAME = "$(TARGET_NAME)";
- PROVISIONING_PROFILE_SPECIFIER = "";
- SWIFT_VERSION = 5.0;
- TARGETED_DEVICE_FAMILY = "1,2";
- };
- name = Release;
- };
- 55B781F724A61CE70036F8E5 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CODE_SIGN_STYLE = Automatic;
- DEVELOPMENT_TEAM = ZKG876RKJ8;
- INFOPLIST_FILE = ClientApp/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 13.4;
- LD_RUNPATH_SEARCH_PATHS = (
- "$(inherited)",
- "@executable_path/Frameworks",
- );
- PRODUCT_BUNDLE_IDENTIFIER = io.gnosis.WalletConnectSwift.ClientApp;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 5.0;
- TARGETED_DEVICE_FAMILY = "1,2";
- };
- name = Debug;
- };
- 55B781F824A61CE70036F8E5 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CODE_SIGN_STYLE = Automatic;
- DEVELOPMENT_TEAM = ZKG876RKJ8;
- INFOPLIST_FILE = ClientApp/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 13.4;
- LD_RUNPATH_SEARCH_PATHS = (
- "$(inherited)",
- "@executable_path/Frameworks",
- );
- PRODUCT_BUNDLE_IDENTIFIER = io.gnosis.WalletConnectSwift.ClientApp;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 5.0;
- TARGETED_DEVICE_FAMILY = "1,2";
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 55B781A324A616A20036F8E5 /* Build configuration list for PBXProject "ExampleApps" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 55B781BA24A616A30036F8E5 /* Debug */,
- 55B781BB24A616A30036F8E5 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 55B781D424A619A90036F8E5 /* Build configuration list for PBXNativeTarget "ServerApp" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 55B781D524A619A90036F8E5 /* Debug */,
- 55B781D624A619A90036F8E5 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 55B781F624A61CE70036F8E5 /* Build configuration list for PBXNativeTarget "ClientApp" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 55B781F724A61CE70036F8E5 /* Debug */,
- 55B781F824A61CE70036F8E5 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
-
-/* Begin XCRemoteSwiftPackageReference section */
- 555DE0B124BC3516002714B9 /* XCRemoteSwiftPackageReference "Web3.swift" */ = {
- isa = XCRemoteSwiftPackageReference;
- repositoryURL = "https://github.com/Boilertalk/Web3.swift.git";
- requirement = {
- kind = upToNextMinorVersion;
- minimumVersion = 0.4.2;
- };
- };
- 55B781DB24A61B0D0036F8E5 /* XCRemoteSwiftPackageReference "WalletConnectSwift" */ = {
- isa = XCRemoteSwiftPackageReference;
- repositoryURL = "https://github.com/WalletConnect/WalletConnectSwift.git";
- requirement = {
- branch = master;
- kind = branch;
- };
- };
-/* End XCRemoteSwiftPackageReference section */
-
-/* Begin XCSwiftPackageProductDependency section */
- 555DE0B224BC3516002714B9 /* Web3 */ = {
- isa = XCSwiftPackageProductDependency;
- package = 555DE0B124BC3516002714B9 /* XCRemoteSwiftPackageReference "Web3.swift" */;
- productName = Web3;
- };
- 55B781DC24A61B0D0036F8E5 /* WalletConnectSwift */ = {
- isa = XCSwiftPackageProductDependency;
- package = 55B781DB24A61B0D0036F8E5 /* XCRemoteSwiftPackageReference "WalletConnectSwift" */;
- productName = WalletConnectSwift;
- };
- 55B7820224A61D600036F8E5 /* WalletConnectSwift */ = {
- isa = XCSwiftPackageProductDependency;
- package = 55B781DB24A61B0D0036F8E5 /* XCRemoteSwiftPackageReference "WalletConnectSwift" */;
- productName = WalletConnectSwift;
- };
-/* End XCSwiftPackageProductDependency section */
- };
- rootObject = 55B781A024A616A20036F8E5 /* Project object */;
-}
diff --git a/ExampleApps/ExampleApps.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ExampleApps/ExampleApps.xcodeproj/project.xcworkspace/contents.xcworkspacedata
deleted file mode 100644
index 919434a62..000000000
--- a/ExampleApps/ExampleApps.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
diff --git a/ExampleApps/ExampleApps.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ExampleApps/ExampleApps.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
deleted file mode 100644
index 18d981003..000000000
--- a/ExampleApps/ExampleApps.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
- IDEDidComputeMac32BitWarning
-
-
-
diff --git a/ExampleApps/ServerApp/AppDelegate.swift b/ExampleApps/ServerApp/AppDelegate.swift
deleted file mode 100644
index 6710930d0..000000000
--- a/ExampleApps/ServerApp/AppDelegate.swift
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// AppDelegate.swift
-// ServerExample
-//
-// Created by Andrey Scherbovich on 20.08.19.
-// Copyright © 2019 Gnosis Ltd. All rights reserved.
-//
-
-import UIKit
-
-@UIApplicationMain
-class AppDelegate: UIResponder, UIApplicationDelegate {
-
- var window: UIWindow?
-
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- // Override point for customization after application launch.
- return true
- }
-
- func applicationWillResignActive(_ application: UIApplication) {
- // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
- // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
- }
-
- func applicationDidEnterBackground(_ application: UIApplication) {
- // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
- }
-
- func applicationWillEnterForeground(_ application: UIApplication) {
- // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
- }
-
- func applicationDidBecomeActive(_ application: UIApplication) {
- // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
- }
-
- func applicationWillTerminate(_ application: UIApplication) {
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
- }
-
- func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
- guard let controller = window?.rootViewController as? MainViewController else {
- return false
- }
- controller.didScan(url.absoluteString.replacingOccurrences(of: "wc://wc?uri=", with: ""))
- return true
- }
-
-}
diff --git a/ExampleApps/ServerApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/ExampleApps/ServerApp/Assets.xcassets/AppIcon.appiconset/Contents.json
deleted file mode 100644
index 9221b9bb1..000000000
--- a/ExampleApps/ServerApp/Assets.xcassets/AppIcon.appiconset/Contents.json
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "images" : [
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "20x20"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "20x20"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "29x29"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "29x29"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "40x40"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "40x40"
- },
- {
- "idiom" : "iphone",
- "scale" : "2x",
- "size" : "60x60"
- },
- {
- "idiom" : "iphone",
- "scale" : "3x",
- "size" : "60x60"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "20x20"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "20x20"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "29x29"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "29x29"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "40x40"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "40x40"
- },
- {
- "idiom" : "ipad",
- "scale" : "1x",
- "size" : "76x76"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "76x76"
- },
- {
- "idiom" : "ipad",
- "scale" : "2x",
- "size" : "83.5x83.5"
- },
- {
- "idiom" : "ios-marketing",
- "scale" : "1x",
- "size" : "1024x1024"
- }
- ],
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/ExampleApps/ServerApp/Assets.xcassets/Contents.json b/ExampleApps/ServerApp/Assets.xcassets/Contents.json
deleted file mode 100644
index 73c00596a..000000000
--- a/ExampleApps/ServerApp/Assets.xcassets/Contents.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "info" : {
- "author" : "xcode",
- "version" : 1
- }
-}
diff --git a/ExampleApps/ServerApp/Base.lproj/LaunchScreen.storyboard b/ExampleApps/ServerApp/Base.lproj/LaunchScreen.storyboard
deleted file mode 100644
index 865e9329f..000000000
--- a/ExampleApps/ServerApp/Base.lproj/LaunchScreen.storyboard
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ExampleApps/ServerApp/Base.lproj/Main.storyboard b/ExampleApps/ServerApp/Base.lproj/Main.storyboard
deleted file mode 100644
index 1655c501c..000000000
--- a/ExampleApps/ServerApp/Base.lproj/Main.storyboard
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ExampleApps/ServerApp/Info.plist b/ExampleApps/ServerApp/Info.plist
deleted file mode 100644
index ca7452883..000000000
--- a/ExampleApps/ServerApp/Info.plist
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- $(DEVELOPMENT_LANGUAGE)
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- $(PRODUCT_BUNDLE_PACKAGE_TYPE)
- CFBundleShortVersionString
- 1.0
- CFBundleURLTypes
-
-
- CFBundleTypeRole
- Editor
- CFBundleURLSchemes
-
- wc
-
-
-
- CFBundleVersion
- 1
- LSRequiresIPhoneOS
-
- NSCameraUsageDescription
- Scan WalletConnect QR Code
- UIApplicationSceneManifest
-
- UIApplicationSupportsMultipleScenes
-
-
- UILaunchStoryboardName
- LaunchScreen
- UIMainStoryboardFile
- Main
- UIRequiredDeviceCapabilities
-
- armv7
-
- UISupportedInterfaceOrientations
-
- UIInterfaceOrientationPortrait
-
- UISupportedInterfaceOrientations~ipad
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
-
-
diff --git a/ExampleApps/ServerApp/MainViewController.swift b/ExampleApps/ServerApp/MainViewController.swift
deleted file mode 100644
index 191098eff..000000000
--- a/ExampleApps/ServerApp/MainViewController.swift
+++ /dev/null
@@ -1,279 +0,0 @@
-//
-// Copyright © 2019 Gnosis Ltd. All rights reserved.
-//
-
-import UIKit
-import Web3
-import WalletConnectSwift
-
-class MainViewController: UIViewController {
- @IBOutlet weak var walletAddressLabel: UILabel!
- @IBOutlet weak var statusLabel: UILabel!
- @IBOutlet weak var scanQRCodeButton: UIButton!
- @IBOutlet weak var disconnectButton: UIButton!
-
- var scannerController: ScannerViewController?
- var server: Server!
- var session: Session!
- let privateKey: EthereumPrivateKey = try! EthereumPrivateKey(
- privateKey: .init(hex: "BD9F406A928238E9500E4C7276F77E6D15118D62CC6B65B5A39C442BE6F1262F"))
-
- let sessionKey = "sessionKey"
-
- @IBAction func scan(_ sender: Any) {
- scannerController = ScannerViewController.create(delegate: self)
- present(scannerController!, animated: true)
- }
-
- @IBAction func disconnect(_ sender: Any) {
- try! server.disconnect(from: session)
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- configureServer()
- walletAddressLabel.text = privateKey.address.hex(eip55: true)
- statusLabel.text = "Disconnected"
- disconnectButton.isHidden = true
- }
-
- private func configureServer() {
- server = Server(delegate: self)
- server.register(handler: PersonalSignHandler(for: self, server: server, privateKey: privateKey))
- server.register(handler: SignTransactionHandler(for: self, server: server, privateKey: privateKey))
- if let oldSessionObject = UserDefaults.standard.object(forKey: sessionKey) as? Data,
- let session = try? JSONDecoder().decode(Session.self, from: oldSessionObject) {
- try? server.reconnect(to: session)
- }
- }
-
- func onMainThread(_ closure: @escaping () -> Void) {
- if Thread.isMainThread {
- closure()
- } else {
- DispatchQueue.main.async {
- closure()
- }
- }
- }
-}
-
-class BaseHandler: RequestHandler {
- weak var controller: UIViewController!
- weak var sever: Server!
- weak var privateKey: EthereumPrivateKey!
-
- init(for controller: UIViewController, server: Server, privateKey: EthereumPrivateKey) {
- self.controller = controller
- self.sever = server
- self.privateKey = privateKey
- }
-
- func canHandle(request: Request) -> Bool {
- return false
- }
-
- func handle(request: Request) {
- // to override
- }
-
- func askToSign(request: Request, message: String, sign: @escaping () -> String) {
- let onSign = {
- let signature = sign()
- self.sever.send(.signature(signature, for: request))
- }
- let onCancel = {
- self.sever.send(.reject(request))
- }
- DispatchQueue.main.async {
- UIAlertController.showShouldSign(from: self.controller,
- title: "Request to sign a message",
- message: message,
- onSign: onSign,
- onCancel: onCancel)
- }
- }
-}
-
-class PersonalSignHandler: BaseHandler {
- override func canHandle(request: Request) -> Bool {
- return request.method == "personal_sign"
- }
-
- override func handle(request: Request) {
- do {
- let messageBytes = try request.parameter(of: String.self, at: 0)
- let address = try request.parameter(of: String.self, at: 1)
-
- guard address == privateKey.address.hex(eip55: true) else {
- sever.send(.reject(request))
- return
- }
-
- let decodedMessage = String(data: Data(hex: messageBytes), encoding: .utf8) ?? messageBytes
-
- askToSign(request: request, message: decodedMessage) {
- let personalMessageData = self.personalMessageData(messageData: Data(hex: messageBytes))
- let (v, r, s) = try! self.privateKey.sign(message: .init(hex: personalMessageData.toHexString()))
- return "0x" + r.toHexString() + s.toHexString() + String(v + 27, radix: 16) // v in [0, 1]
- }
- } catch {
- sever.send(.invalid(request))
- return
- }
- }
-
- private func personalMessageData(messageData: Data) -> Data {
- let prefix = "\u{19}Ethereum Signed Message:\n"
- let prefixData = (prefix + String(messageData.count)).data(using: .ascii)!
- return prefixData + messageData
- }
-}
-
-class SignTransactionHandler: BaseHandler {
- override func canHandle(request: Request) -> Bool {
- return request.method == "eth_signTransaction"
- }
-
- override func handle(request: Request) {
- do {
- let transaction = try request.parameter(of: EthereumTransaction.self, at: 0)
- guard transaction.from == privateKey.address else {
- self.sever.send(.reject(request))
- return
- }
-
- askToSign(request: request, message: transaction.description) {
- let signedTx = try! transaction.sign(with: self.privateKey, chainId: 4)
- let (r, s, v) = (signedTx.r, signedTx.s, signedTx.v)
- return r.hex() + s.hex().dropFirst(2) + String(v.quantity, radix: 16)
- }
- } catch {
- self.sever.send(.invalid(request))
- }
- }
-}
-
-extension Response {
- static func signature(_ signature: String, for request: Request) -> Response {
- return try! Response(url: request.url, value: signature, id: request.id!)
- }
-}
-
-extension MainViewController: ServerDelegate {
- func server(_ server: Server, didFailToConnect url: WCURL) {
- onMainThread {
- self.scanQRCodeButton.isEnabled = true
- self.scanQRCodeButton.isHidden = false
- self.disconnectButton.isHidden = true
- UIAlertController.showFailedToConnect(from: self)
- }
- }
-
- func server(_ server: Server, shouldStart session: Session, completion: @escaping (Session.WalletInfo) -> Void) {
- let walletMeta = Session.ClientMeta(name: "Test Wallet",
- description: nil,
- icons: [],
- url: URL(string: "https://safe.gnosis.io")!)
- let walletInfo = Session.WalletInfo(approved: true,
- accounts: [privateKey.address.hex(eip55: true)],
- chainId: 4,
- peerId: UUID().uuidString,
- peerMeta: walletMeta)
- onMainThread {
- UIAlertController.showShouldStart(from: self, clientName: session.dAppInfo.peerMeta.name, onStart: {
- completion(walletInfo)
- }, onClose: {
- completion(Session.WalletInfo(approved: false, accounts: [], chainId: 4, peerId: "", peerMeta: walletMeta))
- self.scanQRCodeButton.isEnabled = true
- })
- }
- }
-
- func server(_ server: Server, didConnect session: Session) {
- if let currentSession = self.session,
- currentSession.url.key != session.url.key {
- print("Test app only supports 1 session atm, cleaning...")
- try? self.server.disconnect(from: currentSession)
- }
- self.session = session
- let sessionData = try! JSONEncoder().encode(session)
- UserDefaults.standard.set(sessionData, forKey: sessionKey)
- onMainThread {
- self.scanQRCodeButton.isHidden = true
- self.disconnectButton.isHidden = false
- self.statusLabel.text = "Connected to \(session.dAppInfo.peerMeta.name)"
- }
- }
-
- func server(_ server: Server, didDisconnect session: Session) {
- UserDefaults.standard.removeObject(forKey: sessionKey)
- onMainThread {
- self.scanQRCodeButton.isEnabled = true
- self.scanQRCodeButton.isHidden = false
- self.disconnectButton.isHidden = true
- self.statusLabel.text = "Disconnected"
- }
- }
-
- func server(_ server: Server, didUpdate session: Session) {
- // no-op
- }
-}
-
-extension MainViewController: ScannerViewControllerDelegate {
- func didScan(_ code: String) {
- guard let url = WCURL(code) else { return }
- scanQRCodeButton.isEnabled = false
- scannerController?.dismiss(animated: true)
- do {
- try self.server.connect(to: url)
- } catch {
- return
- }
- }
-}
-
-extension UIAlertController {
- func withCloseButton(title: String = "Close", onClose: (() -> Void)? = nil ) -> UIAlertController {
- addAction(UIAlertAction(title: title, style: .cancel) { _ in onClose?() } )
- return self
- }
-
- static func showShouldStart(from controller: UIViewController, clientName: String, onStart: @escaping () -> Void, onClose: @escaping (() -> Void)) {
- let alert = UIAlertController(title: "Request to start a session", message: clientName, preferredStyle: .alert)
- let startAction = UIAlertAction(title: "Start", style: .default) { _ in onStart() }
- alert.addAction(startAction)
- controller.present(alert.withCloseButton(onClose: onClose), animated: true)
- }
-
- static func showFailedToConnect(from controller: UIViewController) {
- let alert = UIAlertController(title: "Failed to connect", message: nil, preferredStyle: .alert)
- controller.present(alert.withCloseButton(), animated: true)
- }
-
- static func showDisconnected(from controller: UIViewController) {
- let alert = UIAlertController(title: "Did disconnect", message: nil, preferredStyle: .alert)
- controller.present(alert.withCloseButton(), animated: true)
- }
-
- static func showShouldSign(from controller: UIViewController, title: String, message: String, onSign: @escaping () -> Void, onCancel: @escaping () -> Void) {
- let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
- let startAction = UIAlertAction(title: "Sign", style: .default) { _ in onSign() }
- alert.addAction(startAction)
- controller.present(alert.withCloseButton(title: "Reject", onClose: onCancel), animated: true)
- }
-}
-
-extension EthereumTransaction {
- var description: String {
- return """
- to: \(String(describing: to!.hex(eip55: true))),
- value: \(String(describing: value!.hex())),
- gasPrice: \(String(describing: gasPrice!.hex())),
- gas: \(String(describing: gas!.hex())),
- data: \(data.hex()),
- nonce: \(String(describing: nonce!.hex()))
- """
- }
-}
diff --git a/ExampleApps/ServerApp/ScannerViewController.swift b/ExampleApps/ServerApp/ScannerViewController.swift
deleted file mode 100644
index 06e64e01a..000000000
--- a/ExampleApps/ServerApp/ScannerViewController.swift
+++ /dev/null
@@ -1,64 +0,0 @@
-//
-// Copyright © 2019 Gnosis Ltd. All rights reserved.
-//
-
-import UIKit
-import AVFoundation
-
-protocol ScannerViewControllerDelegate {
- func didScan(_ code: String)
-}
-
-class ScannerViewController: UIViewController {
- let captureSession = AVCaptureSession()
- var videoPreviewLayer: AVCaptureVideoPreviewLayer!
- var delegate: ScannerViewControllerDelegate!
-
- static func create(delegate: ScannerViewControllerDelegate) -> ScannerViewController {
- let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
- let controller = storyboard.instantiateViewController(withIdentifier: "ScannerViewController") as! ScannerViewController
- controller.delegate = delegate
- return controller
- }
-
- @IBAction func close(_ sender: Any) {
- dismiss(animated: true)
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- let deviceDiscoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera], mediaType: .video, position: .back)
- guard let captureDevice = deviceDiscoverySession.devices.first else {
- print("can't find capture device")
- return
- }
- do {
- let input = try AVCaptureDeviceInput(device: captureDevice)
- captureSession.addInput(input)
- let captureMetadataOutput = AVCaptureMetadataOutput()
- captureSession.addOutput(captureMetadataOutput)
- captureMetadataOutput.setMetadataObjectsDelegate(self, queue: .main)
- captureMetadataOutput.metadataObjectTypes = [.qr]
- captureSession.startRunning()
-
- videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
- videoPreviewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
- videoPreviewLayer.frame = view.layer.bounds
- view.layer.insertSublayer(videoPreviewLayer, at: 0)
- } catch {
- print("Error: \(error)")
- }
- }
-}
-
-extension ScannerViewController: AVCaptureMetadataOutputObjectsDelegate {
- func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
- guard !metadataObjects.isEmpty else { return }
- let metadata = metadataObjects[0] as! AVMetadataMachineReadableCodeObject
- if metadata.type == .qr && metadata.stringValue != nil {
- delegate.didScan(metadata.stringValue!)
- captureSession.stopRunning()
- }
- }
-}
From 056b402daa724c7da17661c941e68b5f10d02ec5 Mon Sep 17 00:00:00 2001
From: Dmitry Bespalov
Date: Fri, 12 Nov 2021 12:06:25 +0100
Subject: [PATCH 13/13] Updated README
---
README.md | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/README.md b/README.md
index 5c8631f1d..6a26103f6 100644
--- a/README.md
+++ b/README.md
@@ -4,16 +4,11 @@ Swift SDK implementing [WalletConnect 1.x.x](https://docs.walletconnect.org) pro
# Features
-- Server (wallet)
+- Server (wallet side)
- Create, reconnect, disconnect, and update session
- Flexible, extendable request handling with `Codable` support via JSON RPC 2.0
- - Example App:
- - Connecting via QR code reader
- - Connecting via deep link ("wc" scheme)
- - Reconnecting after restart
- - Examples of request handlers
-- Client (native dapp)
+- Client (native dapp side)
- Create, reconnect, disconnect, and update session
- Default implementation of [WalletConnect SDK API](https://docs.walletconnect.org/json-rpc/ethereum)
- `personal_sign`
@@ -23,12 +18,20 @@ Swift SDK implementing [WalletConnect 1.x.x](https://docs.walletconnect.org) pro
- `eth_signTransaction`
- `eth_sendRawTransaction`
- Send custom RPC requests with `Codable` support via JSON RPC 2.0
- - Example App:
- - Generating QR-code with WC URL
- - Connecting via deep link
- - Reconnecting after restart
- - WalletConnect SDK requests
- - Custom request (Ethereum JSON RPC)
+
+# Example Code
+Example code is in a separate repository: https://github.com/WalletConnect/WalletConnectSwift-Example
+
+- Wallet Example App:
+ - Connecting via QR code reader
+ - Connecting via deep link ("wc" scheme)
+ - Reconnecting after restart
+ - Examples of request handlers
+- Dapp Example App:
+ - Connecting via QR code reader
+ - Connecting via deep link ("wc" scheme)
+ - Reconnecting after restart
+ - Examples of request handlers
## Usage in a Wallet