@metamask/keyring-internal-snap-client
Version:
MetaMask Keyring Snap internal clients
56 lines • 2.4 kB
text/typescript
import type { RestrictedMessenger } from "@metamask/base-controller";
import type { KeyringRequestV1, KeyringResponseV1 } from "@metamask/keyring-internal-api";
import { KeyringClient } from "@metamask/keyring-snap-client";
import type { HandleSnapRequest } from "@metamask/snaps-controllers";
import type { SnapId } from "@metamask/snaps-sdk";
import type { HandlerType } from "@metamask/snaps-utils";
type AllowedActions = HandleSnapRequest;
/**
* A restricted-`Messenger` used by `KeyringInternalSnapClient` to dispatch
* internal Snap requests.
*/
export type KeyringInternalSnapClientMessenger = RestrictedMessenger<'KeyringInternalSnapClient', AllowedActions, never, AllowedActions['type'], never>;
/**
* A `KeyringClient` that allows the communication with a Snap through a
* `Messenger`.
*/
export declare class KeyringInternalSnapClient extends KeyringClient {
#private;
/**
* Create a new instance of `KeyringInternalSnapClient`.
*
* The `handlerType` argument has a hard-coded default `string` value instead
* of a `HandlerType` value to prevent the `@metamask/snaps-utils` module
* from being required at runtime.
*
* @param args - Constructor arguments.
* @param args.messenger - The `KeyringInternalSnapClientMessenger` instance to use.
* @param args.snapId - The ID of the Snap to use (default: `'undefined'`).
* @param args.origin - The sender's origin (default: `'metamask'`).
* @param args.handler - The handler type (default: `'onKeyringRequest'`).
*/
constructor({ messenger, snapId, origin, handler, }: {
messenger: KeyringInternalSnapClientMessenger;
snapId?: SnapId;
origin?: string;
handler?: HandlerType;
});
/**
* Create a new instance of `KeyringInternalSnapClient` with the specified
* `snapId`.
*
* @param snapId - The ID of the Snap to use in the new instance.
* @returns A new instance of `KeyringInternalSnapClient` with the
* specified Snap ID.
*/
withSnapId(snapId: SnapId): KeyringInternalSnapClient;
/**
* Submit a keyring request v1 (with no `origin`).
*
* @param request - Keyring request.
* @returns Keyring request's response.
*/
submitRequestV1(request: KeyringRequestV1): Promise<KeyringResponseV1>;
}
export {};
//# sourceMappingURL=KeyringInternalSnapClient.d.cts.map