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