From 1a917a3e63f369ef1b7fb67c6480fb4e6b4d5d7c Mon Sep 17 00:00:00 2001 From: Arch0125 Date: Mon, 18 Sep 2023 20:51:41 +0530 Subject: [PATCH] add method to get snap wallet addresses --- .../MetamaskSnapConfigureModal.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/MetamaskSnap/MetamaskSnapConfigureModal.tsx b/src/components/MetamaskSnap/MetamaskSnapConfigureModal.tsx index 93231a5c09..24cef95e8b 100644 --- a/src/components/MetamaskSnap/MetamaskSnapConfigureModal.tsx +++ b/src/components/MetamaskSnap/MetamaskSnapConfigureModal.tsx @@ -25,12 +25,12 @@ const MetamaskSnapConfigureModal = () => { async function getSignature(mode: number) { if (mode == 1) { const signer = provider.getSigner(account); - const signature = await signer.signMessage('Add address to receive notifications'); + const signature = await signer.signMessage(`Add address ${account} to receive notifications via Push Snap in MetaMask`); return signature; } if (mode == 2) { const signer = provider.getSigner(account); - const signature = await signer.signMessage('Remove address to receive notifications'); + const signature = await signer.signMessage(`Remove address ${account }to stop receive notifications via Push Snap in MetaMask`); return signature; } } @@ -51,7 +51,6 @@ const MetamaskSnapConfigureModal = () => { }, }); console.log('Added', searchedUser); - setWalletAddresses((prev) => [...prev, searchedUser]); } } else { console.log('Signature Validation Failed'); @@ -90,6 +89,18 @@ const MetamaskSnapConfigureModal = () => { } }; + const getWalletAddresses = async () => { + const result = await window.ethereum?.request({ + method: 'wallet_invokeSnap', + params: { + snapId: defaultSnapOrigin, + request: { method: 'pushproto_getaddresses' }, + }, + }); + console.log('result', result); + setWalletAddresses(result); + } + const containerRef = React.useRef(null); useClickAway(containerRef, () => { console.log('Set show to be null'); @@ -126,7 +137,7 @@ const MetamaskSnapConfigureModal = () => { gap="5px" > Add - Remove + Get Addresses