Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caip222 over universal linking #1361

Merged
merged 85 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
c4ae4ad
savepoint
llbartekll Mar 26, 2024
0dbb3e8
Add LinkTransportInteractor and type2 envelope
llbartekll Mar 26, 2024
70d753d
savepoint
llbartekll Mar 27, 2024
fa331e2
savepoint
llbartekll Mar 27, 2024
89ff584
fix type2 envelope, add tests
llbartekll Mar 27, 2024
2cacba8
deserialise type2 envelope in integ test
llbartekll Mar 27, 2024
de9a790
fix multiple instances of envelope dispatcher
llbartekll Mar 28, 2024
07b6cd2
authenticateRequestPublisher connected
llbartekll Mar 28, 2024
135c60b
savepoint
llbartekll Mar 28, 2024
62416a7
savepoint
llbartekll Mar 29, 2024
6ee08c9
fix unit tests build
llbartekll Mar 29, 2024
331e661
fix tests that are failing due to summer time change
llbartekll Mar 29, 2024
378244d
savepoint
llbartekll Apr 2, 2024
119e247
savepoint
llbartekll Apr 2, 2024
75a3a77
savepoint
llbartekll Apr 2, 2024
a952042
savepoint
llbartekll Apr 2, 2024
c3c1e24
pass first integration test
llbartekll Apr 2, 2024
bad4b99
savepoint
llbartekll Apr 4, 2024
73a08a8
savepoint
llbartekll Apr 4, 2024
a95d153
Merge branch 'develop' of github.com:WalletConnect/WalletConnectSwift…
llbartekll Apr 4, 2024
f9ee474
savepoint
llbartekll Apr 4, 2024
bc0ddec
successfully transport response
llbartekll Apr 5, 2024
c45c03b
turn off notify
llbartekll Apr 5, 2024
3bf55dd
savepoint
llbartekll Apr 5, 2024
1ab1591
Add tryDeserializeRequestOrResponse to the serialiser
llbartekll Apr 5, 2024
892369e
integrate tryDeserializeRequestOrResponse in LinkDispatcher
llbartekll Apr 5, 2024
5e7e833
add LinkSessionRequestSubscriber
llbartekll Apr 22, 2024
c6306b2
add SessionRequestDispatcher
llbartekll Apr 22, 2024
e62c0dc
savepoint
llbartekll Apr 22, 2024
4ece6ae
savepoint
llbartekll Apr 22, 2024
2216fae
add sessionResponderDispatcher
llbartekll Apr 22, 2024
383e659
savepoint
llbartekll Apr 22, 2024
7effce2
savepoint
llbartekll Apr 22, 2024
7998891
savepoint
llbartekll Apr 22, 2024
fce42b6
handle error response
llbartekll Apr 22, 2024
241242c
savepoint
llbartekll Apr 23, 2024
5f641a9
savepoint
llbartekll Apr 23, 2024
6acbcba
savepoint
llbartekll Apr 23, 2024
6c13a19
add testLinkSessionRequest
llbartekll Apr 24, 2024
0490290
savepoint
llbartekll Apr 24, 2024
cf07a20
Merge branch 'develop' of github.com:WalletConnect/WalletConnectSwift…
llbartekll Apr 25, 2024
c8f8478
Merge branch 'develop' of github.com:WalletConnect/WalletConnectSwift…
llbartekll May 3, 2024
01a73dd
savepoint
llbartekll May 4, 2024
5e3aeaa
savepoint
llbartekll May 7, 2024
09d5842
savepoint
llbartekll May 8, 2024
db910fc
savepoint
llbartekll May 13, 2024
a8485ea
savepoint
llbartekll May 13, 2024
4f7b2f8
savepoint
llbartekll May 13, 2024
ff7d865
handle link mode on wallet launch
llbartekll May 13, 2024
44d39d9
savepoint
llbartekll May 15, 2024
812681d
Merge branch 'develop' of github.com:WalletConnect/WalletConnectSwift…
llbartekll May 15, 2024
a10a77b
fix crash: configure w3w client in the scene delegate
llbartekll May 15, 2024
4384fe4
remove type3 an4 envelopes
llbartekll May 17, 2024
7313b17
savepoint
llbartekll May 20, 2024
ca89dd2
savepoint
llbartekll May 20, 2024
3c2963e
add integration tests, introduce linkMode in metadata
llbartekll May 22, 2024
81ac80c
add AuthenticateTransportTypeSwitcher
llbartekll May 22, 2024
45a66bd
fix build
llbartekll May 22, 2024
780cb2c
use linkMode property for link mode
llbartekll May 22, 2024
03d6c5e
update tests, add relay blockPublishing
llbartekll May 23, 2024
3c26608
add testUpgradeSessionToLinkModeAndSendRequestOverLinkMode
llbartekll May 23, 2024
63a1b50
make linkMode property bool
llbartekll May 23, 2024
e411b7e
savepoint
llbartekll May 23, 2024
605386f
add verify context
llbartekll May 23, 2024
ad4820c
update apps integration
llbartekll May 24, 2024
3dacb6f
fix verify in dapp
llbartekll May 24, 2024
b987df6
add config screen to dapp
llbartekll May 24, 2024
7f6f11c
savepoint
llbartekll May 24, 2024
b20eb8b
add appmetadata init validation
llbartekll May 24, 2024
a15c615
fix integration tests
llbartekll May 24, 2024
d81deb1
fix builds
llbartekll May 24, 2024
423eb35
fix redirect
llbartekll May 27, 2024
427ef24
cleanup
llbartekll May 27, 2024
c664759
remove unused class
llbartekll May 27, 2024
d820c4a
fix kms tests
llbartekll May 27, 2024
17ac8a5
fix wcm build
llbartekll May 27, 2024
a93b69e
update tests
llbartekll May 27, 2024
3f877c8
change qos in dispatch queues
llbartekll May 28, 2024
43f2c87
add envelope tests
llbartekll May 28, 2024
a393a8e
Add envelope tests
llbartekll May 28, 2024
ee2a57a
add envelope type tests
llbartekll May 28, 2024
85c4dd2
Apply suggestions from code review
llbartekll May 28, 2024
cb957fc
Update Sources/WalletConnectSign/Auth/Services/App/AuthResponseSubscr…
llbartekll May 28, 2024
3dbf75c
blockPublishing not public
llbartekll May 28, 2024
5afa672
fix build
llbartekll May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WalletConnectKMSTests"
BuildableName = "WalletConnectKMSTests"
BlueprintName = "WalletConnectKMSTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
11 changes: 11 additions & 0 deletions Example/DApp/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import UIKit
import WalletConnectSign

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -15,6 +16,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) async -> Bool {
guard let url = userActivity.webpageURL,
let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
return true
}
try! Sign.instance.dispatchEnvelope(url.absoluteString)

return true
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
Expand Down
6 changes: 6 additions & 0 deletions Example/DApp/Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

import Foundation

enum Constants: String {
case groupIdentifier = "group.com.walletconnect.dapp"
}
llbartekll marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions Example/DApp/DApp.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:lab.web3modal.com</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.walletconnect.dapp</string>
Expand Down
14 changes: 14 additions & 0 deletions Example/DApp/DAppRelease.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:lab.web3modal.com</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.walletconnect.dapp</string>
</array>
</dict>
</plist>
15 changes: 15 additions & 0 deletions Example/DApp/Modules/Configuration/ConfigModule.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import SwiftUI

final class ConfigModule {
@discardableResult
static func create(app: Application) -> UIViewController {
let router = ConfigRouter(app: app)
let presenter = ConfigPresenter(router: router)
let view = ConfigView().environmentObject(presenter)

let viewController = SceneViewController(viewModel: presenter, content: view)
router.viewController = viewController

return viewController
}
}
36 changes: 36 additions & 0 deletions Example/DApp/Modules/Configuration/ConfigPresenter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import UIKit
import Combine

import WalletConnectSign

final class ConfigPresenter: ObservableObject, SceneViewModel {


private let router: ConfigRouter

init(
router: ConfigRouter
) {
defer { setupInitialState() }
self.router = router
}

func onAppear() {

}

private func setupInitialState() {

}

func cleanLinkModeSupportedWalletsCache() {
let userDefaults = UserDefaults(suiteName: Constants.groupIdentifier.rawValue)!
let prefix = "com.walletconnect.sdk.linkModeLinks"
let keys = userDefaults.dictionaryRepresentation().keys

for key in keys where key.hasPrefix(prefix) {
userDefaults.removeObject(forKey: key)
}
}

}
15 changes: 15 additions & 0 deletions Example/DApp/Modules/Configuration/ConfigRouter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import Foundation
import UIKit

import WalletConnectSign
llbartekll marked this conversation as resolved.
Show resolved Hide resolved

final class ConfigRouter {
weak var viewController: UIViewController!

private let app: Application

init(app: Application) {
self.app = app
}
}
53 changes: 53 additions & 0 deletions Example/DApp/Modules/Configuration/ConfigView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import SwiftUI

struct ConfigView: View {
@EnvironmentObject var presenter: ConfigPresenter

var body: some View {
NavigationStack {
ZStack {
Color(red: 25/255, green: 26/255, blue: 26/255)
.ignoresSafeArea()

ScrollView {
VStack {
Button {
presenter.cleanLinkModeSupportedWalletsCache()
} label: {
HStack {
Spacer()
Text("Clean Link Mode Supported Wallets Cache")
.font(.system(size: 16, weight: .semibold))
.foregroundColor(.white)
.padding(.vertical, 25)
Spacer()
}
.background(Color(red: 95/255, green: 159/255, blue: 248/255))
.cornerRadius(16)
}
.padding(.top, 10)
}
.padding(12)
}
.padding(.bottom, 76)
.onAppear {
presenter.onAppear()
}
}
.navigationTitle("Configuration")
.navigationBarTitleDisplayMode(.inline)
.toolbarColorScheme(.dark, for: .navigationBar)
.toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(
Color(red: 25/255, green: 26/255, blue: 26/255),
for: .navigationBar
)
}
}
}

struct ConfigView_Previews: PreviewProvider {
static var previews: some View {
ConfigView()
}
}
26 changes: 25 additions & 1 deletion Example/DApp/Modules/Sign/SignPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,30 @@ final class SignPresenter: ObservableObject {
}
}

@MainActor
func connectWalletWithSessionAuthenticateLinkMode() {

Task {
llbartekll marked this conversation as resolved.
Show resolved Hide resolved
do {
ActivityIndicatorManager.shared.start()
if let pairingUri = try await Sign.instance.authenticate(.stub(methods: ["personal_sign"]), walletUniversalLink: "https://lab.web3modal.com/wallet") {
walletConnectUri = pairingUri
ActivityIndicatorManager.shared.stop()
router.presentNewPairing(walletConnectUri: walletConnectUri!)
}
} catch {
AlertPresenter.present(message: error.localizedDescription, type: .error)
ActivityIndicatorManager.shared.stop()
}
}
}

@MainActor
func openConfiguration() {
router.openConfig()
}

@MainActor
func disconnect() {
if let session {
Task { @MainActor in
Expand Down Expand Up @@ -218,7 +242,7 @@ extension SignPresenter: SceneViewModel {}
// MARK: - Authenticate request stub
extension AuthRequestParams {
static func stub(
domain: String = "app.web3inbox",
domain: String = "lab.web3modal.com",
chains: [String] = ["eip155:1", "eip155:137"],
nonce: String = "32891756",
uri: String = "https://app.web3inbox.com/login",
Expand Down
4 changes: 4 additions & 0 deletions Example/DApp/Modules/Sign/SignRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ final class SignRouter {
func popToRoot() {
viewController.popToRoot()
}

func openConfig() {
ConfigModule.create(app: app).push(from: viewController)
}
}
Loading
Loading