{"version":3,"file":"methods.cjs","sourceRoot":"","sources":["../../../src/types/methods/methods.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n  CancelBackgroundEventParams,\n  CancelBackgroundEventResult,\n} from './cancel-background-event';\nimport type { ClearStateParams, ClearStateResult } from './clear-state';\nimport type {\n  CloseWebSocketParams,\n  CloseWebSocketResult,\n} from './close-web-socket';\nimport type {\n  CreateInterfaceParams,\n  CreateInterfaceResult,\n} from './create-interface';\nimport type { DialogParams, DialogResult } from './dialog';\nimport type { EndTraceParams, EndTraceResult } from './end-trace';\nimport type {\n  GetBackgroundEventsParams,\n  GetBackgroundEventsResult,\n} from './get-background-events';\nimport type {\n  GetBip32EntropyParams,\n  GetBip32EntropyResult,\n} from './get-bip32-entropy';\nimport type {\n  GetBip32PublicKeyParams,\n  GetBip32PublicKeyResult,\n} from './get-bip32-public-key';\nimport type {\n  GetBip44EntropyParams,\n  GetBip44EntropyResult,\n} from './get-bip44-entropy';\nimport type {\n  GetClientStatusParams,\n  GetClientStatusResult,\n} from './get-client-status';\nimport type { GetEntropyParams, GetEntropyResult } from './get-entropy';\nimport type { GetFileParams, GetFileResult } from './get-file';\nimport type {\n  GetInterfaceContextParams,\n  GetInterfaceContextResult,\n} from './get-interface-context';\nimport type {\n  GetInterfaceStateParams,\n  GetInterfaceStateResult,\n} from './get-interface-state';\nimport type { GetLocaleParams, GetLocaleResult } from './get-locale';\nimport type {\n  GetPreferencesParams,\n  GetPreferencesResult,\n} from './get-preferences';\nimport type { GetSnapsParams, GetSnapsResult } from './get-snaps';\nimport type { GetStateParams, GetStateResult } from './get-state';\nimport type {\n  GetWebSocketsParams,\n  GetWebSocketsResult,\n} from './get-web-sockets';\nimport type {\n  InvokeKeyringParams,\n  InvokeKeyringResult,\n} from './invoke-keyring';\nimport type { InvokeSnapParams, InvokeSnapResult } from './invoke-snap';\nimport type {\n  ListEntropySourcesParams,\n  ListEntropySourcesResult,\n} from './list-entropy-sources';\nimport type {\n  ManageAccountsParams,\n  ManageAccountsResult,\n} from './manage-accounts';\nimport type { ManageStateParams, ManageStateResult } from './manage-state';\nimport type {\n  CreateSessionParams,\n  CreateSessionResult,\n  GetSessionParams,\n  GetSessionResult,\n  InvokeMethodParams,\n  InvokeMethodResult,\n  RevokeSessionParams,\n  RevokeSessionResult,\n} from './multichain';\nimport type { NotifyParams, NotifyResult } from './notify';\nimport type {\n  OpenWebSocketParams,\n  OpenWebSocketResult,\n} from './open-web-socket';\nimport type { RequestSnapsParams, RequestSnapsResult } from './request-snaps';\nimport type {\n  ResolveInterfaceParams,\n  ResolveInterfaceResult,\n} from './resolve-interface';\nimport type {\n  ScheduleBackgroundEventParams,\n  ScheduleBackgroundEventResult,\n} from './schedule-background-event';\nimport type {\n  SendWebSocketMessageParams,\n  SendWebSocketMessageResult,\n} from './send-web-socket-message';\nimport type { SetStateParams, SetStateResult } from './set-state';\nimport type { StartTraceParams, StartTraceResult } from './start-trace';\nimport type { TrackErrorParams, TrackErrorResult } from './track-error';\nimport type { TrackEventParams, TrackEventResult } from './track-event';\nimport type {\n  UpdateInterfaceParams,\n  UpdateInterfaceResult,\n} from './update-interface';\nimport type { Method } from '../../internals';\n\n/**\n * The methods that are available to the Snap. Each method is a tuple of the\n * request parameters and the result returned by the method.\n */\nexport type SnapMethods = {\n  /* eslint-disable @typescript-eslint/naming-convention */\n  snap_clearState: [ClearStateParams, ClearStateResult];\n  snap_dialog: [DialogParams, DialogResult];\n  snap_endTrace: [EndTraceParams, EndTraceResult];\n  snap_getBip32Entropy: [GetBip32EntropyParams, GetBip32EntropyResult];\n  snap_getBip32PublicKey: [GetBip32PublicKeyParams, GetBip32PublicKeyResult];\n  snap_getBip44Entropy: [GetBip44EntropyParams, GetBip44EntropyResult];\n  snap_getClientStatus: [GetClientStatusParams, GetClientStatusResult];\n  snap_getEntropy: [GetEntropyParams, GetEntropyResult];\n  snap_getFile: [GetFileParams, GetFileResult];\n  snap_getLocale: [GetLocaleParams, GetLocaleResult];\n  snap_getPreferences: [GetPreferencesParams, GetPreferencesResult];\n  snap_getState: [GetStateParams, GetStateResult];\n  snap_listEntropySources: [ListEntropySourcesParams, ListEntropySourcesResult];\n  snap_manageAccounts: [ManageAccountsParams, ManageAccountsResult];\n  snap_manageState: [ManageStateParams, ManageStateResult];\n  snap_notify: [NotifyParams, NotifyResult];\n  snap_scheduleBackgroundEvent: [\n    ScheduleBackgroundEventParams,\n    ScheduleBackgroundEventResult,\n  ];\n  snap_cancelBackgroundEvent: [\n    CancelBackgroundEventParams,\n    CancelBackgroundEventResult,\n  ];\n  snap_getBackgroundEvents: [\n    GetBackgroundEventsParams,\n    GetBackgroundEventsResult,\n  ];\n  snap_createInterface: [CreateInterfaceParams, CreateInterfaceResult];\n  snap_updateInterface: [UpdateInterfaceParams, UpdateInterfaceResult];\n  snap_getInterfaceState: [GetInterfaceStateParams, GetInterfaceStateResult];\n  snap_getInterfaceContext: [\n    GetInterfaceContextParams,\n    GetInterfaceContextResult,\n  ];\n  snap_resolveInterface: [ResolveInterfaceParams, ResolveInterfaceResult];\n  snap_setState: [SetStateParams, SetStateResult];\n  snap_startTrace: [StartTraceParams, StartTraceResult];\n  snap_trackEvent: [TrackEventParams, TrackEventResult];\n  snap_trackError: [TrackErrorParams, TrackErrorResult];\n  snap_openWebSocket: [OpenWebSocketParams, OpenWebSocketResult];\n  snap_closeWebSocket: [CloseWebSocketParams, CloseWebSocketResult];\n  snap_getWebSockets: [GetWebSocketsParams, GetWebSocketsResult];\n  snap_sendWebSocketMessage: [\n    SendWebSocketMessageParams,\n    SendWebSocketMessageResult,\n  ];\n  wallet_createSession: [CreateSessionParams, CreateSessionResult];\n  wallet_getSession: [GetSessionParams, GetSessionResult];\n  wallet_getSnaps: [GetSnapsParams, GetSnapsResult];\n  wallet_invokeKeyring: [InvokeKeyringParams, InvokeKeyringResult];\n  wallet_invokeMethod: [InvokeMethodParams, InvokeMethodResult];\n  wallet_invokeSnap: [InvokeSnapParams, InvokeSnapResult];\n  wallet_snap: [InvokeSnapParams, InvokeSnapResult];\n  wallet_requestSnaps: [RequestSnapsParams, RequestSnapsResult];\n  wallet_revokeSession: [RevokeSessionParams, RevokeSessionResult];\n  /* eslint-enable @typescript-eslint/naming-convention */\n};\n\n/**\n * The request function that is available to the Snap. It takes a request\n * object and returns a promise that resolves to the result of the request.\n *\n * @param request - The request object.\n * @param request.method - The method to call.\n * @param request.params - The parameters to pass to the method. This is\n * inferred from the method, based on the {@link SnapMethods} type, and may be\n * optional.\n * @returns A promise that resolves to the result of the request. This is\n * inferred from the request method, based on the {@link SnapMethods} type.\n * @example\n * // Get the user's locale\n * const result = await request({\n *   method: 'snap_getLocale',\n * });\n * @example\n * // Get a file\n * const result = await request({\n *   method: 'snap_getFile',\n *   params: {\n *     path: 'foo/bar.txt',\n *   },\n * });\n */\nexport type RequestFunction = <MethodName extends keyof SnapMethods>(\n  request: Method<MethodName, SnapMethods[MethodName][0]>,\n) => Promise<SnapMethods[MethodName][1]>;\n"]}