@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
50 lines • 2.15 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 { GetBackgroundEventsParams, GetBackgroundEventsResult } from "@metamask/snaps-sdk";
import { type PendingJsonRpcResponse } from "@metamask/utils";
import type { CronjobControllerGetAction, JsonRpcRequestWithOrigin } from "../types.mjs";
export type GetBackgroundEventsMethodActions = PermissionControllerHasPermissionAction | CronjobControllerGetAction;
/**
* Get the scheduled background events for the Snap.
*
* @example
* ```ts
* const events = await snap.request({
* method: 'snap_getBackgroundEvents',
* });
* console.log(events);
* // [
* // {
* // id: 'event-1',
* // scheduledAt: 1672531200000,
* // snapId: 'npm:example-snap',
* // date: 1672531200000,
* // request: {
* // method: 'example_method',
* // params: { example: 'data' },
* // },
* // },
* // ...,
* // ]
* ```
*/
export declare const getBackgroundEventsHandler: {
implementation: typeof getGetBackgroundEventsImplementation;
actionNames: ("CronjobController:get" | "PermissionController:hasPermission")[];
};
/**
* The `snap_getBackgroundEvents` 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 An array of background events.
*/
declare function getGetBackgroundEventsImplementation(req: JsonRpcRequestWithOrigin<GetBackgroundEventsParams>, res: PendingJsonRpcResponse<GetBackgroundEventsResult>, _next: unknown, end: JsonRpcEngineEndCallback, _hooks: never, messenger: Messenger<string, GetBackgroundEventsMethodActions>): Promise<void>;
export {};
//# sourceMappingURL=getBackgroundEvents.d.mts.map