@metamask-previews/keyring-api 21.0.0-45ee2b8 → 21.0.0-50e2da5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.cjs","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,6EAA6E","sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n// This rule seems to be triggering a false positive on the `KeyringAccount`.\n\nimport type { JsonRpcRequest } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { ResolvedAccountAddress } from './address';\nimport type { Balance } from './balance';\nimport type { CaipChainId, CaipAssetType, CaipAssetTypeOrId } from './caip';\nimport type { DiscoveredAccount } from './discovery';\nimport type { EntropySourceId } from './entropy';\nimport type { KeyringAccountData } from './export';\nimport type { MetaMaskOptions } from './options';\nimport type { Paginated, Pagination } from './pagination';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\nimport type { Transaction } from './transaction';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional). The\n * 'metamask' internal options needs to be re-emitted during `notify:*` events.\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(\n options?: Record<string, Json> & MetaMaskOptions,\n ): Promise<KeyringAccount>;\n\n /**\n * Lists the assets of an account (fungibles and non-fungibles) represented\n * by their respective CAIP-19:\n * - Asset types for fungibles assets.\n * - Asset IDs for non-fungible ones.\n *\n * @param id - The ID of the account to list the assets for.\n * @returns A promise that resolves to list of assets for that account.\n */\n listAccountAssets?(id: string): Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Lists the transactions of an account, paginated and ordered by the most\n * recent first.\n *\n * The pagination options are used to limit the number of transactions in the\n * response and to iterate over the results.\n *\n * @param id - The ID of the account to list the transactions for.\n * @param pagination - The pagination options.\n * @returns A promise that resolves to the next page of transactions.\n */\n listAccountTransactions?(\n id: string,\n pagination: Pagination,\n ): Promise<Paginated<Transaction>>;\n\n /**\n * Discover accounts.\n *\n * This method is called by the client to allow the keyring to discover\n * existing accounts based on the provided scopes and entropy source ID. Are\n * considered existing accounts, accounts that have at least one transaction,\n * as per BIP-44.\n *\n * The `groupIndex` is used to group accounts with the same value. In\n * strictly BIP-44 wallets, it matches `account_index`, but in wallets that\n * deviate from BIP-44 recommendations, it may align with a different path\n * level for compatibility.\n *\n * @param scopes - The list of scopes for account discovery.\n * @param entropySource - The ID of the entropy source used to derive the accounts.\n * @param groupIndex - The group index that should be used to derive the accounts.\n * @returns A promise resolving to a list of discovered accounts.\n */\n discoverAccounts?(\n scopes: CaipChainId[],\n entropySource: EntropySourceId,\n groupIndex: number,\n ): Promise<DiscoveredAccount[]>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Resolves the address of an account from a signing request.\n *\n * This is required by the routing system of MetaMask to dispatch\n * incoming non-EVM dapp signing requests.\n *\n * @param scope - Request's scope (CAIP-2).\n * @param request - Signing request object.\n * @returns A Promise that resolves to the account address that must\n * be used to process this signing request, or null if none candidates\n * could be found.\n */\n resolveAccountAddress?(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
1
+ {"version":3,"file":"keyring.cjs","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,6EAA6E","sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n// This rule seems to be triggering a false positive on the `KeyringAccount`.\n\nimport type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { ResolvedAccountAddress } from './address';\nimport type { Balance } from './balance';\nimport type { CaipChainId, CaipAssetType, CaipAssetTypeOrId } from './caip';\nimport type { DiscoveredAccount } from './discovery';\nimport type { EntropySourceId } from './entropy';\nimport type { KeyringAccountData } from './export';\nimport type { MetaMaskOptions } from './options';\nimport type { Paginated, Pagination } from './pagination';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\nimport type { Transaction } from './transaction';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional). The\n * 'metamask' internal options needs to be re-emitted during `notify:*` events.\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(\n options?: Record<string, Json> & MetaMaskOptions,\n ): Promise<KeyringAccount>;\n\n /**\n * Lists the assets of an account (fungibles and non-fungibles) represented\n * by their respective CAIP-19:\n * - Asset types for fungibles assets.\n * - Asset IDs for non-fungible ones.\n *\n * @param id - The ID of the account to list the assets for.\n * @returns A promise that resolves to list of assets for that account.\n */\n listAccountAssets?(id: string): Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Lists the transactions of an account, paginated and ordered by the most\n * recent first.\n *\n * The pagination options are used to limit the number of transactions in the\n * response and to iterate over the results.\n *\n * @param id - The ID of the account to list the transactions for.\n * @param pagination - The pagination options.\n * @returns A promise that resolves to the next page of transactions.\n */\n listAccountTransactions?(\n id: string,\n pagination: Pagination,\n ): Promise<Paginated<Transaction>>;\n\n /**\n * Discover accounts.\n *\n * This method is called by the client to allow the keyring to discover\n * existing accounts based on the provided scopes and entropy source ID. Are\n * considered existing accounts, accounts that have at least one transaction,\n * as per BIP-44.\n *\n * The `groupIndex` is used to group accounts with the same value. In\n * strictly BIP-44 wallets, it matches `account_index`, but in wallets that\n * deviate from BIP-44 recommendations, it may align with a different path\n * level for compatibility.\n *\n * @param scopes - The list of scopes for account discovery.\n * @param entropySource - The ID of the entropy source used to derive the accounts.\n * @param groupIndex - The group index that should be used to derive the accounts.\n * @returns A promise resolving to a list of discovered accounts.\n */\n discoverAccounts?(\n scopes: CaipChainId[],\n entropySource: EntropySourceId,\n groupIndex: number,\n ): Promise<DiscoveredAccount[]>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Resolves the address of an account from a signing request.\n *\n * This is required by the routing system of MetaMask to dispatch\n * incoming non-EVM dapp signing requests.\n *\n * @param scope - Request's scope (CAIP-2).\n * @param request - Signing request object.\n * @returns A Promise that resolves to the account address that must\n * be used to process this signing request, or null if none candidates\n * could be found.\n */\n resolveAccountAddress?(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null>;\n\n /**\n * Set the selected accounts.\n *\n * @param accounts - The accounts to set as selected.\n */\n setSelectedAccounts(accounts: AccountId[]): Promise<void>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { JsonRpcRequest } from "@metamask/keyring-utils";
1
+ import type { AccountId, JsonRpcRequest } from "@metamask/keyring-utils";
2
2
  import type { Json } from "@metamask/utils";
3
3
  import type { KeyringAccount } from "./account.cjs";
4
4
  import type { ResolvedAccountAddress } from "./address.cjs";
@@ -131,6 +131,12 @@ export type Keyring = {
131
131
  * could be found.
132
132
  */
133
133
  resolveAccountAddress?(scope: CaipChainId, request: JsonRpcRequest): Promise<ResolvedAccountAddress | null>;
134
+ /**
135
+ * Set the selected accounts.
136
+ *
137
+ * @param accounts - The accounts to set as selected.
138
+ */
139
+ setSelectedAccounts(accounts: AccountId[]): Promise<void>;
134
140
  /**
135
141
  * Filter supported chains for a given account.
136
142
  *
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.d.cts","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAgC;AAC9D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAkB;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAkB;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAe;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAoB;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAiB;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,yBAAqB;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAmB;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,0BAAsB;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB;;;;;;;OAOG;IACH,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAE1C;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAE5D;;;;;;;;;OASG;IACH,aAAa,CACX,OAAO,CAAC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C;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAErE;;;;;;;;OAQG;IACH,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzC;;;;;;;;OAQG;IACH,aAAa,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAExD;;;;;;;OAOG;IACH,YAAY,CAAC,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAE3C;;;;;;;;OAQG;IACH,UAAU,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAE7D;;;;;;;OAOG;IACH,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEjE;;;;;;;;;OASG;IACH,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;;;;OAQG;IACH,aAAa,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { JsonRpcRequest } from "@metamask/keyring-utils";
1
+ import type { AccountId, JsonRpcRequest } from "@metamask/keyring-utils";
2
2
  import type { Json } from "@metamask/utils";
3
3
  import type { KeyringAccount } from "./account.mjs";
4
4
  import type { ResolvedAccountAddress } from "./address.mjs";
@@ -131,6 +131,12 @@ export type Keyring = {
131
131
  * could be found.
132
132
  */
133
133
  resolveAccountAddress?(scope: CaipChainId, request: JsonRpcRequest): Promise<ResolvedAccountAddress | null>;
134
+ /**
135
+ * Set the selected accounts.
136
+ *
137
+ * @param accounts - The accounts to set as selected.
138
+ */
139
+ setSelectedAccounts(accounts: AccountId[]): Promise<void>;
134
140
  /**
135
141
  * Filter supported chains for a given account.
136
142
  *
@@ -1 +1 @@
1
- {"version":3,"file":"keyring.d.mts","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,gCAAgC;AAC9D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAkB;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAkB;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,mBAAe;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAoB;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAiB;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,yBAAqB;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAmB;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,0BAAsB;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB;;;;;;;OAOG;IACH,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAE1C;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,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":"AAAA,sEAAsE;AACtE,6EAA6E","sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n// This rule seems to be triggering a false positive on the `KeyringAccount`.\n\nimport type { JsonRpcRequest } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { ResolvedAccountAddress } from './address';\nimport type { Balance } from './balance';\nimport type { CaipChainId, CaipAssetType, CaipAssetTypeOrId } from './caip';\nimport type { DiscoveredAccount } from './discovery';\nimport type { EntropySourceId } from './entropy';\nimport type { KeyringAccountData } from './export';\nimport type { MetaMaskOptions } from './options';\nimport type { Paginated, Pagination } from './pagination';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\nimport type { Transaction } from './transaction';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional). The\n * 'metamask' internal options needs to be re-emitted during `notify:*` events.\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(\n options?: Record<string, Json> & MetaMaskOptions,\n ): Promise<KeyringAccount>;\n\n /**\n * Lists the assets of an account (fungibles and non-fungibles) represented\n * by their respective CAIP-19:\n * - Asset types for fungibles assets.\n * - Asset IDs for non-fungible ones.\n *\n * @param id - The ID of the account to list the assets for.\n * @returns A promise that resolves to list of assets for that account.\n */\n listAccountAssets?(id: string): Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Lists the transactions of an account, paginated and ordered by the most\n * recent first.\n *\n * The pagination options are used to limit the number of transactions in the\n * response and to iterate over the results.\n *\n * @param id - The ID of the account to list the transactions for.\n * @param pagination - The pagination options.\n * @returns A promise that resolves to the next page of transactions.\n */\n listAccountTransactions?(\n id: string,\n pagination: Pagination,\n ): Promise<Paginated<Transaction>>;\n\n /**\n * Discover accounts.\n *\n * This method is called by the client to allow the keyring to discover\n * existing accounts based on the provided scopes and entropy source ID. Are\n * considered existing accounts, accounts that have at least one transaction,\n * as per BIP-44.\n *\n * The `groupIndex` is used to group accounts with the same value. In\n * strictly BIP-44 wallets, it matches `account_index`, but in wallets that\n * deviate from BIP-44 recommendations, it may align with a different path\n * level for compatibility.\n *\n * @param scopes - The list of scopes for account discovery.\n * @param entropySource - The ID of the entropy source used to derive the accounts.\n * @param groupIndex - The group index that should be used to derive the accounts.\n * @returns A promise resolving to a list of discovered accounts.\n */\n discoverAccounts?(\n scopes: CaipChainId[],\n entropySource: EntropySourceId,\n groupIndex: number,\n ): Promise<DiscoveredAccount[]>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Resolves the address of an account from a signing request.\n *\n * This is required by the routing system of MetaMask to dispatch\n * incoming non-EVM dapp signing requests.\n *\n * @param scope - Request's scope (CAIP-2).\n * @param request - Signing request object.\n * @returns A Promise that resolves to the account address that must\n * be used to process this signing request, or null if none candidates\n * could be found.\n */\n resolveAccountAddress?(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
1
+ {"version":3,"file":"keyring.mjs","sourceRoot":"","sources":["../../src/api/keyring.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,6EAA6E","sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\n// This rule seems to be triggering a false positive on the `KeyringAccount`.\n\nimport type { AccountId, JsonRpcRequest } from '@metamask/keyring-utils';\nimport type { Json } from '@metamask/utils';\n\nimport type { KeyringAccount } from './account';\nimport type { ResolvedAccountAddress } from './address';\nimport type { Balance } from './balance';\nimport type { CaipChainId, CaipAssetType, CaipAssetTypeOrId } from './caip';\nimport type { DiscoveredAccount } from './discovery';\nimport type { EntropySourceId } from './entropy';\nimport type { KeyringAccountData } from './export';\nimport type { MetaMaskOptions } from './options';\nimport type { Paginated, Pagination } from './pagination';\nimport type { KeyringRequest } from './request';\nimport type { KeyringResponse } from './response';\nimport type { Transaction } from './transaction';\n\n/**\n * Keyring interface.\n *\n * Represents the functionality and operations related to managing accounts and\n * handling requests.\n */\nexport type Keyring = {\n /**\n * List accounts.\n *\n * Retrieves an array of KeyringAccount objects representing the available\n * accounts.\n *\n * @returns A promise that resolves to an array of KeyringAccount objects.\n */\n listAccounts(): Promise<KeyringAccount[]>;\n\n /**\n * Get an account.\n *\n * Retrieves the KeyringAccount object for the given account ID.\n *\n * @param id - The ID of the account to retrieve.\n * @returns A promise that resolves to the KeyringAccount object if found, or\n * undefined otherwise.\n */\n getAccount(id: string): Promise<KeyringAccount | undefined>;\n\n /**\n * Create an account.\n *\n * Creates a new account with optional, keyring-defined, account options.\n *\n * @param options - Keyring-defined options for the account (optional). The\n * 'metamask' internal options needs to be re-emitted during `notify:*` events.\n * @returns A promise that resolves to the newly created KeyringAccount\n * object without any private information.\n */\n createAccount(\n options?: Record<string, Json> & MetaMaskOptions,\n ): Promise<KeyringAccount>;\n\n /**\n * Lists the assets of an account (fungibles and non-fungibles) represented\n * by their respective CAIP-19:\n * - Asset types for fungibles assets.\n * - Asset IDs for non-fungible ones.\n *\n * @param id - The ID of the account to list the assets for.\n * @returns A promise that resolves to list of assets for that account.\n */\n listAccountAssets?(id: string): Promise<CaipAssetTypeOrId[]>;\n\n /**\n * Lists the transactions of an account, paginated and ordered by the most\n * recent first.\n *\n * The pagination options are used to limit the number of transactions in the\n * response and to iterate over the results.\n *\n * @param id - The ID of the account to list the transactions for.\n * @param pagination - The pagination options.\n * @returns A promise that resolves to the next page of transactions.\n */\n listAccountTransactions?(\n id: string,\n pagination: Pagination,\n ): Promise<Paginated<Transaction>>;\n\n /**\n * Discover accounts.\n *\n * This method is called by the client to allow the keyring to discover\n * existing accounts based on the provided scopes and entropy source ID. Are\n * considered existing accounts, accounts that have at least one transaction,\n * as per BIP-44.\n *\n * The `groupIndex` is used to group accounts with the same value. In\n * strictly BIP-44 wallets, it matches `account_index`, but in wallets that\n * deviate from BIP-44 recommendations, it may align with a different path\n * level for compatibility.\n *\n * @param scopes - The list of scopes for account discovery.\n * @param entropySource - The ID of the entropy source used to derive the accounts.\n * @param groupIndex - The group index that should be used to derive the accounts.\n * @returns A promise resolving to a list of discovered accounts.\n */\n discoverAccounts?(\n scopes: CaipChainId[],\n entropySource: EntropySourceId,\n groupIndex: number,\n ): Promise<DiscoveredAccount[]>;\n\n /**\n * Retrieve the balances of a given account.\n *\n * This method fetches the balances of specified assets for a given account\n * ID. It returns a promise that resolves to an object where the keys are\n * asset types and the values are balance objects containing the amount and\n * unit.\n *\n * @example\n * ```ts\n * await keyring.getAccountBalances(\n * '43550276-c7d6-4fac-87c7-00390ad0ce90',\n * ['bip122:000000000019d6689c085ae165831e93/slip44:0']\n * );\n * // Returns something similar to:\n * // {\n * // 'bip122:000000000019d6689c085ae165831e93/slip44:0': {\n * // amount: '0.0001',\n * // unit: 'BTC',\n * // }\n * // }\n * ```\n * @param id - ID of the account to retrieve the balances for.\n * @param assets - Array of asset types (CAIP-19) to retrieve balances for.\n * @returns A promise that resolves to an object mapping asset types to their\n * respective balances.\n */\n getAccountBalances?(\n id: string,\n assets: CaipAssetType[],\n ): Promise<Record<CaipAssetType, Balance>>;\n\n /**\n * Resolves the address of an account from a signing request.\n *\n * This is required by the routing system of MetaMask to dispatch\n * incoming non-EVM dapp signing requests.\n *\n * @param scope - Request's scope (CAIP-2).\n * @param request - Signing request object.\n * @returns A Promise that resolves to the account address that must\n * be used to process this signing request, or null if none candidates\n * could be found.\n */\n resolveAccountAddress?(\n scope: CaipChainId,\n request: JsonRpcRequest,\n ): Promise<ResolvedAccountAddress | null>;\n\n /**\n * Set the selected accounts.\n *\n * @param accounts - The accounts to set as selected.\n */\n setSelectedAccounts(accounts: AccountId[]): Promise<void>;\n\n /**\n * Filter supported chains for a given account.\n *\n * @param id - ID of the account to be checked.\n * @param chains - List of chains (CAIP-2) to be checked.\n * @returns A Promise that resolves to a filtered list of CAIP-2 IDs\n * representing the supported chains.\n */\n filterAccountChains(id: string, chains: string[]): Promise<string[]>;\n\n /**\n * Update an account.\n *\n * Updates the account with the given account object. Does nothing if the\n * account does not exist.\n *\n * @param account - The updated account object.\n * @returns A promise that resolves when the account is successfully updated.\n */\n updateAccount(account: KeyringAccount): Promise<void>;\n\n /**\n * Delete an account from the keyring.\n *\n * Deletes the account with the given ID from the keyring.\n *\n * @param id - The ID of the account to delete.\n * @returns A promise that resolves when the account is successfully deleted.\n */\n deleteAccount(id: string): Promise<void>;\n\n /**\n * Exports an account's private key.\n *\n * If the keyring cannot export a private key, this function should throw an\n * error.\n *\n * @param id - The ID of the account to export.\n * @returns A promise that resolves to the exported account.\n */\n exportAccount?(id: string): Promise<KeyringAccountData>;\n\n /**\n * List all submitted requests.\n *\n * Retrieves an array of KeyringRequest objects representing the submitted\n * requests.\n *\n * @returns A promise that resolves to an array of KeyringRequest objects.\n */\n listRequests?(): Promise<KeyringRequest[]>;\n\n /**\n * Get a request.\n *\n * Retrieves the KeyringRequest object for the given request ID.\n *\n * @param id - The ID of the request to retrieve.\n * @returns A promise that resolves to the KeyringRequest object if found, or\n * undefined otherwise.\n */\n getRequest?(id: string): Promise<KeyringRequest | undefined>;\n\n /**\n * Submit a request.\n *\n * Submits the given KeyringRequest object.\n *\n * @param request - The KeyringRequest object to submit.\n * @returns A promise that resolves to the request response.\n */\n submitRequest(request: KeyringRequest): Promise<KeyringResponse>;\n\n /**\n * Approve a request.\n *\n * Approves the request with the given ID and sets the response if provided.\n *\n * @param id - The ID of the request to approve.\n * @param data - The response to the request (optional).\n * @returns A promise that resolves when the request is successfully\n * approved.\n */\n approveRequest?(id: string, data?: Record<string, Json>): Promise<void>;\n\n /**\n * Reject a request.\n *\n * Rejects the request with the given ID.\n *\n * @param id - The ID of the request to reject.\n * @returns A promise that resolves when the request is successfully\n * rejected.\n */\n rejectRequest?(id: string): Promise<void>;\n};\n"]}
package/dist/index.cjs CHANGED
@@ -21,4 +21,5 @@ __exportStar(require("./eth/index.cjs"), exports);
21
21
  __exportStar(require("./trx/index.cjs"), exports);
22
22
  __exportStar(require("./rpc.cjs"), exports);
23
23
  __exportStar(require("./events.cjs"), exports);
24
+ __exportStar(require("./methods.cjs"), exports);
24
25
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAsB;AACtB,kDAAsB;AACtB,kDAAsB;AACtB,kDAAsB;AACtB,kDAAsB;AAEtB,4CAAsB;AACtB,+CAAyB","sourcesContent":["export * from './api';\nexport * from './btc';\nexport * from './sol';\nexport * from './eth';\nexport * from './trx';\nexport type * from './contexts';\nexport * from './rpc';\nexport * from './events';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAsB;AACtB,kDAAsB;AACtB,kDAAsB;AACtB,kDAAsB;AACtB,kDAAsB;AAEtB,4CAAsB;AACtB,+CAAyB;AACzB,gDAA0B","sourcesContent":["export * from './api';\nexport * from './btc';\nexport * from './sol';\nexport * from './eth';\nexport * from './trx';\nexport type * from './contexts';\nexport * from './rpc';\nexport * from './events';\nexport * from './methods';\n"]}
package/dist/index.d.cts CHANGED
@@ -6,4 +6,5 @@ export * from "./trx/index.cjs";
6
6
  export type * from "./contexts.cjs";
7
7
  export * from "./rpc.cjs";
8
8
  export * from "./events.cjs";
9
+ export * from "./methods.cjs";
9
10
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,oCAAgC;AAChC,0BAAsB;AACtB,6BAAyB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,oCAAgC;AAChC,0BAAsB;AACtB,6BAAyB;AACzB,8BAA0B"}
package/dist/index.d.mts CHANGED
@@ -6,4 +6,5 @@ export * from "./trx/index.mjs";
6
6
  export type * from "./contexts.mjs";
7
7
  export * from "./rpc.mjs";
8
8
  export * from "./events.mjs";
9
+ export * from "./methods.mjs";
9
10
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,oCAAgC;AAChC,0BAAsB;AACtB,6BAAyB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,oCAAgC;AAChC,0BAAsB;AACtB,6BAAyB;AACzB,8BAA0B"}
package/dist/index.mjs CHANGED
@@ -5,4 +5,5 @@ export * from "./eth/index.mjs";
5
5
  export * from "./trx/index.mjs";
6
6
  export * from "./rpc.mjs";
7
7
  export * from "./events.mjs";
8
+ export * from "./methods.mjs";
8
9
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AAEtB,0BAAsB;AACtB,6BAAyB","sourcesContent":["export * from './api';\nexport * from './btc';\nexport * from './sol';\nexport * from './eth';\nexport * from './trx';\nexport type * from './contexts';\nexport * from './rpc';\nexport * from './events';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AACtB,gCAAsB;AAEtB,0BAAsB;AACtB,6BAAyB;AACzB,8BAA0B","sourcesContent":["export * from './api';\nexport * from './btc';\nexport * from './sol';\nexport * from './eth';\nexport * from './trx';\nexport type * from './contexts';\nexport * from './rpc';\nexport * from './events';\nexport * from './methods';\n"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetSelectedAccountsReponseStruct = exports.GetSelectedAccountsRequestStruct = exports.KeyringMethod = void 0;
4
+ const superstruct_1 = require("@metamask/superstruct");
5
+ var KeyringMethod;
6
+ (function (KeyringMethod) {
7
+ KeyringMethod["GetSelectedAccounts"] = "getSelectedAccounts";
8
+ })(KeyringMethod || (exports.KeyringMethod = KeyringMethod = {}));
9
+ exports.GetSelectedAccountsRequestStruct = (0, superstruct_1.object)({
10
+ method: (0, superstruct_1.literal)(KeyringMethod.GetSelectedAccounts),
11
+ });
12
+ exports.GetSelectedAccountsReponseStruct = (0, superstruct_1.array)((0, superstruct_1.string)());
13
+ //# sourceMappingURL=methods.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.cjs","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":";;;AAAA,uDAM+B;AAE/B,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,4DAA2C,CAAA;AAC7C,CAAC,EAFW,aAAa,6BAAb,aAAa,QAExB;AAEY,QAAA,gCAAgC,GAAG,IAAA,oBAAM,EAAC;IACrD,MAAM,EAAE,IAAA,qBAAO,EAAC,aAAa,CAAC,mBAAmB,CAAC;CACnD,CAAC,CAAC;AAEU,QAAA,gCAAgC,GAAG,IAAA,mBAAK,EAAC,IAAA,oBAAM,GAAE,CAAC,CAAC","sourcesContent":["import {\n array,\n literal,\n object,\n string,\n type Infer,\n} from '@metamask/superstruct';\n\nexport enum KeyringMethod {\n GetSelectedAccounts = 'getSelectedAccounts',\n}\n\nexport const GetSelectedAccountsRequestStruct = object({\n method: literal(KeyringMethod.GetSelectedAccounts),\n});\n\nexport const GetSelectedAccountsReponseStruct = array(string());\n\nexport type GetSelectedAccountsResponse = Infer<\n typeof GetSelectedAccountsReponseStruct\n>;\n"]}
@@ -0,0 +1,12 @@
1
+ import { type Infer } from "@metamask/superstruct";
2
+ export declare enum KeyringMethod {
3
+ GetSelectedAccounts = "getSelectedAccounts"
4
+ }
5
+ export declare const GetSelectedAccountsRequestStruct: import("@metamask/superstruct").Struct<{
6
+ method: KeyringMethod;
7
+ }, {
8
+ method: import("@metamask/superstruct").Struct<KeyringMethod, KeyringMethod>;
9
+ }>;
10
+ export declare const GetSelectedAccountsReponseStruct: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
11
+ export type GetSelectedAccountsResponse = Infer<typeof GetSelectedAccountsReponseStruct>;
12
+ //# sourceMappingURL=methods.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.d.cts","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,8BAA8B;AAE/B,oBAAY,aAAa;IACvB,mBAAmB,wBAAwB;CAC5C;AAED,eAAO,MAAM,gCAAgC;;;;EAE3C,CAAC;AAEH,eAAO,MAAM,gCAAgC,wGAAkB,CAAC;AAEhE,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAC7C,OAAO,gCAAgC,CACxC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type Infer } from "@metamask/superstruct";
2
+ export declare enum KeyringMethod {
3
+ GetSelectedAccounts = "getSelectedAccounts"
4
+ }
5
+ export declare const GetSelectedAccountsRequestStruct: import("@metamask/superstruct").Struct<{
6
+ method: KeyringMethod;
7
+ }, {
8
+ method: import("@metamask/superstruct").Struct<KeyringMethod, KeyringMethod>;
9
+ }>;
10
+ export declare const GetSelectedAccountsReponseStruct: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>;
11
+ export type GetSelectedAccountsResponse = Infer<typeof GetSelectedAccountsReponseStruct>;
12
+ //# sourceMappingURL=methods.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.d.mts","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EACX,8BAA8B;AAE/B,oBAAY,aAAa;IACvB,mBAAmB,wBAAwB;CAC5C;AAED,eAAO,MAAM,gCAAgC;;;;EAE3C,CAAC;AAEH,eAAO,MAAM,gCAAgC,wGAAkB,CAAC;AAEhE,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAC7C,OAAO,gCAAgC,CACxC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { array, literal, object, string } from "@metamask/superstruct";
2
+ export var KeyringMethod;
3
+ (function (KeyringMethod) {
4
+ KeyringMethod["GetSelectedAccounts"] = "getSelectedAccounts";
5
+ })(KeyringMethod || (KeyringMethod = {}));
6
+ export const GetSelectedAccountsRequestStruct = object({
7
+ method: literal(KeyringMethod.GetSelectedAccounts),
8
+ });
9
+ export const GetSelectedAccountsReponseStruct = array(string());
10
+ //# sourceMappingURL=methods.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.mjs","sourceRoot":"","sources":["../src/methods.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,MAAM,EAEP,8BAA8B;AAE/B,MAAM,CAAN,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,4DAA2C,CAAA;AAC7C,CAAC,EAFW,aAAa,KAAb,aAAa,QAExB;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;IACrD,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC;CACnD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC","sourcesContent":["import {\n array,\n literal,\n object,\n string,\n type Infer,\n} from '@metamask/superstruct';\n\nexport enum KeyringMethod {\n GetSelectedAccounts = 'getSelectedAccounts',\n}\n\nexport const GetSelectedAccountsRequestStruct = object({\n method: literal(KeyringMethod.GetSelectedAccounts),\n});\n\nexport const GetSelectedAccountsReponseStruct = array(string());\n\nexport type GetSelectedAccountsResponse = Infer<\n typeof GetSelectedAccountsReponseStruct\n>;\n"]}
package/dist/rpc.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BatchResponseStruct = exports.BatchRequestStruct = exports.RejectRequestResponseStruct = exports.RejectRequestRequestStruct = exports.ApproveRequestResponseStruct = exports.ApproveRequestRequestStruct = exports.SubmitRequestResponseStruct = exports.SubmitRequestRequestStruct = exports.GetRequestResponseStruct = exports.GetRequestRequestStruct = exports.ListRequestsResponseStruct = exports.ListRequestsRequestStruct = exports.ExportAccountResponseStruct = exports.ExportAccountRequestStruct = exports.DeleteAccountResponseStruct = exports.DeleteAccountRequestStruct = exports.UpdateAccountResponseStruct = exports.UpdateAccountRequestStruct = exports.FilterAccountChainsResponseStruct = exports.FilterAccountChainsRequestStruct = exports.ResolveAccountAddressResponseStruct = exports.ResolveAccountAddressRequestStruct = exports.GetAccountBalancesResponseStruct = exports.GetAccountBalancesRequestStruct = exports.ListAccountAssetsResponseStruct = exports.ListAccountAssetsRequestStruct = exports.ListAccountTransactionsResponseStruct = exports.ListAccountTransactionsRequestStruct = exports.DiscoverAccountsResponseStruct = exports.DiscoverAccountsRequestStruct = exports.CreateAccountResponseStruct = exports.CreateAccountRequestStruct = exports.GetAccountResponseStruct = exports.GetAccountRequestStruct = exports.ListAccountsResponseStruct = exports.ListAccountsRequestStruct = exports.KeyringRpcMethod = void 0;
3
+ exports.RejectRequestResponseStruct = exports.RejectRequestRequestStruct = exports.ApproveRequestResponseStruct = exports.ApproveRequestRequestStruct = exports.SubmitRequestResponseStruct = exports.SubmitRequestRequestStruct = exports.GetRequestResponseStruct = exports.GetRequestRequestStruct = exports.ListRequestsResponseStruct = exports.ListRequestsRequestStruct = exports.ExportAccountResponseStruct = exports.ExportAccountRequestStruct = exports.DeleteAccountResponseStruct = exports.DeleteAccountRequestStruct = exports.UpdateAccountResponseStruct = exports.UpdateAccountRequestStruct = exports.FilterAccountChainsResponseStruct = exports.FilterAccountChainsStruct = exports.ResolveAccountAddressResponseStruct = exports.ResolveAccountAddressRequestStruct = exports.GetAccountBalancesResponseStruct = exports.GetAccountBalancesRequestStruct = exports.ListAccountAssetsResponseStruct = exports.ListAccountAssetsRequestStruct = exports.ListAccountTransactionsResponseStruct = exports.ListAccountTransactionsRequestStruct = exports.DiscoverAccountsResponseStruct = exports.DiscoverAccountsRequestStruct = exports.CreateAccountResponseStruct = exports.CreateAccountRequestStruct = exports.GetAccountResponseStruct = exports.GetAccountRequestStruct = exports.ListAccountsResponseStruct = exports.ListAccountsRequestStruct = exports.KeyringRpcMethod = void 0;
4
4
  exports.isKeyringRpcMethod = isKeyringRpcMethod;
5
5
  const keyring_utils_1 = require("@metamask/keyring-utils");
6
6
  const superstruct_1 = require("@metamask/superstruct");
@@ -28,7 +28,7 @@ var KeyringRpcMethod;
28
28
  KeyringRpcMethod["SubmitRequest"] = "keyring_submitRequest";
29
29
  KeyringRpcMethod["ApproveRequest"] = "keyring_approveRequest";
30
30
  KeyringRpcMethod["RejectRequest"] = "keyring_rejectRequest";
31
- KeyringRpcMethod["Batch"] = "keyring_batch";
31
+ KeyringRpcMethod["SetSelectedAccounts"] = "keyring_setSelectedAccounts";
32
32
  })(KeyringRpcMethod || (exports.KeyringRpcMethod = KeyringRpcMethod = {}));
33
33
  /**
34
34
  * Check if a method is a keyring RPC method.
@@ -46,37 +46,37 @@ const CommonHeader = {
46
46
  };
47
47
  // ----------------------------------------------------------------------------
48
48
  // List accounts
49
- exports.ListAccountsRequestStruct = (0, superstruct_1.object)({
49
+ exports.ListAccountsRequestStruct = (0, keyring_utils_1.object)({
50
50
  ...CommonHeader,
51
51
  method: (0, superstruct_1.literal)('keyring_listAccounts'),
52
52
  });
53
53
  exports.ListAccountsResponseStruct = (0, superstruct_1.array)(api_1.KeyringAccountStruct);
54
54
  // ----------------------------------------------------------------------------
55
55
  // Get account
56
- exports.GetAccountRequestStruct = (0, superstruct_1.object)({
56
+ exports.GetAccountRequestStruct = (0, keyring_utils_1.object)({
57
57
  ...CommonHeader,
58
58
  method: (0, superstruct_1.literal)('keyring_getAccount'),
59
- params: (0, superstruct_1.object)({
59
+ params: (0, keyring_utils_1.object)({
60
60
  id: keyring_utils_1.UuidStruct,
61
61
  }),
62
62
  });
63
63
  exports.GetAccountResponseStruct = api_1.KeyringAccountStruct;
64
64
  // ----------------------------------------------------------------------------
65
65
  // Create account
66
- exports.CreateAccountRequestStruct = (0, superstruct_1.object)({
66
+ exports.CreateAccountRequestStruct = (0, keyring_utils_1.object)({
67
67
  ...CommonHeader,
68
68
  method: (0, superstruct_1.literal)('keyring_createAccount'),
69
- params: (0, superstruct_1.object)({
69
+ params: (0, keyring_utils_1.object)({
70
70
  options: (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct),
71
71
  }),
72
72
  });
73
73
  exports.CreateAccountResponseStruct = api_1.KeyringAccountStruct;
74
74
  // ----------------------------------------------------------------------------
75
75
  // Discover accounts
76
- exports.DiscoverAccountsRequestStruct = (0, superstruct_1.object)({
76
+ exports.DiscoverAccountsRequestStruct = (0, keyring_utils_1.object)({
77
77
  ...CommonHeader,
78
78
  method: (0, superstruct_1.literal)('keyring_discoverAccounts'),
79
- params: (0, superstruct_1.object)({
79
+ params: (0, keyring_utils_1.object)({
80
80
  scopes: (0, superstruct_1.array)(api_1.CaipChainIdStruct),
81
81
  entropySource: (0, superstruct_1.string)(),
82
82
  groupIndex: (0, superstruct_1.number)(),
@@ -85,10 +85,10 @@ exports.DiscoverAccountsRequestStruct = (0, superstruct_1.object)({
85
85
  exports.DiscoverAccountsResponseStruct = (0, superstruct_1.array)(api_1.DiscoveredAccountStruct);
86
86
  // ----------------------------------------------------------------------------
87
87
  // List account transactions
88
- exports.ListAccountTransactionsRequestStruct = (0, superstruct_1.object)({
88
+ exports.ListAccountTransactionsRequestStruct = (0, keyring_utils_1.object)({
89
89
  ...CommonHeader,
90
90
  method: (0, superstruct_1.literal)('keyring_listAccountTransactions'),
91
- params: (0, superstruct_1.object)({
91
+ params: (0, keyring_utils_1.object)({
92
92
  id: keyring_utils_1.UuidStruct,
93
93
  pagination: api_1.PaginationStruct,
94
94
  }),
@@ -96,20 +96,20 @@ exports.ListAccountTransactionsRequestStruct = (0, superstruct_1.object)({
96
96
  exports.ListAccountTransactionsResponseStruct = api_1.TransactionsPageStruct;
97
97
  // ----------------------------------------------------------------------------
98
98
  // List account assets
99
- exports.ListAccountAssetsRequestStruct = (0, superstruct_1.object)({
99
+ exports.ListAccountAssetsRequestStruct = (0, keyring_utils_1.object)({
100
100
  ...CommonHeader,
101
101
  method: (0, superstruct_1.literal)('keyring_listAccountAssets'),
102
- params: (0, superstruct_1.object)({
102
+ params: (0, keyring_utils_1.object)({
103
103
  id: keyring_utils_1.UuidStruct,
104
104
  }),
105
105
  });
106
106
  exports.ListAccountAssetsResponseStruct = (0, superstruct_1.array)(api_1.CaipAssetTypeOrIdStruct);
107
107
  // ----------------------------------------------------------------------------
108
108
  // Get account balances
109
- exports.GetAccountBalancesRequestStruct = (0, superstruct_1.object)({
109
+ exports.GetAccountBalancesRequestStruct = (0, keyring_utils_1.object)({
110
110
  ...CommonHeader,
111
111
  method: (0, superstruct_1.literal)(`${KeyringRpcMethod.GetAccountBalances}`),
112
- params: (0, superstruct_1.object)({
112
+ params: (0, keyring_utils_1.object)({
113
113
  id: keyring_utils_1.UuidStruct,
114
114
  assets: (0, superstruct_1.array)(api_1.CaipAssetTypeStruct),
115
115
  }),
@@ -117,23 +117,23 @@ exports.GetAccountBalancesRequestStruct = (0, superstruct_1.object)({
117
117
  exports.GetAccountBalancesResponseStruct = (0, superstruct_1.record)(api_1.CaipAssetTypeStruct, api_1.BalanceStruct);
118
118
  // ----------------------------------------------------------------------------
119
119
  // Resolve account address
120
- exports.ResolveAccountAddressRequestStruct = (0, superstruct_1.object)({
120
+ exports.ResolveAccountAddressRequestStruct = (0, keyring_utils_1.object)({
121
121
  ...CommonHeader,
122
122
  method: (0, superstruct_1.literal)('keyring_resolveAccountAddress'),
123
- params: (0, superstruct_1.object)({
123
+ params: (0, keyring_utils_1.object)({
124
124
  scope: api_1.CaipChainIdStruct,
125
125
  request: keyring_utils_1.JsonRpcRequestStruct,
126
126
  }),
127
127
  });
128
- exports.ResolveAccountAddressResponseStruct = (0, superstruct_1.nullable)((0, superstruct_1.object)({
128
+ exports.ResolveAccountAddressResponseStruct = (0, superstruct_1.nullable)((0, keyring_utils_1.object)({
129
129
  address: api_1.CaipAccountIdStruct,
130
130
  }));
131
131
  // ----------------------------------------------------------------------------
132
132
  // Filter account chains
133
- exports.FilterAccountChainsRequestStruct = (0, superstruct_1.object)({
133
+ exports.FilterAccountChainsStruct = (0, keyring_utils_1.object)({
134
134
  ...CommonHeader,
135
135
  method: (0, superstruct_1.literal)('keyring_filterAccountChains'),
136
- params: (0, superstruct_1.object)({
136
+ params: (0, keyring_utils_1.object)({
137
137
  id: keyring_utils_1.UuidStruct,
138
138
  chains: (0, superstruct_1.array)((0, superstruct_1.string)()),
139
139
  }),
@@ -141,54 +141,54 @@ exports.FilterAccountChainsRequestStruct = (0, superstruct_1.object)({
141
141
  exports.FilterAccountChainsResponseStruct = (0, superstruct_1.array)((0, superstruct_1.string)());
142
142
  // ----------------------------------------------------------------------------
143
143
  // Update account
144
- exports.UpdateAccountRequestStruct = (0, superstruct_1.object)({
144
+ exports.UpdateAccountRequestStruct = (0, keyring_utils_1.object)({
145
145
  ...CommonHeader,
146
146
  method: (0, superstruct_1.literal)('keyring_updateAccount'),
147
- params: (0, superstruct_1.object)({
147
+ params: (0, keyring_utils_1.object)({
148
148
  account: api_1.KeyringAccountStruct,
149
149
  }),
150
150
  });
151
151
  exports.UpdateAccountResponseStruct = (0, superstruct_1.literal)(null);
152
152
  // ----------------------------------------------------------------------------
153
153
  // Delete account
154
- exports.DeleteAccountRequestStruct = (0, superstruct_1.object)({
154
+ exports.DeleteAccountRequestStruct = (0, keyring_utils_1.object)({
155
155
  ...CommonHeader,
156
156
  method: (0, superstruct_1.literal)('keyring_deleteAccount'),
157
- params: (0, superstruct_1.object)({
157
+ params: (0, keyring_utils_1.object)({
158
158
  id: keyring_utils_1.UuidStruct,
159
159
  }),
160
160
  });
161
161
  exports.DeleteAccountResponseStruct = (0, superstruct_1.literal)(null);
162
162
  // ----------------------------------------------------------------------------
163
163
  // Export account
164
- exports.ExportAccountRequestStruct = (0, superstruct_1.object)({
164
+ exports.ExportAccountRequestStruct = (0, keyring_utils_1.object)({
165
165
  ...CommonHeader,
166
166
  method: (0, superstruct_1.literal)('keyring_exportAccount'),
167
- params: (0, superstruct_1.object)({
167
+ params: (0, keyring_utils_1.object)({
168
168
  id: keyring_utils_1.UuidStruct,
169
169
  }),
170
170
  });
171
171
  exports.ExportAccountResponseStruct = api_1.KeyringAccountDataStruct;
172
172
  // ----------------------------------------------------------------------------
173
173
  // List requests
174
- exports.ListRequestsRequestStruct = (0, superstruct_1.object)({
174
+ exports.ListRequestsRequestStruct = (0, keyring_utils_1.object)({
175
175
  ...CommonHeader,
176
176
  method: (0, superstruct_1.literal)('keyring_listRequests'),
177
177
  });
178
178
  exports.ListRequestsResponseStruct = (0, superstruct_1.array)(api_1.KeyringRequestStruct);
179
179
  // ----------------------------------------------------------------------------
180
180
  // Get request
181
- exports.GetRequestRequestStruct = (0, superstruct_1.object)({
181
+ exports.GetRequestRequestStruct = (0, keyring_utils_1.object)({
182
182
  ...CommonHeader,
183
183
  method: (0, superstruct_1.literal)('keyring_getRequest'),
184
- params: (0, superstruct_1.object)({
184
+ params: (0, keyring_utils_1.object)({
185
185
  id: keyring_utils_1.UuidStruct,
186
186
  }),
187
187
  });
188
188
  exports.GetRequestResponseStruct = api_1.KeyringRequestStruct;
189
189
  // ----------------------------------------------------------------------------
190
190
  // Submit request
191
- exports.SubmitRequestRequestStruct = (0, superstruct_1.object)({
191
+ exports.SubmitRequestRequestStruct = (0, keyring_utils_1.object)({
192
192
  ...CommonHeader,
193
193
  method: (0, superstruct_1.literal)('keyring_submitRequest'),
194
194
  params: api_1.KeyringRequestStruct,
@@ -196,10 +196,10 @@ exports.SubmitRequestRequestStruct = (0, superstruct_1.object)({
196
196
  exports.SubmitRequestResponseStruct = api_1.KeyringResponseStruct;
197
197
  // ----------------------------------------------------------------------------
198
198
  // Approve request
199
- exports.ApproveRequestRequestStruct = (0, superstruct_1.object)({
199
+ exports.ApproveRequestRequestStruct = (0, keyring_utils_1.object)({
200
200
  ...CommonHeader,
201
201
  method: (0, superstruct_1.literal)('keyring_approveRequest'),
202
- params: (0, superstruct_1.object)({
202
+ params: (0, keyring_utils_1.object)({
203
203
  id: keyring_utils_1.UuidStruct,
204
204
  data: (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct),
205
205
  }),
@@ -207,67 +207,12 @@ exports.ApproveRequestRequestStruct = (0, superstruct_1.object)({
207
207
  exports.ApproveRequestResponseStruct = (0, superstruct_1.literal)(null);
208
208
  // ----------------------------------------------------------------------------
209
209
  // Reject request
210
- exports.RejectRequestRequestStruct = (0, superstruct_1.object)({
210
+ exports.RejectRequestRequestStruct = (0, keyring_utils_1.object)({
211
211
  ...CommonHeader,
212
212
  method: (0, superstruct_1.literal)('keyring_rejectRequest'),
213
- params: (0, superstruct_1.object)({
213
+ params: (0, keyring_utils_1.object)({
214
214
  id: keyring_utils_1.UuidStruct,
215
215
  }),
216
216
  });
217
217
  exports.RejectRequestResponseStruct = (0, superstruct_1.literal)(null);
218
- // ----------------------------------------------------------------------------
219
- // Batch RPC requests
220
- exports.BatchRequestStruct = (0, superstruct_1.object)({
221
- ...CommonHeader,
222
- method: (0, superstruct_1.literal)('keyring_batch'),
223
- params: (0, superstruct_1.object)({
224
- id: keyring_utils_1.UuidStruct,
225
- requests: (0, superstruct_1.array)((0, superstruct_1.union)([
226
- exports.ListAccountsRequestStruct,
227
- exports.GetAccountRequestStruct,
228
- exports.CreateAccountRequestStruct,
229
- exports.DiscoverAccountsRequestStruct,
230
- exports.ListAccountAssetsRequestStruct,
231
- exports.ListAccountTransactionsRequestStruct,
232
- exports.GetAccountBalancesRequestStruct,
233
- exports.ResolveAccountAddressRequestStruct,
234
- exports.FilterAccountChainsRequestStruct,
235
- exports.UpdateAccountRequestStruct,
236
- exports.DeleteAccountRequestStruct,
237
- exports.ExportAccountRequestStruct,
238
- exports.ListRequestsRequestStruct,
239
- exports.GetRequestRequestStruct,
240
- exports.SubmitRequestRequestStruct,
241
- exports.ApproveRequestRequestStruct,
242
- exports.RejectRequestRequestStruct,
243
- ])),
244
- }),
245
- });
246
- exports.BatchResponseStruct = (0, superstruct_1.array)((0, superstruct_1.union)([
247
- (0, superstruct_1.object)({
248
- response: (0, superstruct_1.union)([
249
- exports.ListAccountsResponseStruct,
250
- exports.ListAccountsResponseStruct,
251
- exports.GetAccountResponseStruct,
252
- exports.CreateAccountResponseStruct,
253
- exports.DiscoverAccountsResponseStruct,
254
- exports.ListAccountAssetsResponseStruct,
255
- exports.ListAccountTransactionsResponseStruct,
256
- exports.GetAccountBalancesResponseStruct,
257
- exports.ResolveAccountAddressResponseStruct,
258
- exports.FilterAccountChainsResponseStruct,
259
- exports.UpdateAccountResponseStruct,
260
- exports.DeleteAccountResponseStruct,
261
- exports.ExportAccountResponseStruct,
262
- exports.ListRequestsResponseStruct,
263
- exports.GetRequestResponseStruct,
264
- exports.SubmitRequestResponseStruct,
265
- exports.ApproveRequestResponseStruct,
266
- exports.RejectRequestResponseStruct,
267
- ]),
268
- }),
269
- (0, superstruct_1.object)({
270
- error: (0, superstruct_1.string)(),
271
- }),
272
- ]));
273
218
  //# sourceMappingURL=rpc.cjs.map