Skip to content

Commit f3e64c7

Browse files
authored
feat!: Remove useCaip25Permission feature flag and enable behaviour by default (#3413)
This removes the `useCaip25Permission` feature flag for the `SnapController` and enables the CAIP-25 behaviour by default. ## Breaking changes - The `SnapController` no longer accepts the `useCaip25Permission` feature flag. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Removes the `useCaip25Permission` feature flag and always grants `endowment:caip25` when a Snap requests `endowment:ethereum-provider`, updating tests accordingly. > > - **SnapController**: > - Remove `FeatureFlags.useCaip25Permission`. > - Always add `endowment:caip25` (with `authorizedScopes` caveat based on selected network) when `endowment:ethereum-provider` is requested in `#getPermissionsToGrant`. > - **Tests** (`SnapController.test.tsx`): > - Update install/update tests to expect CAIP-25 without feature flag. > - Remove tests covering the disabled-flag case. > - Adjust test setup/options to drop `featureFlags.useCaip25Permission`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit bd0c978. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 8571a4d commit f3e64c7

File tree

2 files changed

+3
-81
lines changed

2 files changed

+3
-81
lines changed

packages/snaps-controllers/src/snaps/SnapController.test.tsx

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -5990,7 +5990,7 @@ describe('SnapController', () => {
59905990
snapController.destroy();
59915991
});
59925992

5993-
it('grants the `endowment:caip25` permission to a Snap with `endowment:ethereum-provider` if the `useCaip25Permission` feature flag is enabled', async () => {
5993+
it('grants the `endowment:caip25` permission to a Snap with `endowment:ethereum-provider`', async () => {
59945994
const rootMessenger = getControllerMessenger();
59955995
const messenger = getSnapControllerMessenger(rootMessenger);
59965996

@@ -6026,9 +6026,6 @@ describe('SnapController', () => {
60266026
getSnapControllerOptions({
60276027
messenger,
60286028
detectSnapLocation: loopbackDetect({ manifest }),
6029-
featureFlags: {
6030-
useCaip25Permission: true,
6031-
},
60326029
}),
60336030
);
60346031

@@ -6072,7 +6069,7 @@ describe('SnapController', () => {
60726069
snapController.destroy();
60736070
});
60746071

6075-
it('grants the `endowment:caip25` permission when updating a Snap with `endowment:ethereum-provider` if the `useCaip25Permission` feature flag is enabled', async () => {
6072+
it('grants the `endowment:caip25` permission when updating a Snap with `endowment:ethereum-provider`', async () => {
60766073
const newVersion = '1.0.2';
60776074
const newVersionRange = '>=1.0.1';
60786075

@@ -6132,9 +6129,6 @@ describe('SnapController', () => {
61326129
getSnapControllerOptions({
61336130
messenger,
61346131
detectSnapLocation: detectLocationMock,
6135-
featureFlags: {
6136-
useCaip25Permission: true,
6137-
},
61386132
}),
61396133
);
61406134

@@ -6205,71 +6199,6 @@ describe('SnapController', () => {
62056199
controller.destroy();
62066200
});
62076201

6208-
it('does not grant the `endowment:caip25` permission to a Snap with `endowment:ethereum-provider` if the `useCaip25Permission` feature flag is disabled', async () => {
6209-
const rootMessenger = getControllerMessenger();
6210-
const messenger = getSnapControllerMessenger(rootMessenger);
6211-
6212-
rootMessenger.registerActionHandler(
6213-
'PermissionController:getPermissions',
6214-
() => ({}),
6215-
);
6216-
6217-
rootMessenger.registerActionHandler(
6218-
'SelectedNetworkController:getNetworkClientIdForDomain',
6219-
() => 'mainnet',
6220-
);
6221-
6222-
rootMessenger.registerActionHandler(
6223-
'NetworkController:getNetworkClientById',
6224-
() => ({
6225-
configuration: {
6226-
chainId: '0x1',
6227-
},
6228-
}),
6229-
);
6230-
6231-
const { manifest } = await getMockSnapFilesWithUpdatedChecksum({
6232-
manifest: getSnapManifest({
6233-
initialPermissions: {
6234-
'endowment:page-home': {},
6235-
'endowment:ethereum-provider': {},
6236-
},
6237-
}),
6238-
});
6239-
6240-
const snapController = getSnapController(
6241-
getSnapControllerOptions({
6242-
messenger,
6243-
detectSnapLocation: loopbackDetect({ manifest }),
6244-
featureFlags: {
6245-
useCaip25Permission: false,
6246-
},
6247-
}),
6248-
);
6249-
6250-
await snapController.installSnaps(MOCK_ORIGIN, {
6251-
[MOCK_SNAP_ID]: {},
6252-
});
6253-
6254-
const approvedPermissions = {
6255-
'endowment:page-home': {
6256-
caveats: null,
6257-
},
6258-
'endowment:ethereum-provider': {},
6259-
};
6260-
6261-
expect(messenger.call).toHaveBeenCalledWith(
6262-
'PermissionController:grantPermissions',
6263-
{
6264-
approvedPermissions,
6265-
subject: { origin: MOCK_SNAP_ID },
6266-
requestData: expect.any(Object),
6267-
},
6268-
);
6269-
6270-
snapController.destroy();
6271-
});
6272-
62736202
it('does not grant the `endowment:caip25` permission if the Snap does not have the `endowment:ethereum-provider` permission', async () => {
62746203
const rootMessenger = getControllerMessenger();
62756204
const messenger = getSnapControllerMessenger(rootMessenger);
@@ -6305,9 +6234,6 @@ describe('SnapController', () => {
63056234
getSnapControllerOptions({
63066235
messenger,
63076236
detectSnapLocation: loopbackDetect({ manifest }),
6308-
featureFlags: {
6309-
useCaip25Permission: true,
6310-
},
63116237
}),
63126238
);
63136239

packages/snaps-controllers/src/snaps/SnapController.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,6 @@ type FeatureFlags = {
707707
allowLocalSnaps?: boolean;
708708
disableSnapInstallation?: boolean;
709709
rejectInvalidPlatformVersion?: boolean;
710-
useCaip25Permission?: boolean;
711710

712711
/**
713712
* Force any local Snap to be treated as a preinstalled Snap.
@@ -4414,10 +4413,7 @@ export class SnapController extends BaseController<
44144413
* @returns The permissions to grant to the Snap.
44154414
*/
44164415
#getPermissionsToGrant(snapId: SnapId, newPermissions: RequestedPermissions) {
4417-
if (
4418-
this.#featureFlags.useCaip25Permission &&
4419-
Object.keys(newPermissions).includes(SnapEndowments.EthereumProvider)
4420-
) {
4416+
if (Object.keys(newPermissions).includes(SnapEndowments.EthereumProvider)) {
44214417
// This will return the globally selected network if the Snap doesn't have
44224418
// one set.
44234419
const networkClientId = this.messagingSystem.call(

0 commit comments

Comments
 (0)