import { a as i } from "../../index-DEq3oXQF.js";
import { z as s } from "zod";
import l from "lodash.once";
import { logger as m } from "../../logger.js";
import { nearFailoverRpcProvider as f } from "./rpc.js";
import { decodeQueryResult as p } from "./decodeQueryResult.js";
const u = l((r) => f({
  urls: r
})), h = async ({
  tokenAddress: r,
  accountId: t,
  rpcUrls: n
}) => {
  try {
    const e = { account_id: t }, o = i.from(JSON.stringify(e)).toString("base64"), a = await u(n).query({
      request_type: "call_function",
      method_name: "ft_balance_of",
      account_id: r,
      args_base64: o,
      finality: "optimistic"
    }), c = p(a, s.string());
    return BigInt(c);
  } catch (e) {
    return m.error(
      new Error("error fetching near nep141 balance", { cause: e })
    ), null;
  }
};
export {
  h as getNearNep141Balance
};
//# sourceMappingURL=getNearNep141Balance.js.map
