UNPKG

@metamask/snaps-rpc-methods

Version:
82 lines 4.33 kB
import type { CryptographicFunctions } from "@metamask/key-tree"; import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from "@metamask/permission-controller"; import { PermissionType } from "@metamask/permission-controller"; import type { GetBip32PublicKeyParams, GetBip32PublicKeyResult } from "@metamask/snaps-sdk"; import type { NonEmptyArray } from "@metamask/utils"; import type { MethodHooksObject } from "../utils.cjs"; declare const targetName = "snap_getBip32PublicKey"; export type GetBip32PublicKeyMethodHooks = { /** * Get the mnemonic of the provided source. If no source is provided, the * mnemonic of the primary keyring will be returned. * * @param source - The optional ID of the source to get the mnemonic of. * @returns The mnemonic of the provided source, or the default source if no * source is provided. */ getMnemonic: (source?: string | undefined) => Promise<Uint8Array>; /** * Get the mnemonic seed of the provided source. If no source is provided, the * mnemonic seed of the primary keyring will be returned. * * @param source - The optional ID of the source to get the mnemonic of. * @returns The mnemonic seed of the provided source, or the default source if no * source is provided. */ getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>; /** * Waits for the extension to be unlocked. * * @returns A promise that resolves once the extension is unlocked. */ getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>; /** * Get the cryptographic functions to use for the client. This may return an * empty object or `undefined` to fall back to the default cryptographic * functions. * * @returns The cryptographic functions to use for the client. */ getClientCryptography: () => CryptographicFunctions | undefined; }; type GetBip32PublicKeySpecificationBuilderOptions = { methodHooks: GetBip32PublicKeyMethodHooks; }; export declare const Bip32PublicKeyArgsStruct: import("@metamask/superstruct").Struct<{ curve: "secp256k1" | "ed25519" | "ed25519Bip32"; path: string[]; source?: string | undefined; compressed?: boolean | undefined; }, { path: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>; curve: import("@metamask/superstruct").Describe<"secp256k1" | "ed25519" | "ed25519Bip32">; compressed: import("@metamask/superstruct").Struct<boolean | undefined, null>; source: import("@metamask/superstruct").Struct<string | undefined, null>; }>; export declare const getBip32PublicKeyBuilder: Readonly<{ readonly targetName: "snap_getBip32PublicKey"; readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, GetBip32PublicKeySpecificationBuilderOptions, { permissionType: PermissionType.RestrictedMethod; targetName: typeof targetName; methodImplementation: ReturnType<typeof getBip32PublicKeyImplementation>; allowedCaveats: Readonly<NonEmptyArray<string>> | null; validator: PermissionValidatorConstraint; }>; readonly methodHooks: MethodHooksObject<GetBip32PublicKeyMethodHooks>; }>; /** * Builds the method implementation for `snap_getBip32PublicKey`. * * @param hooks - The RPC method hooks. * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user. * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed of the user. * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked * and prompts the user to unlock their MetaMask if it is locked. * @param hooks.getClientCryptography - A function to retrieve the cryptographic * functions to use for the client. * @returns The method implementation which returns a public key. * @throws If the params are invalid. */ export declare function getBip32PublicKeyImplementation({ getMnemonic, getMnemonicSeed, getUnlockPromise, getClientCryptography, }: GetBip32PublicKeyMethodHooks): (args: RestrictedMethodOptions<GetBip32PublicKeyParams>) => Promise<GetBip32PublicKeyResult>; export {}; //# sourceMappingURL=getBip32PublicKey.d.cts.map