@metamask/snaps-rpc-methods 13.1.0 → 13.2.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 +9 -1
- package/dist/endowments/index.cjs +1 -0
- package/dist/endowments/index.cjs.map +1 -1
- package/dist/endowments/index.d.cts.map +1 -1
- package/dist/endowments/index.d.mts.map +1 -1
- package/dist/endowments/index.mjs +1 -0
- package/dist/endowments/index.mjs.map +1 -1
- package/dist/permitted/createInterface.d.cts +10 -10
- package/dist/permitted/createInterface.d.mts +10 -10
- package/dist/permitted/handlers.cjs +2 -0
- package/dist/permitted/handlers.cjs.map +1 -1
- package/dist/permitted/handlers.d.cts +2 -1
- package/dist/permitted/handlers.d.cts.map +1 -1
- package/dist/permitted/handlers.d.mts +2 -1
- package/dist/permitted/handlers.d.mts.map +1 -1
- package/dist/permitted/handlers.mjs +2 -0
- package/dist/permitted/handlers.mjs.map +1 -1
- package/dist/permitted/index.cjs.map +1 -1
- package/dist/permitted/index.d.cts +3 -1
- package/dist/permitted/index.d.cts.map +1 -1
- package/dist/permitted/index.d.mts +3 -1
- package/dist/permitted/index.d.mts.map +1 -1
- package/dist/permitted/index.mjs.map +1 -1
- package/dist/permitted/trackError.cjs +94 -0
- package/dist/permitted/trackError.cjs.map +1 -0
- package/dist/permitted/trackError.d.cts +32 -0
- package/dist/permitted/trackError.d.cts.map +1 -0
- package/dist/permitted/trackError.d.mts +32 -0
- package/dist/permitted/trackError.d.mts.map +1 -0
- package/dist/permitted/trackError.mjs +91 -0
- package/dist/permitted/trackError.mjs.map +1 -0
- package/dist/permitted/updateInterface.d.cts +10 -10
- package/dist/permitted/updateInterface.d.mts +10 -10
- package/dist/restricted/dialog.d.cts +20 -20
- package/dist/restricted/dialog.d.mts +20 -20
- package/dist/restricted/notify.d.cts +15 -15
- package/dist/restricted/notify.d.mts +15 -15
- package/package.json +4 -4
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackErrorHandler = void 0;
|
|
4
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
5
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
6
|
+
const hookNames = {
|
|
7
|
+
trackError: true,
|
|
8
|
+
getSnap: true,
|
|
9
|
+
};
|
|
10
|
+
const TrackableErrorStruct = (0, superstruct_1.object)({
|
|
11
|
+
name: (0, superstruct_1.string)(),
|
|
12
|
+
message: (0, superstruct_1.string)(),
|
|
13
|
+
stack: (0, superstruct_1.nullable)((0, superstruct_1.string)()),
|
|
14
|
+
cause: (0, superstruct_1.nullable)((0, superstruct_1.lazy)(() => TrackableErrorStruct)),
|
|
15
|
+
});
|
|
16
|
+
const TrackErrorParametersStruct = (0, superstruct_1.object)({
|
|
17
|
+
error: TrackableErrorStruct,
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Handler for the `snap_trackError` method.
|
|
21
|
+
*/
|
|
22
|
+
exports.trackErrorHandler = {
|
|
23
|
+
methodNames: ['snap_trackError'],
|
|
24
|
+
implementation: getTrackErrorImplementation,
|
|
25
|
+
hookNames,
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The `snap_trackError` method implementation. This method allows preinstalled
|
|
29
|
+
* Snaps to send errors to the Sentry instance in the client for tracking.
|
|
30
|
+
*
|
|
31
|
+
* @param request - The JSON-RPC request object.
|
|
32
|
+
* @param response - The JSON-RPC response object.
|
|
33
|
+
* @param _next - The `json-rpc-engine` "next" callback. Not used by this
|
|
34
|
+
* function.
|
|
35
|
+
* @param end - The `json-rpc-engine` "end" callback.
|
|
36
|
+
* @param hooks - The RPC method hooks.
|
|
37
|
+
* @param hooks.trackError - The hook function to track an error.
|
|
38
|
+
* @param hooks.getSnap - The hook function to get Snap metadata.
|
|
39
|
+
* @returns Nothing.
|
|
40
|
+
*/
|
|
41
|
+
function getTrackErrorImplementation(request, response, _next, end, { trackError, getSnap }) {
|
|
42
|
+
const snap = getSnap(request.origin);
|
|
43
|
+
if (!snap?.preinstalled) {
|
|
44
|
+
return end(rpc_errors_1.rpcErrors.methodNotFound());
|
|
45
|
+
}
|
|
46
|
+
const { params } = request;
|
|
47
|
+
try {
|
|
48
|
+
const validatedParams = getValidatedParams(params);
|
|
49
|
+
const error = deserializeError(validatedParams.error);
|
|
50
|
+
response.result = trackError(error);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return end(error);
|
|
54
|
+
}
|
|
55
|
+
return end();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Validates the parameters for the snap_trackEvent method.
|
|
59
|
+
*
|
|
60
|
+
* @param params - Parameters to validate.
|
|
61
|
+
* @returns Validated parameters.
|
|
62
|
+
* @throws Throws RPC error if validation fails.
|
|
63
|
+
*/
|
|
64
|
+
function getValidatedParams(params) {
|
|
65
|
+
try {
|
|
66
|
+
return (0, superstruct_1.create)(params, TrackErrorParametersStruct);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (error instanceof superstruct_1.StructError) {
|
|
70
|
+
throw rpc_errors_1.rpcErrors.invalidParams({
|
|
71
|
+
message: `Invalid params: ${error.message}.`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/* istanbul ignore next */
|
|
75
|
+
throw rpc_errors_1.rpcErrors.internal();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Deserialize a {@link TrackableError} into a standard {@link Error} object.
|
|
80
|
+
*
|
|
81
|
+
* @param error - The error to deserialize.
|
|
82
|
+
* @returns A standard {@link Error} object with the same properties as the
|
|
83
|
+
* original {@link TrackableError}.
|
|
84
|
+
*/
|
|
85
|
+
function deserializeError(error) {
|
|
86
|
+
const deserializedError = new Error(error.message);
|
|
87
|
+
deserializedError.name = error.name;
|
|
88
|
+
deserializedError.stack = error.stack ?? undefined;
|
|
89
|
+
deserializedError.cause = error.cause
|
|
90
|
+
? deserializeError(error.cause)
|
|
91
|
+
: undefined;
|
|
92
|
+
return deserializedError;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=trackError.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trackError.cjs","sourceRoot":"","sources":["../../src/permitted/trackError.ts"],"names":[],"mappings":";;;AAEA,qDAAiD;AASjD,uDAO+B;AAK/B,MAAM,SAAS,GAA6C;IAC1D,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;CACd,CAAC;AAoBF,MAAM,oBAAoB,GAA2B,IAAA,oBAAM,EAAC;IAC1D,IAAI,EAAE,IAAA,oBAAM,GAAE;IACd,OAAO,EAAE,IAAA,oBAAM,GAAE;IACjB,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACzB,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,kBAAI,EAAiB,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC;CAClE,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,IAAA,oBAAM,EAAC;IACxC,KAAK,EAAE,oBAAoB;CAC5B,CAAC,CAAC;AAOH;;GAEG;AACU,QAAA,iBAAiB,GAI1B;IACF,WAAW,EAAE,CAAC,iBAAiB,CAAC;IAChC,cAAc,EAAE,2BAA2B;IAC3C,SAAS;CACV,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAS,2BAA2B,CAClC,OAA6C,EAC7C,QAAkD,EAClD,KAAc,EACd,GAA6B,EAC7B,EAAE,UAAU,EAAE,OAAO,EAAyB;IAE9C,MAAM,IAAI,GAAG,OAAO,CACjB,OAAiE,CAAC,MAAM,CAC1E,CAAC;IAEF,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC,sBAAS,CAAC,cAAc,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,gBAAgB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAEtD,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,IAAA,oBAAM,EAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QAED,0BAA0B;QAC1B,MAAM,sBAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,KAAqB;IAC7C,MAAM,iBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnD,iBAAiB,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACpC,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC;IACnD,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;QACnC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC;QAC/B,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n JsonRpcRequest,\n TrackableError,\n TrackErrorParams,\n TrackErrorResult,\n} from '@metamask/snaps-sdk';\nimport type { InferMatching, Snap } from '@metamask/snaps-utils';\nimport type { Struct } from '@metamask/superstruct';\nimport {\n create,\n lazy,\n nullable,\n object,\n string,\n StructError,\n} from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst hookNames: MethodHooksObject<TrackErrorMethodHooks> = {\n trackError: true,\n getSnap: true,\n};\n\nexport type TrackErrorMethodHooks = {\n /**\n * Track an error.\n *\n * @param error - The error object to track.\n * @returns The ID of the tracked error, as returned by the Sentry instance\n * in the client.\n */\n trackError: (error: Error) => string;\n\n /**\n * Get Snap metadata.\n *\n * @param snapId - The ID of a Snap.\n */\n getSnap: (snapId: string) => Snap | undefined;\n};\n\nconst TrackableErrorStruct: Struct<TrackableError> = object({\n name: string(),\n message: string(),\n stack: nullable(string()),\n cause: nullable(lazy<TrackableError>(() => TrackableErrorStruct)),\n});\n\nconst TrackErrorParametersStruct = object({\n error: TrackableErrorStruct,\n});\n\nexport type TrackErrorParameters = InferMatching<\n typeof TrackErrorParametersStruct,\n TrackErrorParams\n>;\n\n/**\n * Handler for the `snap_trackError` method.\n */\nexport const trackErrorHandler: PermittedHandlerExport<\n TrackErrorMethodHooks,\n TrackErrorParameters,\n TrackErrorResult\n> = {\n methodNames: ['snap_trackError'],\n implementation: getTrackErrorImplementation,\n hookNames,\n};\n\n/**\n * The `snap_trackError` method implementation. This method allows preinstalled\n * Snaps to send errors to the Sentry instance in the client for tracking.\n *\n * @param request - The JSON-RPC request object.\n * @param response - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.trackError - The hook function to track an error.\n * @param hooks.getSnap - The hook function to get Snap metadata.\n * @returns Nothing.\n */\nfunction getTrackErrorImplementation(\n request: JsonRpcRequest<TrackErrorParameters>,\n response: PendingJsonRpcResponse<TrackErrorResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { trackError, getSnap }: TrackErrorMethodHooks,\n): void {\n const snap = getSnap(\n (request as JsonRpcRequest<TrackErrorParams> & { origin: string }).origin,\n );\n\n if (!snap?.preinstalled) {\n return end(rpcErrors.methodNotFound());\n }\n\n const { params } = request;\n\n try {\n const validatedParams = getValidatedParams(params);\n const error = deserializeError(validatedParams.error);\n\n response.result = trackError(error);\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validates the parameters for the snap_trackEvent method.\n *\n * @param params - Parameters to validate.\n * @returns Validated parameters.\n * @throws Throws RPC error if validation fails.\n */\nfunction getValidatedParams(params: unknown): TrackErrorParameters {\n try {\n return create(params, TrackErrorParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n\n/**\n * Deserialize a {@link TrackableError} into a standard {@link Error} object.\n *\n * @param error - The error to deserialize.\n * @returns A standard {@link Error} object with the same properties as the\n * original {@link TrackableError}.\n */\nfunction deserializeError(error: TrackableError): Error {\n const deserializedError = new Error(error.message);\n deserializedError.name = error.name;\n deserializedError.stack = error.stack ?? undefined;\n deserializedError.cause = error.cause\n ? deserializeError(error.cause)\n : undefined;\n\n return deserializedError;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PermittedHandlerExport } from "@metamask/permission-controller";
|
|
2
|
+
import type { TrackableError, TrackErrorParams, TrackErrorResult } from "@metamask/snaps-sdk";
|
|
3
|
+
import type { InferMatching, Snap } from "@metamask/snaps-utils";
|
|
4
|
+
import type { Struct } from "@metamask/superstruct";
|
|
5
|
+
export type TrackErrorMethodHooks = {
|
|
6
|
+
/**
|
|
7
|
+
* Track an error.
|
|
8
|
+
*
|
|
9
|
+
* @param error - The error object to track.
|
|
10
|
+
* @returns The ID of the tracked error, as returned by the Sentry instance
|
|
11
|
+
* in the client.
|
|
12
|
+
*/
|
|
13
|
+
trackError: (error: Error) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Get Snap metadata.
|
|
16
|
+
*
|
|
17
|
+
* @param snapId - The ID of a Snap.
|
|
18
|
+
*/
|
|
19
|
+
getSnap: (snapId: string) => Snap | undefined;
|
|
20
|
+
};
|
|
21
|
+
declare const TrackErrorParametersStruct: Struct<{
|
|
22
|
+
error: TrackableError;
|
|
23
|
+
}, {
|
|
24
|
+
error: Struct<TrackableError, unknown>;
|
|
25
|
+
}>;
|
|
26
|
+
export type TrackErrorParameters = InferMatching<typeof TrackErrorParametersStruct, TrackErrorParams>;
|
|
27
|
+
/**
|
|
28
|
+
* Handler for the `snap_trackError` method.
|
|
29
|
+
*/
|
|
30
|
+
export declare const trackErrorHandler: PermittedHandlerExport<TrackErrorMethodHooks, TrackErrorParameters, TrackErrorResult>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=trackError.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trackError.d.cts","sourceRoot":"","sources":["../../src/permitted/trackError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EAEV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACjB,4BAA4B;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,8BAA8B;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAkBpD,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;IAErC;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAAC;CAC/C,CAAC;AASF,QAAA,MAAM,0BAA0B;;;;EAE9B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAC9C,OAAO,0BAA0B,EACjC,gBAAgB,CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,sBAAsB,CACpD,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,CAKjB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PermittedHandlerExport } from "@metamask/permission-controller";
|
|
2
|
+
import type { TrackableError, TrackErrorParams, TrackErrorResult } from "@metamask/snaps-sdk";
|
|
3
|
+
import type { InferMatching, Snap } from "@metamask/snaps-utils";
|
|
4
|
+
import type { Struct } from "@metamask/superstruct";
|
|
5
|
+
export type TrackErrorMethodHooks = {
|
|
6
|
+
/**
|
|
7
|
+
* Track an error.
|
|
8
|
+
*
|
|
9
|
+
* @param error - The error object to track.
|
|
10
|
+
* @returns The ID of the tracked error, as returned by the Sentry instance
|
|
11
|
+
* in the client.
|
|
12
|
+
*/
|
|
13
|
+
trackError: (error: Error) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Get Snap metadata.
|
|
16
|
+
*
|
|
17
|
+
* @param snapId - The ID of a Snap.
|
|
18
|
+
*/
|
|
19
|
+
getSnap: (snapId: string) => Snap | undefined;
|
|
20
|
+
};
|
|
21
|
+
declare const TrackErrorParametersStruct: Struct<{
|
|
22
|
+
error: TrackableError;
|
|
23
|
+
}, {
|
|
24
|
+
error: Struct<TrackableError, unknown>;
|
|
25
|
+
}>;
|
|
26
|
+
export type TrackErrorParameters = InferMatching<typeof TrackErrorParametersStruct, TrackErrorParams>;
|
|
27
|
+
/**
|
|
28
|
+
* Handler for the `snap_trackError` method.
|
|
29
|
+
*/
|
|
30
|
+
export declare const trackErrorHandler: PermittedHandlerExport<TrackErrorMethodHooks, TrackErrorParameters, TrackErrorResult>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=trackError.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trackError.d.mts","sourceRoot":"","sources":["../../src/permitted/trackError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EAEV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACjB,4BAA4B;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,8BAA8B;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAkBpD,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;IAErC;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,CAAC;CAC/C,CAAC;AASF,QAAA,MAAM,0BAA0B;;;;EAE9B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAC9C,OAAO,0BAA0B,EACjC,gBAAgB,CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,sBAAsB,CACpD,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,CAKjB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { rpcErrors } from "@metamask/rpc-errors";
|
|
2
|
+
import { create, lazy, nullable, object, string, StructError } from "@metamask/superstruct";
|
|
3
|
+
const hookNames = {
|
|
4
|
+
trackError: true,
|
|
5
|
+
getSnap: true,
|
|
6
|
+
};
|
|
7
|
+
const TrackableErrorStruct = object({
|
|
8
|
+
name: string(),
|
|
9
|
+
message: string(),
|
|
10
|
+
stack: nullable(string()),
|
|
11
|
+
cause: nullable(lazy(() => TrackableErrorStruct)),
|
|
12
|
+
});
|
|
13
|
+
const TrackErrorParametersStruct = object({
|
|
14
|
+
error: TrackableErrorStruct,
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Handler for the `snap_trackError` method.
|
|
18
|
+
*/
|
|
19
|
+
export const trackErrorHandler = {
|
|
20
|
+
methodNames: ['snap_trackError'],
|
|
21
|
+
implementation: getTrackErrorImplementation,
|
|
22
|
+
hookNames,
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The `snap_trackError` method implementation. This method allows preinstalled
|
|
26
|
+
* Snaps to send errors to the Sentry instance in the client for tracking.
|
|
27
|
+
*
|
|
28
|
+
* @param request - The JSON-RPC request object.
|
|
29
|
+
* @param response - The JSON-RPC response object.
|
|
30
|
+
* @param _next - The `json-rpc-engine` "next" callback. Not used by this
|
|
31
|
+
* function.
|
|
32
|
+
* @param end - The `json-rpc-engine` "end" callback.
|
|
33
|
+
* @param hooks - The RPC method hooks.
|
|
34
|
+
* @param hooks.trackError - The hook function to track an error.
|
|
35
|
+
* @param hooks.getSnap - The hook function to get Snap metadata.
|
|
36
|
+
* @returns Nothing.
|
|
37
|
+
*/
|
|
38
|
+
function getTrackErrorImplementation(request, response, _next, end, { trackError, getSnap }) {
|
|
39
|
+
const snap = getSnap(request.origin);
|
|
40
|
+
if (!snap?.preinstalled) {
|
|
41
|
+
return end(rpcErrors.methodNotFound());
|
|
42
|
+
}
|
|
43
|
+
const { params } = request;
|
|
44
|
+
try {
|
|
45
|
+
const validatedParams = getValidatedParams(params);
|
|
46
|
+
const error = deserializeError(validatedParams.error);
|
|
47
|
+
response.result = trackError(error);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return end(error);
|
|
51
|
+
}
|
|
52
|
+
return end();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Validates the parameters for the snap_trackEvent method.
|
|
56
|
+
*
|
|
57
|
+
* @param params - Parameters to validate.
|
|
58
|
+
* @returns Validated parameters.
|
|
59
|
+
* @throws Throws RPC error if validation fails.
|
|
60
|
+
*/
|
|
61
|
+
function getValidatedParams(params) {
|
|
62
|
+
try {
|
|
63
|
+
return create(params, TrackErrorParametersStruct);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof StructError) {
|
|
67
|
+
throw rpcErrors.invalidParams({
|
|
68
|
+
message: `Invalid params: ${error.message}.`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/* istanbul ignore next */
|
|
72
|
+
throw rpcErrors.internal();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Deserialize a {@link TrackableError} into a standard {@link Error} object.
|
|
77
|
+
*
|
|
78
|
+
* @param error - The error to deserialize.
|
|
79
|
+
* @returns A standard {@link Error} object with the same properties as the
|
|
80
|
+
* original {@link TrackableError}.
|
|
81
|
+
*/
|
|
82
|
+
function deserializeError(error) {
|
|
83
|
+
const deserializedError = new Error(error.message);
|
|
84
|
+
deserializedError.name = error.name;
|
|
85
|
+
deserializedError.stack = error.stack ?? undefined;
|
|
86
|
+
deserializedError.cause = error.cause
|
|
87
|
+
? deserializeError(error.cause)
|
|
88
|
+
: undefined;
|
|
89
|
+
return deserializedError;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=trackError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trackError.mjs","sourceRoot":"","sources":["../../src/permitted/trackError.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AASjD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,MAAM,EACN,WAAW,EACZ,8BAA8B;AAK/B,MAAM,SAAS,GAA6C;IAC1D,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAI;CACd,CAAC;AAoBF,MAAM,oBAAoB,GAA2B,MAAM,CAAC;IAC1D,IAAI,EAAE,MAAM,EAAE;IACd,OAAO,EAAE,MAAM,EAAE;IACjB,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAiB,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC;CAClE,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,MAAM,CAAC;IACxC,KAAK,EAAE,oBAAoB;CAC5B,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAI1B;IACF,WAAW,EAAE,CAAC,iBAAiB,CAAC;IAChC,cAAc,EAAE,2BAA2B;IAC3C,SAAS;CACV,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAS,2BAA2B,CAClC,OAA6C,EAC7C,QAAkD,EAClD,KAAc,EACd,GAA6B,EAC7B,EAAE,UAAU,EAAE,OAAO,EAAyB;IAE9C,MAAM,IAAI,GAAG,OAAO,CACjB,OAAiE,CAAC,MAAM,CAC1E,CAAC;IAEF,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,gBAAgB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAEtD,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,MAAe;IACzC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,MAAM,SAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mBAAmB,KAAK,CAAC,OAAO,GAAG;aAC7C,CAAC,CAAC;QACL,CAAC;QAED,0BAA0B;QAC1B,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,KAAqB;IAC7C,MAAM,iBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnD,iBAAiB,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACpC,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC;IACnD,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;QACnC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC;QAC/B,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n JsonRpcRequest,\n TrackableError,\n TrackErrorParams,\n TrackErrorResult,\n} from '@metamask/snaps-sdk';\nimport type { InferMatching, Snap } from '@metamask/snaps-utils';\nimport type { Struct } from '@metamask/superstruct';\nimport {\n create,\n lazy,\n nullable,\n object,\n string,\n StructError,\n} from '@metamask/superstruct';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst hookNames: MethodHooksObject<TrackErrorMethodHooks> = {\n trackError: true,\n getSnap: true,\n};\n\nexport type TrackErrorMethodHooks = {\n /**\n * Track an error.\n *\n * @param error - The error object to track.\n * @returns The ID of the tracked error, as returned by the Sentry instance\n * in the client.\n */\n trackError: (error: Error) => string;\n\n /**\n * Get Snap metadata.\n *\n * @param snapId - The ID of a Snap.\n */\n getSnap: (snapId: string) => Snap | undefined;\n};\n\nconst TrackableErrorStruct: Struct<TrackableError> = object({\n name: string(),\n message: string(),\n stack: nullable(string()),\n cause: nullable(lazy<TrackableError>(() => TrackableErrorStruct)),\n});\n\nconst TrackErrorParametersStruct = object({\n error: TrackableErrorStruct,\n});\n\nexport type TrackErrorParameters = InferMatching<\n typeof TrackErrorParametersStruct,\n TrackErrorParams\n>;\n\n/**\n * Handler for the `snap_trackError` method.\n */\nexport const trackErrorHandler: PermittedHandlerExport<\n TrackErrorMethodHooks,\n TrackErrorParameters,\n TrackErrorResult\n> = {\n methodNames: ['snap_trackError'],\n implementation: getTrackErrorImplementation,\n hookNames,\n};\n\n/**\n * The `snap_trackError` method implementation. This method allows preinstalled\n * Snaps to send errors to the Sentry instance in the client for tracking.\n *\n * @param request - The JSON-RPC request object.\n * @param response - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.trackError - The hook function to track an error.\n * @param hooks.getSnap - The hook function to get Snap metadata.\n * @returns Nothing.\n */\nfunction getTrackErrorImplementation(\n request: JsonRpcRequest<TrackErrorParameters>,\n response: PendingJsonRpcResponse<TrackErrorResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { trackError, getSnap }: TrackErrorMethodHooks,\n): void {\n const snap = getSnap(\n (request as JsonRpcRequest<TrackErrorParams> & { origin: string }).origin,\n );\n\n if (!snap?.preinstalled) {\n return end(rpcErrors.methodNotFound());\n }\n\n const { params } = request;\n\n try {\n const validatedParams = getValidatedParams(params);\n const error = deserializeError(validatedParams.error);\n\n response.result = trackError(error);\n } catch (error) {\n return end(error);\n }\n\n return end();\n}\n\n/**\n * Validates the parameters for the snap_trackEvent method.\n *\n * @param params - Parameters to validate.\n * @returns Validated parameters.\n * @throws Throws RPC error if validation fails.\n */\nfunction getValidatedParams(params: unknown): TrackErrorParameters {\n try {\n return create(params, TrackErrorParametersStruct);\n } catch (error) {\n if (error instanceof StructError) {\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n\n/**\n * Deserialize a {@link TrackableError} into a standard {@link Error} object.\n *\n * @param error - The error to deserialize.\n * @returns A standard {@link Error} object with the same properties as the\n * original {@link TrackableError}.\n */\nfunction deserializeError(error: TrackableError): Error {\n const deserializedError = new Error(error.message);\n deserializedError.name = error.name;\n deserializedError.stack = error.stack ?? undefined;\n deserializedError.cause = error.cause\n ? deserializeError(error.cause)\n : undefined;\n\n return deserializedError;\n}\n"]}
|
|
@@ -49,8 +49,8 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
49
49
|
label: string;
|
|
50
50
|
variant?: "default" | "critical" | "warning" | undefined;
|
|
51
51
|
} | {
|
|
52
|
-
name: string;
|
|
53
52
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
53
|
+
name: string;
|
|
54
54
|
value?: string | undefined;
|
|
55
55
|
label?: string | undefined;
|
|
56
56
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -59,15 +59,15 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
59
59
|
} | {
|
|
60
60
|
value: string;
|
|
61
61
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
62
|
-
name?: string | undefined;
|
|
63
62
|
variant?: "primary" | "secondary" | undefined;
|
|
63
|
+
name?: string | undefined;
|
|
64
64
|
buttonType?: "button" | "submit" | undefined;
|
|
65
65
|
} | {
|
|
66
|
-
name: string;
|
|
67
66
|
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
67
|
+
name: string;
|
|
68
68
|
children: ({
|
|
69
|
-
name: string;
|
|
70
69
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
70
|
+
name: string;
|
|
71
71
|
value?: string | undefined;
|
|
72
72
|
label?: string | undefined;
|
|
73
73
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -76,8 +76,8 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
76
76
|
} | {
|
|
77
77
|
value: string;
|
|
78
78
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
79
|
-
name?: string | undefined;
|
|
80
79
|
variant?: "primary" | "secondary" | undefined;
|
|
80
|
+
name?: string | undefined;
|
|
81
81
|
buttonType?: "button" | "submit" | undefined;
|
|
82
82
|
})[];
|
|
83
83
|
} | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
@@ -137,8 +137,8 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
137
137
|
label: string;
|
|
138
138
|
variant?: "default" | "critical" | "warning" | undefined;
|
|
139
139
|
} | {
|
|
140
|
-
name: string;
|
|
141
140
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
141
|
+
name: string;
|
|
142
142
|
value?: string | undefined;
|
|
143
143
|
label?: string | undefined;
|
|
144
144
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -147,15 +147,15 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
147
147
|
} | {
|
|
148
148
|
value: string;
|
|
149
149
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
150
|
-
name?: string | undefined;
|
|
151
150
|
variant?: "primary" | "secondary" | undefined;
|
|
151
|
+
name?: string | undefined;
|
|
152
152
|
buttonType?: "button" | "submit" | undefined;
|
|
153
153
|
} | {
|
|
154
|
-
name: string;
|
|
155
154
|
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
155
|
+
name: string;
|
|
156
156
|
children: ({
|
|
157
|
-
name: string;
|
|
158
157
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
158
|
+
name: string;
|
|
159
159
|
value?: string | undefined;
|
|
160
160
|
label?: string | undefined;
|
|
161
161
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -164,8 +164,8 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
164
164
|
} | {
|
|
165
165
|
value: string;
|
|
166
166
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
167
|
-
name?: string | undefined;
|
|
168
167
|
variant?: "primary" | "secondary" | undefined;
|
|
168
|
+
name?: string | undefined;
|
|
169
169
|
buttonType?: "button" | "submit" | undefined;
|
|
170
170
|
})[];
|
|
171
171
|
} | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
@@ -49,8 +49,8 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
49
49
|
label: string;
|
|
50
50
|
variant?: "default" | "critical" | "warning" | undefined;
|
|
51
51
|
} | {
|
|
52
|
-
name: string;
|
|
53
52
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
53
|
+
name: string;
|
|
54
54
|
value?: string | undefined;
|
|
55
55
|
label?: string | undefined;
|
|
56
56
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -59,15 +59,15 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
59
59
|
} | {
|
|
60
60
|
value: string;
|
|
61
61
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
62
|
-
name?: string | undefined;
|
|
63
62
|
variant?: "primary" | "secondary" | undefined;
|
|
63
|
+
name?: string | undefined;
|
|
64
64
|
buttonType?: "button" | "submit" | undefined;
|
|
65
65
|
} | {
|
|
66
|
-
name: string;
|
|
67
66
|
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
67
|
+
name: string;
|
|
68
68
|
children: ({
|
|
69
|
-
name: string;
|
|
70
69
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
70
|
+
name: string;
|
|
71
71
|
value?: string | undefined;
|
|
72
72
|
label?: string | undefined;
|
|
73
73
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -76,8 +76,8 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
76
76
|
} | {
|
|
77
77
|
value: string;
|
|
78
78
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
79
|
-
name?: string | undefined;
|
|
80
79
|
variant?: "primary" | "secondary" | undefined;
|
|
80
|
+
name?: string | undefined;
|
|
81
81
|
buttonType?: "button" | "submit" | undefined;
|
|
82
82
|
})[];
|
|
83
83
|
} | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
@@ -137,8 +137,8 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
137
137
|
label: string;
|
|
138
138
|
variant?: "default" | "critical" | "warning" | undefined;
|
|
139
139
|
} | {
|
|
140
|
-
name: string;
|
|
141
140
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
141
|
+
name: string;
|
|
142
142
|
value?: string | undefined;
|
|
143
143
|
label?: string | undefined;
|
|
144
144
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -147,15 +147,15 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
147
147
|
} | {
|
|
148
148
|
value: string;
|
|
149
149
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
150
|
-
name?: string | undefined;
|
|
151
150
|
variant?: "primary" | "secondary" | undefined;
|
|
151
|
+
name?: string | undefined;
|
|
152
152
|
buttonType?: "button" | "submit" | undefined;
|
|
153
153
|
} | {
|
|
154
|
-
name: string;
|
|
155
154
|
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
155
|
+
name: string;
|
|
156
156
|
children: ({
|
|
157
|
-
name: string;
|
|
158
157
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
158
|
+
name: string;
|
|
159
159
|
value?: string | undefined;
|
|
160
160
|
label?: string | undefined;
|
|
161
161
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -164,8 +164,8 @@ declare const UpdateInterfaceParametersStruct: import("@metamask/superstruct").S
|
|
|
164
164
|
} | {
|
|
165
165
|
value: string;
|
|
166
166
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
167
|
-
name?: string | undefined;
|
|
168
167
|
variant?: "primary" | "secondary" | undefined;
|
|
168
|
+
name?: string | undefined;
|
|
169
169
|
buttonType?: "button" | "submit" | undefined;
|
|
170
170
|
})[];
|
|
171
171
|
} | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
@@ -112,8 +112,8 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
112
112
|
label: string;
|
|
113
113
|
variant?: "default" | "critical" | "warning" | undefined;
|
|
114
114
|
} | {
|
|
115
|
-
name: string;
|
|
116
115
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
116
|
+
name: string;
|
|
117
117
|
value?: string | undefined;
|
|
118
118
|
label?: string | undefined;
|
|
119
119
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -122,15 +122,15 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
122
122
|
} | {
|
|
123
123
|
value: string;
|
|
124
124
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
125
|
-
name?: string | undefined;
|
|
126
125
|
variant?: "primary" | "secondary" | undefined;
|
|
126
|
+
name?: string | undefined;
|
|
127
127
|
buttonType?: "button" | "submit" | undefined;
|
|
128
128
|
} | {
|
|
129
|
-
name: string;
|
|
130
129
|
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
130
|
+
name: string;
|
|
131
131
|
children: ({
|
|
132
|
-
name: string;
|
|
133
132
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
133
|
+
name: string;
|
|
134
134
|
value?: string | undefined;
|
|
135
135
|
label?: string | undefined;
|
|
136
136
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -139,8 +139,8 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
139
139
|
} | {
|
|
140
140
|
value: string;
|
|
141
141
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
142
|
-
name?: string | undefined;
|
|
143
142
|
variant?: "primary" | "secondary" | undefined;
|
|
143
|
+
name?: string | undefined;
|
|
144
144
|
buttonType?: "button" | "submit" | undefined;
|
|
145
145
|
})[];
|
|
146
146
|
} | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
@@ -202,8 +202,8 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
202
202
|
label: string;
|
|
203
203
|
variant?: "default" | "critical" | "warning" | undefined;
|
|
204
204
|
} | {
|
|
205
|
-
name: string;
|
|
206
205
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
206
|
+
name: string;
|
|
207
207
|
value?: string | undefined;
|
|
208
208
|
label?: string | undefined;
|
|
209
209
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -212,15 +212,15 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
212
212
|
} | {
|
|
213
213
|
value: string;
|
|
214
214
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
215
|
-
name?: string | undefined;
|
|
216
215
|
variant?: "primary" | "secondary" | undefined;
|
|
216
|
+
name?: string | undefined;
|
|
217
217
|
buttonType?: "button" | "submit" | undefined;
|
|
218
218
|
} | {
|
|
219
|
-
name: string;
|
|
220
219
|
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
220
|
+
name: string;
|
|
221
221
|
children: ({
|
|
222
|
-
name: string;
|
|
223
222
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
223
|
+
name: string;
|
|
224
224
|
value?: string | undefined;
|
|
225
225
|
label?: string | undefined;
|
|
226
226
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -229,8 +229,8 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
229
229
|
} | {
|
|
230
230
|
value: string;
|
|
231
231
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
232
|
-
name?: string | undefined;
|
|
233
232
|
variant?: "primary" | "secondary" | undefined;
|
|
233
|
+
name?: string | undefined;
|
|
234
234
|
buttonType?: "button" | "submit" | undefined;
|
|
235
235
|
})[];
|
|
236
236
|
} | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
@@ -293,8 +293,8 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
293
293
|
label: string;
|
|
294
294
|
variant?: "default" | "critical" | "warning" | undefined;
|
|
295
295
|
} | {
|
|
296
|
-
name: string;
|
|
297
296
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
297
|
+
name: string;
|
|
298
298
|
value?: string | undefined;
|
|
299
299
|
label?: string | undefined;
|
|
300
300
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -303,15 +303,15 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
303
303
|
} | {
|
|
304
304
|
value: string;
|
|
305
305
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
306
|
-
name?: string | undefined;
|
|
307
306
|
variant?: "primary" | "secondary" | undefined;
|
|
307
|
+
name?: string | undefined;
|
|
308
308
|
buttonType?: "button" | "submit" | undefined;
|
|
309
309
|
} | {
|
|
310
|
-
name: string;
|
|
311
310
|
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
311
|
+
name: string;
|
|
312
312
|
children: ({
|
|
313
|
-
name: string;
|
|
314
313
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
314
|
+
name: string;
|
|
315
315
|
value?: string | undefined;
|
|
316
316
|
label?: string | undefined;
|
|
317
317
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -320,8 +320,8 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
320
320
|
} | {
|
|
321
321
|
value: string;
|
|
322
322
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
323
|
-
name?: string | undefined;
|
|
324
323
|
variant?: "primary" | "secondary" | undefined;
|
|
324
|
+
name?: string | undefined;
|
|
325
325
|
buttonType?: "button" | "submit" | undefined;
|
|
326
326
|
})[];
|
|
327
327
|
} | import("@metamask/snaps-sdk/jsx").SnapElement<{
|
|
@@ -382,8 +382,8 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
382
382
|
label: string;
|
|
383
383
|
variant?: "default" | "critical" | "warning" | undefined;
|
|
384
384
|
} | {
|
|
385
|
-
name: string;
|
|
386
385
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
386
|
+
name: string;
|
|
387
387
|
value?: string | undefined;
|
|
388
388
|
label?: string | undefined;
|
|
389
389
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -392,15 +392,15 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
392
392
|
} | {
|
|
393
393
|
value: string;
|
|
394
394
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
395
|
-
name?: string | undefined;
|
|
396
395
|
variant?: "primary" | "secondary" | undefined;
|
|
396
|
+
name?: string | undefined;
|
|
397
397
|
buttonType?: "button" | "submit" | undefined;
|
|
398
398
|
} | {
|
|
399
|
-
name: string;
|
|
400
399
|
type: import("@metamask/snaps-sdk").NodeType.Form;
|
|
400
|
+
name: string;
|
|
401
401
|
children: ({
|
|
402
|
-
name: string;
|
|
403
402
|
type: import("@metamask/snaps-sdk").NodeType.Input;
|
|
403
|
+
name: string;
|
|
404
404
|
value?: string | undefined;
|
|
405
405
|
label?: string | undefined;
|
|
406
406
|
inputType?: "number" | "text" | "password" | undefined;
|
|
@@ -409,8 +409,8 @@ declare const DialogParametersStruct: import("@metamask/superstruct").Struct<{
|
|
|
409
409
|
} | {
|
|
410
410
|
value: string;
|
|
411
411
|
type: import("@metamask/snaps-sdk").NodeType.Button;
|
|
412
|
-
name?: string | undefined;
|
|
413
412
|
variant?: "primary" | "secondary" | undefined;
|
|
413
|
+
name?: string | undefined;
|
|
414
414
|
buttonType?: "button" | "submit" | undefined;
|
|
415
415
|
})[];
|
|
416
416
|
} | import("@metamask/snaps-sdk/jsx").SnapElement<{
|