mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Fix manually connecting sites (#13320)
This commit is contained in:
parent
b5973b46e0
commit
a5873eb7ff
@ -1,3 +1,4 @@
|
||||
import nanoid from 'nanoid';
|
||||
import {
|
||||
CaveatTypes,
|
||||
RestrictedMethods,
|
||||
@ -59,11 +60,13 @@ export function getPermissionBackgroundApiMethods(permissionController) {
|
||||
},
|
||||
|
||||
requestAccountsPermissionWithId: async (origin) => {
|
||||
const [, { id }] = await permissionController.requestPermissions(
|
||||
const id = nanoid();
|
||||
permissionController.requestPermissions(
|
||||
{ origin },
|
||||
{
|
||||
eth_accounts: {},
|
||||
},
|
||||
{ id },
|
||||
);
|
||||
return id;
|
||||
},
|
||||
|
@ -160,9 +160,11 @@ describe('permission background API methods', () => {
|
||||
describe('requestAccountsPermissionWithId', () => {
|
||||
it('request an accounts permission and returns the request id', async () => {
|
||||
const permissionController = {
|
||||
requestPermissions: jest.fn().mockImplementationOnce(async () => {
|
||||
return [null, { id: 'arbitraryId' }];
|
||||
}),
|
||||
requestPermissions: jest
|
||||
.fn()
|
||||
.mockImplementationOnce(async (_, __, { id }) => {
|
||||
return [null, { id }];
|
||||
}),
|
||||
};
|
||||
|
||||
const id = await getPermissionBackgroundApiMethods(
|
||||
@ -173,9 +175,13 @@ describe('permission background API methods', () => {
|
||||
expect(permissionController.requestPermissions).toHaveBeenCalledWith(
|
||||
{ origin: 'foo.com' },
|
||||
{ eth_accounts: {} },
|
||||
{ id: expect.any(String) },
|
||||
);
|
||||
|
||||
expect(id).toStrictEqual('arbitraryId');
|
||||
expect(id.length > 0).toBe(true);
|
||||
expect(id).toStrictEqual(
|
||||
permissionController.requestPermissions.mock.calls[0][2].id,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user