@@ -220,29 +220,35 @@ export const onRpcRequest: OnRpcRequestHandler = async ({
220220export const onUserInput : OnUserInputHandler =
221221 userEventDispatcher . createUserInputEventHandler ( ) ;
222222
223- export const onInstall : OnInstallHandler = async ( ) => {
224- /**
225- * Local Development Only
226- *
227- * The message signing snap must be installed and the gator permissions snap must
228- * have permission to communicate with the message signing snap, or the request is rejected.
229- *
230- * Since the message signing snap is preinstalled in production, and has
231- * initialConnections configured to automatically connect to the gator snap, this is not needed in production.
232- */
233- // eslint-disable-next-line no-restricted-globals
234- if ( snapEnv === 'local' && isStorePermissionsFeatureEnabled ) {
235- const installedSnaps = ( await snap . request ( {
236- method : 'wallet_getSnaps' ,
237- } ) ) as unknown as GetSnapsResponse ;
238- if ( ! installedSnaps [ messageSigningSnapId ] ) {
239- logger . debug ( 'Installing local message signing snap' ) ;
240- await snap . request ( {
241- method : 'wallet_requestSnaps' ,
242- params : {
243- [ messageSigningSnapId ] : { } ,
244- } ,
245- } ) ;
223+ /**
224+ * Local Development Only
225+ *
226+ * The message signing snap must be installed and the gator permissions snap must
227+ * have permission to communicate with the message signing snap, or the request is rejected.
228+ *
229+ * Since the message signing snap is preinstalled in production, and has
230+ * initialConnections configured to automatically connect to the gator snap, this is not needed in production.
231+ */
232+ // eslint-disable-next-line no-restricted-globals
233+ if ( snapEnv === 'local' ) {
234+ const installHandler : OnInstallHandler = async ( ) => {
235+ if ( isStorePermissionsFeatureEnabled ) {
236+ const installedSnaps = ( await snap . request ( {
237+ method : 'wallet_getSnaps' ,
238+ } ) ) as unknown as GetSnapsResponse ;
239+ if ( ! installedSnaps [ messageSigningSnapId ] ) {
240+ logger . debug ( 'Installing local message signing snap' ) ;
241+ await snap . request ( {
242+ method : 'wallet_requestSnaps' ,
243+ params : {
244+ [ messageSigningSnapId ] : { } ,
245+ } ,
246+ } ) ;
247+ }
246248 }
247- }
248- } ;
249+ } ;
250+
251+ // Export onInstall for local development only
252+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
253+ ( globalThis as any ) . onInstall = installHandler ;
254+ }
0 commit comments