Skip to content

Commit

Permalink
feat: send smart account address first in CAIP25 response (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bacis authored Feb 12, 2024
1 parent e362091 commit 8a8fe68
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8a8fe68

Please sign in to comment.