diff --git a/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-eth-accounts.test.ts b/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-eth-accounts.test.ts index 186091272d47..02a60a870776 100644 --- a/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-eth-accounts.test.ts +++ b/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-eth-accounts.test.ts @@ -42,11 +42,23 @@ describe('CAIP-25 eth_accounts adapters', () => { notifications: [], accounts: ['eip155:100:0x100'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: ['wallet:eip155:0x5'], + }, }, isMultichainOrigin: false, }); - expect(ethAccounts).toStrictEqual(['0x1', '0x2', '0x4', '0x3', '0x100']); + expect(ethAccounts).toStrictEqual([ + '0x1', + '0x2', + '0x4', + '0x3', + '0x100', + '0x5', + ]); }); }); @@ -87,6 +99,10 @@ describe('CAIP-25 eth_accounts adapters', () => { notifications: [], accounts: ['eip155:100:0x100'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + }, }, isMultichainOrigin: false, }; @@ -128,6 +144,15 @@ describe('CAIP-25 eth_accounts adapters', () => { notifications: [], accounts: ['eip155:100:0x1', 'eip155:100:0x2', 'eip155:100:0x3'], }, + 'wallet:eip155': { + methods: [], + notifications: [], + accounts: [ + 'wallet:eip155:0x1', + 'wallet:eip155:0x2', + 'wallet:eip155:0x3', + ], + }, }, isMultichainOrigin: false, }); diff --git a/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-eth-accounts.ts b/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-eth-accounts.ts index de8afc41ad1f..5501b840d9b0 100644 --- a/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-eth-accounts.ts +++ b/app/scripts/lib/multichain-api/adapters/caip-permission-adapter-eth-accounts.ts @@ -12,6 +12,16 @@ import { ScopeString, } from '../scope'; +const isEip155ScopeString = (scopeString: ScopeString) => { + const { namespace, reference } = parseScopeString(scopeString); + + return ( + namespace === KnownCaipNamespace.Eip155 || + (namespace === KnownCaipNamespace.Wallet && + reference === KnownCaipNamespace.Eip155) + ); +}; + export const getEthAccounts = (caip25CaveatValue: Caip25CaveatValue) => { const ethAccounts: string[] = []; const sessionScopes = mergeScopes( @@ -21,12 +31,9 @@ export const getEthAccounts = (caip25CaveatValue: Caip25CaveatValue) => { Object.entries(sessionScopes).forEach(([_, { accounts }]) => { accounts?.forEach((account) => { - const { - address, - chain: { namespace }, - } = parseCaipAccountId(account); + const { address, chainId } = parseCaipAccountId(account); - if (namespace === KnownCaipNamespace.Eip155) { + if (isEip155ScopeString(chainId)) { ethAccounts.push(address); } }); @@ -42,9 +49,7 @@ const setEthAccountsForScopesObject = ( const updatedScopesObject: ScopesObject = {}; Object.entries(scopesObject).forEach(([scopeString, scopeObject]) => { - const { namespace } = parseScopeString(scopeString); - - if (namespace !== KnownCaipNamespace.Eip155) { + if (!isEip155ScopeString(scopeString as ScopeString)) { updatedScopesObject[scopeString as ScopeString] = scopeObject; return; } diff --git a/test/e2e/run-api-specs-multichain.ts b/test/e2e/run-api-specs-multichain.ts index 6389d383d0ba..e292124fff55 100644 --- a/test/e2e/run-api-specs-multichain.ts +++ b/test/e2e/run-api-specs-multichain.ts @@ -155,7 +155,7 @@ async function main() { notifications: ['eth_subscription'], }, 'wallet:eip155': { - accounts: [], + accounts: [`wallet:eip155:${ACCOUNT_1}`], methods: walletEip155Methods, notifications: [], },