@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
71 lines • 3.69 kB
text/typescript
import type { CryptographicFunctions } from "@metamask/key-tree";
import type { PermissionSpecificationBuilder, PermissionValidatorConstraint, RestrictedMethodOptions } from "@metamask/permission-controller";
import { PermissionType } from "@metamask/permission-controller";
import type { GetBip32EntropyParams, GetBip32EntropyResult } from "@metamask/snaps-sdk";
import type { NonEmptyArray } from "@metamask/utils";
import type { MethodHooksObject } from "../utils.mjs";
declare const targetName = "snap_getBip32Entropy";
export type GetBip32EntropyMethodHooks = {
/**
* 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 GetBip32EntropySpecificationBuilderOptions = {
methodHooks: GetBip32EntropyMethodHooks;
};
export declare const getBip32EntropyBuilder: Readonly<{
readonly targetName: "snap_getBip32Entropy";
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, GetBip32EntropySpecificationBuilderOptions, {
permissionType: PermissionType.RestrictedMethod;
targetName: typeof targetName;
methodImplementation: ReturnType<typeof getBip32EntropyImplementation>;
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
validator: PermissionValidatorConstraint;
}>;
readonly methodHooks: MethodHooksObject<GetBip32EntropyMethodHooks>;
}>;
/**
* Builds the method implementation for `snap_getBip32Entropy`.
*
* @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 `JsonSLIP10Node`.
* @throws If the params are invalid.
*/
export declare function getBip32EntropyImplementation({ getMnemonic, getMnemonicSeed, getUnlockPromise, getClientCryptography, }: GetBip32EntropyMethodHooks): (args: RestrictedMethodOptions<GetBip32EntropyParams>) => Promise<GetBip32EntropyResult>;
export {};
//# sourceMappingURL=getBip32Entropy.d.mts.map