@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
50 lines • 2.62 kB
text/typescript
import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from "@metamask/permission-controller";
import { PermissionType } from "@metamask/permission-controller";
import type { GetLocaleResult, GetPreferencesResult } from "@metamask/snaps-sdk";
import type { NonEmptyArray } from "@metamask/utils";
import type { MethodHooksObject } from "../utils.cjs";
declare const methodName = "snap_getLocale";
export type GetLocaleMethodHooks = {
getPreferences: () => GetPreferencesResult;
};
type SpecificationBuilderOptions = {
allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
methodHooks: GetLocaleMethodHooks;
};
type Specification = ValidPermissionSpecification<{
permissionType: PermissionType.RestrictedMethod;
targetName: typeof methodName;
methodImplementation: ReturnType<typeof getImplementation>;
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
}>;
/**
* The specification builder for the `snap_getLocale` permission.
* `snap_getLocale` allows snaps to get the user selected locale.
*
* @param options - The specification builder options.
* @param options.allowedCaveats - The optional allowed caveats for the permission.
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
* @returns The specification for the `snap_getLocale` permission.
* @deprecated - To be removed in favor of `snap_getPreferences`.
*/
export declare const specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, Specification>;
export declare const getLocaleBuilder: Readonly<{
readonly targetName: "snap_getLocale";
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, {
permissionType: PermissionType.RestrictedMethod;
targetName: typeof methodName;
methodImplementation: ReturnType<typeof getImplementation>;
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
}>;
readonly methodHooks: MethodHooksObject<GetLocaleMethodHooks>;
}>;
/**
* Builds the method implementation for `snap_getLocale`.
*
* @param hooks - The RPC method hooks.
* @param hooks.getPreferences - A function that returns the user selected preferences.
* @returns The user selected locale.
*/
export declare function getImplementation({ getPreferences }: GetLocaleMethodHooks): (_args: RestrictedMethodOptions<RestrictedMethodParameters>) => Promise<GetLocaleResult>;
export {};
//# sourceMappingURL=getLocale.d.cts.map