import "../../constants/chains.constants.mjs";
import { zeroAddress as e } from "../../constants/protocol.constants.mjs";
import "./erc20tokenFunctions.mjs";
import "../../data-structures/http/index.mjs";
import "./addresses.mjs";
import { Logger as t } from "../../error-handling/logger.mjs";
import { createJsonRpcProvider as n } from "./create-provider.mjs";
import "../../externalABIs/index.mjs";
import { ERC20ABI as r } from "../../externalABIs/swapAbi.mjs";
import "./ipfs.mjs";
import { ethers as i } from "ethers";
import "@solana/web3.js";
import "@solana/spl-token";
//#region libs/shared/common/src/functions/utils/publicBalance.utils.ts
var a = async (t, n, a) => {
	try {
		let o = a.erc20TokenAddress, s, c = new i.Contract(a.erc20TokenAddress, r, t);
		s = o === e ? await t.getBalance(n) : await c?.balanceOf(n);
		let l = s;
		return l <= 0n ? null : {
			token: a,
			balance: l
		};
	} catch {
		return null;
	}
}, o = async (a, o, s) => {
	try {
		let t = n(a), c = new i.Contract(s, r, t), l;
		return l = s === e ? await t.getBalance(o) : await c?.balanceOf(o), l;
	} catch {
		return t.error(`Failed to fetch public balance for address ${o}`), null;
	}
};
//#endregion
export { a as getPublicBalance, o as getPublicBalanceByTokenAddress };
