Skip to content

Commit

Permalink
Merge pull request #1148 from WalletConnect/develop
Browse files Browse the repository at this point in the history
1.8.5
  • Loading branch information
flypaper0 authored Oct 2, 2023
2 parents 13446a8 + 2e1b67d commit 2f2b22e
Show file tree
Hide file tree
Showing 30 changed files with 614 additions and 246 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift.git",
"state": {
"branch": null,
"revision": "32f641cf24fc7abc1c591a2025e9f2f572648b0f",
"version": "1.7.2"
"revision": "db51c407d3be4a051484a141bf0bff36c43d3b1e",
"version": "1.8.0"
}
},
{
Expand Down Expand Up @@ -69,8 +69,8 @@
"repositoryURL": "https://github.com/getsentry/sentry-cocoa.git",
"state": {
"branch": null,
"revision": "04bee4ad86d74d4cb4d7101ff826d6e355301ba9",
"version": "8.9.4"
"revision": "14aa6e47b03b820fd2b338728637570b9e969994",
"version": "8.12.0"
}
},
{
Expand Down
11 changes: 6 additions & 5 deletions Example/IntegrationTests/Push/NotifyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ final class NotifyTests: XCTestCase {
let updateScope: Set<String> = ["alerts"]
expectation.assertForOverFulfill = false

try! await walletNotifyClientA.register(account: account, domain: gmDappDomain, onSign: sign)
try! await walletNotifyClientA.subscribe(appDomain: gmDappDomain, account: account)

var didUpdate = false
walletNotifyClientA.subscriptionsPublisher
.sink { [unowned self] subscriptions in
Expand All @@ -181,15 +178,16 @@ final class NotifyTests: XCTestCase {
}
}.store(in: &publishers)

try! await walletNotifyClientA.register(account: account, domain: gmDappDomain, onSign: sign)
try! await walletNotifyClientA.subscribe(appDomain: gmDappDomain, account: account)

wait(for: [expectation], timeout: InputConfig.defaultTimeout)
}

func testNotifyServerSubscribeAndNotifies() async throws {
let subscribeExpectation = expectation(description: "creates notify subscription")
let messageExpectation = expectation(description: "receives a notify message")
let notifyMessage = NotifyMessage.stub()
try! await walletNotifyClientA.register(account: account, domain: gmDappDomain, onSign: sign)
try! await walletNotifyClientA.subscribe(appDomain: gmDappDomain, account: account)

var didNotify = false
walletNotifyClientA.subscriptionsPublisher
Expand All @@ -215,6 +213,9 @@ final class NotifyTests: XCTestCase {
}
}.store(in: &publishers)

try! await walletNotifyClientA.register(account: account, domain: gmDappDomain, onSign: sign)
try! await walletNotifyClientA.subscribe(appDomain: gmDappDomain, account: account)

wait(for: [subscribeExpectation, messageExpectation], timeout: InputConfig.defaultTimeout)
}

Expand Down
5 changes: 4 additions & 1 deletion Example/Shared/DefaultSocketFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ extension WebSocket: WebSocketConnecting { }

struct DefaultSocketFactory: WebSocketFactory {
func create(with url: URL) -> WebSocketConnecting {
return WebSocket(url: url)
let socket = WebSocket(url: url)
let queue = DispatchQueue(label: "com.walletconnect.sdk.sockets", attributes: .concurrent)
socket.callbackQueue = queue
return socket
}
}
3 changes: 1 addition & 2 deletions Example/WalletApp/ApplicationLayer/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import WalletConnectChat

final class Application {
var uri: String?
var uri: WalletConnectURI?
var requestSent = false

lazy var pushRegisterer = PushRegisterer()
Expand All @@ -11,4 +11,3 @@ final class Application {
lazy var messageSigner = MessageSignerFactory(signerFactory: DefaultSignerFactory()).create()
lazy var configurationService = ConfigurationService()
}

14 changes: 8 additions & 6 deletions Example/WalletApp/ApplicationLayer/ConfigurationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ final class ConfigurationService {

Notify.instance.setLogging(level: .debug)

if let clientId = try? Networking.interactor.getClientId() {
LoggingService.instance.setUpUser(account: importAccount.account.absoluteString, clientId: clientId)
ProfilingService.instance.setUpProfiling(account: importAccount.account.absoluteString, clientId: clientId)
}
LoggingService.instance.startLogging()

Task {
do {
try await Notify.instance.register(account: importAccount.account, domain: "com.walletconnect", onSign: importAccount.onSign)
} catch {
DispatchQueue.main.async {
let logMessage = LogMessage(message: "Push Server registration failed with: \(error.localizedDescription)")
ProfilingService.instance.send(logMessage: logMessage)
UIApplication.currentWindow.rootViewController?.showAlert(title: "Register error", error: error)
}
}
}

if let clientId = try? Networking.interactor.getClientId() {
LoggingService.instance.setUpUser(account: importAccount.account.absoluteString, clientId: clientId)
ProfilingService.instance.setUpProfiling(account: importAccount.account.absoluteString, clientId: clientId)
}
LoggingService.instance.startLogging()
}
}
1 change: 1 addition & 0 deletions Example/WalletApp/ApplicationLayer/ProfilingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ final class ProfilingService {

handleLogs(from: Networking.instance.logsPublisher)
handleLogs(from: Notify.instance.logsPublisher)
handleLogs(from: Push.instance.logsPublisher)
}

private func handleLogs(from publisher: AnyPublisher<Log, Never>) {
Expand Down
8 changes: 4 additions & 4 deletions Example/WalletApp/ApplicationLayer/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window = UIWindow(windowScene: windowScene)
window?.makeKeyAndVisible()

app.uri = connectionOptions.urlContexts.first?.url.absoluteString.replacingOccurrences(of: "walletapp://wc?uri=", with: "")
app.uri = WalletConnectURI(connectionOptions: connectionOptions)
app.requestSent = (connectionOptions.urlContexts.first?.url.absoluteString.replacingOccurrences(of: "walletapp://wc?", with: "") == "requestSent")

configurators.configure()
Expand All @@ -37,11 +37,11 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let context = URLContexts.first else { return }

let queryParams = context.url.queryParameters
let uri = WalletConnectURI(urlContext: context)

if let uri = queryParams["uri"] as? String {
if let uri {
Task {
try await Pair.instance.pair(uri: WalletConnectURI(string: uri)!)
try await Pair.instance.pair(uri: uri)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,31 @@ struct AuthRequestView: View {
.foregroundColor(.grey8)
.font(.system(size: 22, weight: .medium, design: .rounded))

Text(presenter.request.payload.domain)
.foregroundColor(.grey50)
.font(.system(size: 13, weight: .semibold, design: .rounded))
.multilineTextAlignment(.center)
.lineSpacing(4)
if case .valid = presenter.validationStatus {
HStack {
Image(systemName: "checkmark.seal.fill")
.font(.system(size: 14, weight: .semibold, design: .rounded))
.foregroundColor(.blue)

Text(presenter.request.payload.domain)
.foregroundColor(.grey8)
.font(.system(size: 13, weight: .semibold, design: .rounded))
.lineSpacing(4)
}
.padding(.top, 8)
} else {
Text(presenter.request.payload.domain)
.foregroundColor(.grey8)
.font(.system(size: 13, weight: .semibold, design: .rounded))
.multilineTextAlignment(.center)
.lineSpacing(4)
.padding(.top, 8)
}

switch presenter.validationStatus {
case .unknown:
verifyBadgeView(imageName: "exclamationmark.circle.fill", title: "Cannot verify", color: .orange)

case .valid:
verifyBadgeView(imageName: "checkmark.seal.fill", title: "Verified domain", color: .blue)

case .invalid:
verifyBadgeView(imageName: "exclamationmark.triangle.fill", title: "Invalid domain", color: .red)

Expand Down Expand Up @@ -68,52 +79,21 @@ struct AuthRequestView: View {
}
}

HStack(spacing: 20) {
Button {
Task(priority: .userInitiated) { try await
presenter.onReject()
}
} label: {
Text("Decline")
.frame(maxWidth: .infinity)
.foregroundColor(.white)
.font(.system(size: 20, weight: .semibold, design: .rounded))
.padding(.vertical, 11)
.background(
LinearGradient(
gradient: Gradient(colors: [
.foregroundNegative,
.lightForegroundNegative
]),
startPoint: .top, endPoint: .bottom)
)
.cornerRadius(20)
if case .scam = presenter.validationStatus {
VStack(spacing: 20) {
declineButton()
allowButton()
}
.shadow(color: .white.opacity(0.25), radius: 8, y: 2)

Button {
Task(priority: .userInitiated) { try await
presenter.onApprove()
}
} label: {
Text("Allow")
.frame(maxWidth: .infinity)
.foregroundColor(.white)
.font(.system(size: 20, weight: .semibold, design: .rounded))
.padding(.vertical, 11)
.background(
LinearGradient(
gradient: Gradient(colors: [
.foregroundPositive,
.lightForegroundPositive
]),
startPoint: .top, endPoint: .bottom)
)
.cornerRadius(20)
.padding(.top, 25)
} else {
HStack {
declineButton()
allowButton()
}
.shadow(color: .white.opacity(0.25), radius: 8, y: 2)
.padding(.top, 25)
}
.padding(.top, 25)


}
.padding(20)
.background(.ultraThinMaterial)
Expand Down Expand Up @@ -147,13 +127,12 @@ struct AuthRequestView: View {
}
.padding(.horizontal, 18)
.padding(.vertical, 10)
.frame(height: 250)
.frame(height: 150)
}
.background(Color.whiteBackground)
.cornerRadius(20, corners: .allCorners)
.padding(.horizontal, 5)
.padding(.bottom, 5)

}
.background(.thinMaterial)
.cornerRadius(25, corners: .allCorners)
Expand Down Expand Up @@ -199,6 +178,61 @@ struct AuthRequestView: View {
.background(color.opacity(0.15))
.cornerRadius(20)
}

private func declineButton() -> some View {
Button {
Task(priority: .userInitiated) { try await
presenter.onReject()
}
} label: {
Text("Decline")
.frame(maxWidth: .infinity)
.foregroundColor(.white)
.font(.system(size: 20, weight: .semibold, design: .rounded))
.padding(.vertical, 11)
.background(
LinearGradient(
gradient: Gradient(colors: [
.foregroundNegative,
.lightForegroundNegative
]),
startPoint: .top, endPoint: .bottom)
)
.cornerRadius(20)
}
.shadow(color: .white.opacity(0.25), radius: 8, y: 2)
}

private func allowButton() -> some View {
Button {
Task(priority: .userInitiated) { try await
presenter.onApprove()
}
} label: {
Text(presenter.validationStatus == .scam ? "Proceed anyway" : "Allow")
.frame(maxWidth: .infinity)
.foregroundColor(presenter.validationStatus == .scam ? .grey50 : .white)
.font(.system(size: 20, weight: .semibold, design: .rounded))
.padding(.vertical, 11)
.background(
Group {
if presenter.validationStatus == .scam {
Color.clear
} else {
LinearGradient(
gradient: Gradient(colors: [
.foregroundPositive,
.lightForegroundPositive
]),
startPoint: .top, endPoint: .bottom
)
}
}
)
.cornerRadius(20)
}
.shadow(color: .white.opacity(0.25), radius: 8, y: 2)
}
}

#if DEBUG
Expand Down
Loading

0 comments on commit 2f2b22e

Please sign in to comment.