@nibgate/sdk 0.2.27 → 0.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/nibgate.js CHANGED
@@ -27505,20 +27505,6 @@ ${prettyStateOverride(stateOverride)}`;
27505
27505
  document.removeEventListener("touchend", cancelHold);
27506
27506
  };
27507
27507
  card.addEventListener("remove", cleanup);
27508
- async function fetchBalance(addr) {
27509
- try {
27510
- const sel = "0xdd62e1c6";
27511
- const pad4 = (a) => "000000000000000000000000" + a.slice(2).toLowerCase();
27512
- const data = sel + pad4("0x3600000000000000000000000000000000000000") + pad4(addr);
27513
- const hex = await window.ethereum.request({
27514
- method: "eth_call",
27515
- params: [{ to: "0x0077777d7EBA4688BDeF3E311b846F25870A19B9", data }, "latest"]
27516
- });
27517
- return hex && hex !== "0x" ? (Number(BigInt(hex)) / 1e6).toFixed(2) + " USDC" : "0.00 USDC";
27518
- } catch {
27519
- return "\u2014";
27520
- }
27521
- }
27522
27508
  let balEl = null, gwOverlay = null, balTimer = null;
27523
27509
  function depIcon() {
27524
27510
  return '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline;vertical-align:middle"><path d="M12 17V3"/><path d="m6 11 6 6 6-6"/><path d="M19 21H5"/></svg>';
@@ -27566,13 +27552,20 @@ ${prettyStateOverride(stateOverride)}`;
27566
27552
  return balEl;
27567
27553
  }
27568
27554
  async function refreshBal() {
27569
- if (!card.isConnected || !window.ethereum) return;
27555
+ if (!card.isConnected || !window.ethereum || !options.gatewayBalanceUrl) return;
27570
27556
  try {
27571
27557
  const accts = await window.ethereum.request({ method: "eth_accounts" });
27572
27558
  const addr = Array.isArray(accts) && accts[0] ? accts[0] : null;
27573
27559
  if (!addr) return;
27574
27560
  const t = ensureBal().querySelector("[data-nibgate-bal-txt]");
27575
- if (t) t.textContent = await fetchBalance(addr);
27561
+ if (!t) return;
27562
+ const r = await fetch(options.gatewayBalanceUrl, {
27563
+ method: "POST",
27564
+ headers: { "Content-Type": "application/json" },
27565
+ body: JSON.stringify({ address: addr })
27566
+ });
27567
+ const data = await r.json();
27568
+ t.textContent = data?.balance || "";
27576
27569
  } catch {
27577
27570
  }
27578
27571
  }