Skip to content

Commit

Permalink
Make eth_accounts return all permitted accounts (#18516)
Browse files Browse the repository at this point in the history
* 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 <jiexiluan@gmail.com>
  • Loading branch information
3 people authored Jun 8, 2023
1 parent 35ae06d commit 9830b14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions app/scripts/controllers/permissions/specifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
},

Expand Down
6 changes: 3 additions & 3 deletions app/scripts/controllers/permissions/specifications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 () => {
Expand Down

0 comments on commit 9830b14

Please sign in to comment.