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

[Sign] #575 concurrent settle request and propose response #594

Merged
Merged
Changes from all commits
Commits
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
17 changes: 12 additions & 5 deletions Sources/WalletConnectSign/Engine/Common/ApproveEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ final class ApproveEngine {

let result = SessionType.ProposeResponse(relay: relay, responderPublicKey: selfPublicKey.hexRepresentation)
let response = RPCResponse(id: payload.id, result: result)
try await networkingInteractor.respond(topic: payload.topic, response: response, protocolMethod: SessionProposeProtocolMethod())

async let proposeResponse: () = networkingInteractor.respond(topic: payload.topic, response: response, protocolMethod: SessionProposeProtocolMethod())

async let settleRequest: () = settle(topic: sessionTopic, proposal: proposal, namespaces: sessionNamespaces)

let _ = try await [proposeResponse, settleRequest]

try pairing.updateExpiry()
pairingStore.setPairing(pairing)

try await settle(topic: sessionTopic, proposal: proposal, namespaces: sessionNamespaces)
}

func reject(proposerPubKey: String, reason: SignReasonCode) async throws {
Expand Down Expand Up @@ -138,12 +141,16 @@ final class ApproveEngine {

logger.debug("Sending session settle request")

try await networkingInteractor.subscribe(topic: topic)
sessionStore.setSession(session)

let protocolMethod = SessionSettleProtocolMethod()
let request = RPCRequest(method: protocolMethod.method, params: settleParams)
try await networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod)

async let subscription: () = networkingInteractor.subscribe(topic: topic)
async let settleRequest: () = networkingInteractor.request(request, topic: topic, protocolMethod: protocolMethod)

let _ = try await [settleRequest, subscription]

onSessionSettle?(session.publicRepresentation())
}
}
Expand Down