File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
packages/examples/packages/lifecycle-hooks Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 77 "url" : " https://github.com/MetaMask/snaps.git"
88 },
99 "source" : {
10- "shasum" : " hTwghLmR+2f8zwjEcFujq/ojCDoMnQRcYBPMJ73IqGE =" ,
10+ "shasum" : " /Wc+1sY2V4NwgUxQT81/nquwTBDsw2vdNEkkYd8g+0Q =" ,
1111 "location" : {
1212 "npm" : {
1313 "filePath" : " dist/bundle.js" ,
1818 },
1919 "initialPermissions" : {
2020 "snap_dialog" : {},
21+ "snap_notify" : {},
2122 "endowment:lifecycle-hooks" : {}
2223 },
2324 "platformVersion" : " 9.2.0" ,
Original file line number Diff line number Diff line change 11import type {
2+ OnActiveHandler ,
23 OnInstallHandler ,
34 OnStartHandler ,
45 OnUpdateHandler ,
@@ -85,3 +86,43 @@ export const onUpdate: OnUpdateHandler = async () => {
8586 } ,
8687 } ) ;
8788} ;
89+
90+ /**
91+ * Handle activation of the client. This handler is called when the client is
92+ * activated, and can be used to perform any initialization that is required.
93+ *
94+ * This handler is optional.
95+ *
96+ * @see https://docs.metamask.io/snaps/reference/entry-points/#onactive
97+ * @returns The JSON-RPC response.
98+ */
99+ export const onActive : OnActiveHandler = async ( ) => {
100+ return await snap . request ( {
101+ method : 'snap_notify' ,
102+ params : {
103+ type : 'inApp' ,
104+ message :
105+ 'The client was activated, and the "onActive" handler was called.' ,
106+ } ,
107+ } ) ;
108+ } ;
109+
110+ /**
111+ * Handle deactivation of the client. This handler is called when the client
112+ * is deactivated, and can be used to perform any cleanup that is required.
113+ *
114+ * This handler is optional.
115+ *
116+ * @see https://docs.metamask.io/snaps/reference/entry-points/#oninactive
117+ * @returns The JSON-RPC response.
118+ */
119+ export const onInactive = async ( ) => {
120+ return await snap . request ( {
121+ method : 'snap_notify' ,
122+ params : {
123+ type : 'inApp' ,
124+ message :
125+ 'The client was deactivated, and the "onInactive" handler was called.' ,
126+ } ,
127+ } ) ;
128+ } ;
You can’t perform that action at this time.
0 commit comments