From 1725963cf239ea791dab7103521d862681d63d25 Mon Sep 17 00:00:00 2001 From: Karandeep Singh <90941366+KannuSingh@users.noreply.github.com> Date: Fri, 24 May 2024 14:17:05 -0400 Subject: [PATCH] fix: session approval accounts order (#562) * fix: session approval accounts order * fix: On session proposal with a single chain, approve modal shows no chains or accounts #557 Co-authored-by: Gancho Radkov <43912948+ganchoradkov@users.noreply.github.com> --- .../wallets/react-wallet-v2/src/utils/SmartAccountUtil.ts | 7 +------ .../react-wallet-v2/src/views/SessionProposalModal.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/advanced/wallets/react-wallet-v2/src/utils/SmartAccountUtil.ts b/advanced/wallets/react-wallet-v2/src/utils/SmartAccountUtil.ts index 6ef93f7e2..82b7fbb1a 100644 --- a/advanced/wallets/react-wallet-v2/src/utils/SmartAccountUtil.ts +++ b/advanced/wallets/react-wallet-v2/src/utils/SmartAccountUtil.ts @@ -71,12 +71,7 @@ export function supportedAddressPriority( const chainIdParsed = allowedChainIds[0].replace(`${nameSpaceKey}:`, '') const chain = providedAllowedChains.find(chain => chain?.id.toString() === chainIdParsed)! if (allowedChainIds.length > 0 && smartAccountAddress) { - 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] - }) - return [`${nameSpaceKey}:${chain.id}:${smartAccountAddress}`, ...allowedAccounts] + return [`${nameSpaceKey}:${chain.id}:${smartAccountAddress}`] } return [] } diff --git a/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx b/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx index 16fd508d8..b8a9cc113 100644 --- a/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx +++ b/advanced/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx @@ -254,8 +254,8 @@ export default function SessionProposalModal() { setIsLoadingApprove(true) try { if (reorderedEip155Accounts.length > 0) { - // reorderedEip155Accounts includes Smart Accounts(if enabled) and EOA's - namespaces.eip155.accounts = reorderedEip155Accounts + // we should append the smart accounts to the available eip155 accounts + namespaces.eip155.accounts = reorderedEip155Accounts.concat(namespaces.eip155.accounts) } //get capabilities for all reorderedEip155Accounts in wallet const capabilities = getWalletCapabilities(reorderedEip155Accounts) @@ -335,7 +335,7 @@ export default function SessionProposalModal() { Accounts - {(supportedChains.length > 1 && + {(supportedChains.length > 0 && supportedChains.map((chain, i) => { return ( @@ -361,7 +361,7 @@ export default function SessionProposalModal() { Chains - {(supportedChains.length > 1 && + {(supportedChains.length > 0 && supportedChains.map((chain, i) => { if (!chain) { return <>