@nibgate/sdk 0.2.27 → 0.2.28

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,21 +27505,7 @@ ${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
- let balEl = null, gwOverlay = null, balTimer = null;
27508
+ let gwOverlay = 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>';
27525
27511
  }
@@ -27554,37 +27540,29 @@ ${prettyStateOverride(stateOverride)}`;
27554
27540
  document.removeEventListener("keydown", onDepKey);
27555
27541
  }
27556
27542
  }
27543
+ let balEl = null;
27557
27544
  function ensureBal() {
27558
27545
  if (balEl && balEl.isConnected) return balEl;
27559
27546
  balEl = el(
27560
27547
  "span",
27561
27548
  { "data-nibgate-bal": "", style: "margin-left:4px;cursor:pointer;white-space:nowrap;color:var(--accent,#7c9a6d)" },
27562
- "\xB7\xA0<span data-nibgate-bal-txt></span>\xA0|\xA0" + depIcon()
27549
+ "\xB7\xA0|\xA0" + depIcon()
27563
27550
  );
27564
27551
  balEl.addEventListener("click", showDeposit);
27565
27552
  if (label.parentNode) label.parentNode.insertBefore(balEl, label.nextSibling);
27566
27553
  return balEl;
27567
27554
  }
27568
- async function refreshBal() {
27569
- if (!card.isConnected || !window.ethereum) return;
27570
- try {
27571
- const accts = await window.ethereum.request({ method: "eth_accounts" });
27572
- const addr = Array.isArray(accts) && accts[0] ? accts[0] : null;
27573
- if (!addr) return;
27574
- const t = ensureBal().querySelector("[data-nibgate-bal-txt]");
27575
- if (t) t.textContent = await fetchBalance(addr);
27576
- } catch {
27577
- }
27578
- }
27579
27555
  if (window.ethereum) {
27580
- balTimer = setInterval(refreshBal, 3e3);
27581
- setTimeout(refreshBal, 1e3);
27582
- window.ethereum.on("accountsChanged", refreshBal);
27556
+ setTimeout(() => {
27557
+ const accts = window.ethereum.request({ method: "eth_accounts" }).catch(() => []);
27558
+ accts.then((a) => {
27559
+ if (Array.isArray(a) && a[0]) ensureBal();
27560
+ });
27561
+ }, 1e3);
27583
27562
  }
27584
27563
  return { ...ctrl, element: card, destroy: () => {
27585
27564
  cleanup();
27586
27565
  card.remove();
27587
- if (balTimer) clearInterval(balTimer);
27588
27566
  if (gwOverlay) {
27589
27567
  gwOverlay.remove();
27590
27568
  gwOverlay = null;