@metamask/snaps-simulation 3.2.0 → 3.4.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 +17 -1
- package/dist/constants.cjs +2 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +2 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/methods/hooks/end-trace.cjs +29 -0
- package/dist/methods/hooks/end-trace.cjs.map +1 -0
- package/dist/methods/hooks/end-trace.d.cts +9 -0
- package/dist/methods/hooks/end-trace.d.cts.map +1 -0
- package/dist/methods/hooks/end-trace.d.mts +9 -0
- package/dist/methods/hooks/end-trace.d.mts.map +1 -0
- package/dist/methods/hooks/end-trace.mjs +25 -0
- package/dist/methods/hooks/end-trace.mjs.map +1 -0
- package/dist/methods/hooks/get-snap.cjs +52 -0
- package/dist/methods/hooks/get-snap.cjs.map +1 -0
- package/dist/methods/hooks/get-snap.d.cts +11 -0
- package/dist/methods/hooks/get-snap.d.cts.map +1 -0
- package/dist/methods/hooks/get-snap.d.mts +11 -0
- package/dist/methods/hooks/get-snap.d.mts.map +1 -0
- package/dist/methods/hooks/get-snap.mjs +48 -0
- package/dist/methods/hooks/get-snap.mjs.map +1 -0
- package/dist/methods/hooks/index.cjs +5 -0
- package/dist/methods/hooks/index.cjs.map +1 -1
- package/dist/methods/hooks/index.d.cts +5 -0
- package/dist/methods/hooks/index.d.cts.map +1 -1
- package/dist/methods/hooks/index.d.mts +5 -0
- package/dist/methods/hooks/index.d.mts.map +1 -1
- package/dist/methods/hooks/index.mjs +5 -0
- package/dist/methods/hooks/index.mjs.map +1 -1
- package/dist/methods/hooks/start-trace.cjs +34 -0
- package/dist/methods/hooks/start-trace.cjs.map +1 -0
- package/dist/methods/hooks/start-trace.d.cts +9 -0
- package/dist/methods/hooks/start-trace.d.cts.map +1 -0
- package/dist/methods/hooks/start-trace.d.mts +9 -0
- package/dist/methods/hooks/start-trace.d.mts.map +1 -0
- package/dist/methods/hooks/start-trace.mjs +30 -0
- package/dist/methods/hooks/start-trace.mjs.map +1 -0
- package/dist/methods/hooks/track-error.cjs +31 -0
- package/dist/methods/hooks/track-error.cjs.map +1 -0
- package/dist/methods/hooks/track-error.d.cts +9 -0
- package/dist/methods/hooks/track-error.d.cts.map +1 -0
- package/dist/methods/hooks/track-error.d.mts +9 -0
- package/dist/methods/hooks/track-error.d.mts.map +1 -0
- package/dist/methods/hooks/track-error.mjs +27 -0
- package/dist/methods/hooks/track-error.mjs.map +1 -0
- package/dist/methods/hooks/track-event.cjs +29 -0
- package/dist/methods/hooks/track-event.cjs.map +1 -0
- package/dist/methods/hooks/track-event.d.cts +13 -0
- package/dist/methods/hooks/track-event.d.cts.map +1 -0
- package/dist/methods/hooks/track-event.d.mts +13 -0
- package/dist/methods/hooks/track-event.d.mts.map +1 -0
- package/dist/methods/hooks/track-event.mjs +25 -0
- package/dist/methods/hooks/track-event.mjs.map +1 -0
- package/dist/options.cjs +1 -0
- package/dist/options.cjs.map +1 -1
- package/dist/options.d.cts +6 -0
- package/dist/options.d.cts.map +1 -1
- package/dist/options.d.mts +6 -0
- package/dist/options.d.mts.map +1 -1
- package/dist/options.mjs +1 -0
- package/dist/options.mjs.map +1 -1
- package/dist/request.cjs +21 -1
- package/dist/request.cjs.map +1 -1
- package/dist/request.d.cts.map +1 -1
- package/dist/request.d.mts.map +1 -1
- package/dist/request.mjs +22 -2
- package/dist/request.mjs.map +1 -1
- package/dist/simulation.cjs +26 -7
- package/dist/simulation.cjs.map +1 -1
- package/dist/simulation.d.cts +36 -3
- package/dist/simulation.d.cts.map +1 -1
- package/dist/simulation.d.mts +36 -3
- package/dist/simulation.d.mts.map +1 -1
- package/dist/simulation.mjs +27 -8
- package/dist/simulation.mjs.map +1 -1
- package/dist/store/index.cjs +1 -0
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +1 -0
- package/dist/store/index.d.cts.map +1 -1
- package/dist/store/index.d.mts +1 -0
- package/dist/store/index.d.mts.map +1 -1
- package/dist/store/index.mjs +1 -0
- package/dist/store/index.mjs.map +1 -1
- package/dist/store/mocks.d.cts +1 -0
- package/dist/store/mocks.d.cts.map +1 -1
- package/dist/store/mocks.d.mts +1 -0
- package/dist/store/mocks.d.mts.map +1 -1
- package/dist/store/notifications.d.cts +1 -0
- package/dist/store/notifications.d.cts.map +1 -1
- package/dist/store/notifications.d.mts +1 -0
- package/dist/store/notifications.d.mts.map +1 -1
- package/dist/store/state.d.cts +2 -0
- package/dist/store/state.d.cts.map +1 -1
- package/dist/store/state.d.mts +2 -0
- package/dist/store/state.d.mts.map +1 -1
- package/dist/store/store.cjs +2 -0
- package/dist/store/store.cjs.map +1 -1
- package/dist/store/store.d.cts +1 -0
- package/dist/store/store.d.cts.map +1 -1
- package/dist/store/store.d.mts +1 -0
- package/dist/store/store.d.mts.map +1 -1
- package/dist/store/store.mjs +2 -0
- package/dist/store/store.mjs.map +1 -1
- package/dist/store/trackables.cjs +70 -0
- package/dist/store/trackables.cjs.map +1 -0
- package/dist/store/trackables.d.cts +98 -0
- package/dist/store/trackables.d.cts.map +1 -0
- package/dist/store/trackables.d.mts +98 -0
- package/dist/store/trackables.d.mts.map +1 -0
- package/dist/store/trackables.mjs +67 -0
- package/dist/store/trackables.mjs.map +1 -0
- package/dist/store/ui.d.cts +1 -0
- package/dist/store/ui.d.cts.map +1 -1
- package/dist/store/ui.d.mts +1 -0
- package/dist/store/ui.d.mts.map +1 -1
- package/dist/structs.cjs +17 -0
- package/dist/structs.cjs.map +1 -1
- package/dist/structs.d.cts +182 -12
- package/dist/structs.d.cts.map +1 -1
- package/dist/structs.d.mts +182 -12
- package/dist/structs.d.mts.map +1 -1
- package/dist/structs.mjs +18 -1
- package/dist/structs.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +11 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +11 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/account.cjs +21 -0
- package/dist/utils/account.cjs.map +1 -0
- package/dist/utils/account.d.cts +26 -0
- package/dist/utils/account.d.cts.map +1 -0
- package/dist/utils/account.d.mts +26 -0
- package/dist/utils/account.d.mts.map +1 -0
- package/dist/utils/account.mjs +17 -0
- package/dist/utils/account.mjs.map +1 -0
- package/package.json +9 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-error.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/track-error.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAgBnD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,eAAe,yBAInE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RunSagaFunction } from "../../store/index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Get a method that can be used to track an error.
|
|
4
|
+
*
|
|
5
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
6
|
+
* @returns A method that can be used to track an error.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTrackErrorImplementation(runSaga: RunSagaFunction): (error: Error) => any;
|
|
9
|
+
//# sourceMappingURL=track-error.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-error.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/track-error.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAgBnD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,eAAe,yBAInE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getJsonError } from "@metamask/snaps-sdk";
|
|
2
|
+
import { put } from "redux-saga/effects";
|
|
3
|
+
import { trackError } from "../../store/index.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Track an error.
|
|
6
|
+
*
|
|
7
|
+
* @param error - The error to track.
|
|
8
|
+
* @returns `null`.
|
|
9
|
+
* @yields Adds the error to the store.
|
|
10
|
+
*/
|
|
11
|
+
function* trackErrorImplementation(error) {
|
|
12
|
+
const serialisedError = getJsonError(error);
|
|
13
|
+
yield put(trackError(serialisedError));
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get a method that can be used to track an error.
|
|
18
|
+
*
|
|
19
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
20
|
+
* @returns A method that can be used to track an error.
|
|
21
|
+
*/
|
|
22
|
+
export function getTrackErrorImplementation(runSaga) {
|
|
23
|
+
return (...args) => {
|
|
24
|
+
return runSaga(trackErrorImplementation, ...args).result();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=track-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-error.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/track-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,4BAA4B;AAEnD,OAAO,EAAE,GAAG,EAAE,2BAA2B;AAGzC,OAAO,EAAE,UAAU,EAAE,8BAAoB;AAEzC;;;;;;GAMG;AACH,QAAQ,CAAC,CAAC,wBAAwB,CAAC,KAAY;IAC7C,MAAM,eAAe,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAwB;IAClE,OAAO,CAAC,GAAG,IAAiD,EAAE,EAAE;QAC9D,OAAO,OAAO,CAAC,wBAAwB,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { getJsonError } from '@metamask/snaps-sdk';\nimport type { SagaIterator } from 'redux-saga';\nimport { put } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { trackError } from '../../store';\n\n/**\n * Track an error.\n *\n * @param error - The error to track.\n * @returns `null`.\n * @yields Adds the error to the store.\n */\nfunction* trackErrorImplementation(error: Error): SagaIterator {\n const serialisedError = getJsonError(error);\n yield put(trackError(serialisedError));\n return null;\n}\n\n/**\n * Get a method that can be used to track an error.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A method that can be used to track an error.\n */\nexport function getTrackErrorImplementation(runSaga: RunSagaFunction) {\n return (...args: Parameters<typeof trackErrorImplementation>) => {\n return runSaga(trackErrorImplementation, ...args).result();\n };\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTrackEventImplementation = void 0;
|
|
4
|
+
const effects_1 = require("redux-saga/effects");
|
|
5
|
+
const store_1 = require("../../store/index.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Track an event.
|
|
8
|
+
*
|
|
9
|
+
* @param event - The event to track.
|
|
10
|
+
* @returns `null`.
|
|
11
|
+
* @yields Adds the event to the store.
|
|
12
|
+
*/
|
|
13
|
+
function* trackEventImplementation(event) {
|
|
14
|
+
yield (0, effects_1.put)((0, store_1.trackEvent)(event));
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get a method that can be used to track an event.
|
|
19
|
+
*
|
|
20
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
21
|
+
* @returns A method that can be used to track an event.
|
|
22
|
+
*/
|
|
23
|
+
function getTrackEventImplementation(runSaga) {
|
|
24
|
+
return (...args) => {
|
|
25
|
+
return runSaga(trackEventImplementation, ...args).result();
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.getTrackEventImplementation = getTrackEventImplementation;
|
|
29
|
+
//# sourceMappingURL=track-event.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-event.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/track-event.ts"],"names":[],"mappings":";;;AAEA,gDAAyC;AAGzC,iDAAyC;AAEzC;;;;;;GAMG;AACH,QAAQ,CAAC,CAAC,wBAAwB,CAChC,KAAgC;IAEhC,MAAM,IAAA,aAAG,EAAC,IAAA,kBAAU,EAAC,KAAK,CAAC,CAAC,CAAC;IAC7B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAgB,2BAA2B,CAAC,OAAwB;IAClE,OAAO,CAAC,GAAG,IAAiD,EAAE,EAAE;QAC9D,OAAO,OAAO,CAAC,wBAAwB,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC;AAJD,kEAIC","sourcesContent":["import type { TrackEventParams } from '@metamask/snaps-sdk';\nimport type { SagaIterator } from 'redux-saga';\nimport { put } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { trackEvent } from '../../store';\n\n/**\n * Track an event.\n *\n * @param event - The event to track.\n * @returns `null`.\n * @yields Adds the event to the store.\n */\nfunction* trackEventImplementation(\n event: TrackEventParams['event'],\n): SagaIterator {\n yield put(trackEvent(event));\n return null;\n}\n\n/**\n * Get a method that can be used to track an event.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A method that can be used to track an event.\n */\nexport function getTrackEventImplementation(runSaga: RunSagaFunction) {\n return (...args: Parameters<typeof trackEventImplementation>) => {\n return runSaga(trackEventImplementation, ...args).result();\n };\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RunSagaFunction } from "../../store/index.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Get a method that can be used to track an event.
|
|
4
|
+
*
|
|
5
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
6
|
+
* @returns A method that can be used to track an event.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTrackEventImplementation(runSaga: RunSagaFunction): (event: {
|
|
9
|
+
event: string;
|
|
10
|
+
properties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
11
|
+
sensitiveProperties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
12
|
+
}) => any;
|
|
13
|
+
//# sourceMappingURL=track-event.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-event.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/track-event.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAiBnD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,eAAe;;;;UAInE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RunSagaFunction } from "../../store/index.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Get a method that can be used to track an event.
|
|
4
|
+
*
|
|
5
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
6
|
+
* @returns A method that can be used to track an event.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTrackEventImplementation(runSaga: RunSagaFunction): (event: {
|
|
9
|
+
event: string;
|
|
10
|
+
properties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
11
|
+
sensitiveProperties?: Record<string, import("@metamask/snaps-sdk").Json> | undefined;
|
|
12
|
+
}) => any;
|
|
13
|
+
//# sourceMappingURL=track-event.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-event.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/track-event.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAiBnD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,eAAe;;;;UAInE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { put } from "redux-saga/effects";
|
|
2
|
+
import { trackEvent } from "../../store/index.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Track an event.
|
|
5
|
+
*
|
|
6
|
+
* @param event - The event to track.
|
|
7
|
+
* @returns `null`.
|
|
8
|
+
* @yields Adds the event to the store.
|
|
9
|
+
*/
|
|
10
|
+
function* trackEventImplementation(event) {
|
|
11
|
+
yield put(trackEvent(event));
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get a method that can be used to track an event.
|
|
16
|
+
*
|
|
17
|
+
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
18
|
+
* @returns A method that can be used to track an event.
|
|
19
|
+
*/
|
|
20
|
+
export function getTrackEventImplementation(runSaga) {
|
|
21
|
+
return (...args) => {
|
|
22
|
+
return runSaga(trackEventImplementation, ...args).result();
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=track-event.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-event.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/track-event.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,2BAA2B;AAGzC,OAAO,EAAE,UAAU,EAAE,8BAAoB;AAEzC;;;;;;GAMG;AACH,QAAQ,CAAC,CAAC,wBAAwB,CAChC,KAAgC;IAEhC,MAAM,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,OAAwB;IAClE,OAAO,CAAC,GAAG,IAAiD,EAAE,EAAE;QAC9D,OAAO,OAAO,CAAC,wBAAwB,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { TrackEventParams } from '@metamask/snaps-sdk';\nimport type { SagaIterator } from 'redux-saga';\nimport { put } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { trackEvent } from '../../store';\n\n/**\n * Track an event.\n *\n * @param event - The event to track.\n * @returns `null`.\n * @yields Adds the event to the store.\n */\nfunction* trackEventImplementation(\n event: TrackEventParams['event'],\n): SagaIterator {\n yield put(trackEvent(event));\n return null;\n}\n\n/**\n * Get a method that can be used to track an event.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A method that can be used to track an event.\n */\nexport function getTrackEventImplementation(runSaga: RunSagaFunction) {\n return (...args: Parameters<typeof trackEventImplementation>) => {\n return runSaga(trackEventImplementation, ...args).result();\n };\n}\n"]}
|
package/dist/options.cjs
CHANGED
|
@@ -9,6 +9,7 @@ const SimulationAccountStruct = (0, superstruct_1.object)({
|
|
|
9
9
|
id: (0, superstruct_1.string)(),
|
|
10
10
|
scopes: (0, superstruct_1.array)(utils_1.CaipChainIdStruct),
|
|
11
11
|
selected: (0, superstruct_1.defaulted)((0, superstruct_1.optional)((0, superstruct_1.boolean)()), false),
|
|
12
|
+
owned: (0, superstruct_1.defaulted)((0, superstruct_1.optional)((0, superstruct_1.boolean)()), false),
|
|
12
13
|
assets: (0, superstruct_1.defaulted)((0, superstruct_1.optional)((0, superstruct_1.array)(utils_1.CaipAssetTypeStruct)), []),
|
|
13
14
|
});
|
|
14
15
|
const SimulationAssetStruct = (0, superstruct_1.object)({
|
package/dist/options.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.cjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AACA,uDAU+B;AAC/B,2CAIyB;AAEzB,+CAMqB;AAErB,MAAM,uBAAuB,GAAG,IAAA,oBAAM,EAAC;IACrC,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,EAAE,EAAE,IAAA,oBAAM,GAAE;IACZ,MAAM,EAAE,IAAA,mBAAK,EAAC,yBAAiB,CAAC;IAChC,QAAQ,EAAE,IAAA,uBAA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AmB,EAAE,qBAAqB,CAAC,CAAC,EAC5D,0BAAc,CACf;IACD,YAAY,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,KAAK,CAAC;IACnD,iBAAiB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACvD,sBAAsB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,iBAAiB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACvD,kBAAkB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACxD,eAAe,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACrD,eAAe,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACrD,sBAAsB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,YAAY,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;CACnD,CAAC,CAAC;AAmCH;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,OAA8B;IACvD,OAAO,IAAA,oBAAM,EACX,OAAO,EACP,uBAAuB,CACW,CAAC;AACvC,CAAC;AALD,gCAKC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n DEFAULT_ACCOUNTS,\n DEFAULT_ASSETS,\n DEFAULT_CURRENCY,\n DEFAULT_LOCALE,\n DEFAULT_SRP,\n} from './constants';\n\nconst SimulationAccountStruct = object({\n address: string(),\n id: string(),\n scopes: array(CaipChainIdStruct),\n selected: defaulted(optional(boolean()), false),\n assets: defaulted(optional(array(CaipAssetTypeStruct)), []),\n});\n\nexport type SimulationAccount = Infer<typeof SimulationAccountStruct>;\n\nconst SimulationAssetStruct = object({\n name: string(),\n symbol: string(),\n});\n\nexport type SimulationAsset = Infer<typeof SimulationAssetStruct>;\n\nconst SimulationOptionsStruct = object({\n currency: defaulted(optional(string()), DEFAULT_CURRENCY),\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n accounts: defaulted(\n optional(array(SimulationAccountStruct)),\n DEFAULT_ACCOUNTS,\n ),\n assets: defaulted(\n optional(record(CaipAssetTypeStruct, SimulationAssetStruct)),\n DEFAULT_ASSETS,\n ),\n hideBalances: defaulted(optional(boolean()), false),\n useSecurityAlerts: defaulted(optional(boolean()), true),\n simulateOnChainActions: defaulted(optional(boolean()), true),\n useTokenDetection: defaulted(optional(boolean()), true),\n batchCheckBalances: defaulted(optional(boolean()), true),\n displayNftMedia: defaulted(optional(boolean()), true),\n useNftDetection: defaulted(optional(boolean()), true),\n useExternalPricingData: defaulted(optional(boolean()), true),\n showTestnets: defaulted(optional(boolean()), true),\n});\n\n/**\n * Options for the simulation.\n *\n * @property currency - The currency to use. Defaults to `usd`.\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n * @property unencryptedState - The initial unencrypted state of the Snap, if\n * any. Defaults to `null`.\n * @property accounts - The accounts to use in the simulation, if any. Defaults\n * to an empty array.\n * @property assets - The assets to use in the simulation, if any. Defaults to\n * an empty object.\n * @property useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @property simulateOnChainActions - Whether to simulate transactions and signatures.\n * @property useTokenDetection - Whether to auto-detect tokens.\n * @property batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @property displayNftMedia - Whether to display NFT media.\n * @property useNftDetection - Whether to auto-detect NFTs.\n * @property useExternalPricingData - Whether to get token price data from an external source.\n * @property showTestnets - Whether to show testnets.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"options.cjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AACA,uDAU+B;AAC/B,2CAIyB;AAEzB,+CAMqB;AAErB,MAAM,uBAAuB,GAAG,IAAA,oBAAM,EAAC;IACrC,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,EAAE,EAAE,IAAA,oBAAM,GAAE;IACZ,MAAM,EAAE,IAAA,mBAAK,EAAC,yBAAiB,CAAC;IAChC,QAAQ,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,KAAK,CAAC;IAC/C,KAAK,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE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Y,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,KAAK,CAAC;IACnD,iBAAiB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACvD,sBAAsB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,iBAAiB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACvD,kBAAkB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACxD,eAAe,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACrD,eAAe,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IACrD,sBAAsB,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,YAAY,EAAE,IAAA,uBAAS,EAAC,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC,EAAE,IAAI,CAAC;CACnD,CAAC,CAAC;AAmCH;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,OAA8B;IACvD,OAAO,IAAA,oBAAM,EACX,OAAO,EACP,uBAAuB,CACW,CAAC;AACvC,CAAC;AALD,gCAKC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n DEFAULT_ACCOUNTS,\n DEFAULT_ASSETS,\n DEFAULT_CURRENCY,\n DEFAULT_LOCALE,\n DEFAULT_SRP,\n} from './constants';\n\nconst SimulationAccountStruct = object({\n address: string(),\n id: string(),\n scopes: array(CaipChainIdStruct),\n selected: defaulted(optional(boolean()), false),\n owned: defaulted(optional(boolean()), false),\n assets: defaulted(optional(array(CaipAssetTypeStruct)), []),\n});\n\nexport type SimulationAccount = Infer<typeof SimulationAccountStruct>;\n\nconst SimulationAssetStruct = object({\n name: string(),\n symbol: string(),\n});\n\nexport type SimulationAsset = Infer<typeof SimulationAssetStruct>;\n\nconst SimulationOptionsStruct = object({\n currency: defaulted(optional(string()), DEFAULT_CURRENCY),\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n accounts: defaulted(\n optional(array(SimulationAccountStruct)),\n DEFAULT_ACCOUNTS,\n ),\n assets: defaulted(\n optional(record(CaipAssetTypeStruct, SimulationAssetStruct)),\n DEFAULT_ASSETS,\n ),\n hideBalances: defaulted(optional(boolean()), false),\n useSecurityAlerts: defaulted(optional(boolean()), true),\n simulateOnChainActions: defaulted(optional(boolean()), true),\n useTokenDetection: defaulted(optional(boolean()), true),\n batchCheckBalances: defaulted(optional(boolean()), true),\n displayNftMedia: defaulted(optional(boolean()), true),\n useNftDetection: defaulted(optional(boolean()), true),\n useExternalPricingData: defaulted(optional(boolean()), true),\n showTestnets: defaulted(optional(boolean()), true),\n});\n\n/**\n * Options for the simulation.\n *\n * @property currency - The currency to use. Defaults to `usd`.\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n * @property unencryptedState - The initial unencrypted state of the Snap, if\n * any. Defaults to `null`.\n * @property accounts - The accounts to use in the simulation, if any. Defaults\n * to an empty array.\n * @property assets - The assets to use in the simulation, if any. Defaults to\n * an empty object.\n * @property useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @property simulateOnChainActions - Whether to simulate transactions and signatures.\n * @property useTokenDetection - Whether to auto-detect tokens.\n * @property batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @property displayNftMedia - Whether to display NFT media.\n * @property useNftDetection - Whether to auto-detect NFTs.\n * @property useExternalPricingData - Whether to get token price data from an external source.\n * @property showTestnets - Whether to show testnets.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
|
package/dist/options.d.cts
CHANGED
|
@@ -4,12 +4,14 @@ declare const SimulationAccountStruct: import("@metamask/superstruct").Struct<{
|
|
|
4
4
|
id: string;
|
|
5
5
|
scopes: `${string}:${string}`[];
|
|
6
6
|
selected?: boolean | undefined;
|
|
7
|
+
owned?: boolean | undefined;
|
|
7
8
|
assets?: `${string}:${string}/${string}:${string}`[] | undefined;
|
|
8
9
|
}, {
|
|
9
10
|
address: import("@metamask/superstruct").Struct<string, null>;
|
|
10
11
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
11
12
|
scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
|
|
12
13
|
selected: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
14
|
+
owned: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
13
15
|
assets: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
|
|
14
16
|
}>;
|
|
15
17
|
export type SimulationAccount = Infer<typeof SimulationAccountStruct>;
|
|
@@ -36,6 +38,7 @@ declare const SimulationOptionsStruct: import("@metamask/superstruct").Struct<{
|
|
|
36
38
|
id: string;
|
|
37
39
|
scopes: `${string}:${string}`[];
|
|
38
40
|
selected?: boolean | undefined;
|
|
41
|
+
owned?: boolean | undefined;
|
|
39
42
|
assets?: `${string}:${string}/${string}:${string}`[] | undefined;
|
|
40
43
|
}[] | undefined;
|
|
41
44
|
hideBalances?: boolean | undefined;
|
|
@@ -58,18 +61,21 @@ declare const SimulationOptionsStruct: import("@metamask/superstruct").Struct<{
|
|
|
58
61
|
id: string;
|
|
59
62
|
scopes: `${string}:${string}`[];
|
|
60
63
|
selected?: boolean | undefined;
|
|
64
|
+
owned?: boolean | undefined;
|
|
61
65
|
assets?: `${string}:${string}/${string}:${string}`[] | undefined;
|
|
62
66
|
}[] | undefined, import("@metamask/superstruct").Struct<{
|
|
63
67
|
address: string;
|
|
64
68
|
id: string;
|
|
65
69
|
scopes: `${string}:${string}`[];
|
|
66
70
|
selected?: boolean | undefined;
|
|
71
|
+
owned?: boolean | undefined;
|
|
67
72
|
assets?: `${string}:${string}/${string}:${string}`[] | undefined;
|
|
68
73
|
}, {
|
|
69
74
|
address: import("@metamask/superstruct").Struct<string, null>;
|
|
70
75
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
71
76
|
scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
|
|
72
77
|
selected: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
78
|
+
owned: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
73
79
|
assets: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
|
|
74
80
|
}>>;
|
|
75
81
|
assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, {
|
package/dist/options.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.cts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AA0BnD,QAAA,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"options.d.cts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AA0BnD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;EAO3B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEtE,QAAA,MAAM,qBAAqB;;;;;;EAGzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAElE,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B3B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAK5E"}
|
package/dist/options.d.mts
CHANGED
|
@@ -4,12 +4,14 @@ declare const SimulationAccountStruct: import("@metamask/superstruct").Struct<{
|
|
|
4
4
|
id: string;
|
|
5
5
|
scopes: `${string}:${string}`[];
|
|
6
6
|
selected?: boolean | undefined;
|
|
7
|
+
owned?: boolean | undefined;
|
|
7
8
|
assets?: `${string}:${string}/${string}:${string}`[] | undefined;
|
|
8
9
|
}, {
|
|
9
10
|
address: import("@metamask/superstruct").Struct<string, null>;
|
|
10
11
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
11
12
|
scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
|
|
12
13
|
selected: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
14
|
+
owned: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
13
15
|
assets: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
|
|
14
16
|
}>;
|
|
15
17
|
export type SimulationAccount = Infer<typeof SimulationAccountStruct>;
|
|
@@ -36,6 +38,7 @@ declare const SimulationOptionsStruct: import("@metamask/superstruct").Struct<{
|
|
|
36
38
|
id: string;
|
|
37
39
|
scopes: `${string}:${string}`[];
|
|
38
40
|
selected?: boolean | undefined;
|
|
41
|
+
owned?: boolean | undefined;
|
|
39
42
|
assets?: `${string}:${string}/${string}:${string}`[] | undefined;
|
|
40
43
|
}[] | undefined;
|
|
41
44
|
hideBalances?: boolean | undefined;
|
|
@@ -58,18 +61,21 @@ declare const SimulationOptionsStruct: import("@metamask/superstruct").Struct<{
|
|
|
58
61
|
id: string;
|
|
59
62
|
scopes: `${string}:${string}`[];
|
|
60
63
|
selected?: boolean | undefined;
|
|
64
|
+
owned?: boolean | undefined;
|
|
61
65
|
assets?: `${string}:${string}/${string}:${string}`[] | undefined;
|
|
62
66
|
}[] | undefined, import("@metamask/superstruct").Struct<{
|
|
63
67
|
address: string;
|
|
64
68
|
id: string;
|
|
65
69
|
scopes: `${string}:${string}`[];
|
|
66
70
|
selected?: boolean | undefined;
|
|
71
|
+
owned?: boolean | undefined;
|
|
67
72
|
assets?: `${string}:${string}/${string}:${string}`[] | undefined;
|
|
68
73
|
}, {
|
|
69
74
|
address: import("@metamask/superstruct").Struct<string, null>;
|
|
70
75
|
id: import("@metamask/superstruct").Struct<string, null>;
|
|
71
76
|
scopes: import("@metamask/superstruct").Struct<`${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}`, null>>;
|
|
72
77
|
selected: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
78
|
+
owned: import("@metamask/superstruct").Struct<boolean | undefined, null>;
|
|
73
79
|
assets: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
|
|
74
80
|
}>>;
|
|
75
81
|
assets: import("@metamask/superstruct").Struct<Record<`${string}:${string}/${string}:${string}`, {
|
package/dist/options.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.mts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AA0BnD,QAAA,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"options.d.mts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AA0BnD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;EAO3B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEtE,QAAA,MAAM,qBAAqB;;;;;;EAGzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAElE,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B3B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,iBAAiB,CAK5E"}
|
package/dist/options.mjs
CHANGED
|
@@ -6,6 +6,7 @@ const SimulationAccountStruct = object({
|
|
|
6
6
|
id: string(),
|
|
7
7
|
scopes: array(CaipChainIdStruct),
|
|
8
8
|
selected: defaulted(optional(boolean()), false),
|
|
9
|
+
owned: defaulted(optional(boolean()), false),
|
|
9
10
|
assets: defaulted(optional(array(CaipAssetTypeStruct)), []),
|
|
10
11
|
});
|
|
11
12
|
const SimulationAssetStruct = object({
|
package/dist/options.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACX,wBAAwB;AAEzB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,EACZ,wBAAoB;AAErB,MAAM,uBAAuB,GAAG,MAAM,CAAC;IACrC,OAAO,EAAE,MAAM,EAAE;IACjB,EAAE,EAAE,MAAM,EAAE;IACZ,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAChC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC;IAC/C,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,EAAE,EAAE,CAAC;CAC5D,CAAC,CAAC;AAI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EAAE,CAAC,EAAE,IAAI,CAAC;IACxD,eAAe,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACrD,eAAe,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IACrD,sBAAsB,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;IAC5D,YAAY,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC;CACnD,CAAC,CAAC;AAmCH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAA8B;IACvD,OAAO,MAAM,CACX,OAAO,EACP,uBAAuB,CACW,CAAC;AACvC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n DEFAULT_ACCOUNTS,\n DEFAULT_ASSETS,\n DEFAULT_CURRENCY,\n DEFAULT_LOCALE,\n DEFAULT_SRP,\n} from './constants';\n\nconst SimulationAccountStruct = object({\n address: string(),\n id: string(),\n scopes: array(CaipChainIdStruct),\n selected: defaulted(optional(boolean()), false),\n assets: defaulted(optional(array(CaipAssetTypeStruct)), []),\n});\n\nexport type SimulationAccount = Infer<typeof SimulationAccountStruct>;\n\nconst SimulationAssetStruct = object({\n name: string(),\n symbol: string(),\n});\n\nexport type SimulationAsset = Infer<typeof SimulationAssetStruct>;\n\nconst SimulationOptionsStruct = object({\n currency: defaulted(optional(string()), DEFAULT_CURRENCY),\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n accounts: defaulted(\n optional(array(SimulationAccountStruct)),\n DEFAULT_ACCOUNTS,\n ),\n assets: defaulted(\n optional(record(CaipAssetTypeStruct, SimulationAssetStruct)),\n DEFAULT_ASSETS,\n ),\n hideBalances: defaulted(optional(boolean()), false),\n useSecurityAlerts: defaulted(optional(boolean()), true),\n simulateOnChainActions: defaulted(optional(boolean()), true),\n useTokenDetection: defaulted(optional(boolean()), true),\n batchCheckBalances: defaulted(optional(boolean()), true),\n displayNftMedia: defaulted(optional(boolean()), true),\n useNftDetection: defaulted(optional(boolean()), true),\n useExternalPricingData: defaulted(optional(boolean()), true),\n showTestnets: defaulted(optional(boolean()), true),\n});\n\n/**\n * Options for the simulation.\n *\n * @property currency - The currency to use. Defaults to `usd`.\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n * @property unencryptedState - The initial unencrypted state of the Snap, if\n * any. Defaults to `null`.\n * @property accounts - The accounts to use in the simulation, if any. Defaults\n * to an empty array.\n * @property assets - The assets to use in the simulation, if any. Defaults to\n * an empty object.\n * @property useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @property simulateOnChainActions - Whether to simulate transactions and signatures.\n * @property useTokenDetection - Whether to auto-detect tokens.\n * @property batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @property displayNftMedia - Whether to display NFT media.\n * @property useNftDetection - Whether to auto-detect NFTs.\n * @property useExternalPricingData - Whether to get token price data from an external source.\n * @property showTestnets - Whether to show testnets.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACP,8BAA8B;AAC/B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACX,wBAAwB;AAEzB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,EACZ,wBAAoB;AAErB,MAAM,uBAAuB,GAAG,MAAM,CAAC;IACrC,OAAO,EAAE,MAAM,EAAE;IACjB,EAAE,EAAE,MAAM,EAAE;IACZ,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAChC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC;IAC/C,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC;IAC5C,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,EAAE,EAAE,CAAC;CAC5D,CAAC,CAAC;AAIH,MAAM,qBAAqB,GAAG,MAAM,CAAC;IACnC,IAAI,EAAE,MAAM,EAAE;IACd,MAAM,EAAE,MAAM,EAAE;CACjB,CAAC,CAAC;AAIH,MAAM,uBAAuB,GAAG,MAAM,CAAC;IACrC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,gBAAgB,CAAC;IACzD,oBAAoB,EAAE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,WAAW,CAAC;IAChE,MAAM,EAAE,SAAS,CAAC,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CAAC;CACnD,CAAC,CAAC;AAmCH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAA8B;IACvD,OAAO,MAAM,CACX,OAAO,EACP,uBAAuB,CACW,CAAC;AACvC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n array,\n boolean,\n create,\n defaulted,\n nullable,\n object,\n optional,\n record,\n string,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n JsonStruct,\n} from '@metamask/utils';\n\nimport {\n DEFAULT_ACCOUNTS,\n DEFAULT_ASSETS,\n DEFAULT_CURRENCY,\n DEFAULT_LOCALE,\n DEFAULT_SRP,\n} from './constants';\n\nconst SimulationAccountStruct = object({\n address: string(),\n id: string(),\n scopes: array(CaipChainIdStruct),\n selected: defaulted(optional(boolean()), false),\n owned: defaulted(optional(boolean()), false),\n assets: defaulted(optional(array(CaipAssetTypeStruct)), []),\n});\n\nexport type SimulationAccount = Infer<typeof SimulationAccountStruct>;\n\nconst SimulationAssetStruct = object({\n name: string(),\n symbol: string(),\n});\n\nexport type SimulationAsset = Infer<typeof SimulationAssetStruct>;\n\nconst SimulationOptionsStruct = object({\n currency: defaulted(optional(string()), DEFAULT_CURRENCY),\n secretRecoveryPhrase: defaulted(optional(string()), DEFAULT_SRP),\n locale: defaulted(optional(string()), DEFAULT_LOCALE),\n state: defaulted(optional(nullable(record(string(), JsonStruct))), null),\n unencryptedState: defaulted(\n optional(nullable(record(string(), JsonStruct))),\n null,\n ),\n accounts: defaulted(\n optional(array(SimulationAccountStruct)),\n DEFAULT_ACCOUNTS,\n ),\n assets: defaulted(\n optional(record(CaipAssetTypeStruct, SimulationAssetStruct)),\n DEFAULT_ASSETS,\n ),\n hideBalances: defaulted(optional(boolean()), false),\n useSecurityAlerts: defaulted(optional(boolean()), true),\n simulateOnChainActions: defaulted(optional(boolean()), true),\n useTokenDetection: defaulted(optional(boolean()), true),\n batchCheckBalances: defaulted(optional(boolean()), true),\n displayNftMedia: defaulted(optional(boolean()), true),\n useNftDetection: defaulted(optional(boolean()), true),\n useExternalPricingData: defaulted(optional(boolean()), true),\n showTestnets: defaulted(optional(boolean()), true),\n});\n\n/**\n * Options for the simulation.\n *\n * @property currency - The currency to use. Defaults to `usd`.\n * @property secretRecoveryPhrase - The secret recovery phrase to use. This is\n * used to derive addresses and private keys. Defaults to a test recovery\n * phrase.\n * @property locale - The locale to use. Defaults to `en`.\n * @property state - The initial state of the Snap, if any. Defaults to `null`.\n * @property unencryptedState - The initial unencrypted state of the Snap, if\n * any. Defaults to `null`.\n * @property accounts - The accounts to use in the simulation, if any. Defaults\n * to an empty array.\n * @property assets - The assets to use in the simulation, if any. Defaults to\n * an empty object.\n * @property useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @property simulateOnChainActions - Whether to simulate transactions and signatures.\n * @property useTokenDetection - Whether to auto-detect tokens.\n * @property batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @property displayNftMedia - Whether to display NFT media.\n * @property useNftDetection - Whether to auto-detect NFTs.\n * @property useExternalPricingData - Whether to get token price data from an external source.\n * @property showTestnets - Whether to show testnets.\n */\nexport type SimulationUserOptions = Infer<typeof SimulationOptionsStruct>;\n\n/**\n * Options for the simulation, with defaults filled in.\n *\n * See {@link SimulationUserOptions} for documentation.\n */\nexport type SimulationOptions = Required<SimulationUserOptions>;\n\n/**\n * Get the options for the simulation.\n *\n * @param options - The user options. Any options not specified will be filled\n * in with default values.\n * @returns The simulation options.\n */\nexport function getOptions(options: SimulationUserOptions): SimulationOptions {\n return create(\n options,\n SimulationOptionsStruct,\n ) as Required<SimulationUserOptions>;\n}\n"]}
|
package/dist/request.cjs
CHANGED
|
@@ -45,9 +45,14 @@ function handleRequest({ snapId, store, executionService, handler, controllerMes
|
|
|
45
45
|
},
|
|
46
46
|
})
|
|
47
47
|
.then(async (result) => {
|
|
48
|
-
const
|
|
48
|
+
const state = store.getState();
|
|
49
|
+
const notifications = (0, store_1.getNotifications)(state);
|
|
50
|
+
const errors = (0, store_1.getErrors)(state);
|
|
51
|
+
const events = (0, store_1.getEvents)(state);
|
|
52
|
+
const traces = (0, store_1.getTraces)(state);
|
|
49
53
|
const interfaceId = notifications[0]?.content;
|
|
50
54
|
store.dispatch((0, store_1.clearNotifications)());
|
|
55
|
+
store.dispatch((0, store_1.clearTrackables)());
|
|
51
56
|
try {
|
|
52
57
|
const getInterfaceFn = await getInterfaceApi(result, snapId, controllerMessenger, simulationOptions, interfaceId);
|
|
53
58
|
return {
|
|
@@ -56,6 +61,11 @@ function handleRequest({ snapId, store, executionService, handler, controllerMes
|
|
|
56
61
|
result: (0, utils_1.getSafeJson)(result),
|
|
57
62
|
},
|
|
58
63
|
notifications,
|
|
64
|
+
tracked: {
|
|
65
|
+
errors,
|
|
66
|
+
events,
|
|
67
|
+
traces,
|
|
68
|
+
},
|
|
59
69
|
...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),
|
|
60
70
|
};
|
|
61
71
|
}
|
|
@@ -67,6 +77,11 @@ function handleRequest({ snapId, store, executionService, handler, controllerMes
|
|
|
67
77
|
error: unwrappedError.serialize(),
|
|
68
78
|
},
|
|
69
79
|
notifications: [],
|
|
80
|
+
tracked: {
|
|
81
|
+
errors: [],
|
|
82
|
+
events: [],
|
|
83
|
+
traces: [],
|
|
84
|
+
},
|
|
70
85
|
getInterface: getInterfaceError,
|
|
71
86
|
};
|
|
72
87
|
}
|
|
@@ -79,6 +94,11 @@ function handleRequest({ snapId, store, executionService, handler, controllerMes
|
|
|
79
94
|
error: unwrappedError.serialize(),
|
|
80
95
|
},
|
|
81
96
|
notifications: [],
|
|
97
|
+
tracked: {
|
|
98
|
+
errors: [],
|
|
99
|
+
events: [],
|
|
100
|
+
traces: [],
|
|
101
|
+
},
|
|
82
102
|
getInterface: getInterfaceError,
|
|
83
103
|
};
|
|
84
104
|
});
|
package/dist/request.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.cjs","s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,CACH,CAAC;YAEF,MAAM,OAAO,GAAG,IAAA,+BAAmB,EACjC,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP;gBACE,EAAE;gBACF,OAAO;aACR,CACF,CAAC;YAEF,OAAO;gBACL,OAAO;gBACP,GAAG,OAAO;aACX,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAzCD,0CAyCC","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n type ComponentOrElement,\n ComponentOrElementStruct,\n type JsonRpcError,\n type SnapId,\n} from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport {\n assert,\n getSafeJson,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getInterface, getInterfaceActions } from './interface';\nimport type { SimulationOptions } from './options';\nimport { clearNotifications, getNotifications } from './store';\nimport type { RunSagaFunction, Store } from './store';\nimport { SnapResponseStruct } from './structs';\nimport type {\n RequestOptions,\n SnapHandlerInterface,\n SnapRequest,\n} from './types';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n simulationOptions: SimulationOptions;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.simulationOptions - The simulation options.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n simulationOptions,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const getInterfaceError = () => {\n throw new Error(\n 'Unable to get the interface from the Snap: The request to the Snap failed.',\n );\n };\n\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then(async (result) => {\n const notifications = getNotifications(store.getState());\n const interfaceId = notifications[0]?.content;\n store.dispatch(clearNotifications());\n\n try {\n const getInterfaceFn = await getInterfaceApi(\n result,\n snapId,\n controllerMessenger,\n simulationOptions,\n interfaceId,\n );\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n ...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),\n };\n } catch (error) {\n const [unwrappedError] = unwrapError(error);\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n const sagaPromise = runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n simulationOptions,\n ).toPromise();\n const result = await Promise.race([promise, sagaPromise]);\n\n // If the request promise has resolved to an error, we should throw\n // instead of waiting for an interface that likely will never be displayed\n if (\n is(result, SnapResponseStruct) &&\n hasProperty(result.response, 'error')\n ) {\n throw new Error(\n `Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${\n (result.response.error as JsonRpcError).message\n }`,\n );\n }\n\n return await sagaPromise;\n };\n\n return promise;\n}\n\n/**\n * Get the interface ID from the result if it's available or create a new interface if the result contains static components.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The interface ID or undefined if the result doesn't include content.\n */\nexport async function getInterfaceFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n) {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return result.id as string;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n assert(\n is(result.content, ComponentOrElementStruct),\n 'The Snap returned an invalid interface.',\n );\n\n const id = await controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n result.content as ComponentOrElement,\n );\n\n return id;\n }\n\n return undefined;\n}\n\n/**\n * Get the response content from the `SnapInterfaceController` and include the\n * interaction methods.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @param options - The simulation options.\n * @param contentId - The id of the interface if it exists outside of the result.\n * @returns The content components if any.\n */\nexport async function getInterfaceApi(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n contentId?: string,\n): Promise<(() => SnapHandlerInterface) | undefined> {\n const interfaceId = await getInterfaceFromResult(\n result,\n snapId,\n controllerMessenger,\n );\n\n const id = interfaceId ?? contentId;\n\n if (id) {\n return () => {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const actions = getInterfaceActions(\n snapId,\n controllerMessenger,\n options,\n {\n id,\n content,\n },\n );\n\n return {\n content,\n ...actions,\n };\n };\n }\n\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"request.cjs","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":";;;AACA,mDAK6B;AAE7B,uDAAoD;AACpD,uDAA2C;AAC3C,2CAKyB;AACzB,8CAA0C;AAG1C,+CAAgE;AAGhE,6CAOiB;AACjB,2CA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;;;GAUG;AACI,KAAK,UAAU,eAAe,CACnC,MAAe,EACf,MAAc,EACd,mBAA4C,EAC5C,OAA0B,EAC1B,SAAkB;IAElB,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAC9C,MAAM,EACN,MAAM,EACN,mBAAmB,CACpB,CAAC;IAEF,MAAM,EAAE,GAAG,WAAW,IAAI,SAAS,CAAC;IAEpC,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,GAAG,EAAE;YACV,MAAM,EAAE,OAAO,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAC1C,sCAAsC,EACtC,MAAM,EACN,EAAE,CACH,CAAC;YAEF,MAAM,OAAO,GAAG,IAAA,+BAAmB,EACjC,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP;gBACE,EAAE;gBACF,OAAO;aACR,CACF,CAAC;YAEF,OAAO;gBACL,OAAO;gBACP,GAAG,OAAO;aACX,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAzCD,0CAyCC","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n type ComponentOrElement,\n ComponentOrElementStruct,\n type JsonRpcError,\n type SnapId,\n} from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport {\n assert,\n getSafeJson,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getInterface, getInterfaceActions } from './interface';\nimport type { SimulationOptions } from './options';\nimport type { RunSagaFunction, Store } from './store';\nimport {\n getTraces,\n getErrors,\n clearNotifications,\n getNotifications,\n getEvents,\n clearTrackables,\n} from './store';\nimport { SnapResponseStruct } from './structs';\nimport type {\n RequestOptions,\n SnapHandlerInterface,\n SnapRequest,\n} from './types';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n simulationOptions: SimulationOptions;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.simulationOptions - The simulation options.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n simulationOptions,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const getInterfaceError = () => {\n throw new Error(\n 'Unable to get the interface from the Snap: The request to the Snap failed.',\n );\n };\n\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then(async (result) => {\n const state = store.getState();\n const notifications = getNotifications(state);\n const errors = getErrors(state);\n const events = getEvents(state);\n const traces = getTraces(state);\n const interfaceId = notifications[0]?.content;\n\n store.dispatch(clearNotifications());\n store.dispatch(clearTrackables());\n\n try {\n const getInterfaceFn = await getInterfaceApi(\n result,\n snapId,\n controllerMessenger,\n simulationOptions,\n interfaceId,\n );\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n tracked: {\n errors,\n events,\n traces,\n },\n ...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),\n };\n } catch (error) {\n const [unwrappedError] = unwrapError(error);\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n tracked: {\n errors: [],\n events: [],\n traces: [],\n },\n getInterface: getInterfaceError,\n };\n }\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n tracked: {\n errors: [],\n events: [],\n traces: [],\n },\n getInterface: getInterfaceError,\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n const sagaPromise = runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n simulationOptions,\n ).toPromise();\n const result = await Promise.race([promise, sagaPromise]);\n\n // If the request promise has resolved to an error, we should throw\n // instead of waiting for an interface that likely will never be displayed\n if (\n is(result, SnapResponseStruct) &&\n hasProperty(result.response, 'error')\n ) {\n throw new Error(\n `Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${\n (result.response.error as JsonRpcError).message\n }`,\n );\n }\n\n return await sagaPromise;\n };\n\n return promise;\n}\n\n/**\n * Get the interface ID from the result if it's available or create a new interface if the result contains static components.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The interface ID or undefined if the result doesn't include content.\n */\nexport async function getInterfaceFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n) {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return result.id as string;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n assert(\n is(result.content, ComponentOrElementStruct),\n 'The Snap returned an invalid interface.',\n );\n\n const id = await controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n result.content as ComponentOrElement,\n );\n\n return id;\n }\n\n return undefined;\n}\n\n/**\n * Get the response content from the `SnapInterfaceController` and include the\n * interaction methods.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @param options - The simulation options.\n * @param contentId - The id of the interface if it exists outside of the result.\n * @returns The content components if any.\n */\nexport async function getInterfaceApi(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n contentId?: string,\n): Promise<(() => SnapHandlerInterface) | undefined> {\n const interfaceId = await getInterfaceFromResult(\n result,\n snapId,\n controllerMessenger,\n );\n\n const id = interfaceId ?? contentId;\n\n if (id) {\n return () => {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const actions = getInterfaceActions(\n snapId,\n controllerMessenger,\n options,\n {\n id,\n content,\n },\n );\n\n return {\n content,\n ...actions,\n };\n };\n }\n\n return undefined;\n}\n"]}
|
package/dist/request.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.cts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAC5E,OAAO,EAIL,KAAK,MAAM,EACZ,4BAA4B;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,8BAA8B;AAWzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BAAsB;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAkB;
|
|
1
|
+
{"version":3,"file":"request.d.cts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAC5E,OAAO,EAIL,KAAK,MAAM,EACZ,4BAA4B;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,8BAA8B;AAWzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BAAsB;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAkB;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,0BAAgB;AAUtD,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACZ,oBAAgB;AAEjB,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACpD,OAAO,EAAE,WAAW,CAAC;IACrB,mBAAmB,EAAE,uBAAuB,CAAC;IAC7C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,EACP,OAAO,EAAE,EAAE,EAAa,EAAE,MAA8B,EAAE,GAAG,OAAO,EAAE,GACvE,EAAE,oBAAoB,GAAG,WAAW,CAgHpC;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,+BAsB7C;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,iBAAiB,EAC1B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,MAAM,oBAAoB,CAAC,GAAG,SAAS,CAAC,CAmCnD"}
|
package/dist/request.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.mts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,oCAAoC;AAC5E,OAAO,EAIL,KAAK,MAAM,EACZ,4BAA4B;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,8BAA8B;AAWzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BAAsB;AAE7D,OAA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AAO,EACf,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,uBAAuB,EAC5C,OAAO,EAAE,iBAAiB,EAC1B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,MAAM,oBAAoB,CAAC,GAAG,SAAS,CAAC,CAmCnD"}
|
package/dist/request.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { assert, getSafeJson, hasProperty, isPlainObject } from "@metamask/utils
|
|
|
5
5
|
import $reduxjstoolkit from "@reduxjs/toolkit";
|
|
6
6
|
const { nanoid } = $reduxjstoolkit;
|
|
7
7
|
import { getInterface, getInterfaceActions } from "./interface.mjs";
|
|
8
|
-
import { clearNotifications, getNotifications } from "./store/index.mjs";
|
|
8
|
+
import { getTraces, getErrors, clearNotifications, getNotifications, getEvents, clearTrackables } from "./store/index.mjs";
|
|
9
9
|
import { SnapResponseStruct } from "./structs.mjs";
|
|
10
10
|
/**
|
|
11
11
|
* Send a JSON-RPC request to the Snap, and wrap the response in a
|
|
@@ -43,9 +43,14 @@ export function handleRequest({ snapId, store, executionService, handler, contro
|
|
|
43
43
|
},
|
|
44
44
|
})
|
|
45
45
|
.then(async (result) => {
|
|
46
|
-
const
|
|
46
|
+
const state = store.getState();
|
|
47
|
+
const notifications = getNotifications(state);
|
|
48
|
+
const errors = getErrors(state);
|
|
49
|
+
const events = getEvents(state);
|
|
50
|
+
const traces = getTraces(state);
|
|
47
51
|
const interfaceId = notifications[0]?.content;
|
|
48
52
|
store.dispatch(clearNotifications());
|
|
53
|
+
store.dispatch(clearTrackables());
|
|
49
54
|
try {
|
|
50
55
|
const getInterfaceFn = await getInterfaceApi(result, snapId, controllerMessenger, simulationOptions, interfaceId);
|
|
51
56
|
return {
|
|
@@ -54,6 +59,11 @@ export function handleRequest({ snapId, store, executionService, handler, contro
|
|
|
54
59
|
result: getSafeJson(result),
|
|
55
60
|
},
|
|
56
61
|
notifications,
|
|
62
|
+
tracked: {
|
|
63
|
+
errors,
|
|
64
|
+
events,
|
|
65
|
+
traces,
|
|
66
|
+
},
|
|
57
67
|
...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),
|
|
58
68
|
};
|
|
59
69
|
}
|
|
@@ -65,6 +75,11 @@ export function handleRequest({ snapId, store, executionService, handler, contro
|
|
|
65
75
|
error: unwrappedError.serialize(),
|
|
66
76
|
},
|
|
67
77
|
notifications: [],
|
|
78
|
+
tracked: {
|
|
79
|
+
errors: [],
|
|
80
|
+
events: [],
|
|
81
|
+
traces: [],
|
|
82
|
+
},
|
|
68
83
|
getInterface: getInterfaceError,
|
|
69
84
|
};
|
|
70
85
|
}
|
|
@@ -77,6 +92,11 @@ export function handleRequest({ snapId, store, executionService, handler, contro
|
|
|
77
92
|
error: unwrappedError.serialize(),
|
|
78
93
|
},
|
|
79
94
|
notifications: [],
|
|
95
|
+
tracked: {
|
|
96
|
+
errors: [],
|
|
97
|
+
events: [],
|
|
98
|
+
traces: [],
|
|
99
|
+
},
|
|
80
100
|
getInterface: getInterfaceError,
|
|
81
101
|
};
|
|
82
102
|
});
|
package/dist/request.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.mjs","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,wBAAwB,EAGzB,4BAA4B;AAE7B,OAAO,EAAE,WAAW,EAAE,8BAA8B;AACpD,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAC3C,OAAO,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACd,wBAAwB;;;AAIzB,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,wBAAoB;AAEhE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,0BAAgB;AAE/D,OAAO,EAAE,kBAAkB,EAAE,sBAAkB;AAkB/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,m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AAI,CAAC,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC,EAAY,CAAC;IAC7B,CAAC;IAED,IAAI,aAAa,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC;QAC5D,MAAM,CACJ,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,wBAAwB,CAAC,EAC5C,yCAAyC,CAC1C,CAAC;QAEF,MAAM,EAAE,GAAG,MAAM,mBAAmB,CAAC,IAAI,CACvC,yCAAyC,EACzC,MAAM,EACN,MAAM,CAAC,OAA6B,CACrC,CAAC;QAEF,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAe,EACf,MAAc,EACd,mBAA4C,EAC5C,OAA0B,EAC1B,SAAkB;IAElB,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAC9C,MAAM,EACN,MAAM,EACN,mBAAmB,CACpB,CAAC;IAEF,MAAM,EAAE,GAAG,WAAW,IAAI,SAAS,CAAC;IAEpC,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,GAAG,EAAE;YACV,MAAM,EAAE,OAAO,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAC1C,sCAAsC,EACtC,MAAM,EACN,EAAE,CACH,CAAC;YAEF,MAAM,OAAO,GAAG,mBAAmB,CACjC,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP;gBACE,EAAE;gBACF,OAAO;aACR,CACF,CAAC;YAEF,OAAO;gBACL,OAAO;gBACP,GAAG,OAAO;aACX,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n type ComponentOrElement,\n ComponentOrElementStruct,\n type JsonRpcError,\n type SnapId,\n} from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport {\n assert,\n getSafeJson,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getInterface, getInterfaceActions } from './interface';\nimport type { SimulationOptions } from './options';\nimport { clearNotifications, getNotifications } from './store';\nimport type { RunSagaFunction, Store } from './store';\nimport { SnapResponseStruct } from './structs';\nimport type {\n RequestOptions,\n SnapHandlerInterface,\n SnapRequest,\n} from './types';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n simulationOptions: SimulationOptions;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.simulationOptions - The simulation options.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n simulationOptions,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const getInterfaceError = () => {\n throw new Error(\n 'Unable to get the interface from the Snap: The request to the Snap failed.',\n );\n };\n\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then(async (result) => {\n const notifications = getNotifications(store.getState());\n const interfaceId = notifications[0]?.content;\n store.dispatch(clearNotifications());\n\n try {\n const getInterfaceFn = await getInterfaceApi(\n result,\n snapId,\n controllerMessenger,\n simulationOptions,\n interfaceId,\n );\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n ...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),\n };\n } catch (error) {\n const [unwrappedError] = unwrapError(error);\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n const sagaPromise = runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n simulationOptions,\n ).toPromise();\n const result = await Promise.race([promise, sagaPromise]);\n\n // If the request promise has resolved to an error, we should throw\n // instead of waiting for an interface that likely will never be displayed\n if (\n is(result, SnapResponseStruct) &&\n hasProperty(result.response, 'error')\n ) {\n throw new Error(\n `Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${\n (result.response.error as JsonRpcError).message\n }`,\n );\n }\n\n return await sagaPromise;\n };\n\n return promise;\n}\n\n/**\n * Get the interface ID from the result if it's available or create a new interface if the result contains static components.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The interface ID or undefined if the result doesn't include content.\n */\nexport async function getInterfaceFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n) {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return result.id as string;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n assert(\n is(result.content, ComponentOrElementStruct),\n 'The Snap returned an invalid interface.',\n );\n\n const id = await controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n result.content as ComponentOrElement,\n );\n\n return id;\n }\n\n return undefined;\n}\n\n/**\n * Get the response content from the `SnapInterfaceController` and include the\n * interaction methods.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @param options - The simulation options.\n * @param contentId - The id of the interface if it exists outside of the result.\n * @returns The content components if any.\n */\nexport async function getInterfaceApi(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n contentId?: string,\n): Promise<(() => SnapHandlerInterface) | undefined> {\n const interfaceId = await getInterfaceFromResult(\n result,\n snapId,\n controllerMessenger,\n );\n\n const id = interfaceId ?? contentId;\n\n if (id) {\n return () => {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const actions = getInterfaceActions(\n snapId,\n controllerMessenger,\n options,\n {\n id,\n content,\n },\n );\n\n return {\n content,\n ...actions,\n };\n };\n }\n\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"request.mjs","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,wBAAwB,EAGzB,4BAA4B;AAE7B,OAAO,EAAE,WAAW,EAAE,8BAA8B;AACpD,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAC3C,OAAO,EACL,MAAM,EACN,WAAW,EACX,WAAW,EACX,aAAa,EACd,wBAAwB;;;AAIzB,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,wBAAoB;AAGhE,OAAO,EACL,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,eAAe,EAChB,0BAAgB;AACjB,OAAO,EAAE,kBAAkB,EAAE,sBAAkB;AAkB/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,mBAAmB,EACnB,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AAO,GAAG,EAAE;YACV,MAAM,EAAE,OAAO,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAC1C,sCAAsC,EACtC,MAAM,EACN,EAAE,CACH,CAAC;YAEF,MAAM,OAAO,GAAG,mBAAmB,CACjC,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP;gBACE,EAAE;gBACF,OAAO;aACR,CACF,CAAC;YAEF,OAAO;gBACL,OAAO;gBACP,GAAG,OAAO;aACX,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n type ComponentOrElement,\n ComponentOrElementStruct,\n type JsonRpcError,\n type SnapId,\n} from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport {\n assert,\n getSafeJson,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\n\nimport type { RootControllerMessenger } from './controllers';\nimport { getInterface, getInterfaceActions } from './interface';\nimport type { SimulationOptions } from './options';\nimport type { RunSagaFunction, Store } from './store';\nimport {\n getTraces,\n getErrors,\n clearNotifications,\n getNotifications,\n getEvents,\n clearTrackables,\n} from './store';\nimport { SnapResponseStruct } from './structs';\nimport type {\n RequestOptions,\n SnapHandlerInterface,\n SnapRequest,\n} from './types';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n simulationOptions: SimulationOptions;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.simulationOptions - The simulation options.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n simulationOptions,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const getInterfaceError = () => {\n throw new Error(\n 'Unable to get the interface from the Snap: The request to the Snap failed.',\n );\n };\n\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then(async (result) => {\n const state = store.getState();\n const notifications = getNotifications(state);\n const errors = getErrors(state);\n const events = getEvents(state);\n const traces = getTraces(state);\n const interfaceId = notifications[0]?.content;\n\n store.dispatch(clearNotifications());\n store.dispatch(clearTrackables());\n\n try {\n const getInterfaceFn = await getInterfaceApi(\n result,\n snapId,\n controllerMessenger,\n simulationOptions,\n interfaceId,\n );\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n tracked: {\n errors,\n events,\n traces,\n },\n ...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),\n };\n } catch (error) {\n const [unwrappedError] = unwrapError(error);\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n tracked: {\n errors: [],\n events: [],\n traces: [],\n },\n getInterface: getInterfaceError,\n };\n }\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n tracked: {\n errors: [],\n events: [],\n traces: [],\n },\n getInterface: getInterfaceError,\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n const sagaPromise = runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n simulationOptions,\n ).toPromise();\n const result = await Promise.race([promise, sagaPromise]);\n\n // If the request promise has resolved to an error, we should throw\n // instead of waiting for an interface that likely will never be displayed\n if (\n is(result, SnapResponseStruct) &&\n hasProperty(result.response, 'error')\n ) {\n throw new Error(\n `Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${\n (result.response.error as JsonRpcError).message\n }`,\n );\n }\n\n return await sagaPromise;\n };\n\n return promise;\n}\n\n/**\n * Get the interface ID from the result if it's available or create a new interface if the result contains static components.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The interface ID or undefined if the result doesn't include content.\n */\nexport async function getInterfaceFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n) {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return result.id as string;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n assert(\n is(result.content, ComponentOrElementStruct),\n 'The Snap returned an invalid interface.',\n );\n\n const id = await controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n result.content as ComponentOrElement,\n );\n\n return id;\n }\n\n return undefined;\n}\n\n/**\n * Get the response content from the `SnapInterfaceController` and include the\n * interaction methods.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @param options - The simulation options.\n * @param contentId - The id of the interface if it exists outside of the result.\n * @returns The content components if any.\n */\nexport async function getInterfaceApi(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n contentId?: string,\n): Promise<(() => SnapHandlerInterface) | undefined> {\n const interfaceId = await getInterfaceFromResult(\n result,\n snapId,\n controllerMessenger,\n );\n\n const id = interfaceId ?? contentId;\n\n if (id) {\n return () => {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const actions = getInterfaceActions(\n snapId,\n controllerMessenger,\n options,\n {\n id,\n content,\n },\n );\n\n return {\n content,\n ...actions,\n };\n };\n }\n\n return undefined;\n}\n"]}
|