UNPKG

@biconomy/abstractjs

Version:

SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.

49 lines 1.74 kB
import { addressEquals } from "../../../account/utils/Utils.js"; import { getGasToken } from "./getGasToken.js"; /** * Retrieves detailed information about a specific payment token on a given chain. * This function validates if the token is supported for gas payments and returns its configuration. * * @param client - The Mee client instance * @param parameters - Query parameters for the token * @param parameters.chainId - The blockchain chain ID * @param parameters.tokenAddress - The token contract address to query * * @returns Promise resolving to the payment token configuration * * @example * ```typescript * const tokenInfo = await getPaymentToken(client, { * chainId: 1, * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" // USDC * }); * // Returns: * // { * // isArbitraryPaymentTokensSupported: true, * // paymentToken: { * // name: "USD Coin", * // address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", * // symbol: "USDC", * // decimals: 6, * // permitEnabled: true * // } * // } * ``` * * @throws Will throw an error if: * - The token is not supported on the specified chain * - The chain ID is not supported */ export const getPaymentToken = async (client, parameters) => { const gasToken = await getGasToken(client, { chainId: parameters.chainId, address: parameters.tokenAddress }); const paymentToken = gasToken.paymentTokens.find((paymentToken) => addressEquals(paymentToken.address, parameters.tokenAddress)); return { isArbitraryPaymentTokensSupported: gasToken.isArbitraryPaymentTokensSupported, paymentToken }; }; export default getPaymentToken; //# sourceMappingURL=getPaymentToken.js.map