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

Make eth_accounts return all permitted accounts #18516

Merged
merged 8 commits into from
Jun 8, 2023
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