@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
60 lines • 3.08 kB
text/typescript
import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine";
import type { Messenger } from "@metamask/messenger";
import type { StartTraceParams, TraceContext, TraceRequest } from "@metamask/snaps-sdk";
import type { InferMatching } from "@metamask/snaps-utils";
import type { PendingJsonRpcResponse } from "@metamask/utils";
import type { JsonRpcRequestWithOrigin, SnapControllerGetSnapAction } from "../types.cjs";
import type { MethodHooksObject } from "../utils.cjs";
export type StartTraceMethodHooks = {
/**
* Start a performance trace in Sentry.
*
* @param request - The trace request object.
* @returns The performance trace context.
*/
startTrace: (request: TraceRequest) => TraceContext;
};
export type StartTraceMethodActions = SnapControllerGetSnapAction;
declare const StartTraceParametersStruct: import("@metamask/superstruct").Struct<{
name: string;
id?: string | undefined;
data?: Record<string, string | number | boolean> | undefined;
parentContext?: import("@metamask/snaps-sdk").Json | undefined;
startTime?: number | undefined;
tags?: Record<string, string | number | boolean> | undefined;
}, {
data: import("@metamask/superstruct").ExactOptionalStruct<Record<string, string | number | boolean>, null>;
id: import("@metamask/superstruct").ExactOptionalStruct<string, null>;
name: import("@metamask/superstruct").Struct<string, null>;
parentContext: import("@metamask/superstruct").ExactOptionalStruct<import("@metamask/snaps-sdk").Json, unknown>;
startTime: import("@metamask/superstruct").ExactOptionalStruct<number, null>;
tags: import("@metamask/superstruct").ExactOptionalStruct<Record<string, string | number | boolean>, null>;
}>;
export type StartTraceParameters = InferMatching<typeof StartTraceParametersStruct, StartTraceParams>;
/**
* Handler for the `snap_startTrace` method.
*
* @internal
*/
export declare const startTraceHandler: {
implementation: typeof getStartTraceImplementation;
hookNames: MethodHooksObject<StartTraceMethodHooks>;
actionNames: "SnapController:getSnap"[];
};
/**
* The `snap_startTrace` method implementation. This method is used to start a
* performance trace in Sentry. It is only available to preinstalled Snaps.
*
* @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.startTrace - The hook function to start a performance trace.
* @param messenger - The messenger used to call controller actions.
* @returns Nothing.
*/
declare function getStartTraceImplementation(request: JsonRpcRequestWithOrigin<StartTraceParameters>, response: PendingJsonRpcResponse, _next: unknown, end: JsonRpcEngineEndCallback, { startTrace }: StartTraceMethodHooks, messenger: Messenger<string, StartTraceMethodActions>): void;
export {};
//# sourceMappingURL=startTrace.d.cts.map