@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
105 lines • 5.94 kB
text/typescript
import type { CancelBackgroundEventParams, CancelBackgroundEventResult } from "./cancel-background-event.cjs";
import type { ClearStateParams, ClearStateResult } from "./clear-state.cjs";
import type { CreateInterfaceParams, CreateInterfaceResult } from "./create-interface.cjs";
import type { DialogParams, DialogResult } from "./dialog.cjs";
import type { GetBackgroundEventsParams, GetBackgroundEventsResult } from "./get-background-events.cjs";
import type { GetBip32EntropyParams, GetBip32EntropyResult } from "./get-bip32-entropy.cjs";
import type { GetBip32PublicKeyParams, GetBip32PublicKeyResult } from "./get-bip32-public-key.cjs";
import type { GetBip44EntropyParams, GetBip44EntropyResult } from "./get-bip44-entropy.cjs";
import type { GetClientStatusParams, GetClientStatusResult } from "./get-client-status.cjs";
import type { GetCurrencyRateParams, GetCurrencyRateResult } from "./get-currency-rate.cjs";
import type { GetEntropyParams, GetEntropyResult } from "./get-entropy.cjs";
import type { GetFileParams, GetFileResult } from "./get-file.cjs";
import type { GetInterfaceContextParams, GetInterfaceContextResult } from "./get-interface-context.cjs";
import type { GetInterfaceStateParams, GetInterfaceStateResult } from "./get-interface-state.cjs";
import type { GetLocaleParams, GetLocaleResult } from "./get-locale.cjs";
import type { GetPreferencesParams, GetPreferencesResult } from "./get-preferences.cjs";
import type { GetSnapsParams, GetSnapsResult } from "./get-snaps.cjs";
import type { GetStateParams, GetStateResult } from "./get-state.cjs";
import type { InvokeKeyringParams, InvokeKeyringResult } from "./invoke-keyring.cjs";
import type { InvokeSnapParams, InvokeSnapResult } from "./invoke-snap.cjs";
import type { ListEntropySourcesParams, ListEntropySourcesResult } from "./list-entropy-sources.cjs";
import type { ManageAccountsParams, ManageAccountsResult } from "./manage-accounts.cjs";
import type { ManageStateParams, ManageStateResult } from "./manage-state.cjs";
import type { NotifyParams, NotifyResult } from "./notify.cjs";
import type { RequestSnapsParams, RequestSnapsResult } from "./request-snaps.cjs";
import type { ResolveInterfaceParams, ResolveInterfaceResult } from "./resolve-interface.cjs";
import type { ScheduleBackgroundEventParams, ScheduleBackgroundEventResult } from "./schedule-background-event.cjs";
import type { SetStateParams, SetStateResult } from "./set-state.cjs";
import type { UpdateInterfaceParams, UpdateInterfaceResult } from "./update-interface.cjs";
import type { Method } from "../../internals/index.cjs";
/**
* 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.cts.map