added user prompt to sign in session request of wallet connect
This commit is contained in:
parent
940b4c3c45
commit
68f85d9f29
@ -63,16 +63,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSessionRequest(requestEvent) {
|
function onSessionRequest(requestEvent) {
|
||||||
console.log('Received session request: ', requestEvent);
|
const isConfirmed = confirm(
|
||||||
const { topic, params } = requestEvent;
|
`The dApp ${requestEvent.params.request.method} is requesting an action. Do you want to proceed?`
|
||||||
const { request } = params;
|
);
|
||||||
const requestSession = getSignClient().session.get(topic);
|
|
||||||
const { name, url } = requestSession.peer.metadata;
|
if (isConfirmed) {
|
||||||
console.log(`\nApproving ${request.method} request for session ${name} (${url})...\n`);
|
console.log('Received session request: ', requestEvent);
|
||||||
pkpWalletConnect.approveSessionRequest(requestEvent).then(() => {
|
const { topic, params } = requestEvent;
|
||||||
console.log(`Check the ${name} dapp to confirm whether the request was approved`);
|
const { request } = params;
|
||||||
console.log('\n' + '*'.repeat(50) + '\n');
|
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) {
|
function onSessionDelete(event) {
|
||||||
@ -108,24 +116,11 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main class="flex flex-col items-center justify-center">
|
||||||
<h1>Connect to dapp:</h1>
|
<h1 class="text-2xl font-bold mb-4">Connect to dapp:</h1>
|
||||||
<input type="text" bind:value={uri} placeholder="Enter the URI" />
|
<input type="text" bind:value={uri} placeholder="Enter the URI" class="p-2 mb-4 text-lg w-72" />
|
||||||
<button on:click={handleConnect}>Connect</button>
|
<button
|
||||||
|
on:click={handleConnect}
|
||||||
|
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Connect</button
|
||||||
|
>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<style>
|
|
||||||
main {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
|
||||||
padding: 8px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-size: 16px;
|
|
||||||
width: 300px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user