Skip to content

Commit

Permalink
fix: session approval accounts order (#562)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
KannuSingh and ganchoradkov committed May 24, 2024
1 parent 6b217a9 commit 1725963
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -335,7 +335,7 @@ export default function SessionProposalModal() {
<Grid.Container style={{ marginBottom: '10px', marginTop: '10px' }} justify={'space-between'}>
<Grid>
<Row style={{ color: 'GrayText' }}>Accounts</Row>
{(supportedChains.length > 1 &&
{(supportedChains.length > 0 &&
supportedChains.map((chain, i) => {
return (
<Row key={i}>
Expand All @@ -361,7 +361,7 @@ export default function SessionProposalModal() {
<Row style={{ color: 'GrayText' }} justify="flex-end">
Chains
</Row>
{(supportedChains.length > 1 &&
{(supportedChains.length > 0 &&
supportedChains.map((chain, i) => {
if (!chain) {
return <></>
Expand Down

0 comments on commit 1725963

Please sign in to comment.