@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 +9 -32
- package/dist/nibgate.js.map +3 -3
- package/dist/nibgate.min.js +52 -52
- package/dist/nibgate.min.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/default-ui.js +9 -34
package/package.json
CHANGED
|
@@ -224,24 +224,8 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
224
224
|
const cleanup = () => { document.removeEventListener('mouseup', cancelHold); document.removeEventListener('touchend', cancelHold); };
|
|
225
225
|
card.addEventListener('remove', cleanup);
|
|
226
226
|
|
|
227
|
-
// ── Gateway
|
|
228
|
-
|
|
229
|
-
const GATEWAY_WALLET = '0x0077777d7EBA4688BDeF3E311b846F25870A19B9';
|
|
230
|
-
const USDC_ADDRESS = '0x3600000000000000000000000000000000000000';
|
|
231
|
-
|
|
232
|
-
async function fetchBalance(addr) {
|
|
233
|
-
const sel = '0xdd62e1c6';
|
|
234
|
-
const pad = (a) => '000000000000000000000000' + a.slice(2).toLowerCase();
|
|
235
|
-
const data = sel + pad(USDC_ADDRESS) + pad(addr);
|
|
236
|
-
const r = await fetch(ARC_RPC, {
|
|
237
|
-
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
238
|
-
body: JSON.stringify({ jsonrpc: '2.0', method: 'eth_call', params: [{ to: GATEWAY_WALLET, data }, 'latest'], id: 1 }),
|
|
239
|
-
});
|
|
240
|
-
const j = await r.json();
|
|
241
|
-
return j?.result ? (Number(BigInt(j.result)) / 1_000_000).toFixed(2) + ' USDC' : '\u2014';
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
let balEl = null, gwOverlay = null, balTimer = null;
|
|
227
|
+
// ── Gateway deposit icon ──────────────────────────────────────────────
|
|
228
|
+
let gwOverlay = null;
|
|
245
229
|
|
|
246
230
|
function depIcon() {
|
|
247
231
|
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>';
|
|
@@ -262,33 +246,24 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
262
246
|
}
|
|
263
247
|
function onDepKey(e) { if (e.key === 'Escape' && gwOverlay) { gwOverlay.remove(); gwOverlay = null; document.removeEventListener('keydown', onDepKey); } }
|
|
264
248
|
|
|
249
|
+
let balEl = null;
|
|
265
250
|
function ensureBal() {
|
|
266
251
|
if (balEl && balEl.isConnected) return balEl;
|
|
267
252
|
balEl = el('span', { 'data-nibgate-bal': '', style: 'margin-left:4px;cursor:pointer;white-space:nowrap;color:var(--accent,#7c9a6d)' },
|
|
268
|
-
'\u00b7\u00a0
|
|
253
|
+
'\u00b7\u00a0|\u00a0' + depIcon());
|
|
269
254
|
balEl.addEventListener('click', showDeposit);
|
|
270
255
|
if (label.parentNode) label.parentNode.insertBefore(balEl, label.nextSibling);
|
|
271
256
|
return balEl;
|
|
272
257
|
}
|
|
273
258
|
|
|
274
|
-
async function refreshBal() {
|
|
275
|
-
if (!card.isConnected || !window.ethereum) return;
|
|
276
|
-
try {
|
|
277
|
-
const accts = await window.ethereum.request({ method: 'eth_accounts' });
|
|
278
|
-
const addr = Array.isArray(accts) && accts[0] ? accts[0] : null;
|
|
279
|
-
if (!addr) return;
|
|
280
|
-
const t = ensureBal().querySelector('[data-nibgate-bal-txt]');
|
|
281
|
-
if (t) t.textContent = await fetchBalance(addr);
|
|
282
|
-
} catch {}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
259
|
if (window.ethereum) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
260
|
+
setTimeout(() => {
|
|
261
|
+
const accts = window.ethereum.request({ method: 'eth_accounts' }).catch(() => []);
|
|
262
|
+
accts.then(a => { if (Array.isArray(a) && a[0]) ensureBal(); });
|
|
263
|
+
}, 1000);
|
|
289
264
|
}
|
|
290
265
|
|
|
291
|
-
return { ...ctrl, element: card, destroy: () => { cleanup(); card.remove(); if (
|
|
266
|
+
return { ...ctrl, element: card, destroy: () => { cleanup(); card.remove(); if (gwOverlay) { gwOverlay.remove(); gwOverlay = null; } } };
|
|
292
267
|
}
|
|
293
268
|
|
|
294
269
|
export function renderDefaultRatingUI(container, resource, options = {}) {
|