UNPKG

@0xfutbol/id

Version:

React component library with shared providers for 0xFutbol ID

132 lines (131 loc) 4.16 kB
import {P as readContract,ag as withCache,cv as isNativeTokenAddress}from'./index-DNoa140s.js';import {d as decimals}from'./decimals-CUdgsyo0.js';import'react';import'react/jsx-runtime';import'@0xfutbol/id-sign';import'react-use';import'@0xfutbol/constants';import'thirdweb';import'@matchain/matchid-sdk-react';import'@tanstack/react-query';import'@matchain/matchid-sdk-react/index.css';import'react-dom';const FN_SELECTOR$1 = "0x06fdde03"; const FN_INPUTS$1 = []; const FN_OUTPUTS$1 = [ { type: "string", }, ]; /** * Calls the "name" function on the contract. * @param options - The options for the name function. * @returns The parsed result of the function call. * @extension COMMON * @example * ```ts * import { name } from "thirdweb/extensions/common"; * * const result = await name({ * contract, * }); * * ``` */ async function name$1(options) { return readContract({ contract: options.contract, method: [FN_SELECTOR$1, FN_INPUTS$1, FN_OUTPUTS$1], params: [], }); }/** * Retrieves the name associated with the given contract. * @param options - The options for the transaction. * @returns A promise that resolves to the name associated with the contract. * @extension COMMON * @example * ```ts * import { name } from "thirdweb/extensions/common"; * * const contractName = await name({ contract }); * ``` */ async function name(options) { return withCache(() => name$1(options), { cacheKey: `${options.contract.chain.id}:${options.contract.address}:name`, // can never change, so cache forever cacheTime: Number.POSITIVE_INFINITY, }); }const FN_SELECTOR = "0x95d89b41"; const FN_INPUTS = []; const FN_OUTPUTS = [ { type: "string", }, ]; /** * Calls the "symbol" function on the contract. * @param options - The options for the symbol function. * @returns The parsed result of the function call. * @extension COMMON * @example * ```ts * import { symbol } from "thirdweb/extensions/common"; * * const result = await symbol({ * contract, * }); * * ``` */ async function symbol$1(options) { return readContract({ contract: options.contract, method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS], params: [], }); }/** * Retrieves the name associated with the given contract. * @param options - The options for the transaction. * @returns A promise that resolves to the name associated with the contract. * @extension COMMON * @example * ```ts * import { symbol } from "thirdweb/extensions/common"; * * const contractSymbol = await symbol({ contract }); * ``` */ async function symbol(options) { return withCache(() => symbol$1(options), { cacheKey: `${options.contract.chain.id}:${options.contract.address}:symbol`, // can never change, so cache forever cacheTime: Number.POSITIVE_INFINITY, }); }/** * Retrieves the metadata of a currency. * @param options - The options for the transaction. * @returns A promise that resolves to an object containing the currency metadata. * @extension ERC20 * @example * ```ts * import { getCurrencyMetadata } from "thirdweb/extensions/erc20"; * * const currencyMetadata = await getCurrencyMetadata({ contract }); * ``` */ async function getCurrencyMetadata(options) { // if the contract is the native token, return the native currency metadata if (isNativeTokenAddress(options.contract.address)) { return { name: "Ether", symbol: "ETH", decimals: 18, // overwrite with native currency of the chain if available ...options.contract.chain.nativeCurrency, }; } try { const [name_, symbol_, decimals_] = await Promise.all([ name(options).catch(() => ""), symbol(options), decimals(options), ]); return { name: name_, symbol: symbol_, decimals: decimals_, }; } catch { throw new Error("Invalid currency token"); } }export{getCurrencyMetadata};//# sourceMappingURL=getCurrencyMetadata-BXyjSZEI.js.map