@@ -5330,7 +5330,7 @@ describe('SnapController', () => {
53305330 snapController . destroy ( ) ;
53315331 } ) ;
53325332
5333- it ( 'grants the `endowment:caip25` permission to a Snap with `endowment:ethereum-provider`' , async ( ) => {
5333+ it ( 'grants the `endowment:caip25` permission to a Snap with `endowment:ethereum-provider` if the `useCaip25Permission` feature flag is enabled ' , async ( ) => {
53345334 const rootMessenger = getControllerMessenger ( ) ;
53355335 const messenger = getSnapControllerMessenger ( rootMessenger ) ;
53365336
@@ -5366,6 +5366,9 @@ describe('SnapController', () => {
53665366 getSnapControllerOptions ( {
53675367 messenger,
53685368 detectSnapLocation : loopbackDetect ( { manifest } ) ,
5369+ featureFlags : {
5370+ useCaip25Permission : true ,
5371+ } ,
53695372 } ) ,
53705373 ) ;
53715374
@@ -5409,6 +5412,71 @@ describe('SnapController', () => {
54095412 snapController . destroy ( ) ;
54105413 } ) ;
54115414
5415+ it ( 'does not grant the `endowment:caip25` permission to a Snap with `endowment:ethereum-provider` if the `useCaip25Permission` feature flag is disabled' , async ( ) => {
5416+ const rootMessenger = getControllerMessenger ( ) ;
5417+ const messenger = getSnapControllerMessenger ( rootMessenger ) ;
5418+
5419+ rootMessenger . registerActionHandler (
5420+ 'PermissionController:getPermissions' ,
5421+ ( ) => ( { } ) ,
5422+ ) ;
5423+
5424+ rootMessenger . registerActionHandler (
5425+ 'SelectedNetworkController:getNetworkClientIdForDomain' ,
5426+ ( ) => 'mainnet' ,
5427+ ) ;
5428+
5429+ rootMessenger . registerActionHandler (
5430+ 'NetworkController:getNetworkClientById' ,
5431+ ( ) => ( {
5432+ configuration : {
5433+ chainId : '0x1' ,
5434+ } ,
5435+ } ) ,
5436+ ) ;
5437+
5438+ const { manifest } = await getMockSnapFilesWithUpdatedChecksum ( {
5439+ manifest : getSnapManifest ( {
5440+ initialPermissions : {
5441+ 'endowment:page-home' : { } ,
5442+ 'endowment:ethereum-provider' : { } ,
5443+ } ,
5444+ } ) ,
5445+ } ) ;
5446+
5447+ const snapController = getSnapController (
5448+ getSnapControllerOptions ( {
5449+ messenger,
5450+ detectSnapLocation : loopbackDetect ( { manifest } ) ,
5451+ featureFlags : {
5452+ useCaip25Permission : false ,
5453+ } ,
5454+ } ) ,
5455+ ) ;
5456+
5457+ await snapController . installSnaps ( MOCK_ORIGIN , {
5458+ [ MOCK_SNAP_ID ] : { } ,
5459+ } ) ;
5460+
5461+ const approvedPermissions = {
5462+ 'endowment:page-home' : {
5463+ caveats : null ,
5464+ } ,
5465+ 'endowment:ethereum-provider' : { } ,
5466+ } ;
5467+
5468+ expect ( messenger . call ) . toHaveBeenCalledWith (
5469+ 'PermissionController:grantPermissions' ,
5470+ {
5471+ approvedPermissions,
5472+ subject : { origin : MOCK_SNAP_ID } ,
5473+ requestData : expect . any ( Object ) ,
5474+ } ,
5475+ ) ;
5476+
5477+ snapController . destroy ( ) ;
5478+ } ) ;
5479+
54125480 it ( 'does not grant the `endowment:caip25` permission if the Snap does not have the `endowment:ethereum-provider` permission' , async ( ) => {
54135481 const rootMessenger = getControllerMessenger ( ) ;
54145482 const messenger = getSnapControllerMessenger ( rootMessenger ) ;
@@ -5444,6 +5512,9 @@ describe('SnapController', () => {
54445512 getSnapControllerOptions ( {
54455513 messenger,
54465514 detectSnapLocation : loopbackDetect ( { manifest } ) ,
5515+ featureFlags : {
5516+ useCaip25Permission : true ,
5517+ } ,
54475518 } ) ,
54485519 ) ;
54495520
0 commit comments