From 8a8fe68c3e716b17ec6540a78ab4032cc46de056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20Ba=C4=8Dianskas?= Date: Mon, 12 Feb 2024 13:04:33 +0100 Subject: [PATCH] feat: send smart account address first in CAIP25 response (#479) --- .../react-wallet-v2/src/views/SessionProposalModal.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx b/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx index 778d272..020201e 100644 --- a/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx @@ -275,7 +275,15 @@ export default function SessionProposalModal() { const smartAccountAddress = await smartAccountClient.getAccount() if (wallet && smartAccountAddress) { - namespaces.eip155.accounts = [...namespaces.eip155.accounts, `${nameSpaceKey}:${chain.id}:${smartAccountAddress.address}`] + const allowedAccounts = allowedChainIds.map(id => { + // check if id is a part of any of these array elements namespaces.eip155.accounts + const accountIsAllowed = namespaces.eip155.accounts.findIndex(account => account.includes(id)) + + return namespaces.eip155.accounts[accountIsAllowed] + }) + + // when SA available, make it 1st on dApp + namespaces.eip155.accounts = [`${nameSpaceKey}:${chain.id}:${smartAccountAddress.address}`, ...allowedAccounts] } console.log('approving namespaces:', namespaces.eip155.accounts)