Skip to content

Commit

Permalink
Merge pull request #654 from WalletConnect/develop
Browse files Browse the repository at this point in the history
1.2.1
  • Loading branch information
flypaper0 authored Jan 10, 2023
2 parents c9b6e10 + c7cc625 commit 53e3c5f
Show file tree
Hide file tree
Showing 135 changed files with 3,826 additions and 399 deletions.
692 changes: 579 additions & 113 deletions Example/ExampleApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C56EE21A293F55ED004840D1"
BuildableName = "WalletApp.app"
BlueprintName = "WalletApp"
ReferencedContainer = "container:ExampleApp.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</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">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C56EE21A293F55ED004840D1"
BuildableName = "WalletApp.app"
BlueprintName = "WalletApp"
ReferencedContainer = "container:ExampleApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C56EE21A293F55ED004840D1"
BuildableName = "WalletApp.app"
BlueprintName = "WalletApp"
ReferencedContainer = "container:ExampleApp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ struct ApplicationConfigurator: Configurator {
}

func configure() {
MainModule.create(app: app).present()
WelcomeModule.create(app: app).present()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let context = URLContexts.first else { return }

let uri = context.url.absoluteString.replacingOccurrences(of: "showcase://wc?uri=", with: "")
guard let walletConnectUri = WalletConnectURI(string: uri) else {
return
}

Task {
try await Pair.instance.pair(uri: WalletConnectURI(string: uri)!)
try await Pair.instance.pair(uri: walletConnectUri)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ final class MainPresenter {

var viewControllers: [UIViewController] {
return [
router.chatViewController,
router.walletViewController
router.chatViewController
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ final class MainRouter {

private let app: Application

var walletViewController: UIViewController {
return WalletModule.create(app: app).wrapToNavigationController()
}

var chatViewController: UIViewController {
return WelcomeModule.create(app: app)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import Foundation
import Combine

import WalletConnectRelay
import WalletConnectPairing
import Auth

final class WelcomeInteractor {
private var disposeBag = Set<AnyCancellable>()

private let chatService: ChatService
private let accountStorage: AccountStorage

Expand All @@ -21,4 +27,18 @@ final class WelcomeInteractor {
func trackConnection() -> Stream<SocketConnectionStatus> {
return chatService.connectionPublisher
}

func generateUri() async -> WalletConnectURI {
return try! await Pair.instance.create()
}
}

protocol IATProvider {
var iat: String { get }
}

struct DefaultIATProvider: IATProvider {
var iat: String {
return ISO8601DateFormatter().string(from: Date())
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit
import Combine
import Auth

final class WelcomePresenter: ObservableObject {

Expand All @@ -22,14 +23,36 @@ final class WelcomePresenter: ObservableObject {
}

var buttonTitle: String {
return interactor.isAuthorized() ? "Start Messaging" : "Import account"
return interactor.isAuthorized() ? "Start Messaging" : "Connect wallet"
}

func didPressImport() {
func didPressImport() async {
if let account = interactor.account {
router.presentChats(account: account)
} else {
router.presentImport()
await authWithWallet()
}
}

private func authWithWallet() async {
let uri = await interactor.generateUri()
try? await Auth.instance.request(
RequestParams(
domain: "example.wallet",
chainId: "eip155:1",
nonce: "32891756",
aud: "https://example.wallet/login",
nbf: nil,
exp: nil,
statement: "I accept the ServiceOrg Terms of Service: https://service.invalid/tos",
requestId: nil,
resources: ["ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/", "https://example.com/my-web2-claim.json"]
),
topic: uri.topic
)

DispatchQueue.main.async {
self.router.openWallet(uri: uri.absoluteString)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ final class WelcomeRouter {
.wrapToNavigationController()
.present()
}

func openWallet(uri: String) {
UIApplication.shared.open(URL(string: "walletapp://wc?uri=\(uri)")!)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ struct WelcomeView: View {
.multilineTextAlignment(.center)

BrandButton(title: presenter.buttonTitle, action: {
presenter.didPressImport()
Task {
await presenter.didPressImport()
}
})

Text("By connecting your wallet you agree with our\nTerms of Service")
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 53e3c5f

Please sign in to comment.