diff --git a/src/lib/WalletConnect.svelte b/src/lib/WalletConnect.svelte index 8dcbc7d..e50f8e6 100644 --- a/src/lib/WalletConnect.svelte +++ b/src/lib/WalletConnect.svelte @@ -63,16 +63,24 @@ } function onSessionRequest(requestEvent) { - console.log('Received session request: ', requestEvent); - const { topic, params } = requestEvent; - const { request } = params; - const requestSession = getSignClient().session.get(topic); - const { name, url } = requestSession.peer.metadata; - console.log(`\nApproving ${request.method} request for session ${name} (${url})...\n`); - pkpWalletConnect.approveSessionRequest(requestEvent).then(() => { - console.log(`Check the ${name} dapp to confirm whether the request was approved`); - console.log('\n' + '*'.repeat(50) + '\n'); - }); + const isConfirmed = confirm( + `The dApp ${requestEvent.params.request.method} is requesting an action. Do you want to proceed?` + ); + + if (isConfirmed) { + console.log('Received session request: ', requestEvent); + const { topic, params } = requestEvent; + const { request } = params; + const requestSession = getSignClient().session.get(topic); + const { name, url } = requestSession.peer.metadata; + console.log(`\nApproving ${request.method} request for session ${name} (${url})...\n`); + pkpWalletConnect.approveSessionRequest(requestEvent).then(() => { + console.log(`Check the ${name} dapp to confirm whether the request was approved`); + console.log('\n' + '*'.repeat(50) + '\n'); + }); + } else { + console.log(`User declined the ${requestEvent.params.request.method} request.`); + } } function onSessionDelete(event) { @@ -108,24 +116,11 @@ } -
-

Connect to dapp:

- - +
+

Connect to dapp:

+ +
- -