UNPKG

@metamask/snaps-sdk

Version:

A library containing the core functionality for building MetaMask Snaps

105 lines 5.94 kB
import type { CancelBackgroundEventParams, CancelBackgroundEventResult } from "./cancel-background-event.mjs"; import type { ClearStateParams, ClearStateResult } from "./clear-state.mjs"; import type { CreateInterfaceParams, CreateInterfaceResult } from "./create-interface.mjs"; import type { DialogParams, DialogResult } from "./dialog.mjs"; import type { GetBackgroundEventsParams, GetBackgroundEventsResult } from "./get-background-events.mjs"; import type { GetBip32EntropyParams, GetBip32EntropyResult } from "./get-bip32-entropy.mjs"; import type { GetBip32PublicKeyParams, GetBip32PublicKeyResult } from "./get-bip32-public-key.mjs"; import type { GetBip44EntropyParams, GetBip44EntropyResult } from "./get-bip44-entropy.mjs"; import type { GetClientStatusParams, GetClientStatusResult } from "./get-client-status.mjs"; import type { GetCurrencyRateParams, GetCurrencyRateResult } from "./get-currency-rate.mjs"; import type { GetEntropyParams, GetEntropyResult } from "./get-entropy.mjs"; import type { GetFileParams, GetFileResult } from "./get-file.mjs"; import type { GetInterfaceContextParams, GetInterfaceContextResult } from "./get-interface-context.mjs"; import type { GetInterfaceStateParams, GetInterfaceStateResult } from "./get-interface-state.mjs"; import type { GetLocaleParams, GetLocaleResult } from "./get-locale.mjs"; import type { GetPreferencesParams, GetPreferencesResult } from "./get-preferences.mjs"; import type { GetSnapsParams, GetSnapsResult } from "./get-snaps.mjs"; import type { GetStateParams, GetStateResult } from "./get-state.mjs"; import type { InvokeKeyringParams, InvokeKeyringResult } from "./invoke-keyring.mjs"; import type { InvokeSnapParams, InvokeSnapResult } from "./invoke-snap.mjs"; import type { ListEntropySourcesParams, ListEntropySourcesResult } from "./list-entropy-sources.mjs"; import type { ManageAccountsParams, ManageAccountsResult } from "./manage-accounts.mjs"; import type { ManageStateParams, ManageStateResult } from "./manage-state.mjs"; import type { NotifyParams, NotifyResult } from "./notify.mjs"; import type { RequestSnapsParams, RequestSnapsResult } from "./request-snaps.mjs"; import type { ResolveInterfaceParams, ResolveInterfaceResult } from "./resolve-interface.mjs"; import type { ScheduleBackgroundEventParams, ScheduleBackgroundEventResult } from "./schedule-background-event.mjs"; import type { SetStateParams, SetStateResult } from "./set-state.mjs"; import type { UpdateInterfaceParams, UpdateInterfaceResult } from "./update-interface.mjs"; import type { Method } from "../../internals/index.mjs"; /** * The methods that are available to the Snap. Each method is a tuple of the * request parameters and the result returned by the method. */ export type SnapMethods = { snap_clearState: [ClearStateParams, ClearStateResult]; snap_dialog: [DialogParams, DialogResult]; snap_getBip32Entropy: [GetBip32EntropyParams, GetBip32EntropyResult]; snap_getBip32PublicKey: [GetBip32PublicKeyParams, GetBip32PublicKeyResult]; snap_getBip44Entropy: [GetBip44EntropyParams, GetBip44EntropyResult]; snap_getClientStatus: [GetClientStatusParams, GetClientStatusResult]; snap_getCurrencyRate: [GetCurrencyRateParams, GetCurrencyRateResult]; snap_getEntropy: [GetEntropyParams, GetEntropyResult]; snap_getFile: [GetFileParams, GetFileResult]; snap_getLocale: [GetLocaleParams, GetLocaleResult]; snap_getPreferences: [GetPreferencesParams, GetPreferencesResult]; snap_getState: [GetStateParams, GetStateResult]; snap_listEntropySources: [ListEntropySourcesParams, ListEntropySourcesResult]; snap_manageAccounts: [ManageAccountsParams, ManageAccountsResult]; snap_manageState: [ManageStateParams, ManageStateResult]; snap_notify: [NotifyParams, NotifyResult]; snap_scheduleBackgroundEvent: [ ScheduleBackgroundEventParams, ScheduleBackgroundEventResult ]; snap_cancelBackgroundEvent: [ CancelBackgroundEventParams, CancelBackgroundEventResult ]; snap_getBackgroundEvents: [ GetBackgroundEventsParams, GetBackgroundEventsResult ]; snap_createInterface: [CreateInterfaceParams, CreateInterfaceResult]; snap_updateInterface: [UpdateInterfaceParams, UpdateInterfaceResult]; snap_getInterfaceState: [GetInterfaceStateParams, GetInterfaceStateResult]; snap_getInterfaceContext: [ GetInterfaceContextParams, GetInterfaceContextResult ]; snap_resolveInterface: [ResolveInterfaceParams, ResolveInterfaceResult]; snap_setState: [SetStateParams, SetStateResult]; wallet_getSnaps: [GetSnapsParams, GetSnapsResult]; wallet_invokeKeyring: [InvokeKeyringParams, InvokeKeyringResult]; wallet_invokeSnap: [InvokeSnapParams, InvokeSnapResult]; wallet_snap: [InvokeSnapParams, InvokeSnapResult]; wallet_requestSnaps: [RequestSnapsParams, RequestSnapsResult]; }; /** * The request function that is available to the Snap. It takes a request * object and returns a promise that resolves to the result of the request. * * @param request - The request object. * @param request.method - The method to call. * @param request.params - The parameters to pass to the method. This is * inferred from the method, based on the {@link SnapMethods} type, and may be * optional. * @returns A promise that resolves to the result of the request. This is * inferred from the request method, based on the {@link SnapMethods} type. * @example * // Get the user's locale * const result = await request({ * method: 'snap_getLocale', * }); * @example * // Get a file * const result = await request({ * method: 'snap_getFile', * params: { * path: 'foo/bar.txt', * }, * }); */ export type RequestFunction = <MethodName extends keyof SnapMethods>(request: Method<MethodName, SnapMethods[MethodName][0]>) => Promise<SnapMethods[MethodName][1]>; //# sourceMappingURL=methods.d.mts.map