Skip to content

Commit

Permalink
use ignoreLock in eth_requestAccounts and wallet_getPermissions
Browse files Browse the repository at this point in the history
  • Loading branch information
jiexi committed Dec 3, 2024
1 parent 473fa17 commit 71ee61b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('requestEthereumAccountsHandler', () => {
const { handler, getAccounts } = createMockedHandler();

await handler(baseRequest);
expect(getAccounts).toHaveBeenCalled();
expect(getAccounts).toHaveBeenCalledWith(true);
});

describe('eip155 account permissions exist', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function requestEthereumAccountsHandler(
metamaskState,
grantPermissions,
}: {
getAccounts: () => Promise<string[]>;
getAccounts: (ignoreLock?: boolean) => Promise<string[]>;
getUnlockPromise: (shouldShowUnlockRequest: true) => Promise<void>;
requestPermissionApprovalForOrigin: (
requestedPermissions: RequestedPermissions,
Expand All @@ -107,7 +107,7 @@ async function requestEthereumAccountsHandler(
return end();
}

let ethAccounts = await getAccounts();
let ethAccounts = await getAccounts(true);
if (ethAccounts.length > 0) {
// We wait for the extension to unlock in this case only, because permission
// requests are handled when the extension is unlocked, regardless of the
Expand Down Expand Up @@ -172,7 +172,7 @@ async function requestEthereumAccountsHandler(
},
});

ethAccounts = await getAccounts();
ethAccounts = await getAccounts(true);
// first time connection to dapp will lead to no log in the permissionHistory
// and if user has connected to dapp before, the dapp origin will be included in the permissionHistory state
// we will leverage that to identify `is_first_visit` for metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('getPermissionsHandler', () => {
it('gets the lastSelected sorted permissioned eth accounts for the origin', async () => {
const { handler, getAccounts } = createMockedHandler();
await handler(baseRequest);
expect(getAccounts).toHaveBeenCalled();
expect(getAccounts).toHaveBeenCalledWith(true);
});

it('returns the permissions with an eth_accounts permission if some eth accounts are permissioned', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function getPermissionsImplementation(
CaveatSpecificationConstraint
>['getPermissions']
>;
getAccounts: () => Promise<string[]>;
getAccounts: (ignoreLock?: boolean) => Promise<string[]>;
},
) {
const permissions = { ...getPermissionsForOrigin() };
Expand All @@ -70,7 +70,7 @@ async function getPermissionsImplementation(
if (caip25CaveatValue) {
// We cannot derive ethAccounts directly from the CAIP-25 permission
// because the accounts will not be in order of lastSelected
const ethAccounts = await getAccounts();
const ethAccounts = await getAccounts(true);

if (ethAccounts.length > 0) {
permissions[RestrictedMethods.eth_accounts] = {
Expand Down

0 comments on commit 71ee61b

Please sign in to comment.