UNPKG

@metamask/multichain-network-controller

Version:
55 lines 2.33 kB
import type { InternalAccount } from "@metamask/keyring-internal-api"; import type { Infer } from "@metamask/superstruct"; import type { CaipAccountAddress, CaipAccountId, CaipNamespace, CaipReference } from "@metamask/utils"; export declare const ActiveNetworksResponseStruct: import("@metamask/superstruct").Struct<{ activeNetworks: `${string}:${string}:${string}`[]; }, { activeNetworks: import("@metamask/superstruct").Struct<`${string}:${string}:${string}`[], import("@metamask/superstruct").Struct<`${string}:${string}:${string}`, null>>; }>; export type ActiveNetworksResponse = Infer<typeof ActiveNetworksResponseStruct>; /** * The active networks for the currently selected account. */ export type ActiveNetworksByAddress = Record<CaipAccountAddress, { namespace: CaipNamespace; activeChains: CaipReference[]; }>; /** * The domain for multichain accounts API. */ export declare const MULTICHAIN_ACCOUNTS_BASE_URL = "https://accounts.api.cx.metamask.io"; /** * The client header for the multichain accounts API. */ export declare const MULTICHAIN_ACCOUNTS_CLIENT_HEADER = "x-metamask-clientproduct"; /** * The client ID for the multichain accounts API. */ export declare const MULTICHAIN_ACCOUNTS_CLIENT_ID = "metamask-multichain-network-controller"; /** * The allowed active network scopes for the multichain network controller. */ export declare const MULTICHAIN_ALLOWED_ACTIVE_NETWORK_SCOPES: string[]; /** * Converts an internal account to an array of CAIP-10 account IDs. * * @param account - The internal account to convert * @returns The CAIP-10 account IDs */ export declare function toAllowedCaipAccountIds(account: InternalAccount): CaipAccountId[]; /** * Formats the API response into our state structure. * Example input: ["eip155:1:0x123...", "eip155:137:0x123...", "solana:1:0xabc..."] * * @param response - The raw API response * @returns Formatted networks by address */ export declare function toActiveNetworksByAddress(response: ActiveNetworksResponse): ActiveNetworksByAddress; /** * Constructs the URL for the active networks API endpoint. * * @param accountIds - Array of account IDs * @returns URL object for the API endpoint */ export declare function buildActiveNetworksUrl(accountIds: CaipAccountId[]): URL; //# sourceMappingURL=accounts-api.d.mts.map