diff --git a/packages/snaps-controllers/src/snaps/SnapController.test.tsx b/packages/snaps-controllers/src/snaps/SnapController.test.tsx index 9d2ea4efde..c0e409c64a 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.test.tsx +++ b/packages/snaps-controllers/src/snaps/SnapController.test.tsx @@ -96,7 +96,10 @@ import { sleep, } from '../test-utils'; import { delay } from '../utils'; -import { LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS } from './constants'; +import { + LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS, + PERMITTED_CHAINS_ENDOWMENT, +} from './constants'; import { SnapsRegistryStatus } from './registry'; import type { SnapControllerState } from './SnapController'; import { @@ -4676,7 +4679,7 @@ describe('SnapController', () => { 'endowment:ethereum-provider': { caveats: [], }, - permittedChains: {}, + [PERMITTED_CHAINS_ENDOWMENT]: {}, }; expect(messenger.call).toHaveBeenCalledWith( diff --git a/packages/snaps-controllers/src/snaps/SnapController.ts b/packages/snaps-controllers/src/snaps/SnapController.ts index 297514eba4..5f6e39bebe 100644 --- a/packages/snaps-controllers/src/snaps/SnapController.ts +++ b/packages/snaps-controllers/src/snaps/SnapController.ts @@ -118,8 +118,8 @@ import type { TerminateAllSnapsAction, TerminateSnapAction, } from '../services'; -import type { EncryptionResult } from '../types'; -import { +import type { + EncryptionResult, type ExportableKeyEncryptor, type KeyDerivationOptions, } from '../types'; @@ -133,6 +133,7 @@ import { import { ALLOWED_PERMISSIONS, LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS, + PERMITTED_CHAINS_ENDOWMENT, } from './constants'; import type { SnapLocation } from './location'; import { detectSnapLocation } from './location'; @@ -3652,17 +3653,15 @@ export class SnapController extends BaseController< // This needs to be assigned to have proper type inference. const modifiedPermissions: RequestedPermissions = { ...newPermissions, - permittedChains: { + [PERMITTED_CHAINS_ENDOWMENT]: { caveats: [ { type: 'restrictNetworkSwitching', value: [configuration.chainId], }, ], - date: Date.now(), - id: nanoid(), invoker: snapId, - parentCapability: 'permittedChains', + parentCapability: PERMITTED_CHAINS_ENDOWMENT, }, }; diff --git a/packages/snaps-controllers/src/snaps/constants.ts b/packages/snaps-controllers/src/snaps/constants.ts index 2125d9976d..4877ee521a 100644 --- a/packages/snaps-controllers/src/snaps/constants.ts +++ b/packages/snaps-controllers/src/snaps/constants.ts @@ -20,3 +20,5 @@ export const LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS = { iterations: 10_000, }, }; + +export const PERMITTED_CHAINS_ENDOWMENT = 'endowment:permitted-chains';