UNPKG

@0xfutbol/id

Version:

React component library with shared providers for 0xFutbol ID

132 lines (131 loc) 4.14 kB
'use strict';var index=require('./index-gEYw6hWC.js'),decimals=require('./decimals-DNF80AHH.js');require('react'),require('react/jsx-runtime'),require('@0xfutbol/id-sign'),require('react-use'),require('@0xfutbol/constants'),require('thirdweb'),require('@matchain/matchid-sdk-react'),require('@tanstack/react-query'),require('@matchain/matchid-sdk-react/index.css'),require('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 index.P({ 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 index.ag(() => 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 index.P({ 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 index.ag(() => 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 (index.cv(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.d(options), ]); return { name: name_, symbol: symbol_, decimals: decimals_, }; } catch { throw new Error("Invalid currency token"); } }exports.getCurrencyMetadata=getCurrencyMetadata;//# sourceMappingURL=getCurrencyMetadata-D7CN05L7.js.map