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

fix: add snap dummy descriptions copied from ethereum provider and get revoke e2e test passing and snaps permissions unit tests passing #27965

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@ export default class MetamaskController extends EventEmitter {
const requireAllowlist = process.env.REQUIRE_SNAPS_ALLOWLIST;

this.snapController = new SnapController({
dynamicPermissions: ['endowment:caip25'],
environmentEndowmentPermissions: Object.values(EndowmentPermissions),
excludedPermissions: {
...ExcludedSnapPermissions,
Expand Down
9 changes: 7 additions & 2 deletions shared/constants/snaps/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export const ExcludedSnapPermissions = Object.freeze({
'eth_accounts is disabled. For more information please see https://github.com/MetaMask/snaps/issues/990.',
});

export const ExcludedSnapEndowments = Object.freeze({});
export const ExcludedSnapEndowments = Object.freeze({
'endowment:caip25': 'endowment:caip25',
});

export const DynamicSnapPermissions = Object.freeze(['eth_accounts']);
export const DynamicSnapPermissions = Object.freeze([
'eth_accounts',
'endowment:caip25',
]);
5 changes: 2 additions & 3 deletions test/e2e/snaps/test-snap-revoke-perm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const {
const FixtureBuilder = require('../fixture-builder');
const { TEST_SNAPS_WEBSITE_URL } = require('./enums');

// TODO: Resolve this before merging. I'm sure the linter will make sure of it though
describe.skip('Test Snap revoke permission', function () {
describe('Test Snap revoke permission', function () {
it('can revoke a permission', async function () {
await withFixtures(
{
Expand Down Expand Up @@ -119,7 +118,7 @@ describe.skip('Test Snap revoke permission', function () {
});

// try to click on options menu
await driver.clickElement('[data-testid="eth_accounts"]');
await driver.clickElement('[data-testid="endowment:caip25"]');

// try to click on revoke permission
await driver.clickElement({
Expand Down
5 changes: 5 additions & 0 deletions ui/helpers/utils/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export const PERMISSION_DESCRIPTIONS = deepFreeze({
leftIcon: IconName.Eye,
weight: PermissionWeight.eth_accounts,
}),
[EndowmentPermissions['endowment:caip25']]: ({ t }) => ({
label: t('permission_ethereumAccounts'),
leftIcon: IconName.Eye,
weight: PermissionWeight.eth_accounts,
}),
[PermissionNames.permittedChains]: ({ t }) => ({
label: t('permission_walletSwitchEthereumChain'),
leftIcon: IconName.Wifi,
Expand Down