Skip to content

Commit fce5d2b

Browse files
committed
Add missing types
1 parent b132d5c commit fce5d2b

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

packages/snaps-sdk/src/types/handlers/lifecycle.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,29 @@ export type OnUpdateHandler = LifecycleEventHandler;
5050
* @param args.origin - The origin that triggered the lifecycle event hook.
5151
*/
5252
export type OnStartHandler = LifecycleEventHandler;
53+
54+
/**
55+
* The `onActive` handler. This is called when the Snap becomes active.
56+
*
57+
* Note that using this handler requires the `endowment:lifecycle-hooks`
58+
* permission.
59+
*
60+
* This type is an alias for {@link LifecycleEventHandler}.
61+
*
62+
* @param args - The request arguments.
63+
* @param args.origin - The origin that triggered the lifecycle event hook.
64+
*/
65+
export type OnActiveHandler = LifecycleEventHandler;
66+
67+
/**
68+
* The `onInactive` handler. This is called when the Snap becomes inactive.
69+
*
70+
* Note that using this handler requires the `endowment:lifecycle-hooks`
71+
* permission.
72+
*
73+
* This type is an alias for {@link LifecycleEventHandler}.
74+
*
75+
* @param args - The request arguments.
76+
* @param args.origin - The origin that triggered the lifecycle event hook.
77+
*/
78+
export type OnInactiveHandler = LifecycleEventHandler;

packages/snaps-utils/src/handlers/exports.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import type {
2+
OnActiveHandler,
23
OnAssetHistoricalPriceHandler,
34
OnAssetsConversionHandler,
45
OnAssetsLookupHandler,
56
OnAssetsMarketDataHandler,
67
OnClientRequestHandler,
78
OnCronjobHandler,
89
OnHomePageHandler,
10+
OnInactiveHandler,
911
OnInstallHandler,
1012
OnKeyringRequestHandler,
1113
OnNameLookupHandler,
@@ -75,14 +77,14 @@ export const SNAP_EXPORTS = {
7577
[HandlerType.OnActive]: {
7678
type: HandlerType.OnActive,
7779
required: false,
78-
validator: (snapExport: unknown): snapExport is OnStartHandler => {
80+
validator: (snapExport: unknown): snapExport is OnActiveHandler => {
7981
return typeof snapExport === 'function';
8082
},
8183
},
8284
[HandlerType.OnInactive]: {
8385
type: HandlerType.OnInactive,
8486
required: false,
85-
validator: (snapExport: unknown): snapExport is OnStartHandler => {
87+
validator: (snapExport: unknown): snapExport is OnInactiveHandler => {
8688
return typeof snapExport === 'function';
8789
},
8890
},

0 commit comments

Comments
 (0)