@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
53 lines • 2.51 kB
text/typescript
import type { JsonRpcEngineEndCallback } from "@metamask/json-rpc-engine";
import type { Messenger } from "@metamask/messenger";
import type { PermissionControllerHasPermissionAction } from "@metamask/permission-controller";
import type { CancelBackgroundEventParams, CancelBackgroundEventResult } from "@metamask/snaps-sdk";
import { type InferMatching } from "@metamask/snaps-utils";
import { type PendingJsonRpcResponse } from "@metamask/utils";
import type { CronjobControllerCancelAction, JsonRpcRequestWithOrigin } from "../types.cjs";
export type CancelBackgroundEventMethodActions = PermissionControllerHasPermissionAction | CronjobControllerCancelAction;
/**
* Cancel a background event created by
* [`snap_scheduleBackgroundEvent`](https://docs.metamask.io/snaps/reference/snaps-api/snap_schedulebackgroundevent).
*
* @example
* ```ts
* const id = await snap.request({
* method: 'snap_scheduleBackgroundEvent',
* params: {
* // ...
* },
* });
*
* // Later, when you want to cancel the background event:
* snap.request({
* method: 'snap_cancelBackgroundEvent',
* params: { id },
* });
* ```
*/
export declare const cancelBackgroundEventHandler: {
implementation: typeof getCancelBackgroundEventImplementation;
actionNames: ("CronjobController:cancel" | "PermissionController:hasPermission")[];
};
declare const CancelBackgroundEventsParametersStruct: import("@metamask/superstruct").Struct<{
id: string;
}, {
id: import("@metamask/superstruct").Struct<string, null>;
}>;
export type CancelBackgroundEventParameters = InferMatching<typeof CancelBackgroundEventsParametersStruct, CancelBackgroundEventParams>;
/**
* The `snap_cancelBackgroundEvent` method implementation.
*
* @param req - The JSON-RPC request object.
* @param res - 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. Not used by this function.
* @param messenger - The messenger used to call controller actions.
* @returns Nothing.
*/
declare function getCancelBackgroundEventImplementation(req: JsonRpcRequestWithOrigin<CancelBackgroundEventParameters>, res: PendingJsonRpcResponse<CancelBackgroundEventResult>, _next: unknown, end: JsonRpcEngineEndCallback, _hooks: never, messenger: Messenger<string, CancelBackgroundEventMethodActions>): Promise<void>;
export {};
//# sourceMappingURL=cancelBackgroundEvent.d.cts.map