Skip to content

Commit b9afc23

Browse files
authored
Merge pull request #1362 from WalletConnect/develop
1.19.0
2 parents d819f76 + 3afcf07 commit b9afc23

File tree

87 files changed

+2644
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2644
-473
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1530"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
</BuildAction>
10+
<TestAction
11+
buildConfiguration = "Debug"
12+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
13+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
14+
shouldUseLaunchSchemeArgsEnv = "YES"
15+
shouldAutocreateTestPlan = "YES">
16+
<Testables>
17+
<TestableReference
18+
skipped = "NO">
19+
<BuildableReference
20+
BuildableIdentifier = "primary"
21+
BlueprintIdentifier = "WalletConnectKMSTests"
22+
BuildableName = "WalletConnectKMSTests"
23+
BlueprintName = "WalletConnectKMSTests"
24+
ReferencedContainer = "container:">
25+
</BuildableReference>
26+
</TestableReference>
27+
</Testables>
28+
</TestAction>
29+
<LaunchAction
30+
buildConfiguration = "Debug"
31+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
32+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
33+
launchStyle = "0"
34+
useCustomWorkingDirectory = "NO"
35+
ignoresPersistentStateOnLaunch = "NO"
36+
debugDocumentVersioning = "YES"
37+
debugServiceExtension = "internal"
38+
allowLocationSimulation = "YES">
39+
</LaunchAction>
40+
<ProfileAction
41+
buildConfiguration = "Release"
42+
shouldUseLaunchSchemeArgsEnv = "YES"
43+
savedToolIdentifier = ""
44+
useCustomWorkingDirectory = "NO"
45+
debugDocumentVersioning = "YES">
46+
</ProfileAction>
47+
<AnalyzeAction
48+
buildConfiguration = "Debug">
49+
</AnalyzeAction>
50+
<ArchiveAction
51+
buildConfiguration = "Release"
52+
revealArchiveInOrganizer = "YES">
53+
</ArchiveAction>
54+
</Scheme>

Example/DApp/AppDelegate.swift

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UIKit
2+
import WalletConnectSign
23

34
@main
45
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -15,6 +16,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1516
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
1617
}
1718

19+
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) async -> Bool {
20+
guard let url = userActivity.webpageURL,
21+
let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
22+
return true
23+
}
24+
try! Sign.instance.dispatchEnvelope(url.absoluteString)
25+
26+
return true
27+
}
28+
1829
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
1930
// Called when the user discards a scene session.
2031
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.

Example/DApp/Constants.swift

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
import Foundation
3+
4+
enum Constants {
5+
static let groupIdentifier = "group.com.walletconnect.dapp"
6+
}

Example/DApp/DApp.entitlements

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>com.apple.developer.associated-domains</key>
6+
<array>
7+
<string>applinks:lab.web3modal.com</string>
8+
</array>
59
<key>com.apple.security.application-groups</key>
610
<array>
711
<string>group.com.walletconnect.dapp</string>

Example/DApp/DAppRelease.entitlements

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.developer.associated-domains</key>
6+
<array>
7+
<string>applinks:lab.web3modal.com</string>
8+
</array>
9+
<key>com.apple.security.application-groups</key>
10+
<array>
11+
<string>group.com.walletconnect.dapp</string>
12+
</array>
13+
</dict>
14+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import SwiftUI
2+
3+
final class ConfigModule {
4+
@discardableResult
5+
static func create(app: Application) -> UIViewController {
6+
let router = ConfigRouter(app: app)
7+
let presenter = ConfigPresenter(router: router)
8+
let view = ConfigView().environmentObject(presenter)
9+
10+
let viewController = SceneViewController(viewModel: presenter, content: view)
11+
router.viewController = viewController
12+
13+
return viewController
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import UIKit
2+
import Combine
3+
4+
import WalletConnectSign
5+
6+
final class ConfigPresenter: ObservableObject, SceneViewModel {
7+
8+
9+
private let router: ConfigRouter
10+
11+
init(
12+
router: ConfigRouter
13+
) {
14+
defer { setupInitialState() }
15+
self.router = router
16+
}
17+
18+
func onAppear() {
19+
20+
}
21+
22+
private func setupInitialState() {
23+
24+
}
25+
26+
func cleanLinkModeSupportedWalletsCache() {
27+
let userDefaults = UserDefaults(suiteName: Constants.groupIdentifier)!
28+
let prefix = "com.walletconnect.sdk.linkModeLinks"
29+
let keys = userDefaults.dictionaryRepresentation().keys
30+
31+
for key in keys where key.hasPrefix(prefix) {
32+
userDefaults.removeObject(forKey: key)
33+
}
34+
}
35+
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
import Foundation
3+
import UIKit
4+
import WalletConnectSign
5+
6+
final class ConfigRouter {
7+
weak var viewController: UIViewController!
8+
9+
private let app: Application
10+
11+
init(app: Application) {
12+
self.app = app
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import SwiftUI
2+
3+
struct ConfigView: View {
4+
@EnvironmentObject var presenter: ConfigPresenter
5+
6+
var body: some View {
7+
NavigationStack {
8+
ZStack {
9+
Color(red: 25/255, green: 26/255, blue: 26/255)
10+
.ignoresSafeArea()
11+
12+
ScrollView {
13+
VStack {
14+
Button {
15+
presenter.cleanLinkModeSupportedWalletsCache()
16+
} label: {
17+
HStack {
18+
Spacer()
19+
Text("Clean Link Mode Supported Wallets Cache")
20+
.font(.system(size: 16, weight: .semibold))
21+
.foregroundColor(.white)
22+
.padding(.vertical, 25)
23+
Spacer()
24+
}
25+
.background(Color(red: 95/255, green: 159/255, blue: 248/255))
26+
.cornerRadius(16)
27+
}
28+
.padding(.top, 10)
29+
}
30+
.padding(12)
31+
}
32+
.padding(.bottom, 76)
33+
.onAppear {
34+
presenter.onAppear()
35+
}
36+
}
37+
.navigationTitle("Configuration")
38+
.navigationBarTitleDisplayMode(.inline)
39+
.toolbarColorScheme(.dark, for: .navigationBar)
40+
.toolbarBackground(.visible, for: .navigationBar)
41+
.toolbarBackground(
42+
Color(red: 25/255, green: 26/255, blue: 26/255),
43+
for: .navigationBar
44+
)
45+
}
46+
}
47+
}
48+
49+
struct ConfigView_Previews: PreviewProvider {
50+
static var previews: some View {
51+
ConfigView()
52+
}
53+
}

Example/DApp/Modules/Sign/SignPresenter.swift

+24-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,29 @@ final class SignPresenter: ObservableObject {
108108
}
109109
}
110110

111+
@MainActor
112+
func connectWalletWithSessionAuthenticateLinkMode() {
113+
Task {
114+
do {
115+
ActivityIndicatorManager.shared.start()
116+
if let pairingUri = try await Sign.instance.authenticate(.stub(methods: ["personal_sign"]), walletUniversalLink: "https://lab.web3modal.com/wallet") {
117+
walletConnectUri = pairingUri
118+
ActivityIndicatorManager.shared.stop()
119+
router.presentNewPairing(walletConnectUri: walletConnectUri!)
120+
}
121+
} catch {
122+
AlertPresenter.present(message: error.localizedDescription, type: .error)
123+
ActivityIndicatorManager.shared.stop()
124+
}
125+
}
126+
}
127+
128+
@MainActor
129+
func openConfiguration() {
130+
router.openConfig()
131+
}
132+
133+
@MainActor
111134
func disconnect() {
112135
if let session {
113136
Task { @MainActor in
@@ -218,7 +241,7 @@ extension SignPresenter: SceneViewModel {}
218241
// MARK: - Authenticate request stub
219242
extension AuthRequestParams {
220243
static func stub(
221-
domain: String = "app.web3inbox",
244+
domain: String = "lab.web3modal.com",
222245
chains: [String] = ["eip155:1", "eip155:137"],
223246
nonce: String = "32891756",
224247
uri: String = "https://app.web3inbox.com/login",

Example/DApp/Modules/Sign/SignRouter.swift

+4
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ final class SignRouter {
3434
func popToRoot() {
3535
viewController.popToRoot()
3636
}
37+
38+
func openConfig() {
39+
ConfigModule.create(app: app).push(from: viewController)
40+
}
3741
}

0 commit comments

Comments
 (0)