Skip to content

Commit

Permalink
Merge pull request #1365 from WalletConnect/link-mode-fixes
Browse files Browse the repository at this point in the history
Link mode fixes
  • Loading branch information
llbartekll authored May 31, 2024
2 parents 3afcf07 + a575e09 commit d50f11f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 34 deletions.
6 changes: 6 additions & 0 deletions Example/WalletApp/ApplicationLayer/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate, UNUserNotificatio
if case WalletConnectURI.Errors.expired = error {
AlertPresenter.present(message: error.localizedDescription, type: .error)
} else {
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
let queryItems = components.queryItems,
queryItems.contains(where: { $0.name == "wc_ev" }) else {
return
}

do {
try Web3Wallet.instance.dispatchEnvelope(url.absoluteString)
} catch {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectModal/Modal/Screens/WalletList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ struct WalletList: View {
.stroke(.gray.opacity(0.4), lineWidth: 1)
)

Text(String(wallet.name.split(separator: " ").first!))
Text(String(wallet.name.split(separator: " ").first ?? " "))
.font(.system(size: 12))
.foregroundColor(.foreground1)
.multilineTextAlignment(.center)
Expand Down
12 changes: 0 additions & 12 deletions Sources/WalletConnectPairing/PairingClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import Foundation
import Combine

public class PairingClient: PairingRegisterer, PairingInteracting, PairingClientProtocol {
enum Errors: Error {
case pairingDoesNotSupportRequiredMethod
}
public var pingResponsePublisher: AnyPublisher<(String), Never> {
pingResponsePublisherSubject.eraseToAnyPublisher()
}
Expand Down Expand Up @@ -139,15 +136,6 @@ public class PairingClient: PairingRegisterer, PairingInteracting, PairingClient
_ = try pairingsProvider.getPairing(for: topic)
}

public func validateMethodSupport(topic: String, method: String) throws {
_ = try pairingsProvider.getPairing(for: topic)
let pairing = pairingStorage.getPairing(forTopic: topic)
guard let methods = pairing?.methods,
methods.contains(method) else {
throw Errors.pairingDoesNotSupportRequiredMethod
}
}

public func register<RequestParams>(method: ProtocolMethod) -> AnyPublisher<RequestSubscriptionPayload<RequestParams>, Never> {
logger.debug("Pairing Client - registering for \(method.method)")
return pairingRequestsSubscriber.subscribeForRequest(method)
Expand Down
21 changes: 0 additions & 21 deletions Sources/WalletConnectSign/Sign/SignClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,27 +320,6 @@ public final class SignClient: SignClientProtocol {

//---------------------------------------AUTH-----------------------------------

/// For a dApp to propose an authenticated session to a wallet.
/// Function will propose a session on existing pairing.
public func authenticate(
_ params: AuthRequestParams,
topic: String
) async throws {
try pairingClient.validatePairingExistance(topic)
try pairingClient.validateMethodSupport(topic: topic, method: SessionAuthenticatedProtocolMethod().method)
logger.debug("Requesting Authentication on existing pairing")
try await appRequestService.request(params: params, topic: topic)

let namespaces = try ProposalNamespaceBuilder.buildNamespace(from: params)
try await appProposeService.propose(
pairingTopic: topic,
namespaces: [:],
optionalNamespaces: namespaces,
sessionProperties: nil,
relay: RelayProtocolOptions(protocol: "irn", data: nil)
)
}

/// For a dApp to propose an authenticated session to a wallet.
public func authenticate(
_ params: AuthRequestParams,
Expand Down
2 changes: 2 additions & 0 deletions Sources/WalletConnectSign/Sign/SignClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public protocol SignClientProtocol {
var requestExpirationPublisher: AnyPublisher<RPCID, Never> { get }

func connect(requiredNamespaces: [String: ProposalNamespace], optionalNamespaces: [String: ProposalNamespace]?, sessionProperties: [String: String]?, topic: String) async throws

func request(params: Request) async throws
func approve(proposalId: String, namespaces: [String: SessionNamespace], sessionProperties: [String: String]?) async throws -> Session
func authenticate(_ params: AuthRequestParams, walletUniversalLink: String?) async throws -> WalletConnectURI?
func rejectSession(proposalId: String, reason: RejectionReason) async throws
func rejectSession(requestId: RPCID) async throws
func update(topic: String, namespaces: [String: SessionNamespace]) async throws
Expand Down

0 comments on commit d50f11f

Please sign in to comment.