@nibgate/sdk 0.2.26 → 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,22 +27505,7 @@ ${prettyStateOverride(stateOverride)}`;
27505
27505
  document.removeEventListener("touchend", cancelHold);
27506
27506
  };
27507
27507
  card.addEventListener("remove", cleanup);
27508
- const ARC_RPC = "https://arc-testnet.drpc.org";
27509
- const GATEWAY_WALLET = "0x0077777d7EBA4688BDeF3E311b846F25870A19B9";
27510
- const USDC_ADDRESS = "0x3600000000000000000000000000000000000000";
27511
- async function fetchBalance(addr) {
27512
- const sel = "0xdd62e1c6";
27513
- const pad4 = (a) => "000000000000000000000000" + a.slice(2).toLowerCase();
27514
- const data = sel + pad4(USDC_ADDRESS) + pad4(addr);
27515
- const r = await fetch(ARC_RPC, {
27516
- method: "POST",
27517
- headers: { "Content-Type": "application/json" },
27518
- body: JSON.stringify({ jsonrpc: "2.0", method: "eth_call", params: [{ to: GATEWAY_WALLET, data }, "latest"], id: 1 })
27519
- });
27520
- const j = await r.json();
27521
- return j?.result ? (Number(BigInt(j.result)) / 1e6).toFixed(2) + " USDC" : "\u2014";
27522
- }
27523
- let balEl = null, gwOverlay = null, balTimer = null;
27508
+ let gwOverlay = null;
27524
27509
  function depIcon() {
27525
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>';
27526
27511
  }
@@ -27555,37 +27540,29 @@ ${prettyStateOverride(stateOverride)}`;
27555
27540
  document.removeEventListener("keydown", onDepKey);
27556
27541
  }
27557
27542
  }
27543
+ let balEl = null;
27558
27544
  function ensureBal() {
27559
27545
  if (balEl && balEl.isConnected) return balEl;
27560
27546
  balEl = el(
27561
27547
  "span",
27562
27548
  { "data-nibgate-bal": "", style: "margin-left:4px;cursor:pointer;white-space:nowrap;color:var(--accent,#7c9a6d)" },
27563
- "\xB7\xA0<span data-nibgate-bal-txt></span>\xA0|\xA0" + depIcon()
27549
+ "\xB7\xA0|\xA0" + depIcon()
27564
27550
  );
27565
27551
  balEl.addEventListener("click", showDeposit);
27566
27552
  if (label.parentNode) label.parentNode.insertBefore(balEl, label.nextSibling);
27567
27553
  return balEl;
27568
27554
  }
27569
- async function refreshBal() {
27570
- if (!card.isConnected || !window.ethereum) return;
27571
- try {
27572
- const accts = await window.ethereum.request({ method: "eth_accounts" });
27573
- const addr = Array.isArray(accts) && accts[0] ? accts[0] : null;
27574
- if (!addr) return;
27575
- const t = ensureBal().querySelector("[data-nibgate-bal-txt]");
27576
- if (t) t.textContent = await fetchBalance(addr);
27577
- } catch {
27578
- }
27579
- }
27580
27555
  if (window.ethereum) {
27581
- balTimer = setInterval(refreshBal, 3e3);
27582
- setTimeout(refreshBal, 1e3);
27583
- 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);
27584
27562
  }
27585
27563
  return { ...ctrl, element: card, destroy: () => {
27586
27564
  cleanup();
27587
27565
  card.remove();
27588
- if (balTimer) clearInterval(balTimer);
27589
27566
  if (gwOverlay) {
27590
27567
  gwOverlay.remove();
27591
27568
  gwOverlay = null;