{"version":3,"sources":["../src/account.ts","../src/apollo.ts","../src/client.ts","../src/clientShareProvider.ts","../src/network.ts","../src/utils/formatBalance.ts"],"names":["KeybanAccount","rpcClient","tppId","createApolloClient","apiUrl","accessTokenProvider","authLink","setContext","_","headers","token","httpLink","createHttpLink","wsUrl","wsLink","GraphQLWsLink","createClient","transportLink","split","query","definition","getMainDefinition","ApolloClient","InMemoryCache","relayStylePagination","date","ApolloLink","KeybanClientBase","config","metadataConfig","KeybanClientShareProvider","indexerPrefix","metadataUrl","res","RpcClient","err","username","password","connection","otp","loginUrl","width","height","left","top","popup","authenticatedPromise","resolve","handler","event","interval","logoutUrl","KeybanClient","#client","#pendingAccounts","KeybanEvmClient","StarknetClient","StellarClient","key","pending","promise","client","#rpcClient","clientShare","KeybanNetwork","formatBalance","balance","decimals","symbol","fmt","formatUnits"],"mappings":"2aAwGO,IAAeA,CAAf,CAAA,KAA6B,CAWxB,SAAA,CAOV,WAAYC,CAAAA,CAAAA,CAAsB,CAChC,IAAA,CAAK,SAAYA,CAAAA,EACnB,CA8JA,MAAM,SAASC,CAAe,CAAA,CAC5B,OAAO,IAAA,CAAK,SAAU,CAAA,IAAA,CAAK,KAAO,CAAA,OAAA,CAASA,EAAO,IAAK,CAAA,OAAO,CAChE,CASA,MAAM,YAAA,EAA8B,CAGlC,OAAO,QAAQ,OAAQ,EACzB,CACF,ECpRO,SAASC,CAAAA,CACdC,CACAC,CAAAA,CAAAA,CACA,CACA,IAAMC,CAAWC,CAAAA,UAAAA,CAAW,MAAOC,CAAG,CAAA,CAAE,OAAAC,CAAAA,CAAQ,CAAM,GAAA,CACpD,IAAMC,CAAAA,CAAQ,MAAML,CAAsB,IAAA,CAE1C,OAAO,CACL,OAAS,CAAA,CACP,GAAGI,CAAAA,CACH,cAAeC,CAAQ,CAAA,CAAA,OAAA,EAAUA,CAAK,CAAA,CAAA,CAAK,EAC7C,CACF,CACF,CAAC,EAEKC,CAAWC,CAAAA,cAAAA,CAAe,CAAE,GAAA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AA,CAAWD,CAAQ,CAAA,QAAA,CACnBE,CAASF,CAAAA,CAAAA,CAAQ,OACjBA,CAAQ,CAAA,MAAA,EACVC,CAAWN,CAAAA,CAAAA,CAAO,QAAS,CAAA,QAAA,CAC3BO,CAASP,CAAAA,CAAAA,CAAO,SAAS,MAChBK,EAAAA,CAAAA,CAAQ,QACjBC,EAAAA,CAAAA,CAAWN,CAAO,CAAA,cAAA,CAAe,QACjCO,CAAAA,CAAAA,CAASP,EAAO,cAAe,CAAA,MAAA,EACtBnD,CACTyD,GAAAA,CAAAA,CAAWzD,CAAM,CAAA,QAAA,EAAY,MAC7B0D,CAAAA,CAAAA,CAAS1D,EAAM,MAAU,EAAA,MAAA,CAAA,CAE3ByD,CAAWA,CAAAA,CAAAA,EAAY,CAEvB,CAAA,IAAME,CAAMC,CAAAA,WAAAA,CACV,OAAOJ,CAAQ,CAAA,GAAA,EAAQ,QAAWA,CAAAA,CAAAA,CAAQ,GAAM,CAAA,MAAA,CAAOA,CAAQ,CAAA,GAAG,EAClEC,CACF,CAAA,CACA,OAAOC,CAAAA,CAAS,CAAGC,EAAAA,CAAG,CAAID,CAAAA,EAAAA,CAAM,GAAKC,CACvC","file":"chunk-WPOOJWVI.mjs","sourcesContent":["/**\n * @module Account\n */\n\nimport type { Address, Hash, Hex } from \"~/index\";\nimport { RpcClient } from \"~/rpc\";\n\n/**\n * Represents the estimation of fees for a transaction.\n * @see {@link KeybanAccount#estimateTransfer}\n */\nexport type FeesEstimation = {\n  /**\n   * The total maximum fees for the transaction.\n   */\n  maxFees: bigint;\n\n  details: {\n    /**\n     * The maximum fee per unit of gas.\n     */\n    maxFeePerGas: bigint;\n\n    /**\n     * The maximum priority fee per unit of gas.\n     */\n    maxPriorityFeePerGas: bigint;\n\n    /**\n     * The estimated gas cost for the transaction.\n     */\n    gasCost: bigint;\n  };\n};\n\n/**\n * Represents the options for a transaction.\n * see {@link KeybanAccount#transfer}\n */\nexport type TransactionOptions = {\n  /** The maximum fee per unit of gas */\n  maxFeePerGas?: bigint;\n  /** The maximum priority fee per unit of gas */\n  maxPriorityFeePerGas?: bigint;\n};\n\n/**\n * Represents the parameters for transferring ERC20 tokens.\n * @property {Address} contractAddress - The address of the ERC20 token contract\n * @property {Address} to - The recipient's address\n * @property {bigint} value - The transfer amount in the smallest token unit\n * @property {TransactionOptions} txOptions - The transaction options\n * @see {@link KeybanAccount#transferERC20}\n */\nexport type TransferERC20Params = {\n  contractAddress: Address;\n  to: Address;\n  value: bigint;\n  txOptions?: TransactionOptions;\n};\n\n/**\n * Represents the parameters for transferring ERC721 and ERC1155 tokens.\n * @property {Address} contractAddress - The address of the NFT contract\n * @property {bigint} tokenId - The ID of the token\n * @property {Address} to - The recipient's address\n * @property {bigint} value - The transfer amount (for ERC1155 tokens)\n * @property {TransactionOptions} txOptions - The transaction options\n * @property {string} standard - The token standard (ERC721 or ERC1155)\n * @see {@link KeybanAccount#transferNft}\n */\nexport type TransferNftParams = {\n  contractAddress: Address;\n  tokenId: bigint;\n  to: Address;\n  value?: bigint;\n  standard: \"ERC721\" | \"ERC1155\";\n  txOptions?: TransactionOptions;\n};\n\n/**\n * Represents the parameters required to estimate an ERC20 token transfer,\n * excluding the transaction options.\n *\n * This type is derived from `TransferERC20Params` by omitting the `txOptions` property.\n */\nexport type EstimateERC20TransferParams = Omit<\n  TransferERC20Params,\n  \"txOptions\"\n>;\n\n/**\n * Parameters required to estimate the transfer of an NFT, excluding transaction options.\n *\n * This type is derived from `TransferNftParams` by omitting the `txOptions` property.\n * @see {@link TransferNftParams}\n */\nexport type EstimateNftTransferParams = Omit<TransferNftParams, \"txOptions\">;\n\n/**\n * A `KeybanAccount` represents a user's account in the Keyban system.\n * It provides methods to interact with the blockchain, including signing messages,\n * fetching balances, transferring tokens, and estimating transaction costs.\n */\nexport abstract class KeybanAccount {\n  /**\n   * The blockchain address associated with the account.\n   */\n  abstract address: Address;\n\n  /**\n   * The public key associated with the account.\n   */\n  abstract publicKey: string;\n\n  protected rpcClient: RpcClient;\n\n  /**\n   * KeybanAccount constructor\n   * @param rpcClient - the keyban rpc client\n   * @private\n   */\n  constructor(rpcClient: RpcClient) {\n    this.rpcClient = rpcClient;\n  }\n\n  /**\n   * Signs an Ethereum message.\n   * @param message - The message to be signed.\n   * @returns - The signed message as a hex string.\n   * @throws {Error} If the message is empty or there is an issue during signing.\n   */\n  abstract signMessage(message: string): Promise<Hex | string | string[]>;\n\n  /**\n   * Transfers native tokens to another address.\n   * @param to - The recipient's address.\n   * @param value - The transfer amount in wei (must be greater than 0).\n   * @param txOptions - Optional transaction options.\n   * @returns - A promise that resolves to the transaction hash.\n   * @throws {SdkError} If the recipient's address is invalid or the transfer amount is invalid.\n   * @example\n   * ```ts\n   * const handleTransfer = async () => {\n   *   // amount, account, recipient, setTransactionHash are state variables\n   *   try {\n   *     const valueInWei = BigInt(Number(amount) * 1e18);\n   *     const txHash = await account.transfer(recipient as Address, valueInWei);\n   *     setTransactionHash(txHash);\n   *   } catch (err) {\n   *     console.log(err);\n   *   }\n   * };\n   * ```\n   */\n  abstract transfer(\n    to: Address,\n    value: bigint,\n    txOptions?: TransactionOptions,\n  ): Promise<Hash | string>;\n\n  /**\n   * Estimates the cost of transferring native tokens to another address.\n   * @param to - The recipient's address.\n   * @returns - A promise that resolves to a `FeesEstimation` object containing the fee details.\n   * @throws {Error} If there is an issue with estimating the gas or fees.\n   */\n  abstract estimateTransfer(to: Address): Promise<FeesEstimation>;\n\n  /**\n   * Transfers ERC20 tokens to another address.\n   * @param params - The parameters for the ERC20 transfer.\n   * @returns - A promise that resolves to the transaction hash.\n   * @throws {SdkError} If the recipient's address is invalid, the contract address is invalid, or the transfer amount is invalid.\n   * @example\n   * ```ts\n   * const handleTransfer = async () => {\n   *  // amount, account, recipient, contractAddress, setTransactionHash are state variables\n   *  try {\n   *   const valueInWei = BigInt(Number(amount) * 1e18);\n   *   const txHash = await account.transferERC20({\n   *   contractAddress: contractAddress as Address,\n   *   to: recipient as Address,\n   *   value: valueInWei,\n   *   });\n   *   setTransactionHash(txHash);\n   *  } catch (err) {\n   *   console.log(err);\n   *  }\n   * };\n   * ```\n   */\n  abstract transferERC20(params: TransferERC20Params): Promise<Hash>;\n\n  /**\n   * Estimates the cost of transferring ERC20 tokens to another address.\n   * @param params - The parameters for estimating the ERC20 transfer.\n   * @returns - A promise that resolves to a `FeesEstimation` object containing the fee details.\n   * @throws {Error} If there is an issue with estimating the gas or fees.\n   * @example\n   * ```ts\n   * const handleEstimate = async () => {\n   *   // account, recipient, contractAddress, amount, setTransferCost are state variables\n   *   try {\n   *     const valueInWei = BigInt(Number(amount) * 1e18);\n   *     const estimation = await account.estimateTransferERC20({\n   *       contractAddress: contractAddress as Address,\n   *       to: recipient as Address,\n   *       value: valueInWei,\n   *     });\n   *     setTransferCost(estimation.maxFees.toString());\n   *   } catch (err) {\n   *     console.log(err);\n   *   }\n   * };\n   * ```\n   */\n  abstract estimateERC20Transfer(\n    params: EstimateERC20TransferParams,\n  ): Promise<FeesEstimation>;\n\n  /**\n   * Transfers ERC721 and ERC1155 tokens to another address.\n   * @param params - The parameters for the NFT transfer.\n   * @returns - A promise that resolves to the transaction hash.\n   * @throws {SdkError} If the recipient's address is invalid, the contract address is invalid, the transfer amount is invalid, or the token standard is invalid.\n   * @example\n   * ```ts\n   * const handleTransfer = async () => {\n   *  // account, recipient, contractAddress, tokenId, amount, standard, setTransactionHash are state variables\n   *  try {\n   *    const value = BigInt(amount);\n   *    const txHash = await account.transferNft({\n   *      contractAddress: contractAddress as Address,\n   *      tokenId: tokenId as bigint,\n   *      to: recipient as Address,\n   *      value: value,\n   *      standard: standard as 'ERC721' | 'ERC1155',\n   *    });\n   *    setTransactionHash(txHash);\n   *  } catch (err) {\n   *    console.log(err);\n   *  }\n   * };\n   * ```\n   */\n  abstract transferNft(params: TransferNftParams): Promise<Hash>;\n\n  /**\n   * Estimates the cost of transferring ERC721 and ERC1155 tokens to another address.\n   * @param params - The parameters for estimating the NFT transfer.\n   * @returns - A promise that resolves to a `FeesEstimation` object containing the fee details.\n   * @throws {Error} If there is an issue with estimating the gas or fees.\n   * @example\n   * ```ts\n   * const handleEstimate = async () => {\n   *  // account, recipient, contractAddress, tokenId, amount, standard, setTransferCost are state variables\n   *  try {\n   *  const value = BigInt(amount);\n   *  const estimation = await account.estimateNftTransfer({\n   *    contractAddress: contractAddress as Address,\n   *    tokenId: tokenId as bigint,\n   *    to: recipient as Address,\n   *    value: value,\n   *    standard: standard as 'ERC721' | 'ERC1155',\n   *  });\n   *  setTransferCost(estimation.maxFees.toString());\n   *  } catch (err) {\n   *    console.log(err);\n   *  }\n   * };\n   * ```\n   */\n  abstract estimateNftTransfer(\n    params: EstimateNftTransferParams,\n  ): Promise<FeesEstimation>;\n\n  /**\n   * Claims a TPP for a given recipient.\n   * @param tppId - The identifier of the Tokenized Product Passport (TPP) to claim.\n   * @returns A promise that resolves with the result of the RPC call.\n   */\n  async tppClaim(tppId: string) {\n    return this.rpcClient.call(\"tpp\", \"claim\", tppId, this.address);\n  }\n\n  /**\n   * Sets up the account for the loyalty application.\n   * This method signs a setup transaction and submits it to the network.\n   * It makes the account ready to be used with the loyalty application.\n   * It depends on the blockchain network.\n   * @returns A promise that resolves when the setup is complete.\n   */\n  async loyaltySetup(): Promise<void> {\n    // By default, this method does nothing.\n    // Subclasses can override this method to provide specific implementation.\n    return Promise.resolve();\n  }\n}\n","import { InMemoryCache } from \"@apollo/client/cache\";\nimport {\n  ApolloClient,\n  ApolloLink,\n  createHttpLink,\n  split,\n} from \"@apollo/client/core\";\nimport { setContext } from \"@apollo/client/link/context\";\nimport { GraphQLWsLink } from \"@apollo/client/link/subscriptions\";\nimport {\n  getMainDefinition,\n  relayStylePagination,\n} from \"@apollo/client/utilities\";\nimport { createClient } from \"graphql-ws\";\n\n/**\n * Creates an Apollo Client instance.\n * @param apiUrl - The API URL.\n * @param accessTokenProvider - Optional function to provide access token.\n * @returns - The Apollo Client instance.\n * @private\n */\nexport function createApolloClient(\n  apiUrl: URL,\n  accessTokenProvider?: () => string | Promise<string>,\n) {\n  const authLink = setContext(async (_, { headers }) => {\n    const token = await accessTokenProvider?.();\n\n    return {\n      headers: {\n        ...headers,\n        authorization: token ? `Bearer ${token}` : \"\",\n      },\n    };\n  });\n\n  const httpLink = createHttpLink({ uri: apiUrl.toString() });\n\n  const wsUrl = new URL(apiUrl);\n  wsUrl.protocol = \"wss\";\n  const wsLink = new GraphQLWsLink(createClient({ url: wsUrl.toString() }));\n\n  const transportLink = split(\n    ({ query }) => {\n      const definition = getMainDefinition(query);\n      return (\n        definition.kind === \"OperationDefinition\" &&\n        definition.operation === \"subscription\"\n      );\n    },\n    wsLink,\n    httpLink,\n  );\n\n  return new ApolloClient({\n    connectToDevTools: true,\n    cache: new InMemoryCache({\n      typePolicies: {\n        Query: {\n          fields: {\n            tokenBalances: relayStylePagination([\"filter\"]),\n            nftBalances: relayStylePagination([\"filter\"]),\n            assetTransfers: relayStylePagination([\"filter\"]),\n          },\n        },\n        Transaction: {\n          fields: {\n            date: {\n              read(date) {\n                return date ? date + \"Z\" : date;\n              },\n            },\n          },\n        },\n      },\n    }),\n    link: ApolloLink.from([authLink, transportLink]),\n  });\n}\n","/**\n * @module Client\n */\nimport type { NormalizedCacheObject } from \"@apollo/client/cache\";\nimport type { ApolloClient } from \"@apollo/client/core\";\n\nimport { KeybanAccount } from \"~/account\";\nimport type { KeybanApiStatus } from \"~/api\";\nimport { createApolloClient } from \"~/apollo\";\nimport {\n  AuthConnection,\n  KeybanClientShareProvider,\n  KeybanNetwork,\n} from \"~/index\";\nimport { type FeesUnit, NativeCurrency } from \"~/network\";\nimport { RpcClient } from \"~/rpc\";\n\n/**\n * Represents a storage provider for the client share.\n *\n * The purpose of `ClientShareProvider` is to provide an interface that allows integrators\n * to save and restore the client share of their customers. The integrator has the\n * responsibility to securely store the client share.\n * @remarks\n * The client share is not considered sensitive data because only the client\n * can use it, and its usage is secured by strong authentication between the client\n * and the Keyban services.\n *\n * ### Example Implementation\n *\n * Below is a basic implementation of a `CustomClientShareProvider` using a fetch-based provider:\n *\n * ```typescript\n * class CustomClientShareProvider implements ClientShareProvider {\n *    // Retrieves the client share data.\n *    // @returns - A promise resolving to the client share string or `null` if unavailable.\n *   async get(): Promise<string | null> {\n *     try {\n *       const response = await fetch(\"/api/clientShare\", {\n *         method: \"GET\",\n *         headers: { \"Content-Type\": \"application/json\" },\n *       });\n *\n *       if (!response.ok) {\n *         console.error(\"Failed to fetch client share:\", response.statusText);\n *         return null;\n *       }\n *\n *       return response.text();\n *     } catch (error) {\n *       console.error(\"Error retrieving client share:\", error);\n *       return null;\n *     }\n *   }\n *\n *\n *   // Saves the client share data.\n *   // @param clientShare - The client share string to store.\n *   // @returns - A promise that resolves when the operation is complete.\n *   async set(clientShare: string): Promise<void> {\n *     try {\n *       const response = await fetch(\"/api/clientShare\", {\n *         method: \"POST\",\n *         headers: { \"Content-Type\": \"application/json\" },\n *         body: JSON.stringify({ clientShare }),\n *       });\n *\n *       if (!response.ok) {\n *         throw new Error(`Failed to save client share: ${response.statusText}`);\n *       }\n *     } catch (error) {\n *       console.error(\"Error saving client share:\", error);\n *       throw error;\n *     }\n *   }\n * }\n * ```\n *\n * This implementation assumes the existence of an API endpoint `/api/clientShare`\n * to manage the client share on the server side. The integrator should ensure that\n * the endpoint is appropriately secured.\n */\nexport interface ClientShareProvider {\n  /**\n   * Retrieves the client share information.\n   * @param key - The key associated with the client share.\n   * @returns - A promise that resolves to a string containing the client share, or null if not available.\n   */\n  get(key: string): Promise<string | null>;\n  /**\n   * Sets the client share information.\n   * @param key - The key associated with the client share.\n   * @param clientShare - The client share string to set.\n   * @returns - A promise that resolves when the client share has been set.\n   */\n  set(key: string, clientShare: string): Promise<unknown>;\n}\n\n/**\n * Configuration options for initializing the Keyban client.\n */\nexport type KeybanClientConfig = {\n  /**\n   * The base URL of the API. Optional. Defaults to \"https://api.prod.keyban.io\" if not provided.\n   */\n  apiUrl?: URL | string;\n\n  /**\n   * The application ID.\n   */\n  appId: string;\n\n  /**\n   * The blockchain configuration for Keyban.\n   */\n  network: KeybanNetwork;\n\n  /**\n   * The client share provider.\n   */\n  clientShareProvider: ClientShareProvider;\n};\n\nexport type MetadataConfig = {\n  network: { rpcUrl: string; indexerUrl: string };\n  auth: { domain: string; clientId: string };\n};\n\nexport abstract class KeybanClientBase {\n  /**\n   * The Keyban API URL, defaulting to \"https://api.prod.keyban.io\".\n   */\n  apiUrl: URL;\n\n  /**\n   * The application ID used for authentication with the Keyban API.\n   */\n  appId: string;\n\n  /**\n   * The blockchain used by Keyban.\n   */\n  network: KeybanNetwork;\n\n  /**\n   * The Apollo GraphQL client used for making API requests.\n   */\n  apolloClient: ApolloClient<NormalizedCacheObject>;\n\n  protected clientShareProvider: ClientShareProvider;\n  protected metadataConfig: Promise<MetadataConfig>;\n\n  constructor(\n    config: KeybanClientConfig,\n    metadataConfig?: Promise<MetadataConfig>,\n  ) {\n    this.apiUrl = new URL(config.apiUrl ?? \"https://api.prod.keyban.io\");\n    this.appId = config.appId;\n    this.network = config.network;\n\n    this.clientShareProvider = config.clientShareProvider;\n    if (this.clientShareProvider instanceof KeybanClientShareProvider)\n      this.clientShareProvider.registerClient(this);\n\n    const indexerPrefix = {\n      [KeybanNetwork.EthereumAnvil]: \"subql-ethereum-anvil.\",\n      [KeybanNetwork.PolygonAmoy]: \"subql-polygon-amoy.\",\n      [KeybanNetwork.StarknetDevnet]: \"subql-starknet-devnet.\",\n      [KeybanNetwork.StarknetSepolia]: \"subql-starknet-sepolia.\",\n      [KeybanNetwork.StarknetMainnet]: \"subql-starknet-mainnet.\",\n      [KeybanNetwork.StellarQuickstart]: \"subql-stellar-quickstart.\",\n      [KeybanNetwork.StellarTestnet]: \"subql-stellar-testnet.\",\n      [KeybanNetwork.StellarMainnet]: \"subql-stellar-mainnet.\",\n    }[this.network];\n    this.apolloClient = createApolloClient(\n      new URL(this.apiUrl.origin.replace(\"api.\", indexerPrefix)),\n    );\n\n    const metadataUrl = new URL(`/v1/metadata`, this.apiUrl);\n    metadataUrl.searchParams.set(\"network\", this.network);\n    this.metadataConfig =\n      metadataConfig ?? fetch(metadataUrl).then((res) => res.json());\n  }\n\n  protected get rpcClient() {\n    return RpcClient.getInstance(this);\n  }\n\n  /**\n   * Retrieves the native currency details associated with the current chain.\n   *\n   * This getter returns an object that includes the native currency's name, symbol, and decimal precision for the respective blockchain\n   * as defined by the `this.chain` property. Each blockchain in the supported list (e.g., EthereumAnvil, PolygonAmoy, StarknetDevnet, etc.)\n   * has its unique configuration, which is used to construct the returned object.\n   * @returns The native currency information for the current chain.\n   */\n  get nativeCurrency(): NativeCurrency {\n    return {\n      [KeybanNetwork.EthereumAnvil]: {\n        decimals: 18,\n        name: \"Ether\",\n        symbol: \"ETH\",\n      },\n      [KeybanNetwork.PolygonAmoy]: {\n        name: \"POL\",\n        symbol: \"POL\",\n        decimals: 18,\n      },\n      [KeybanNetwork.StarknetDevnet]: {\n        name: \"Starknet Token\",\n        symbol: \"STRK\",\n        decimals: 18,\n      },\n      [KeybanNetwork.StarknetSepolia]: {\n        name: \"StarkNet Token\",\n        symbol: \"STRK\",\n        decimals: 18,\n      },\n      [KeybanNetwork.StarknetMainnet]: {\n        name: \"StarkNet Token\",\n        symbol: \"STRK\",\n        decimals: 18,\n      },\n      [KeybanNetwork.StellarQuickstart]: {\n        name: \"Lumen\",\n        symbol: \"XLM\",\n        decimals: 7,\n      },\n      [KeybanNetwork.StellarTestnet]: {\n        name: \"Lumen\",\n        symbol: \"XLM\",\n        decimals: 7,\n      },\n      [KeybanNetwork.StellarMainnet]: {\n        name: \"Lumen\",\n        symbol: \"XLM\",\n        decimals: 7,\n      },\n    }[this.network];\n  }\n\n  /**\n   * Retrieves the fee unit configuration based on the current blockchain chain.\n   *\n   * This getter returns an object that maps supported blockchain chains to their respective\n   * fee unit details, including the currency symbol and the number of decimal places.\n   * The fee unit is selected according to the chain specified in `this.chain`.\n   * @remarks\n   * Supported configurations include:\n   * - EthereumAnvil & PolygonAmoy with unit \"gwei\" and 9 decimals.\n   * - StarknetDevnet, StarknetSepolia, & StarknetMainnet with unit \"FRI\" and 18 decimals.\n   * - StellarTestnet with unit \"stroop\" and 6 decimals.\n   * @returns An object containing the fee unit configuration for the active chain.\n   */\n  get feesUnit(): FeesUnit {\n    return {\n      [KeybanNetwork.EthereumAnvil]: {\n        symbol: \"gwei\",\n        decimals: 9,\n      },\n      [KeybanNetwork.PolygonAmoy]: {\n        symbol: \"gwei\",\n        decimals: 9,\n      },\n      [KeybanNetwork.StarknetDevnet]: {\n        symbol: \"FRI\",\n        decimals: 18,\n      },\n      [KeybanNetwork.StarknetSepolia]: {\n        symbol: \"FRI\",\n        decimals: 18,\n      },\n      [KeybanNetwork.StarknetMainnet]: {\n        symbol: \"FRI\",\n        decimals: 18,\n      },\n      [KeybanNetwork.StellarQuickstart]: {\n        symbol: \"stroop\",\n        decimals: 7,\n      },\n      [KeybanNetwork.StellarTestnet]: {\n        symbol: \"stroop\",\n        decimals: 7,\n      },\n      [KeybanNetwork.StellarMainnet]: {\n        symbol: \"stroop\",\n        decimals: 7,\n      },\n    }[this.network];\n  }\n\n  /**\n   * Performs a health check on the Keyban API to determine its operational status.\n   * @returns - A promise resolving to the API status, either `\"operational\"` or `\"down\"`.\n   * @example\n   * ```typescript\n   * const status = await client.apiStatus();\n   * console.log(`API Status: ${status}`);\n   * ```\n   * @throws {Error} Throws an error if the health check request fails.\n   * @see {@link KeybanApiStatus}\n   */\n  async apiStatus(): Promise<KeybanApiStatus> {\n    return fetch(new URL(\"/health/ready\", this.apiUrl))\n      .then((res) => (res.ok ? \"operational\" : \"down\"))\n      .catch((err) => {\n        console.error(\"Failed to perform health check\", err);\n        return \"down\";\n      });\n  }\n\n  /**\n   * Checks whether the client is authenticated.\n   * @returns A Promise that resolves to the result of the authentication check.\n   */\n  async isAuthenticated() {\n    return this.rpcClient.call(\"auth\", \"isAuthenticated\");\n  }\n\n  /**\n   * Retrieves the current user information.\n   * @returns A Promise resolving with the user data retrieved from the server.\n   */\n  async getUser() {\n    return this.rpcClient.call(\"auth\", \"getUser\");\n  }\n\n  async passwordLogin(username: string, password: string) {\n    return this.rpcClient.call(\"auth\", \"passwordLogin\", username, password);\n  }\n\n  async passwordlessStart(connection: \"email\" | \"sms\", username: string) {\n    return this.rpcClient.call(\n      \"auth\",\n      \"passwordlessStart\",\n      connection,\n      username,\n    );\n  }\n\n  async passwordlessLogin(\n    connection: \"email\" | \"sms\",\n    username: string,\n    otp: string,\n  ) {\n    return this.rpcClient.call(\n      \"auth\",\n      \"passwordlessLogin\",\n      connection,\n      username,\n      otp,\n    );\n  }\n\n  /**\n   * Initiates the login process by opening a popup window for user authentication.\n   * @param [connection] - Optional authentication connection details.\n   * @returns - A promise that resolves when the user is authenticated or the popup is closed.\n   */\n  async login(connection?: AuthConnection) {\n    const loginUrl = await this.rpcClient.call(\n      \"auth\",\n      \"getLoginUrl\",\n      connection,\n    );\n\n    const width = 500;\n    const height = 685;\n    const left = window.screenX + (window.innerWidth - width) / 2;\n    const top = window.screenY + (window.innerHeight - height) / 2;\n\n    const popup = window.open(\n      loginUrl,\n      `keyban:auth:${this.appId}`,\n      `left=${left},top=${top},width=${width},height=${height},popup,resizable,scrollbars`,\n    );\n\n    // Setup our handler for when user is fully authenticated\n    const authenticatedPromise = new Promise<void>((resolve) => {\n      const handler = (event: MessageEvent) => {\n        if (event.origin !== this.apiUrl.origin) return;\n        if (event.data !== \"keyban:auth:isAuthenticated\") return;\n\n        window.removeEventListener(\"message\", handler);\n\n        resolve();\n      };\n\n      window.addEventListener(\"message\", handler);\n    });\n\n    // Wait for popup to be closed\n    await new Promise<void>((resolve) => {\n      const interval = setInterval(() => {\n        if (!popup?.closed) return;\n\n        clearInterval(interval);\n        resolve();\n      }, 100);\n    });\n\n    // Wait for user to be authenticated or timeout\n    await Promise.race([\n      authenticatedPromise,\n      new Promise((resolve) => setTimeout(resolve, 2000)),\n    ]);\n  }\n\n  async logout() {\n    const logoutUrl = await this.rpcClient.call(\n      \"auth\",\n      \"getLogoutUrl\",\n      window.location.href,\n    );\n\n    const width = 500;\n    const height = 685;\n    const left = window.screenX + (window.innerWidth - width) / 2;\n    const top = window.screenY + (window.innerHeight - height) / 2;\n\n    const popup = window.open(\n      logoutUrl,\n      `keyban:auth:${this.appId}`,\n      `left=${left},top=${top},width=${width},height=${height},popup,resizable,scrollbars`,\n    );\n\n    // Wait for popup to be closed\n    await new Promise<void>((resolve) => {\n      const interval = setInterval(() => {\n        if (!popup?.closed) return;\n\n        clearInterval(interval);\n        resolve();\n      }, 100);\n    });\n  }\n\n  /**\n   * Initializes a `KeybanAccount` associated with the current client.\n   * This method sets up the account by retrieving or generating the client share,\n   * and prepares the account for transactions and other operations.\n   * @returns - A promise that resolves to an instance of `KeybanAccount`.\n   * @throws {SdkError} If initialization fails due to signing errors.\n   * @example\n   * ```typescript\n   * const account = await client.initialize();\n   * console.log(`Account address: ${account.address}`);\n   * ```\n   * @see {@link KeybanAccount}\n   */\n  abstract initialize(): Promise<KeybanAccount>;\n}\n\n/**\n * Main client for interacting with the Keyban API and associated services.\n * This class provides methods to initialize accounts, retrieve balances, query NFTs,\n * and interact with the Keyban blockchain.\n * @remarks\n * The `KeybanClient` serves as the primary interface for developers to interact with\n * the Keyban ecosystem. It handles authentication, communication with the Keyban API,\n * and provides utility methods for common tasks.\n * @example\n * ```typescript\n * // Initialize the client\n * const client = new KeybanClient({\n *   apiUrl: \"https://api.prod.keyban.io\",\n *   appId: \"your-app-id\",\n *   network: KeybanNetwork.EthereumAnvil,\n * });\n *\n * // Initialize an account\n * const account = await client.initialize();\n * ```\n * @see {@link KeybanAccount}\n */\nexport class KeybanClient extends KeybanClientBase {\n  #client: Promise<KeybanClientBase>;\n\n  #pendingAccounts: Map<string, Promise<KeybanAccount>> = new Map();\n\n  /**\n   * Creates a new instance of `KeybanClient`.\n   * @param config - The configuration object to initialize the client.\n   * @throws {SdkError} If the configuration is invalid.\n   * @example\n   * ```typescript\n   * const client = new KeybanClient({\n   *   apiUrl: \"https://api.prod.keyban.io\",\n   *   appId: \"your-app-id\",\n   *   network: KeybanNetwork.EthereumAnvil,\n   * });\n   * ```\n   */\n  constructor(config: KeybanClientConfig) {\n    super(config);\n\n    this.#client = {\n      [KeybanNetwork.EthereumAnvil]: () =>\n        import(\"~/evm\").then(\n          ({ KeybanEvmClient }) =>\n            new KeybanEvmClient(config, this.metadataConfig),\n        ),\n      [KeybanNetwork.PolygonAmoy]: () =>\n        import(\"~/evm\").then(\n          ({ KeybanEvmClient }) =>\n            new KeybanEvmClient(config, this.metadataConfig),\n        ),\n      [KeybanNetwork.StarknetDevnet]: () =>\n        import(\"~/starknet\").then(\n          ({ StarknetClient }) =>\n            new StarknetClient(config, this.metadataConfig),\n        ),\n      [KeybanNetwork.StarknetSepolia]: () =>\n        import(\"~/starknet\").then(\n          ({ StarknetClient }) =>\n            new StarknetClient(config, this.metadataConfig),\n        ),\n      [KeybanNetwork.StarknetMainnet]: () =>\n        import(\"~/starknet\").then(\n          ({ StarknetClient }) =>\n            new StarknetClient(config, this.metadataConfig),\n        ),\n      [KeybanNetwork.StellarQuickstart]: () =>\n        import(\"~/stellar\").then(\n          ({ StellarClient }) => new StellarClient(config, this.metadataConfig),\n        ),\n      [KeybanNetwork.StellarTestnet]: () =>\n        import(\"~/stellar\").then(\n          ({ StellarClient }) => new StellarClient(config, this.metadataConfig),\n        ),\n      [KeybanNetwork.StellarMainnet]: () =>\n        import(\"~/stellar\").then(\n          ({ StellarClient }) => new StellarClient(config, this.metadataConfig),\n        ),\n    }[this.network]();\n  }\n\n  async initialize() {\n    const key = \"WHATEVER\";\n\n    const pending = this.#pendingAccounts.get(key);\n    if (pending) return pending;\n\n    const promise = this.#client.then((client) => client.initialize());\n\n    this.#pendingAccounts.set(key, promise);\n    promise.catch(() => {}).finally(() => this.#pendingAccounts.delete(key));\n\n    return promise;\n  }\n}\n","import { ClientShareProvider, KeybanClientBase } from \"~/client\";\nimport { RpcClient } from \"~/rpc\";\n\n/**\n * A client share provider implementation for the Keyban client.\n *\n * The `KeybanClientShareProvider` class provides methods to get and set the client share.\n * This class is used to interact with the client share storage on the server side.\n * @remarks\n * The client share is saved in a service provided by Keyban, ensuring secure storage\n * and retrieval of the client share information.\n */\nexport class KeybanClientShareProvider implements ClientShareProvider {\n  #client!: KeybanClientBase;\n\n  /**\n   * Internal use only.\n   * @param client - A keyban client\n   * @private\n   */\n  registerClient(client: KeybanClientBase) {\n    this.#client = client;\n  }\n\n  get #rpcClient() {\n    return RpcClient.getInstance(this.#client);\n  }\n\n  /**\n   * Retrieves the client share information.\n   * @param key - The key associated with the client share.\n   * @returns - A promise that resolves to a string containing the client share, or null if not available.\n   */\n  async get(key: string): Promise<string | null> {\n    return this.#rpcClient.call(\"clientShareStorage\", \"get\", key);\n  }\n\n  /**\n   * Sets the client share information.\n   * @param key - The key associated with the client share.\n   * @param clientShare - The client share string to set.\n   * @returns - A promise that resolves when the client share has been set.\n   */\n  async set(key: string, clientShare: string): Promise<unknown> {\n    return this.#rpcClient.call(\"clientShareStorage\", \"set\", key, clientShare);\n  }\n}\n","/**\n * @module Chains\n */\n\n/**\n * @enum {string}\n * The `KeybanNetwork` enumeration defines the various blockchain networks supported by the Keyban SDK.\n * Each member of the enumeration represents a specific blockchain network identified by its unique name.\n * @remarks\n * Use this enumeration to specify the blockchain network you wish to interact with when utilizing\n * the different functionalities of the Keyban SDK, such as account management, transactions, and NFTs.\n * @example\n * ```typescript\n * import { KeybanClient, KeybanNetwork } from '@keyban/sdk';\n *\n * const client = new KeybanClient({\n *   apiUrl: \"https://api.prod.keyban.io\",\n *   appId: \"your-app-id\",\n *   network: KeybanNetwork.EthereumAnvil,\n * });\n * ```\n */\nexport enum KeybanNetwork {\n  /**\n   * Ethereum Anvil Chain.\n   * Primarily used for development and testing purposes. This chain allows simulation of\n   * transactions and interactions without affecting the main chain.\n   */\n  EthereumAnvil = \"EthereumAnvil\",\n\n  /**\n   * Polygon Amoy Chain.\n   * Represents the Polygon Amoy mainnet, offering fast transactions and reduced fees.\n   * Ideal for production applications requiring high performance.\n   */\n  PolygonAmoy = \"PolygonAmoy\",\n\n  /**\n   * Starknet Devnet Chain.\n   */\n  StarknetDevnet = \"StarknetDevnet\",\n\n  /**\n   * Starknet Sepolia Chain.\n   */\n  StarknetSepolia = \"StarknetSepolia\",\n\n  /**\n   * Starknet Mainnet Chain.\n   */\n  StarknetMainnet = \"StarknetMainnet\",\n\n  /**\n   * Stellar Quickstart Chain.\n   */\n  StellarQuickstart = \"StellarQuickstart\",\n\n  /**\n   * Stellar Testnet Chain.\n   */\n  StellarTestnet = \"StellarTestnet\",\n\n  /**\n   * Stellar Mainnet Chain.\n   */\n  StellarMainnet = \"StellarMainnet\",\n}\n\n/**\n * Represents the unit of fees in a specific blockchain.\n * @property {string} symbol - The symbol of the fee unit (e.g., \"gwei\").\n * @property {number} decimals - The number of decimal places for the fee unit.\n */\nexport type FeesUnit = {\n  symbol: string;\n  decimals: number;\n};\n\n/**\n * Represents the native currency of a blockchain network.\n * @property {string} name - The name of the native currency (e.g., \"Ether\").\n * @property {string} symbol - The symbol of the native currency (e.g., \"ETH\").\n * @property {number} decimals - The number of decimal places the currency can be divided into.\n * @example\n * const nativeCurrency = {\n *   name: \"Ether\",\n *   symbol: \"ETH\",\n *   decimals: 18\n * };\n * @example\n * const nativeCurrency = {\n *   name: \"Bitcoin\",\n *   symbol: \"BTC\",\n *   decimals: 8\n * };\n */\nexport type NativeCurrency = {\n  name: string;\n  symbol: string;\n  decimals: number;\n};\n","/**\n * @module Format Balances\n */\nimport { formatUnits } from \"viem\";\n\nimport type { KeybanClient, KeybanToken } from \"~/index\";\n\n/**\n * Represents a balance with optional metadata.\n * @example\n * // Example of a balance in native currency with fees\n * const balance: Balance = {\n *   raw: '1000000000000000000',\n *   decimals: 18,\n *   symbol: 'ETH',\n *   isNative: true,\n *   isFees: true\n * };\n * @example\n * // Example of a balance in a token\n * const tokenBalance: Balance = {\n *   raw: BigInt('500000000000000000'),\n *   decimals: 18,\n *   symbol: 'DAI'\n * };\n */\nexport type Balance = {\n  /**  The raw balance value. */\n  raw: string | bigint;\n  /** The number of decimal places for the balance. */\n  decimals?: number;\n  /** The symbol of the currency. */\n  symbol?: string;\n  /** Indicates if the balance is in the native currency. */\n  isNative?: boolean;\n  /** Indicates if the balance is used for fees. */\n  isFees?: boolean;\n};\n\n/**\n * Formats the balance into a human-readable string with the appropriate decimals and symbol.\n * @param client - The KeybanClient instance which provides information about fees and native currency.\n * @param balance - The balance object containing raw balance, decimals, symbol, and flags indicating if it's fees or native currency.\n * @param [token] - (Optional) The KeybanToken object which provides token-specific decimals and symbol.\n * @returns - A formatted string representing the balance with the appropriate decimals and symbol.\n *\n * test\n * @example\n * ```typescript\n * const client = new KeybanClient(...);\n * const balance = { raw: 1000000000000000000n, decimals: 18, isNative: true };\n * console.log(formatBalance(client, balance)); // \"1 ETH\"\n *\n * const balanceWithToken = { raw: 1000000n };\n * const token = {\n *   id: '1',\n *   type: 'ERC20',\n *   name: 'Tether',\n *   symbol: 'USDT',\n *   decimals: 6,\n *   iconUrl: 'https://example.com/usdt-icon.png'\n * };\n * console.log(formatBalance(client, balanceWithToken, token)); // \"1 USDT\"\n *\n * const feeBalance = { raw: 1000n, isFees: true };\n * console.log(formatBalance(client, feeBalance)); // \"0.000001 gwei\"\n * ```\n */\nexport function formatBalance(\n  client: KeybanClient,\n  balance: Balance,\n  token?: KeybanToken,\n): string {\n  let decimals = balance.decimals;\n  let symbol = balance.symbol;\n  if (balance.isFees) {\n    decimals = client.feesUnit.decimals;\n    symbol = client.feesUnit.symbol;\n  } else if (balance.isNative) {\n    decimals = client.nativeCurrency.decimals;\n    symbol = client.nativeCurrency.symbol;\n  } else if (token) {\n    decimals = token.decimals ?? undefined;\n    symbol = token.symbol ?? undefined;\n  }\n  decimals = decimals ?? 0;\n\n  const fmt = formatUnits(\n    typeof balance.raw === \"bigint\" ? balance.raw : BigInt(balance.raw),\n    decimals,\n  );\n  return symbol ? `${fmt} ${symbol}` : fmt;\n}\n"]}