@metamask/snaps-simulation 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/dist/controllers.cjs.map +1 -1
- package/dist/controllers.d.cts +2 -2
- package/dist/controllers.d.cts.map +1 -1
- package/dist/controllers.d.mts +2 -2
- package/dist/controllers.d.mts.map +1 -1
- package/dist/controllers.mjs.map +1 -1
- package/dist/helpers.cjs +1 -0
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +9 -0
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.mts +9 -0
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +1 -0
- package/dist/helpers.mjs.map +1 -1
- package/dist/interface.cjs +6 -0
- package/dist/interface.cjs.map +1 -1
- package/dist/interface.d.cts +1 -1
- package/dist/interface.d.cts.map +1 -1
- package/dist/interface.d.mts +1 -1
- package/dist/interface.d.mts.map +1 -1
- package/dist/interface.mjs +6 -0
- package/dist/interface.mjs.map +1 -1
- package/dist/methods/hooks/get-preferences.cjs +3 -2
- package/dist/methods/hooks/get-preferences.cjs.map +1 -1
- package/dist/methods/hooks/get-preferences.d.cts +3 -1
- package/dist/methods/hooks/get-preferences.d.cts.map +1 -1
- package/dist/methods/hooks/get-preferences.d.mts +3 -1
- package/dist/methods/hooks/get-preferences.d.mts.map +1 -1
- package/dist/methods/hooks/get-preferences.mjs +3 -2
- package/dist/methods/hooks/get-preferences.mjs.map +1 -1
- package/dist/methods/hooks/index.cjs +2 -1
- package/dist/methods/hooks/index.cjs.map +1 -1
- package/dist/methods/hooks/index.d.cts +2 -1
- package/dist/methods/hooks/index.d.cts.map +1 -1
- package/dist/methods/hooks/index.d.mts +2 -1
- package/dist/methods/hooks/index.d.mts.map +1 -1
- package/dist/methods/hooks/index.mjs +2 -1
- package/dist/methods/hooks/index.mjs.map +1 -1
- package/dist/methods/hooks/notifications.cjs +15 -2
- package/dist/methods/hooks/notifications.cjs.map +1 -1
- package/dist/methods/hooks/notifications.d.cts +13 -1
- package/dist/methods/hooks/notifications.d.cts.map +1 -1
- package/dist/methods/hooks/notifications.d.mts +13 -1
- package/dist/methods/hooks/notifications.d.mts.map +1 -1
- package/dist/methods/hooks/notifications.mjs +16 -3
- package/dist/methods/hooks/notifications.mjs.map +1 -1
- package/dist/methods/hooks/permitted/index.cjs +18 -0
- package/dist/methods/hooks/permitted/index.cjs.map +1 -0
- package/dist/methods/hooks/permitted/index.d.cts +2 -0
- package/dist/methods/hooks/permitted/index.d.cts.map +1 -0
- package/dist/methods/hooks/permitted/index.d.mts +2 -0
- package/dist/methods/hooks/permitted/index.d.mts.map +1 -0
- package/dist/methods/hooks/permitted/index.mjs +2 -0
- package/dist/methods/hooks/permitted/index.mjs.map +1 -0
- package/dist/methods/hooks/permitted/state.cjs +78 -0
- package/dist/methods/hooks/permitted/state.cjs.map +1 -0
- package/dist/methods/hooks/permitted/state.d.cts +24 -0
- package/dist/methods/hooks/permitted/state.d.cts.map +1 -0
- package/dist/methods/hooks/permitted/state.d.mts +24 -0
- package/dist/methods/hooks/permitted/state.d.mts.map +1 -0
- package/dist/methods/hooks/permitted/state.mjs +72 -0
- package/dist/methods/hooks/permitted/state.mjs.map +1 -0
- package/dist/methods/specifications.cjs.map +1 -1
- package/dist/methods/specifications.d.cts +1 -1
- package/dist/methods/specifications.d.cts.map +1 -1
- package/dist/methods/specifications.d.mts +1 -1
- package/dist/methods/specifications.d.mts.map +1 -1
- package/dist/methods/specifications.mjs.map +1 -1
- package/dist/middleware/engine.cjs +7 -4
- package/dist/middleware/engine.cjs.map +1 -1
- package/dist/middleware/engine.d.cts +6 -4
- package/dist/middleware/engine.d.cts.map +1 -1
- package/dist/middleware/engine.d.mts +6 -4
- package/dist/middleware/engine.d.mts.map +1 -1
- package/dist/middleware/engine.mjs +7 -4
- package/dist/middleware/engine.mjs.map +1 -1
- package/dist/options.cjs +1 -0
- package/dist/options.cjs.map +1 -1
- package/dist/options.d.cts +2 -0
- package/dist/options.d.cts.map +1 -1
- package/dist/options.d.mts +2 -0
- package/dist/options.d.mts.map +1 -1
- package/dist/options.mjs +2 -1
- package/dist/options.mjs.map +1 -1
- package/dist/request.cjs +8 -5
- package/dist/request.cjs.map +1 -1
- package/dist/request.d.cts +2 -1
- package/dist/request.d.cts.map +1 -1
- package/dist/request.d.mts +2 -1
- package/dist/request.d.mts.map +1 -1
- package/dist/request.mjs +8 -5
- package/dist/request.mjs.map +1 -1
- package/dist/simulation.cjs +30 -10
- package/dist/simulation.cjs.map +1 -1
- package/dist/simulation.d.cts +101 -13
- package/dist/simulation.d.cts.map +1 -1
- package/dist/simulation.d.mts +101 -13
- package/dist/simulation.d.mts.map +1 -1
- package/dist/simulation.mjs +28 -9
- package/dist/simulation.mjs.map +1 -1
- package/dist/store/notifications.cjs.map +1 -1
- package/dist/store/notifications.d.cts +9 -0
- package/dist/store/notifications.d.cts.map +1 -1
- package/dist/store/notifications.d.mts +9 -0
- package/dist/store/notifications.d.mts.map +1 -1
- package/dist/store/notifications.mjs.map +1 -1
- package/dist/store/ui.cjs.map +1 -1
- package/dist/store/ui.d.cts +1 -1
- package/dist/store/ui.d.cts.map +1 -1
- package/dist/store/ui.d.mts +1 -1
- package/dist/store/ui.d.mts.map +1 -1
- package/dist/store/ui.mjs.map +1 -1
- package/dist/structs.cjs +6 -0
- package/dist/structs.cjs.map +1 -1
- package/dist/structs.d.cts +66 -0
- package/dist/structs.d.cts.map +1 -1
- package/dist/structs.d.mts +66 -0
- package/dist/structs.d.mts.map +1 -1
- package/dist/structs.mjs +6 -0
- package/dist/structs.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +15 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +15 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +14 -14
|
@@ -6,11 +6,20 @@ import type { PayloadAction } from "@reduxjs/toolkit";
|
|
|
6
6
|
* @property id - A unique ID for the notification.
|
|
7
7
|
* @property message - The notification message.
|
|
8
8
|
* @property type - The notification type.
|
|
9
|
+
* @property title - The notification title (expanded view).
|
|
10
|
+
* @property content - The notification JSX content (expanded view).
|
|
11
|
+
* @property footerLink - The notification footer (expanded view).
|
|
9
12
|
*/
|
|
10
13
|
export type Notification = {
|
|
11
14
|
id: string;
|
|
12
15
|
message: string;
|
|
13
16
|
type: NotificationType;
|
|
17
|
+
title?: string;
|
|
18
|
+
content?: string;
|
|
19
|
+
footerLink?: {
|
|
20
|
+
text: string;
|
|
21
|
+
href: string;
|
|
22
|
+
};
|
|
14
23
|
};
|
|
15
24
|
/**
|
|
16
25
|
* The notifications state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.mts","sourceRoot":"","sources":["../../src/store/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,4BAA4B;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD
|
|
1
|
+
{"version":3,"file":"notifications.d.mts","sourceRoot":"","sources":["../../src/store/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,4BAA4B;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B,CAAC;AASF,eAAO,MAAM,kBAAkB;yGAIM,cAAc,YAAY,CAAC;4GAGxB,cAAc,MAAM,CAAC;;mBAS3D,CAAC;AAEH,eAAO,MAAQ,eAAe,sGAAE,kBAAkB,mGAAE,kBAAkB,4FAC1C,CAAC;AAE7B;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;CAG5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.mjs","sourceRoot":"","sources":["../../src/store/notifications.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"notifications.mjs","sourceRoot":"","sources":["../../src/store/notifications.ts"],"names":[],"mappings":";;AAkCA;;GAEG;AACH,MAAM,aAAa,GAAuB;IACxC,aAAa,EAAE,EAAE;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;IAC5C,IAAI,EAAE,eAAe;IACrB,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE;QACR,eAAe,EAAE,CAAC,KAAK,EAAE,MAAmC,EAAE,EAAE;YAC9D,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAA6B,EAAE,EAAE;YAC3D,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAC9C,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CACrD,CAAC;QACJ,CAAC;QACD,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,KAAK,CAAC,aAAa,GAAG,EAAE,CAAC;QAC3B,CAAC;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,GACtE,kBAAkB,CAAC,OAAO,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAC5C,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,EAChD,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,aAAa,CACrC,CAAC","sourcesContent":["import type { NotificationType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\n/**\n * A notification object.\n *\n * @property id - A unique ID for the notification.\n * @property message - The notification message.\n * @property type - The notification type.\n * @property title - The notification title (expanded view).\n * @property content - The notification JSX content (expanded view).\n * @property footerLink - The notification footer (expanded view).\n */\nexport type Notification = {\n id: string;\n message: string;\n type: NotificationType;\n title?: string;\n content?: string;\n footerLink?: { text: string; href: string };\n};\n\n/**\n * The notifications state.\n *\n * @property notifications - An array of notifications.\n */\nexport type NotificationsState = {\n notifications: Notification[];\n};\n\n/**\n * The initial notifications state.\n */\nconst INITIAL_STATE: NotificationsState = {\n notifications: [],\n};\n\nexport const notificationsSlice = createSlice({\n name: 'notifications',\n initialState: INITIAL_STATE,\n reducers: {\n addNotification: (state, action: PayloadAction<Notification>) => {\n state.notifications.push(action.payload);\n },\n removeNotification: (state, action: PayloadAction<string>) => {\n state.notifications = state.notifications.filter(\n (notification) => notification.id !== action.payload,\n );\n },\n clearNotifications: (state) => {\n state.notifications = [];\n },\n },\n});\n\nexport const { addNotification, removeNotification, clearNotifications } =\n notificationsSlice.actions;\n\n/**\n * Get the notifications from the state.\n *\n * @param state - The application state.\n * @returns An array of notifications.\n */\nexport const getNotifications = createSelector(\n (state: ApplicationState) => state.notifications,\n ({ notifications }) => notifications,\n);\n"]}
|
package/dist/store/ui.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.cjs","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":";;;;AAGA,8CAA6E;AAa7E,MAAM,aAAa,GAAY;IAC7B,OAAO,EAAE,IAAI;CACd,CAAC;AAEW,QAAA,OAAO,GAAG,IAAA,qBAAW,EAAC;IACjC,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE;QACR,YAAY,CAAC,KAAK,EAAE,MAAgC;YAClD,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QACjC,CAAC;QACD,cAAc,CAAC,KAAK;YAClB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC;KACF;CACF,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,IAAA,sBAAY,EAC1C,GAAG,eAAO,CAAC,IAAI,mBAAmB,CACnC,CAAC;AAEW,KAAmC,eAAO,CAAC,OAAO,EAAhD,oBAAY,oBAAE,sBAAc,qBAAqB;AAEnD,QAAA,mBAAmB,GAAG,IAAA,wBAAc,EAC/C,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,EACrC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CACnB,CAAC","sourcesContent":["import type { DialogApprovalTypes } from '@metamask/snaps-rpc-methods';\nimport type { DialogType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createAction, createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\nexport type Interface = {\n type: DialogApprovalTypes[DialogType | 'default'];\n id: string;\n};\n\nexport type UiState = {\n current?: Interface | null;\n};\n\nconst INITIAL_STATE: UiState = {\n current: null,\n};\n\nexport const uiSlice = createSlice({\n name: 'ui',\n initialState: INITIAL_STATE,\n reducers: {\n setInterface(state, action: PayloadAction<Interface>) {\n state.current = action.payload;\n },\n closeInterface(state) {\n state.current = null;\n },\n },\n});\n\nexport const resolveInterface = createAction<unknown>(\n `${uiSlice.name}/resolveInterface`,\n);\n\nexport const { setInterface, closeInterface } = uiSlice.actions;\n\nexport const getCurrentInterface = createSelector(\n (state: ApplicationState) => state.ui,\n (ui) => ui.current,\n);\n"]}
|
|
1
|
+
{"version":3,"file":"ui.cjs","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":";;;;AAGA,8CAA6E;AAa7E,MAAM,aAAa,GAAY;IAC7B,OAAO,EAAE,IAAI;CACd,CAAC;AAEW,QAAA,OAAO,GAAG,IAAA,qBAAW,EAAC;IACjC,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE;QACR,YAAY,CAAC,KAAK,EAAE,MAAgC;YAClD,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QACjC,CAAC;QACD,cAAc,CAAC,KAAK;YAClB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC;KACF;CACF,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAG,IAAA,sBAAY,EAC1C,GAAG,eAAO,CAAC,IAAI,mBAAmB,CACnC,CAAC;AAEW,KAAmC,eAAO,CAAC,OAAO,EAAhD,oBAAY,oBAAE,sBAAc,qBAAqB;AAEnD,QAAA,mBAAmB,GAAG,IAAA,wBAAc,EAC/C,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,EACrC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CACnB,CAAC","sourcesContent":["import type { DialogApprovalTypes } from '@metamask/snaps-rpc-methods';\nimport type { DialogType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createAction, createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\nexport type Interface = {\n type: DialogApprovalTypes[DialogType | 'default'] | 'Notification';\n id: string;\n};\n\nexport type UiState = {\n current?: Interface | null;\n};\n\nconst INITIAL_STATE: UiState = {\n current: null,\n};\n\nexport const uiSlice = createSlice({\n name: 'ui',\n initialState: INITIAL_STATE,\n reducers: {\n setInterface(state, action: PayloadAction<Interface>) {\n state.current = action.payload;\n },\n closeInterface(state) {\n state.current = null;\n },\n },\n});\n\nexport const resolveInterface = createAction<unknown>(\n `${uiSlice.name}/resolveInterface`,\n);\n\nexport const { setInterface, closeInterface } = uiSlice.actions;\n\nexport const getCurrentInterface = createSelector(\n (state: ApplicationState) => state.ui,\n (ui) => ui.current,\n);\n"]}
|
package/dist/store/ui.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import type { DialogApprovalTypes } from "@metamask/snaps-rpc-methods";
|
|
|
2
2
|
import type { DialogType } from "@metamask/snaps-sdk";
|
|
3
3
|
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
4
4
|
export type Interface = {
|
|
5
|
-
type: DialogApprovalTypes[DialogType | 'default'];
|
|
5
|
+
type: DialogApprovalTypes[DialogType | 'default'] | 'Notification';
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
|
8
8
|
export type UiState = {
|
package/dist/store/ui.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.cts","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oCAAoC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,4BAA4B;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,mBAAmB,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ui.d.cts","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oCAAoC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,4BAA4B;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,mBAAmB,CAAC,UAAU,GAAG,SAAS,CAAC,GAAG,cAAc,CAAC;IACnE,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAC5B,CAAC;AAMF,eAAO,MAAM,OAAO;yFAIY,cAAc,SAAS,CAAC;;QAOtD,CAAC;AAEH,eAAO,MAAM,gBAAgB,0EAE5B,CAAC;AAEF,eAAO,MAAQ,YAAY,qFAAE,cAAc,6EAAoB,CAAC;AAEhE,eAAO,MAAM,mBAAmB;;;;;;;;;CAG/B,CAAC"}
|
package/dist/store/ui.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import type { DialogApprovalTypes } from "@metamask/snaps-rpc-methods";
|
|
|
2
2
|
import type { DialogType } from "@metamask/snaps-sdk";
|
|
3
3
|
import type { PayloadAction } from "@reduxjs/toolkit";
|
|
4
4
|
export type Interface = {
|
|
5
|
-
type: DialogApprovalTypes[DialogType | 'default'];
|
|
5
|
+
type: DialogApprovalTypes[DialogType | 'default'] | 'Notification';
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
|
8
8
|
export type UiState = {
|
package/dist/store/ui.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.mts","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oCAAoC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,4BAA4B;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB;AAKtD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,mBAAmB,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ui.d.mts","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oCAAoC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,4BAA4B;AACtD,OAAO,KA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AAE,EAAE,CAAC,KAAK,CAAC,EAAE,EACrC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CACnB,CAAC","sourcesContent":["import type { DialogApprovalTypes } from '@metamask/snaps-rpc-methods';\nimport type { DialogType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createAction, createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\nexport type Interface = {\n type: DialogApprovalTypes[DialogType | 'default'];\n id: string;\n};\n\nexport type UiState = {\n current?: Interface | null;\n};\n\nconst INITIAL_STATE: UiState = {\n current: null,\n};\n\nexport const uiSlice = createSlice({\n name: 'ui',\n initialState: INITIAL_STATE,\n reducers: {\n setInterface(state, action: PayloadAction<Interface>) {\n state.current = action.payload;\n },\n closeInterface(state) {\n state.current = null;\n },\n },\n});\n\nexport const resolveInterface = createAction<unknown>(\n `${uiSlice.name}/resolveInterface`,\n);\n\nexport const { setInterface, closeInterface } = uiSlice.actions;\n\nexport const getCurrentInterface = createSelector(\n (state: ApplicationState) => state.ui,\n (ui) => ui.current,\n);\n"]}
|
|
1
|
+
{"version":3,"file":"ui.mjs","sourceRoot":"","sources":["../../src/store/ui.ts"],"names":[],"mappings":";;AAgBA,MAAM,aAAa,GAAY;IAC7B,OAAO,EAAE,IAAI;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC;IACjC,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE;QACR,YAAY,CAAC,KAAK,EAAE,MAAgC;YAClD,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QACjC,CAAC;QACD,cAAc,CAAC,KAAK;YAClB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,CAAC;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAC1C,GAAG,OAAO,CAAC,IAAI,mBAAmB,CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;AAEhE,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAC/C,CAAC,KAAuB,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,EACrC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CACnB,CAAC","sourcesContent":["import type { DialogApprovalTypes } from '@metamask/snaps-rpc-methods';\nimport type { DialogType } from '@metamask/snaps-sdk';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { createAction, createSelector, createSlice } from '@reduxjs/toolkit';\n\nimport type { ApplicationState } from './store';\n\nexport type Interface = {\n type: DialogApprovalTypes[DialogType | 'default'] | 'Notification';\n id: string;\n};\n\nexport type UiState = {\n current?: Interface | null;\n};\n\nconst INITIAL_STATE: UiState = {\n current: null,\n};\n\nexport const uiSlice = createSlice({\n name: 'ui',\n initialState: INITIAL_STATE,\n reducers: {\n setInterface(state, action: PayloadAction<Interface>) {\n state.current = action.payload;\n },\n closeInterface(state) {\n state.current = null;\n },\n },\n});\n\nexport const resolveInterface = createAction<unknown>(\n `${uiSlice.name}/resolveInterface`,\n);\n\nexport const { setInterface, closeInterface } = uiSlice.actions;\n\nexport const getCurrentInterface = createSelector(\n (state: ApplicationState) => state.ui,\n (ui) => ui.current,\n);\n"]}
|
package/dist/structs.cjs
CHANGED
|
@@ -164,6 +164,12 @@ exports.SnapResponseWithoutInterfaceStruct = (0, superstruct_1.object)({
|
|
|
164
164
|
(0, snaps_sdk_1.enumValue)(snaps_sdk_1.NotificationType.InApp),
|
|
165
165
|
(0, snaps_sdk_1.enumValue)(snaps_sdk_1.NotificationType.Native),
|
|
166
166
|
]),
|
|
167
|
+
title: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
168
|
+
content: (0, superstruct_1.optional)((0, superstruct_1.string)()),
|
|
169
|
+
footerLink: (0, superstruct_1.optional)((0, superstruct_1.object)({
|
|
170
|
+
href: (0, superstruct_1.string)(),
|
|
171
|
+
text: (0, superstruct_1.string)(),
|
|
172
|
+
})),
|
|
167
173
|
})),
|
|
168
174
|
});
|
|
169
175
|
exports.SnapResponseWithInterfaceStruct = (0, superstruct_1.assign)(exports.SnapResponseWithoutInterfaceStruct, (0, superstruct_1.object)({
|
package/dist/structs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.cjs","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAClE,iDAA2D;AAC3D,uDAiB+B;AAC/B,2CAMyB;AACzB,mCAAqC;AAIrC,oDAAoD;AACpD,MAAM,eAAe,GAAG,IAAA,mBAAK,EAAC;IAC5B,IAAA,oBAAM,GAAE;IACR,IAAA,oBAAM,GAAE;IACR,IAAA,oBAAM,GAAE;IACR,IAAA,sBAAQ,EAAC,UAAU,CAAC;CACrB,CAAC,CAAC;AAEU,QAAA,wBAAwB,GAAG,IAAA,oBAAM,EAAC;IAC7C;;OAEG;IACH,OAAO,EAAE,IAAA,uBAAS,EAAC,IAAA,oBAAM,GAAE,EAAE,UAAU,CAAC;IAExC;;OAEG;IACH,MAAM,EAAE,IAAA,uBAAS,EAAC,IAAA,oBAAM,GAAE,EAAE,aAAa,CAAC;IAE1C;;;OAGG;IACH,gDAAgD;IAChD,IAAI,EAAE,IAAA,oBAAM,EAAC,uBAAe,EAAE,IAAA,sBAAQ,EAAC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;QACjE,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,IAAA,kBAAU,EAAC,IAAA,oBAAY,EAAC,KAAK,CAAC,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,IAAA,kBAAU,EAAC,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF;;;OAGG;IACH,gDAAgD;IAChD,EAAE,EAAE,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A,oBAAM,EAAC;IACvD,EAAE,EAAE,IAAA,oBAAM,GAAE;IAEZ,QAAQ,EAAE,IAAA,mBAAK,EAAC;QACd,IAAA,oBAAM,EAAC;YACL,MAAM,EAAE,kBAAU;SACnB,CAAC;QACF,IAAA,oBAAM,EAAC;YACL,KAAK,EAAE,kBAAU;SAClB,CAAC;KACH,CAAC;IAEF,aAAa,EAAE,IAAA,mBAAK,EAClB,IAAA,oBAAM,EAAC;QACL,EAAE,EAAE,IAAA,oBAAM,GAAE;QACZ,OAAO,EAAE,IAAA,oBAAM,GAAE;QACjB,IAAI,EAAE,IAAA,mBAAK,EAAC;YACV,IAAA,qBAAS,EAAC,4BAAgB,CAAC,KAAK,CAAC;YACjC,IAAA,qBAAS,EAAC,4BAAgB,CAAC,MAAM,CAAC;SACnC,CAAC;KACH,CAAC,CACH;CACF,CAAC,CAAC;AAEU,QAAA,+BAA+B,GAAG,IAAA,oBAAM,EACnD,0CAAkC,EAClC,IAAA,oBAAM,EAAC;IACL,YAAY,EAAE,IAAA,kBAAI,GAAE;CACrB,CAAC,CACH,CAAC;AAEW,QAAA,kBAAkB,GAAG,IAAA,mBAAK,EAAC;IACtC,0CAAkC;IAClC,uCAA+B;CAChC,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,6BAA6B,CAC3C,QAAsB;IAEtB,IAAA,oBAAY,EAAC,QAAQ,EAAE,uCAA+B,CAAC,CAAC;AAC1D,CAAC;AAJD,sEAIC","sourcesContent":["import { NotificationType, enumValue } from '@metamask/snaps-sdk';\nimport { JSXElementStruct } from '@metamask/snaps-sdk/jsx';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n union,\n record,\n any,\n func,\n type,\n} from '@metamask/superstruct';\nimport {\n assertStruct,\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\n\nimport type { SnapResponse, SnapResponseWithInterface } from './types';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SignatureOptionsStruct = object({\n /**\n * The origin making the signature request.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address signing the signature request. Defaults to a randomly generated\n * address.\n */\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `string`, an object, or an array of objects. This covers the data types\n * for the supported signature methods. Defaults to `0x`.\n */\n data: defaulted(\n union([\n StrictHexStruct,\n literal('0x'),\n record(string(), any()),\n array(record(string(), any())),\n ]),\n '0x',\n ),\n\n /**\n * The signature method being used.\n */\n signatureMethod: defaulted(\n union([\n literal('personal_sign'),\n literal('eth_signTypedData'),\n literal('eth_signTypedData_v3'),\n literal('eth_signTypedData_v4'),\n ]),\n 'personal_sign',\n ),\n});\n\nexport const BaseNameLookupOptionsStruct = object({\n /**\n * The CAIP-2 chain ID. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n});\n\nexport const NameLookupOptionsStruct = union([\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Address to lookup.\n */\n address: string(),\n }),\n ),\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Domain name to lookup.\n */\n domain: string(),\n }),\n ),\n]);\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const JsonRpcMockOptionsStruct = object({\n method: string(),\n result: JsonStruct,\n});\n\nexport const InterfaceStruct = type({\n content: optional(JSXElementStruct),\n});\n\nexport const SnapResponseWithoutInterfaceStruct = object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n }),\n ),\n});\n\nexport const SnapResponseWithInterfaceStruct = assign(\n SnapResponseWithoutInterfaceStruct,\n object({\n getInterface: func(),\n }),\n);\n\nexport const SnapResponseStruct = union([\n SnapResponseWithoutInterfaceStruct,\n SnapResponseWithInterfaceStruct,\n]);\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nexport function assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"structs.cjs","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAClE,iDAA2D;AAC3D,uDAiB+B;AAC/B,2CAMyB;AACzB,mCAAqC;AAIrC,oDAAoD;AACpD,MAAM,eAAe,GAAG,IAAA,mBAAK,EAAC;IAC5B,IAAA,oBAAM,GAAE;IACR,IAAA,oBAAM,GAAE;IACR,IAAA,oBAAM,GAAE;IACR,IAAA,sBAAQ,EAAC,UAAU,CAAC;CACrB,CAAC,CAAC;AAEU,QAAA,wBAAwB,GAAG,IAAA,oBA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AA,sBAAQ,EAClB,IAAA,oBAAM,EAAC;YACL,IAAI,EAAE,IAAA,oBAAM,GAAE;YACd,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC,CACH;KACF,CAAC,CACH;CACF,CAAC,CAAC;AAEU,QAAA,+BAA+B,GAAG,IAAA,oBAAM,EACnD,0CAAkC,EAClC,IAAA,oBAAM,EAAC;IACL,YAAY,EAAE,IAAA,kBAAI,GAAE;CACrB,CAAC,CACH,CAAC;AAEW,QAAA,kBAAkB,GAAG,IAAA,mBAAK,EAAC;IACtC,0CAAkC;IAClC,uCAA+B;CAChC,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,6BAA6B,CAC3C,QAAsB;IAEtB,IAAA,oBAAY,EAAC,QAAQ,EAAE,uCAA+B,CAAC,CAAC;AAC1D,CAAC;AAJD,sEAIC","sourcesContent":["import { NotificationType, enumValue } from '@metamask/snaps-sdk';\nimport { JSXElementStruct } from '@metamask/snaps-sdk/jsx';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n union,\n record,\n any,\n func,\n type,\n} from '@metamask/superstruct';\nimport {\n assertStruct,\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\n\nimport type { SnapResponse, SnapResponseWithInterface } from './types';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SignatureOptionsStruct = object({\n /**\n * The origin making the signature request.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address signing the signature request. Defaults to a randomly generated\n * address.\n */\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `string`, an object, or an array of objects. This covers the data types\n * for the supported signature methods. Defaults to `0x`.\n */\n data: defaulted(\n union([\n StrictHexStruct,\n literal('0x'),\n record(string(), any()),\n array(record(string(), any())),\n ]),\n '0x',\n ),\n\n /**\n * The signature method being used.\n */\n signatureMethod: defaulted(\n union([\n literal('personal_sign'),\n literal('eth_signTypedData'),\n literal('eth_signTypedData_v3'),\n literal('eth_signTypedData_v4'),\n ]),\n 'personal_sign',\n ),\n});\n\nexport const BaseNameLookupOptionsStruct = object({\n /**\n * The CAIP-2 chain ID. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n});\n\nexport const NameLookupOptionsStruct = union([\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Address to lookup.\n */\n address: string(),\n }),\n ),\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Domain name to lookup.\n */\n domain: string(),\n }),\n ),\n]);\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const JsonRpcMockOptionsStruct = object({\n method: string(),\n result: JsonStruct,\n});\n\nexport const InterfaceStruct = type({\n content: optional(JSXElementStruct),\n});\n\nexport const SnapResponseWithoutInterfaceStruct = object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n title: optional(string()),\n content: optional(string()),\n footerLink: optional(\n object({\n href: string(),\n text: string(),\n }),\n ),\n }),\n ),\n});\n\nexport const SnapResponseWithInterfaceStruct = assign(\n SnapResponseWithoutInterfaceStruct,\n object({\n getInterface: func(),\n }),\n);\n\nexport const SnapResponseStruct = union([\n SnapResponseWithoutInterfaceStruct,\n SnapResponseWithInterfaceStruct,\n]);\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nexport function assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n"]}
|
package/dist/structs.d.cts
CHANGED
|
@@ -130,6 +130,12 @@ export declare const SnapResponseWithoutInterfaceStruct: import("@metamask/super
|
|
|
130
130
|
type: "native" | "inApp";
|
|
131
131
|
message: string;
|
|
132
132
|
id: string;
|
|
133
|
+
content?: string | undefined;
|
|
134
|
+
title?: string | undefined;
|
|
135
|
+
footerLink?: {
|
|
136
|
+
text: string;
|
|
137
|
+
href: string;
|
|
138
|
+
} | undefined;
|
|
133
139
|
}[];
|
|
134
140
|
response: {
|
|
135
141
|
result: import("@metamask/snaps-sdk").Json;
|
|
@@ -147,14 +153,35 @@ export declare const SnapResponseWithoutInterfaceStruct: import("@metamask/super
|
|
|
147
153
|
type: "native" | "inApp";
|
|
148
154
|
message: string;
|
|
149
155
|
id: string;
|
|
156
|
+
content?: string | undefined;
|
|
157
|
+
title?: string | undefined;
|
|
158
|
+
footerLink?: {
|
|
159
|
+
text: string;
|
|
160
|
+
href: string;
|
|
161
|
+
} | undefined;
|
|
150
162
|
}[], import("@metamask/superstruct").Struct<{
|
|
151
163
|
type: "native" | "inApp";
|
|
152
164
|
message: string;
|
|
153
165
|
id: string;
|
|
166
|
+
content?: string | undefined;
|
|
167
|
+
title?: string | undefined;
|
|
168
|
+
footerLink?: {
|
|
169
|
+
text: string;
|
|
170
|
+
href: string;
|
|
171
|
+
} | undefined;
|
|
154
172
|
}, {
|
|
155
173
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
156
174
|
message: import("@metamask/superstruct").Struct<string, null>;
|
|
157
175
|
type: import("@metamask/superstruct").Struct<"native" | "inApp", null>;
|
|
176
|
+
title: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
177
|
+
content: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
178
|
+
footerLink: import("@metamask/superstruct").Struct<{
|
|
179
|
+
text: string;
|
|
180
|
+
href: string;
|
|
181
|
+
} | undefined, {
|
|
182
|
+
href: import("@metamask/superstruct").Struct<string, null>;
|
|
183
|
+
text: import("@metamask/superstruct").Struct<string, null>;
|
|
184
|
+
}>;
|
|
158
185
|
}>>;
|
|
159
186
|
}>;
|
|
160
187
|
export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstruct").Struct<{
|
|
@@ -163,6 +190,12 @@ export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstr
|
|
|
163
190
|
type: "native" | "inApp";
|
|
164
191
|
message: string;
|
|
165
192
|
id: string;
|
|
193
|
+
content?: string | undefined;
|
|
194
|
+
title?: string | undefined;
|
|
195
|
+
footerLink?: {
|
|
196
|
+
text: string;
|
|
197
|
+
href: string;
|
|
198
|
+
} | undefined;
|
|
166
199
|
}[];
|
|
167
200
|
response: {
|
|
168
201
|
result: import("@metamask/snaps-sdk").Json;
|
|
@@ -177,14 +210,35 @@ export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstr
|
|
|
177
210
|
type: "native" | "inApp";
|
|
178
211
|
message: string;
|
|
179
212
|
id: string;
|
|
213
|
+
content?: string | undefined;
|
|
214
|
+
title?: string | undefined;
|
|
215
|
+
footerLink?: {
|
|
216
|
+
text: string;
|
|
217
|
+
href: string;
|
|
218
|
+
} | undefined;
|
|
180
219
|
}[], import("@metamask/superstruct").Struct<{
|
|
181
220
|
type: "native" | "inApp";
|
|
182
221
|
message: string;
|
|
183
222
|
id: string;
|
|
223
|
+
content?: string | undefined;
|
|
224
|
+
title?: string | undefined;
|
|
225
|
+
footerLink?: {
|
|
226
|
+
text: string;
|
|
227
|
+
href: string;
|
|
228
|
+
} | undefined;
|
|
184
229
|
}, {
|
|
185
230
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
186
231
|
message: import("@metamask/superstruct").Struct<string, null>;
|
|
187
232
|
type: import("@metamask/superstruct").Struct<"native" | "inApp", null>;
|
|
233
|
+
title: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
234
|
+
content: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
235
|
+
footerLink: import("@metamask/superstruct").Struct<{
|
|
236
|
+
text: string;
|
|
237
|
+
href: string;
|
|
238
|
+
} | undefined, {
|
|
239
|
+
href: import("@metamask/superstruct").Struct<string, null>;
|
|
240
|
+
text: import("@metamask/superstruct").Struct<string, null>;
|
|
241
|
+
}>;
|
|
188
242
|
}>>;
|
|
189
243
|
response: import("@metamask/superstruct").Struct<{
|
|
190
244
|
result: import("@metamask/snaps-sdk").Json;
|
|
@@ -198,6 +252,12 @@ export declare const SnapResponseStruct: import("@metamask/superstruct").Struct<
|
|
|
198
252
|
type: "native" | "inApp";
|
|
199
253
|
message: string;
|
|
200
254
|
id: string;
|
|
255
|
+
content?: string | undefined;
|
|
256
|
+
title?: string | undefined;
|
|
257
|
+
footerLink?: {
|
|
258
|
+
text: string;
|
|
259
|
+
href: string;
|
|
260
|
+
} | undefined;
|
|
201
261
|
}[];
|
|
202
262
|
response: {
|
|
203
263
|
result: import("@metamask/snaps-sdk").Json;
|
|
@@ -210,6 +270,12 @@ export declare const SnapResponseStruct: import("@metamask/superstruct").Struct<
|
|
|
210
270
|
type: "native" | "inApp";
|
|
211
271
|
message: string;
|
|
212
272
|
id: string;
|
|
273
|
+
content?: string | undefined;
|
|
274
|
+
title?: string | undefined;
|
|
275
|
+
footerLink?: {
|
|
276
|
+
text: string;
|
|
277
|
+
href: string;
|
|
278
|
+
} | undefined;
|
|
213
279
|
}[];
|
|
214
280
|
response: {
|
|
215
281
|
result: import("@metamask/snaps-sdk").Json;
|
package/dist/structs.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.d.cts","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,oBAAgB;AAUvE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;IACnC;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAUH;;;OAGG;;IAUH;;;OAGG;;IAQH;;;OAGG;;IAQH;;;;OAIG;;IAQH;;;;OAIG;;IAQH;;;OAGG;;IAQH;;;OAGG;;EAOH,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;IACjC;;OAEG;;IAGH;;;OAGG;;IASH;;;;OAIG;;IAWH;;OAEG;;EAUH,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;IACtC;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;QAmBlC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;IAC5B;;;OAGG;;EAEH,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;EAGnC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;EAE1B,CAAC;AAEH,eAAO,MAAM,kCAAkC
|
|
1
|
+
{"version":3,"file":"structs.d.cts","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,oBAAgB;AAUvE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;IACnC;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAUH;;;OAGG;;IAUH;;;OAGG;;IAQH;;;OAGG;;IAQH;;;;OAIG;;IAQH;;;;OAIG;;IAQH;;;OAGG;;IAQH;;;OAGG;;EAOH,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;IACjC;;OAEG;;IAGH;;;OAGG;;IASH;;;;OAIG;;IAWH;;OAEG;;EAUH,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;IACtC;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;QAmBlC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;IAC5B;;;OAGG;;EAEH,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;EAGnC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;EAE1B,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8B7C,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK3C,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAG7B,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,QAAQ,IAAI,yBAAyB,CAE/C"}
|
package/dist/structs.d.mts
CHANGED
|
@@ -130,6 +130,12 @@ export declare const SnapResponseWithoutInterfaceStruct: import("@metamask/super
|
|
|
130
130
|
type: "native" | "inApp";
|
|
131
131
|
message: string;
|
|
132
132
|
id: string;
|
|
133
|
+
content?: string | undefined;
|
|
134
|
+
title?: string | undefined;
|
|
135
|
+
footerLink?: {
|
|
136
|
+
text: string;
|
|
137
|
+
href: string;
|
|
138
|
+
} | undefined;
|
|
133
139
|
}[];
|
|
134
140
|
response: {
|
|
135
141
|
result: import("@metamask/snaps-sdk").Json;
|
|
@@ -147,14 +153,35 @@ export declare const SnapResponseWithoutInterfaceStruct: import("@metamask/super
|
|
|
147
153
|
type: "native" | "inApp";
|
|
148
154
|
message: string;
|
|
149
155
|
id: string;
|
|
156
|
+
content?: string | undefined;
|
|
157
|
+
title?: string | undefined;
|
|
158
|
+
footerLink?: {
|
|
159
|
+
text: string;
|
|
160
|
+
href: string;
|
|
161
|
+
} | undefined;
|
|
150
162
|
}[], import("@metamask/superstruct").Struct<{
|
|
151
163
|
type: "native" | "inApp";
|
|
152
164
|
message: string;
|
|
153
165
|
id: string;
|
|
166
|
+
content?: string | undefined;
|
|
167
|
+
title?: string | undefined;
|
|
168
|
+
footerLink?: {
|
|
169
|
+
text: string;
|
|
170
|
+
href: string;
|
|
171
|
+
} | undefined;
|
|
154
172
|
}, {
|
|
155
173
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
156
174
|
message: import("@metamask/superstruct").Struct<string, null>;
|
|
157
175
|
type: import("@metamask/superstruct").Struct<"native" | "inApp", null>;
|
|
176
|
+
title: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
177
|
+
content: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
178
|
+
footerLink: import("@metamask/superstruct").Struct<{
|
|
179
|
+
text: string;
|
|
180
|
+
href: string;
|
|
181
|
+
} | undefined, {
|
|
182
|
+
href: import("@metamask/superstruct").Struct<string, null>;
|
|
183
|
+
text: import("@metamask/superstruct").Struct<string, null>;
|
|
184
|
+
}>;
|
|
158
185
|
}>>;
|
|
159
186
|
}>;
|
|
160
187
|
export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstruct").Struct<{
|
|
@@ -163,6 +190,12 @@ export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstr
|
|
|
163
190
|
type: "native" | "inApp";
|
|
164
191
|
message: string;
|
|
165
192
|
id: string;
|
|
193
|
+
content?: string | undefined;
|
|
194
|
+
title?: string | undefined;
|
|
195
|
+
footerLink?: {
|
|
196
|
+
text: string;
|
|
197
|
+
href: string;
|
|
198
|
+
} | undefined;
|
|
166
199
|
}[];
|
|
167
200
|
response: {
|
|
168
201
|
result: import("@metamask/snaps-sdk").Json;
|
|
@@ -177,14 +210,35 @@ export declare const SnapResponseWithInterfaceStruct: import("@metamask/superstr
|
|
|
177
210
|
type: "native" | "inApp";
|
|
178
211
|
message: string;
|
|
179
212
|
id: string;
|
|
213
|
+
content?: string | undefined;
|
|
214
|
+
title?: string | undefined;
|
|
215
|
+
footerLink?: {
|
|
216
|
+
text: string;
|
|
217
|
+
href: string;
|
|
218
|
+
} | undefined;
|
|
180
219
|
}[], import("@metamask/superstruct").Struct<{
|
|
181
220
|
type: "native" | "inApp";
|
|
182
221
|
message: string;
|
|
183
222
|
id: string;
|
|
223
|
+
content?: string | undefined;
|
|
224
|
+
title?: string | undefined;
|
|
225
|
+
footerLink?: {
|
|
226
|
+
text: string;
|
|
227
|
+
href: string;
|
|
228
|
+
} | undefined;
|
|
184
229
|
}, {
|
|
185
230
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
186
231
|
message: import("@metamask/superstruct").Struct<string, null>;
|
|
187
232
|
type: import("@metamask/superstruct").Struct<"native" | "inApp", null>;
|
|
233
|
+
title: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
234
|
+
content: import("@metamask/superstruct").Struct<string | undefined, null>;
|
|
235
|
+
footerLink: import("@metamask/superstruct").Struct<{
|
|
236
|
+
text: string;
|
|
237
|
+
href: string;
|
|
238
|
+
} | undefined, {
|
|
239
|
+
href: import("@metamask/superstruct").Struct<string, null>;
|
|
240
|
+
text: import("@metamask/superstruct").Struct<string, null>;
|
|
241
|
+
}>;
|
|
188
242
|
}>>;
|
|
189
243
|
response: import("@metamask/superstruct").Struct<{
|
|
190
244
|
result: import("@metamask/snaps-sdk").Json;
|
|
@@ -198,6 +252,12 @@ export declare const SnapResponseStruct: import("@metamask/superstruct").Struct<
|
|
|
198
252
|
type: "native" | "inApp";
|
|
199
253
|
message: string;
|
|
200
254
|
id: string;
|
|
255
|
+
content?: string | undefined;
|
|
256
|
+
title?: string | undefined;
|
|
257
|
+
footerLink?: {
|
|
258
|
+
text: string;
|
|
259
|
+
href: string;
|
|
260
|
+
} | undefined;
|
|
201
261
|
}[];
|
|
202
262
|
response: {
|
|
203
263
|
result: import("@metamask/snaps-sdk").Json;
|
|
@@ -210,6 +270,12 @@ export declare const SnapResponseStruct: import("@metamask/superstruct").Struct<
|
|
|
210
270
|
type: "native" | "inApp";
|
|
211
271
|
message: string;
|
|
212
272
|
id: string;
|
|
273
|
+
content?: string | undefined;
|
|
274
|
+
title?: string | undefined;
|
|
275
|
+
footerLink?: {
|
|
276
|
+
text: string;
|
|
277
|
+
href: string;
|
|
278
|
+
} | undefined;
|
|
213
279
|
}[];
|
|
214
280
|
response: {
|
|
215
281
|
result: import("@metamask/snaps-sdk").Json;
|
package/dist/structs.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.d.mts","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,oBAAgB;AAUvE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;IACnC;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAUH;;;OAGG;;IAUH;;;OAGG;;IAQH;;;OAGG;;IAQH;;;;OAIG;;IAQH;;;;OAIG;;IAQH;;;OAGG;;IAQH;;;OAGG;;EAOH,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;IACjC;;OAEG;;IAGH;;;OAGG;;IASH;;;;OAIG;;IAWH;;OAEG;;EAUH,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;IACtC;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;QAmBlC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;IAC5B;;;OAGG;;EAEH,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;EAGnC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;EAE1B,CAAC;AAEH,eAAO,MAAM,kCAAkC
|
|
1
|
+
{"version":3,"file":"structs.d.mts","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,oBAAgB;AAUvE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;IACnC;;OAEG;;IAGH;;OAEG;;IAGH;;;OAGG;;IAUH;;;OAGG;;IAUH;;;OAGG;;IAQH;;;OAGG;;IAQH;;;;OAIG;;IAQH;;;;OAIG;;IAQH;;;OAGG;;IAQH;;;OAGG;;EAOH,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;IACjC;;OAEG;;IAGH;;;OAGG;;IASH;;;;OAIG;;IAWH;;OAEG;;EAUH,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;IACtC;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;QAmBlC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;IAC5B;;;OAGG;;EAEH,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;EAGnC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;EAE1B,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8B7C,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK3C,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAG7B,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,QAAQ,IAAI,yBAAyB,CAE/C"}
|
package/dist/structs.mjs
CHANGED
|
@@ -161,6 +161,12 @@ export const SnapResponseWithoutInterfaceStruct = object({
|
|
|
161
161
|
enumValue(NotificationType.InApp),
|
|
162
162
|
enumValue(NotificationType.Native),
|
|
163
163
|
]),
|
|
164
|
+
title: optional(string()),
|
|
165
|
+
content: optional(string()),
|
|
166
|
+
footerLink: optional(object({
|
|
167
|
+
href: string(),
|
|
168
|
+
text: string(),
|
|
169
|
+
})),
|
|
164
170
|
})),
|
|
165
171
|
});
|
|
166
172
|
export const SnapResponseWithInterfaceStruct = assign(SnapResponseWithoutInterfaceStruct, object({
|
package/dist/structs.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.mjs","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,4BAA4B;AAClE,OAAO,EAAE,gBAAgB,EAAE,gCAAgC;AAC3D,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,IAAI,EACL,8BAA8B;AAC/B,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,YAAY,EACb,wBAAwB;AACzB,OAAO,EAAE,WAAW,EAAE,eAAe;AAIrC,oDAAoD;AACpD,MAAM,eAAe,GAAG,KAAK,CAAC;IAC5B,MAAM,EAAE;IACR,MAAM,EAAE;IACR,MAAM,EAAE;IACR,QAAQ,CAAC,UAAU,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;IAC7C;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC;IAExC;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC;IAE1C;;;OAGG;IACH,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC,eAAe,EAAE,QAAQ,CAA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L,EAAE,EAAE,MAAM,EAAE;QACZ,OAAO,EAAE,MAAM,EAAE;QACjB,IAAI,EAAE,KAAK,CAAC;YACV,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC;YACjC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC;SACnC,CAAC;KACH,CAAC,CACH;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CACnD,kCAAkC,EAClC,MAAM,CAAC;IACL,YAAY,EAAE,IAAI,EAAE;CACrB,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;IACtC,kCAAkC;IAClC,+BAA+B;CAChC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAsB;IAEtB,YAAY,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { NotificationType, enumValue } from '@metamask/snaps-sdk';\nimport { JSXElementStruct } from '@metamask/snaps-sdk/jsx';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n union,\n record,\n any,\n func,\n type,\n} from '@metamask/superstruct';\nimport {\n assertStruct,\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\n\nimport type { SnapResponse, SnapResponseWithInterface } from './types';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SignatureOptionsStruct = object({\n /**\n * The origin making the signature request.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address signing the signature request. Defaults to a randomly generated\n * address.\n */\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `string`, an object, or an array of objects. This covers the data types\n * for the supported signature methods. Defaults to `0x`.\n */\n data: defaulted(\n union([\n StrictHexStruct,\n literal('0x'),\n record(string(), any()),\n array(record(string(), any())),\n ]),\n '0x',\n ),\n\n /**\n * The signature method being used.\n */\n signatureMethod: defaulted(\n union([\n literal('personal_sign'),\n literal('eth_signTypedData'),\n literal('eth_signTypedData_v3'),\n literal('eth_signTypedData_v4'),\n ]),\n 'personal_sign',\n ),\n});\n\nexport const BaseNameLookupOptionsStruct = object({\n /**\n * The CAIP-2 chain ID. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n});\n\nexport const NameLookupOptionsStruct = union([\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Address to lookup.\n */\n address: string(),\n }),\n ),\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Domain name to lookup.\n */\n domain: string(),\n }),\n ),\n]);\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const JsonRpcMockOptionsStruct = object({\n method: string(),\n result: JsonStruct,\n});\n\nexport const InterfaceStruct = type({\n content: optional(JSXElementStruct),\n});\n\nexport const SnapResponseWithoutInterfaceStruct = object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n }),\n ),\n});\n\nexport const SnapResponseWithInterfaceStruct = assign(\n SnapResponseWithoutInterfaceStruct,\n object({\n getInterface: func(),\n }),\n);\n\nexport const SnapResponseStruct = union([\n SnapResponseWithoutInterfaceStruct,\n SnapResponseWithInterfaceStruct,\n]);\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nexport function assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"structs.mjs","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,4BAA4B;AAClE,OAAO,EAAE,gBAAgB,EAAE,gCAAgC;AAC3D,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,IAAI,EACL,8BAA8B;AAC/B,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,YAAY,EACb,wBAAwB;AACzB,OAAO,EAAE,WAAW,EAAE,eAAe;AAIrC,oDAAoD;AACpD,MAAM,eAAe,GAAG,KAAK,CAAC;IAC5B,MAAM,EAAE;IACR,MAAM,EAAE;IACR,MAAM,EAAE;IACR,QAAQ,CAAC,UAAU,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;IAC7C;;OAEG;IACH,OAAO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MAAM,EAAE;IAEZ,QAAQ,EAAE,KAAK,CAAC;QACd,MAAM,CAAC;YACL,MAAM,EAAE,UAAU;SACnB,CAAC;QACF,MAAM,CAAC;YACL,KAAK,EAAE,UAAU;SAClB,CAAC;KACH,CAAC;IAEF,aAAa,EAAE,KAAK,CAClB,MAAM,CAAC;QACL,EAAE,EAAE,MAAM,EAAE;QACZ,OAAO,EAAE,MAAM,EAAE;QACjB,IAAI,EAAE,KAAK,CAAC;YACV,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC;YACjC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC;SACnC,CAAC;QACF,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QACzB,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC3B,UAAU,EAAE,QAAQ,CAClB,MAAM,CAAC;YACL,IAAI,EAAE,MAAM,EAAE;YACd,IAAI,EAAE,MAAM,EAAE;SACf,CAAC,CACH;KACF,CAAC,CACH;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CACnD,kCAAkC,EAClC,MAAM,CAAC;IACL,YAAY,EAAE,IAAI,EAAE;CACrB,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;IACtC,kCAAkC;IAClC,+BAA+B;CAChC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAsB;IAEtB,YAAY,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { NotificationType, enumValue } from '@metamask/snaps-sdk';\nimport { JSXElementStruct } from '@metamask/snaps-sdk/jsx';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n union,\n record,\n any,\n func,\n type,\n} from '@metamask/superstruct';\nimport {\n assertStruct,\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\n\nimport type { SnapResponse, SnapResponseWithInterface } from './types';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SignatureOptionsStruct = object({\n /**\n * The origin making the signature request.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address signing the signature request. Defaults to a randomly generated\n * address.\n */\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `string`, an object, or an array of objects. This covers the data types\n * for the supported signature methods. Defaults to `0x`.\n */\n data: defaulted(\n union([\n StrictHexStruct,\n literal('0x'),\n record(string(), any()),\n array(record(string(), any())),\n ]),\n '0x',\n ),\n\n /**\n * The signature method being used.\n */\n signatureMethod: defaulted(\n union([\n literal('personal_sign'),\n literal('eth_signTypedData'),\n literal('eth_signTypedData_v3'),\n literal('eth_signTypedData_v4'),\n ]),\n 'personal_sign',\n ),\n});\n\nexport const BaseNameLookupOptionsStruct = object({\n /**\n * The CAIP-2 chain ID. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n});\n\nexport const NameLookupOptionsStruct = union([\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Address to lookup.\n */\n address: string(),\n }),\n ),\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Domain name to lookup.\n */\n domain: string(),\n }),\n ),\n]);\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const JsonRpcMockOptionsStruct = object({\n method: string(),\n result: JsonStruct,\n});\n\nexport const InterfaceStruct = type({\n content: optional(JSXElementStruct),\n});\n\nexport const SnapResponseWithoutInterfaceStruct = object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n title: optional(string()),\n content: optional(string()),\n footerLink: optional(\n object({\n href: string(),\n text: string(),\n }),\n ),\n }),\n ),\n});\n\nexport const SnapResponseWithInterfaceStruct = assign(\n SnapResponseWithoutInterfaceStruct,\n object({\n getInterface: func(),\n }),\n);\n\nexport const SnapResponseStruct = union([\n SnapResponseWithoutInterfaceStruct,\n SnapResponseWithInterfaceStruct,\n]);\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nexport function assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json, JsonRpcId, JsonRpcParams } from '@metamask/utils';\n\nimport type {\n NameLookupOptionsStruct,\n SignatureOptionsStruct,\n SnapOptionsStruct,\n SnapResponseStruct,\n TransactionOptionsStruct,\n} from './structs';\n\nexport type RequestOptions = {\n /**\n * The JSON-RPC request ID.\n */\n id?: JsonRpcId;\n\n /**\n * The JSON-RPC method.\n */\n method: string;\n\n /**\n * The JSON-RPC params.\n */\n params?: JsonRpcParams;\n\n /**\n * The origin to send the request from.\n */\n origin?: string;\n};\n\n/**\n * The `runCronjob` options. This is the same as {@link RequestOptions}, except\n * that it does not have an `origin` property.\n */\nexport type CronjobOptions = Omit<RequestOptions, 'origin'>;\n\n/**\n * The options to use for transaction requests.\n *\n * @property chainId - The CAIP-2 chain ID to send the transaction on. Defaults\n * to `eip155:1`.\n * @property origin - The origin to send the transaction from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the transaction from. Defaults to a\n * randomly generated address.\n * @property to - The address to send the transaction to. Defaults to a randomly\n * generated address.\n * @property value - The value to send with the transaction. Defaults to `0`.\n * @property data - The data to send with the transaction. Defaults to `0x`.\n * @property gasLimit - The gas limit to use for the transaction. Defaults to\n * `21_000`.\n * @property maxFeePerGas - The maximum fee per gas to use for the transaction.\n * Defaults to `1`.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas to use for\n * the transaction. Defaults to `1`.\n * @property nonce - The nonce to use for the transaction. Defaults to `0`.\n */\nexport type TransactionOptions = Infer<typeof TransactionOptionsStruct>;\n\n/**\n * The options to use for keyring requests.\n */\nexport type KeyringOptions = RequestOptions;\n\n/**\n * The options to use for name lookup requests.\n *\n * @property chainId - Chain ID.\n * @property domain - Domain name to lookup and resolve.\n * @property address - Address to lookup and resolve.\n */\nexport type NameLookupOptions = Infer<typeof NameLookupOptionsStruct>;\n\n/**\n * The options to use for signature requests.\n *\n * @property origin - The origin to send the signature request from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the signature from. Defaults to a\n * randomly generated address.\n * @property data - The data to sign. Defaults to `0x`.\n * @property signatureMethod - The signature method.\n */\nexport type SignatureOptions = Infer<typeof SignatureOptionsStruct>;\n\n/**\n * The options to use for requests to the snap.\n *\n * @property timeout - The timeout in milliseconds to use. Defaults to `1000`.\n */\nexport type SnapOptions = Infer<typeof SnapOptionsStruct>;\n\n/**\n * Options for uploading a file.\n *\n * @property fileName - The name of the file. By default, this is inferred from\n * the file path if it's a path, and defaults to an empty string if it's a\n * `Uint8Array`.\n * @property contentType - The content type of the file. By default, this is\n * inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type cannot\n * be inferred from the file name.\n */\nexport type FileOptions = {\n fileName?: string;\n contentType?: string;\n};\n\nexport type SnapInterfaceActions = {\n /**\n * Click on an interface element.\n *\n * @param name - The element name to click.\n */\n clickElement(name: string): Promise<void>;\n\n /**\n * Type a value in a interface field.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n typeInField(name: string, value: string): Promise<void>;\n\n /**\n * Select an option with a value in a dropdown.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectInDropdown(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from radio group.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromRadioGroup(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from Selector component.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromSelector(name: string, value: string): Promise<void>;\n\n /**\n * Upload a file.\n *\n * @param name - The element name to upload the file to.\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\n uploadFile(\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ): Promise<void>;\n\n /**\n * Wait for the interface to be updated.\n */\n waitForUpdate: () => Promise<SnapHandlerInterface>;\n};\n\n/**\n * A `snap_dialog` alert interface.\n */\nexport type SnapAlertInterface = {\n /**\n * The type of the interface. This is always `alert`.\n */\n type: 'alert';\n\n /**\n * The content to show in the alert.\n */\n content: JSXElement;\n\n /**\n * Close the alert.\n */\n ok(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` confirmation interface.\n */\nexport type SnapConfirmationInterface = {\n /**\n * The type of the interface. This is always `confirmation`.\n */\n type: 'confirmation';\n\n /**\n * The content to show in the confirmation.\n */\n content: JSXElement;\n\n /**\n * Close the confirmation.\n */\n ok(): Promise<void>;\n\n /**\n * Cancel the confirmation.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` prompt interface.\n */\nexport type SnapPromptInterface = {\n /**\n * The type of the interface. This is always `prompt`.\n */\n type: 'prompt';\n\n /**\n * The content to show in the prompt.\n */\n content: JSXElement;\n\n /**\n * Close the prompt.\n *\n * @param value - The value to close the prompt with.\n */\n ok(value?: string): Promise<void>;\n\n /**\n * Cancel the prompt.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with two buttons defined.\n * The approval of this confirmation is handled by the snap.\n */\nexport type DefaultSnapInterfaceWithFooter = {\n /**\n * The content to show in the interface.\n */\n content: JSXElement;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with one button defined.\n * A cancel button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithPartialFooter =\n DefaultSnapInterfaceWithFooter & {\n /**\n * Cancel the dialog.\n */\n cancel(): Promise<void>;\n };\n\n/**\n * A `snap_dialog` default interface that has no Footer defined.\n * A cancel and ok button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithoutFooter =\n DefaultSnapInterfaceWithPartialFooter & {\n /**\n * Close the dialog.\n *\n */\n ok(): Promise<void>;\n };\n\nexport type DefaultSnapInterface =\n | DefaultSnapInterfaceWithFooter\n | DefaultSnapInterfaceWithPartialFooter\n | DefaultSnapInterfaceWithoutFooter;\n\nexport type SnapInterface = (\n | SnapAlertInterface\n | SnapConfirmationInterface\n | SnapPromptInterface\n | DefaultSnapInterface\n) &\n SnapInterfaceActions;\n\nexport type SnapRequestObject = {\n /**\n * Get a user interface object from a snap. This will throw an error if the\n * snap does not show a user interface within the timeout.\n *\n * @param options - The options to use.\n * @param options.timeout - The timeout in milliseconds to use. Defaults to\n * `1000`.\n * @returns The user interface object.\n */\n getInterface(options?: SnapOptions): Promise<SnapInterface>;\n};\n\n/**\n * A pending request object. This is a promise with extra\n * {@link SnapRequestObject} fields.\n */\nexport type SnapRequest = Promise<SnapResponse> & SnapRequestObject;\n\n/**\n * The options to use for mocking a JSON-RPC request.\n */\nexport type JsonRpcMockOptions = {\n /**\n * The JSON-RPC request method.\n */\n method: string;\n\n /**\n * The JSON-RPC response, which will be returned when a request with the\n * specified method is sent.\n */\n result: Json;\n};\n\n/**\n * This is the main entry point to interact with the snap. It is returned by\n * {@link installSnap}, and has methods to send requests to the snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * const snap = await installSnap();\n * const response = await snap.request({ method: 'hello' });\n *\n * expect(response).toRespondWith('Hello, world!');\n */\nexport type Snap = {\n /**\n * Send a JSON-RPC request to the snap.\n *\n * @param request - The request. This is similar to a JSON-RPC request, but\n * has an extra `origin` field.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n request(request: RequestOptions): SnapRequest;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n */\n onTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n * @deprecated Use {@link onTransaction} instead.\n */\n sendTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a signature request to the snap.\n *\n * @param signature - The signature request object. Contains the params from\n * the various signature methods, but has an extra `origin` and `signatureMethod` field.\n * Any missing fields will be filled in with default values.\n * @returns The response.\n */\n onSignature(\n signature?: Partial<SignatureOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onCronjob(cronjob?: Partial<CronjobOptions>): SnapRequest;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n * @deprecated Use {@link onCronjob} instead.\n */\n runCronjob(cronjob: CronjobOptions): SnapRequest;\n\n /**\n * Get the response from the snap's `onHomePage` method.\n *\n * @returns The response.\n */\n onHomePage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Get the response from the snap's `onSettingsPage` method.\n *\n * @returns The response.\n */\n onSettingsPage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a keyring to the Snap.\n *\n * @param keyringRequest - Keyring request options.\n * @returns The response.\n */\n onKeyringRequest(\n keyringRequest: KeyringOptions,\n ): Promise<SnapResponseWithoutInterface>;\n\n /**\n * Get the response from the Snap's `onInstall` handler.\n *\n * @returns The response.\n */\n onInstall(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onUpdate` handler.\n *\n * @returns The response.\n */\n onUpdate(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onNameLookup` handler.\n *\n * @returns The response.\n */\n onNameLookup(\n nameLookupRequest: NameLookupOptions,\n ): Promise<SnapResponseWithoutInterface>;\n\n /**\n * Mock a JSON-RPC request. This will cause the snap to respond with the\n * specified response when a request with the specified method is sent.\n *\n * @param mock - The mock options.\n * @param mock.method - The JSON-RPC request method.\n * @param mock.result - The JSON-RPC response, which will be returned when a\n * request with the specified method is sent.\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpc({ method: 'eth_accounts', result: ['0x1234'] });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n */\n mockJsonRpc(mock: JsonRpcMockOptions): {\n /**\n * Remove the mock.\n */\n unmock(): void;\n };\n\n /**\n * Close the page running the snap. This is mainly useful for cleaning up\n * the test environment, and calling it is not strictly necessary.\n *\n * @returns A promise that resolves when the page is closed.\n * @deprecated Snaps are now automatically closed when the test ends. This\n * method will be removed in a future release.\n */\n close(): Promise<void>;\n};\n\nexport type SnapHandlerInterface = {\n content: JSXElement;\n} & SnapInterfaceActions;\n\nexport type SnapResponseWithInterface = {\n id: string;\n response: { result: Json } | { error: Json };\n notifications: {\n id: string;\n message: string;\n type: EnumToUnion<NotificationType>;\n }[];\n getInterface(): SnapHandlerInterface;\n};\n\nexport type SnapResponseWithoutInterface = Omit<\n SnapResponseWithInterface,\n 'getInterface'\n>;\n\nexport type SnapResponseType =\n | SnapResponseWithoutInterface\n | SnapResponseWithInterface;\n\nexport type SnapResponse = InferMatching<\n typeof SnapResponseStruct,\n SnapResponseType\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NotificationType, EnumToUnion } from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport type { Json, JsonRpcId, JsonRpcParams } from '@metamask/utils';\n\nimport type {\n NameLookupOptionsStruct,\n SignatureOptionsStruct,\n SnapOptionsStruct,\n SnapResponseStruct,\n TransactionOptionsStruct,\n} from './structs';\n\nexport type RequestOptions = {\n /**\n * The JSON-RPC request ID.\n */\n id?: JsonRpcId;\n\n /**\n * The JSON-RPC method.\n */\n method: string;\n\n /**\n * The JSON-RPC params.\n */\n params?: JsonRpcParams;\n\n /**\n * The origin to send the request from.\n */\n origin?: string;\n};\n\n/**\n * The `runCronjob` options. This is the same as {@link RequestOptions}, except\n * that it does not have an `origin` property.\n */\nexport type CronjobOptions = Omit<RequestOptions, 'origin'>;\n\n/**\n * The options to use for transaction requests.\n *\n * @property chainId - The CAIP-2 chain ID to send the transaction on. Defaults\n * to `eip155:1`.\n * @property origin - The origin to send the transaction from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the transaction from. Defaults to a\n * randomly generated address.\n * @property to - The address to send the transaction to. Defaults to a randomly\n * generated address.\n * @property value - The value to send with the transaction. Defaults to `0`.\n * @property data - The data to send with the transaction. Defaults to `0x`.\n * @property gasLimit - The gas limit to use for the transaction. Defaults to\n * `21_000`.\n * @property maxFeePerGas - The maximum fee per gas to use for the transaction.\n * Defaults to `1`.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas to use for\n * the transaction. Defaults to `1`.\n * @property nonce - The nonce to use for the transaction. Defaults to `0`.\n */\nexport type TransactionOptions = Infer<typeof TransactionOptionsStruct>;\n\n/**\n * The options to use for keyring requests.\n */\nexport type KeyringOptions = RequestOptions;\n\n/**\n * The options to use for name lookup requests.\n *\n * @property chainId - Chain ID.\n * @property domain - Domain name to lookup and resolve.\n * @property address - Address to lookup and resolve.\n */\nexport type NameLookupOptions = Infer<typeof NameLookupOptionsStruct>;\n\n/**\n * The options to use for signature requests.\n *\n * @property origin - The origin to send the signature request from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the signature from. Defaults to a\n * randomly generated address.\n * @property data - The data to sign. Defaults to `0x`.\n * @property signatureMethod - The signature method.\n */\nexport type SignatureOptions = Infer<typeof SignatureOptionsStruct>;\n\n/**\n * The options to use for requests to the snap.\n *\n * @property timeout - The timeout in milliseconds to use. Defaults to `1000`.\n */\nexport type SnapOptions = Infer<typeof SnapOptionsStruct>;\n\n/**\n * Options for uploading a file.\n *\n * @property fileName - The name of the file. By default, this is inferred from\n * the file path if it's a path, and defaults to an empty string if it's a\n * `Uint8Array`.\n * @property contentType - The content type of the file. By default, this is\n * inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type cannot\n * be inferred from the file name.\n */\nexport type FileOptions = {\n fileName?: string;\n contentType?: string;\n};\n\nexport type SnapInterfaceActions = {\n /**\n * Click on an interface element.\n *\n * @param name - The element name to click.\n */\n clickElement(name: string): Promise<void>;\n\n /**\n * Type a value in a interface field.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n typeInField(name: string, value: string): Promise<void>;\n\n /**\n * Select an option with a value in a dropdown.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectInDropdown(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from radio group.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromRadioGroup(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from Selector component.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromSelector(name: string, value: string): Promise<void>;\n\n /**\n * Upload a file.\n *\n * @param name - The element name to upload the file to.\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\n uploadFile(\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ): Promise<void>;\n\n /**\n * Wait for the interface to be updated.\n */\n waitForUpdate: () => Promise<SnapHandlerInterface>;\n};\n\n/**\n * A `snap_dialog` alert interface.\n */\nexport type SnapAlertInterface = {\n /**\n * The type of the interface. This is always `alert`.\n */\n type: 'alert';\n\n /**\n * The content to show in the alert.\n */\n content: JSXElement;\n\n /**\n * Close the alert.\n */\n ok(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` confirmation interface.\n */\nexport type SnapConfirmationInterface = {\n /**\n * The type of the interface. This is always `confirmation`.\n */\n type: 'confirmation';\n\n /**\n * The content to show in the confirmation.\n */\n content: JSXElement;\n\n /**\n * Close the confirmation.\n */\n ok(): Promise<void>;\n\n /**\n * Cancel the confirmation.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` prompt interface.\n */\nexport type SnapPromptInterface = {\n /**\n * The type of the interface. This is always `prompt`.\n */\n type: 'prompt';\n\n /**\n * The content to show in the prompt.\n */\n content: JSXElement;\n\n /**\n * Close the prompt.\n *\n * @param value - The value to close the prompt with.\n */\n ok(value?: string): Promise<void>;\n\n /**\n * Cancel the prompt.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with two buttons defined.\n * The approval of this confirmation is handled by the snap.\n */\nexport type DefaultSnapInterfaceWithFooter = {\n /**\n * The content to show in the interface.\n */\n content: JSXElement;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with one button defined.\n * A cancel button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithPartialFooter =\n DefaultSnapInterfaceWithFooter & {\n /**\n * Cancel the dialog.\n */\n cancel(): Promise<void>;\n };\n\n/**\n * A `snap_dialog` default interface that has no Footer defined.\n * A cancel and ok button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithoutFooter =\n DefaultSnapInterfaceWithPartialFooter & {\n /**\n * Close the dialog.\n *\n */\n ok(): Promise<void>;\n };\n\nexport type DefaultSnapInterface =\n | DefaultSnapInterfaceWithFooter\n | DefaultSnapInterfaceWithPartialFooter\n | DefaultSnapInterfaceWithoutFooter;\n\nexport type SnapInterface = (\n | SnapAlertInterface\n | SnapConfirmationInterface\n | SnapPromptInterface\n | DefaultSnapInterface\n) &\n SnapInterfaceActions;\n\nexport type SnapRequestObject = {\n /**\n * Get a user interface object from a snap. This will throw an error if the\n * snap does not show a user interface within the timeout.\n *\n * @param options - The options to use.\n * @param options.timeout - The timeout in milliseconds to use. Defaults to\n * `1000`.\n * @returns The user interface object.\n */\n getInterface(options?: SnapOptions): Promise<SnapInterface>;\n};\n\n/**\n * A pending request object. This is a promise with extra\n * {@link SnapRequestObject} fields.\n */\nexport type SnapRequest = Promise<SnapResponse> & SnapRequestObject;\n\n/**\n * The options to use for mocking a JSON-RPC request.\n */\nexport type JsonRpcMockOptions = {\n /**\n * The JSON-RPC request method.\n */\n method: string;\n\n /**\n * The JSON-RPC response, which will be returned when a request with the\n * specified method is sent.\n */\n result: Json;\n};\n\n/**\n * This is the main entry point to interact with the snap. It is returned by\n * {@link installSnap}, and has methods to send requests to the snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * const snap = await installSnap();\n * const response = await snap.request({ method: 'hello' });\n *\n * expect(response).toRespondWith('Hello, world!');\n */\nexport type Snap = {\n /**\n * Send a JSON-RPC request to the snap.\n *\n * @param request - The request. This is similar to a JSON-RPC request, but\n * has an extra `origin` field.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n request(request: RequestOptions): SnapRequest;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n */\n onTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n * @deprecated Use {@link onTransaction} instead.\n */\n sendTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a signature request to the snap.\n *\n * @param signature - The signature request object. Contains the params from\n * the various signature methods, but has an extra `origin` and `signatureMethod` field.\n * Any missing fields will be filled in with default values.\n * @returns The response.\n */\n onSignature(\n signature?: Partial<SignatureOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onCronjob(cronjob?: Partial<CronjobOptions>): SnapRequest;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n * @deprecated Use {@link onCronjob} instead.\n */\n runCronjob(cronjob: CronjobOptions): SnapRequest;\n\n /**\n * Run a background event in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param backgroundEvent - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified as the `request` param in the `snap_scheduleBackgroundEvent` method.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onBackgroundEvent(backgroundEvent: CronjobOptions): SnapRequest;\n\n /**\n * Get the response from the snap's `onHomePage` method.\n *\n * @returns The response.\n */\n onHomePage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Get the response from the snap's `onSettingsPage` method.\n *\n * @returns The response.\n */\n onSettingsPage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a keyring to the Snap.\n *\n * @param keyringRequest - Keyring request options.\n * @returns The response.\n */\n onKeyringRequest(\n keyringRequest: KeyringOptions,\n ): Promise<SnapResponseWithoutInterface>;\n\n /**\n * Get the response from the Snap's `onInstall` handler.\n *\n * @returns The response.\n */\n onInstall(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onUpdate` handler.\n *\n * @returns The response.\n */\n onUpdate(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onNameLookup` handler.\n *\n * @returns The response.\n */\n onNameLookup(\n nameLookupRequest: NameLookupOptions,\n ): Promise<SnapResponseWithoutInterface>;\n\n /**\n * Mock a JSON-RPC request. This will cause the snap to respond with the\n * specified response when a request with the specified method is sent.\n *\n * @param mock - The mock options.\n * @param mock.method - The JSON-RPC request method.\n * @param mock.result - The JSON-RPC response, which will be returned when a\n * request with the specified method is sent.\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpc({ method: 'eth_accounts', result: ['0x1234'] });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n */\n mockJsonRpc(mock: JsonRpcMockOptions): {\n /**\n * Remove the mock.\n */\n unmock(): void;\n };\n\n /**\n * Close the page running the snap. This is mainly useful for cleaning up\n * the test environment, and calling it is not strictly necessary.\n *\n * @returns A promise that resolves when the page is closed.\n * @deprecated Snaps are now automatically closed when the test ends. This\n * method will be removed in a future release.\n */\n close(): Promise<void>;\n};\n\nexport type SnapHandlerInterface = {\n content: JSXElement;\n} & SnapInterfaceActions;\n\nexport type SnapResponseWithInterface = {\n id: string;\n response: { result: Json } | { error: Json };\n notifications: {\n id: string;\n message: string;\n type: EnumToUnion<NotificationType>;\n title?: string | undefined;\n content?: string | undefined;\n footerLink?: { text: string; href: string } | undefined;\n }[];\n getInterface(): SnapHandlerInterface;\n};\n\nexport type SnapResponseWithoutInterface = Omit<\n SnapResponseWithInterface,\n 'getInterface'\n>;\n\nexport type SnapResponseType =\n | SnapResponseWithoutInterface\n | SnapResponseWithInterface;\n\nexport type SnapResponse = InferMatching<\n typeof SnapResponseStruct,\n SnapResponseType\n>;\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -345,6 +345,15 @@ export type Snap = {
|
|
|
345
345
|
* @deprecated Use {@link onCronjob} instead.
|
|
346
346
|
*/
|
|
347
347
|
runCronjob(cronjob: CronjobOptions): SnapRequest;
|
|
348
|
+
/**
|
|
349
|
+
* Run a background event in the snap. This is similar to {@link request}, but the
|
|
350
|
+
* request will be sent to the `onCronjob` method of the snap.
|
|
351
|
+
*
|
|
352
|
+
* @param backgroundEvent - The cronjob request. This is similar to a JSON-RPC
|
|
353
|
+
* request, and is normally specified as the `request` param in the `snap_scheduleBackgroundEvent` method.
|
|
354
|
+
* @returns The response promise, with extra {@link SnapRequestObject} fields.
|
|
355
|
+
*/
|
|
356
|
+
onBackgroundEvent(backgroundEvent: CronjobOptions): SnapRequest;
|
|
348
357
|
/**
|
|
349
358
|
* Get the response from the snap's `onHomePage` method.
|
|
350
359
|
*
|
|
@@ -431,6 +440,12 @@ export type SnapResponseWithInterface = {
|
|
|
431
440
|
id: string;
|
|
432
441
|
message: string;
|
|
433
442
|
type: EnumToUnion<NotificationType>;
|
|
443
|
+
title?: string | undefined;
|
|
444
|
+
content?: string | undefined;
|
|
445
|
+
footerLink?: {
|
|
446
|
+
text: string;
|
|
447
|
+
href: string;
|
|
448
|
+
} | undefined;
|
|
434
449
|
}[];
|
|
435
450
|
getInterface(): SnapHandlerInterface;
|
|
436
451
|
};
|