File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
packages/snaps-controllers/src/snaps Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,10 @@ import {
9696 sleep ,
9797} from '../test-utils' ;
9898import { delay } from '../utils' ;
99- import { LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS } from './constants' ;
99+ import {
100+ LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS ,
101+ PERMITTED_CHAINS_ENDOWMENT ,
102+ } from './constants' ;
100103import { SnapsRegistryStatus } from './registry' ;
101104import type { SnapControllerState } from './SnapController' ;
102105import {
@@ -4676,7 +4679,7 @@ describe('SnapController', () => {
46764679 'endowment:ethereum-provider' : {
46774680 caveats : [ ] ,
46784681 } ,
4679- permittedChains : { } ,
4682+ [ PERMITTED_CHAINS_ENDOWMENT ] : { } ,
46804683 } ;
46814684
46824685 expect ( messenger . call ) . toHaveBeenCalledWith (
Original file line number Diff line number Diff line change @@ -118,8 +118,8 @@ import type {
118118 TerminateAllSnapsAction ,
119119 TerminateSnapAction ,
120120} from '../services' ;
121- import type { EncryptionResult } from '../types' ;
122- import {
121+ import type {
122+ EncryptionResult ,
123123 type ExportableKeyEncryptor ,
124124 type KeyDerivationOptions ,
125125} from '../types' ;
@@ -133,6 +133,7 @@ import {
133133import {
134134 ALLOWED_PERMISSIONS ,
135135 LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS ,
136+ PERMITTED_CHAINS_ENDOWMENT ,
136137} from './constants' ;
137138import type { SnapLocation } from './location' ;
138139import { detectSnapLocation } from './location' ;
@@ -3652,17 +3653,15 @@ export class SnapController extends BaseController<
36523653 // This needs to be assigned to have proper type inference.
36533654 const modifiedPermissions : RequestedPermissions = {
36543655 ...newPermissions ,
3655- permittedChains : {
3656+ [ PERMITTED_CHAINS_ENDOWMENT ] : {
36563657 caveats : [
36573658 {
36583659 type : 'restrictNetworkSwitching' ,
36593660 value : [ configuration . chainId ] ,
36603661 } ,
36613662 ] ,
3662- date : Date . now ( ) ,
3663- id : nanoid ( ) ,
36643663 invoker : snapId ,
3665- parentCapability : 'permittedChains' ,
3664+ parentCapability : PERMITTED_CHAINS_ENDOWMENT ,
36663665 } ,
36673666 } ;
36683667
Original file line number Diff line number Diff line change @@ -20,3 +20,5 @@ export const LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS = {
2020 iterations : 10_000 ,
2121 } ,
2222} ;
23+
24+ export const PERMITTED_CHAINS_ENDOWMENT = 'endowment:permitted-chains' ;
You can’t perform that action at this time.
0 commit comments