mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-21 17:37:01 +01:00
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 <jiexiluan@gmail.com>
This commit is contained in:
parent
35ae06d824
commit
9830b14786
@ -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));
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -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 () => {
|
||||
|
Loading…
Reference in New Issue
Block a user