From 9830b1478687f529fee1746bccacc5e206600d49 Mon Sep 17 00:00:00 2001 From: Erik Marks <25517051+rekmarks@users.noreply.github.com> Date: Thu, 8 Jun 2023 13:01:43 -0700 Subject: [PATCH] Make `eth_accounts` return all permitted accounts (#18516) * Make eth_accounts return all permitted accounts rather than just the most recently selected one * fixup! Make eth_accounts return all permitted accounts rather than just the most recently selected one * Trigger --------- Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> Co-authored-by: Jiexi Luan --- app/scripts/controllers/permissions/specifications.js | 4 +--- app/scripts/controllers/permissions/specifications.test.js | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/scripts/controllers/permissions/specifications.js b/app/scripts/controllers/permissions/specifications.js index abae2f67d..42f685bfb 100644 --- a/app/scripts/controllers/permissions/specifications.js +++ b/app/scripts/controllers/permissions/specifications.js @@ -61,9 +61,7 @@ export const getCaveatSpecifications = ({ getIdentities }) => { decorator: (method, caveat) => { return async (args) => { const result = await method(args); - return result - .filter((account) => caveat.value.includes(account)) - .slice(0, 1); + return result.filter((account) => caveat.value.includes(account)); }; }, diff --git a/app/scripts/controllers/permissions/specifications.test.js b/app/scripts/controllers/permissions/specifications.test.js index 7c6cae97a..f716ddaba 100644 --- a/app/scripts/controllers/permissions/specifications.test.js +++ b/app/scripts/controllers/permissions/specifications.test.js @@ -46,7 +46,7 @@ describe('PermissionController specifications', () => { describe('restrictReturnedAccounts', () => { describe('decorator', () => { - it('returns the first array member included in the caveat value', async () => { + it('only returns array members included in the caveat value', async () => { const getIdentities = jest.fn(); const { decorator } = getCaveatSpecifications({ getIdentities })[ CaveatTypes.restrictReturnedAccounts @@ -55,10 +55,10 @@ describe('PermissionController specifications', () => { const method = async () => ['0x1', '0x2', '0x3']; const caveat = { type: CaveatTypes.restrictReturnedAccounts, - value: ['0x1', '0x2'], + value: ['0x1', '0x3'], }; const decorated = decorator(method, caveat); - expect(await decorated()).toStrictEqual(['0x1']); + expect(await decorated()).toStrictEqual(['0x1', '0x3']); }); it('returns an empty array if no array members are included in the caveat value', async () => {