Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: session approval accounts order #562

Merged
merged 6 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespaces.eip155.accounts = reorderedEip155Accounts.concat(namespaces.eip155.accounts)
namespaces.eip155.accounts = [...new Set(reorderedEip155Accounts.concat(namespaces.eip155.accounts))]

this will remove any duplicates from the array

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this by modifying the supportedAddressPriority method to return only the smart account address on supported chain for enabled SA. Will not need this as now no duplication will occur.

}
//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
Loading