@nibgate/sdk 0.2.38 → 0.2.40

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
@@ -27748,8 +27748,10 @@ ${prettyStateOverride(stateOverride)}`;
27748
27748
  wrap3.innerHTML = `
27749
27749
  <div style="display:flex;gap:12px;margin-bottom:20px">
27750
27750
  <div data-gw-wallet-card style="flex:1;background:${theme.bg};border:1px solid ${theme.border};border-radius:12px;padding:16px">
27751
- <div style="font-size:12px;font-weight:600;color:${theme.muted};margin-bottom:4px;letter-spacing:.02em">Wallet</div>
27752
- <div data-gw-wallet-addr class="nui-mono" style="font-size:13px;color:${theme.muted};margin-bottom:4px"></div>
27751
+ <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">
27752
+ <div data-gw-wallet-addr class="nui-mono" style="font-size:13px;color:${theme.muted}"></div>
27753
+ <span data-gw-connect-label style="font-size:12px;font-weight:600;color:${theme.accent}">Connected</span>
27754
+ </div>
27753
27755
  <div data-gw-wallet-balance class="nui-mono" style="font-size:24px;font-weight:700;color:${theme.fg}">\u2014</div>
27754
27756
  </div>
27755
27757
  <div style="flex:1;background:${theme.bg};border:1px solid ${theme.border};border-radius:12px;padding:16px">
@@ -27779,6 +27781,69 @@ ${prettyStateOverride(stateOverride)}`;
27779
27781
  b.style.borderBottomColor = on ? theme.accent : "transparent";
27780
27782
  });
27781
27783
  }
27784
+ const GATEWAY = "0x0077777d7EBA4688BDeF3E311b846F25870A19B9";
27785
+ const SEL_APPROVE = "0x095ea7b3";
27786
+ const SEL_DEPOSIT = "0x47e7ef24";
27787
+ function parse6(v) {
27788
+ const [w = "0", f = ""] = String(v).split(".");
27789
+ return BigInt(w + f.padEnd(6, "0").slice(0, 6));
27790
+ }
27791
+ function addr32(a) {
27792
+ return "000000000000000000000000" + a.slice(2);
27793
+ }
27794
+ function setTx(msg, ok) {
27795
+ const el2 = formEl.querySelector("[data-gw-tx]");
27796
+ if (!el2) return;
27797
+ el2.style.display = "block";
27798
+ el2.style.color = ok ? theme.accent : "#dc2626";
27799
+ el2.textContent = msg;
27800
+ }
27801
+ async function doDeposit() {
27802
+ if (!window.ethereum) {
27803
+ setTx("No wallet found");
27804
+ return;
27805
+ }
27806
+ const input = formEl.querySelector("[data-gw-deposit-amount]");
27807
+ const amt = input?.value;
27808
+ if (!amt || Number(amt) <= 0) {
27809
+ setTx("Enter an amount");
27810
+ return;
27811
+ }
27812
+ const btn = formEl.querySelector("[data-gw-deposit]");
27813
+ try {
27814
+ btn.disabled = true;
27815
+ btn.textContent = "Approving\u2026";
27816
+ const accts = await window.ethereum.request({ method: "eth_accounts" });
27817
+ const addr = accts?.[0];
27818
+ if (!addr) {
27819
+ setTx("Connect wallet");
27820
+ btn.disabled = false;
27821
+ btn.textContent = "Deposit";
27822
+ return;
27823
+ }
27824
+ const amount = parse6(amt).toString(16);
27825
+ const approveTx = await window.ethereum.request({
27826
+ method: "eth_sendTransaction",
27827
+ params: [{ from: addr, to: USDC, data: SEL_APPROVE + addr32(GATEWAY) + amount.padStart(64, "0") }]
27828
+ });
27829
+ setTx("Approved: " + approveTx.slice(0, 10) + "\u2026", true);
27830
+ btn.textContent = "Depositing\u2026";
27831
+ const depositTx = await window.ethereum.request({
27832
+ method: "eth_sendTransaction",
27833
+ params: [{ from: addr, to: GATEWAY, data: SEL_DEPOSIT + addr32(USDC) + amount.padStart(64, "0") }]
27834
+ });
27835
+ setTx("Deposited: " + depositTx.slice(0, 10) + "\u2026", true);
27836
+ updateWallet();
27837
+ btn.textContent = "Deposit";
27838
+ } catch (e) {
27839
+ setTx(e?.message || "Deposit failed");
27840
+ }
27841
+ btn.disabled = false;
27842
+ btn.textContent = "Deposit";
27843
+ }
27844
+ async function doWithdraw() {
27845
+ setTx("Withdraw via admin dashboard", false);
27846
+ }
27782
27847
  function render(t) {
27783
27848
  tab = t;
27784
27849
  select(tabs, t);
@@ -27789,6 +27854,7 @@ ${prettyStateOverride(stateOverride)}`;
27789
27854
  <button type="button" data-gw-deposit class="nui-btn nui-btn-primary" style="width:100%;padding:16px 28px;font-size:20px">Deposit</button>
27790
27855
  <div data-gw-tx class="nui-mono" style="font-size:12px;color:${theme.muted};word-break:break-all;margin-top:12px;display:none"></div>
27791
27856
  `;
27857
+ formEl.querySelector("[data-gw-deposit]")?.addEventListener("click", doDeposit);
27792
27858
  } else {
27793
27859
  formEl.innerHTML = `
27794
27860
  <label class="nui-label">Amount (USDC)</label>
@@ -27796,6 +27862,7 @@ ${prettyStateOverride(stateOverride)}`;
27796
27862
  <button type="button" data-gw-withdraw class="nui-btn nui-btn-primary" style="width:100%;padding:16px 28px;font-size:20px">Withdraw to your wallet</button>
27797
27863
  <div data-gw-tx class="nui-mono" style="font-size:12px;color:${theme.muted};word-break:break-all;margin-top:12px;display:none"></div>
27798
27864
  `;
27865
+ formEl.querySelector("[data-gw-withdraw]")?.addEventListener("click", doWithdraw);
27799
27866
  }
27800
27867
  }
27801
27868
  function shortAddress(a) {