@0xfutbol/id
Version:
React component library with shared providers for 0xFutbol ID
58 lines (57 loc) • 1.95 kB
JavaScript
import {P as readContract,Q as toTokens}from'./index-DNoa140s.js';import {getCurrencyMetadata}from'./getCurrencyMetadata-BXyjSZEI.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';import'./decimals-CUdgsyo0.js';const FN_SELECTOR = "0x70a08231";
const FN_INPUTS = [
{
type: "address",
name: "_address",
},
];
const FN_OUTPUTS = [
{
type: "uint256",
},
];
/**
* Calls the "balanceOf" function on the contract.
* @param options - The options for the balanceOf function.
* @returns The parsed result of the function call.
* @extension ERC20
* @example
* ```ts
* import { balanceOf } from "thirdweb/extensions/erc20";
*
* const result = await balanceOf({
* contract,
* address: ...,
* });
*
* ```
*/
async function balanceOf(options) {
return readContract({
contract: options.contract,
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS],
params: [options.address],
});
}/**
* Retrieves the balance of an ERC20 token for a specific address.
* @param options - The transaction options including the address.
* @returns An object containing the balance value, display value, and symbol.
* @extension ERC20
* @example
* ```ts
* import { getBalance } from "thirdweb/extensions/erc20";
*
* const balance = await getBalance({ contract, address: "0x..." });
* ```
*/
async function getBalance(options) {
const [balanceWei, currencyMetadata] = await Promise.all([
balanceOf(options),
getCurrencyMetadata(options),
]);
return {
...currencyMetadata,
value: balanceWei,
displayValue: toTokens(balanceWei, currencyMetadata.decimals),
};
}export{getBalance};//# sourceMappingURL=getBalance-DfT-llPO.js.map