UNPKG

@metamask/keyring-snap-client

Version:
47 lines 2.29 kB
import type { KeyringAccount, KeyringAccountData, KeyringRequest } from "@metamask/keyring-api"; import { KeyringRpcMethod } from "@metamask/keyring-api"; import type { Json } from "@metamask/utils"; import type { Sender } from "./KeyringClient.mjs"; import { KeyringClient } from "./KeyringClient.mjs"; /** * Convert a tuple to a union. */ type TupleToUnion<Tuple extends readonly unknown[]> = Tuple[number]; /** * Extract the method name from a RPC method name. */ type KeyringRpcMethodToMethodName<RpcMethod extends string> = RpcMethod extends `keyring_${infer Method}` ? Method : never; /** * Public methods list. */ export declare const KeyringPublicRpcMethod: readonly [KeyringRpcMethod.CreateAccount, KeyringRpcMethod.GetAccount, KeyringRpcMethod.UpdateAccount, KeyringRpcMethod.DeleteAccount, KeyringRpcMethod.ExportAccount, KeyringRpcMethod.ListAccounts, KeyringRpcMethod.FilterAccountChains, KeyringRpcMethod.GetRequest, KeyringRpcMethod.ApproveRequest, KeyringRpcMethod.RejectRequest, KeyringRpcMethod.ListRequests]; /** * Union of all public methods. */ type KeyringPublicMethod = KeyringRpcMethodToMethodName<TupleToUnion<typeof KeyringPublicRpcMethod>>; /** * A client that can be used by companion dapp. Only some keyring methods are * available with this client. */ export declare class KeyringPublicClient implements Pick<KeyringClient, KeyringPublicMethod> { #private; /** * Create a new instance of `KeyringPublicClient`. * * @param sender - The `Sender` instance to use to send requests to the snap. */ constructor(sender: Sender); createAccount(options?: Record<string, Json>): Promise<KeyringAccount>; deleteAccount(id: string): Promise<void>; listAccounts(): Promise<KeyringAccount[]>; getAccount(id: string): Promise<KeyringAccount>; getRequest(id: string): Promise<KeyringRequest>; listRequests(): Promise<KeyringRequest[]>; updateAccount(account: KeyringAccount): Promise<void>; approveRequest(id: string, data?: Record<string, Json>): Promise<void>; rejectRequest(id: string): Promise<void>; filterAccountChains(id: string, chains: string[]): Promise<string[]>; exportAccount(id: string): Promise<KeyringAccountData>; } export {}; //# sourceMappingURL=KeyringPublicClient.d.mts.map