Skip to content

Commit

Permalink
Merge pull request #594 from WalletConnect/#575-concurrent-settle-req…
Browse files Browse the repository at this point in the history
…uest-and-propose-response

[Sign] #575 concurrent settle request and propose response
  • Loading branch information
llbartekll authored Nov 21, 2022
2 parents e6a2314 + 597061e commit a07448f
Showing 1 changed file with 12 additions and 5 deletions.
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

0 comments on commit a07448f

Please sign in to comment.