UNPKG

@metamask/snaps-rpc-methods

Version:
51 lines 2.37 kB
import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine"; import type { Messenger } from "@metamask/messenger"; import type { TrackableError, TrackErrorParams, TrackErrorResult } from "@metamask/snaps-sdk"; import type { InferMatching } from "@metamask/snaps-utils"; import type { PendingJsonRpcResponse } from "@metamask/utils"; import type { JsonRpcRequestWithOrigin, SnapControllerGetSnapAction } from "../types.mjs"; import type { MethodHooksObject } from "../utils.mjs"; export type TrackErrorMethodHooks = { /** * Track an error. * * @param error - The error object to track. * @returns The ID of the tracked error, as returned by the Sentry instance * in the client. */ trackError: (error: Error) => string; }; export type TrackErrorMethodActions = SnapControllerGetSnapAction; declare const TrackErrorParametersStruct: import("@metamask/superstruct").Struct<{ error: TrackableError; }, { error: import("@metamask/superstruct").Struct<TrackableError, unknown>; }>; export type TrackErrorParameters = InferMatching<typeof TrackErrorParametersStruct, TrackErrorParams>; /** * Handler for the `snap_trackError` method. * * @internal */ export declare const trackErrorHandler: { implementation: typeof getTrackErrorImplementation; hookNames: MethodHooksObject<TrackErrorMethodHooks>; actionNames: "SnapController:getSnap"[]; }; /** * The `snap_trackError` method implementation. This method allows preinstalled * Snaps to send errors to the Sentry instance in the client for tracking. * * @param request - The JSON-RPC request object. * @param response - The JSON-RPC response object. * @param _next - The `json-rpc-engine` "next" callback. Not used by this * function. * @param end - The `json-rpc-engine` "end" callback. * @param hooks - The RPC method hooks. * @param hooks.trackError - The hook function to track an error. * @param messenger - The messenger used to call controller actions. * @returns Nothing. */ declare function getTrackErrorImplementation(request: JsonRpcRequestWithOrigin<TrackErrorParameters>, response: PendingJsonRpcResponse<TrackErrorResult>, _next: unknown, end: JsonRpcEngineEndCallback, { trackError }: TrackErrorMethodHooks, messenger: Messenger<string, TrackErrorMethodActions>): void; export {}; //# sourceMappingURL=trackError.d.mts.map