@nibgate/sdk 0.2.27 → 0.2.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nibgate/sdk",
3
- "version": "0.2.27",
3
+ "version": "0.2.29",
4
4
  "description": "Framework-agnostic browser and server package for creator-owned gated content, unlock events, and receipts.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -225,19 +225,6 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
225
225
  card.addEventListener('remove', cleanup);
226
226
 
227
227
  // ── Gateway balance + deposit icon ─────────────────────────────────────
228
- async function fetchBalance(addr) {
229
- try {
230
- const sel = '0xdd62e1c6';
231
- const pad = (a) => '000000000000000000000000' + a.slice(2).toLowerCase();
232
- const data = sel + pad('0x3600000000000000000000000000000000000000') + pad(addr);
233
- const hex = await window.ethereum.request({
234
- method: 'eth_call',
235
- params: [{ to: '0x0077777d7EBA4688BDeF3E311b846F25870A19B9', data }, 'latest'],
236
- });
237
- return hex && hex !== '0x' ? (Number(BigInt(hex)) / 1_000_000).toFixed(2) + ' USDC' : '0.00 USDC';
238
- } catch { return '\u2014'; }
239
- }
240
-
241
228
  let balEl = null, gwOverlay = null, balTimer = null;
242
229
 
243
230
  function depIcon() {
@@ -269,13 +256,20 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
269
256
  }
270
257
 
271
258
  async function refreshBal() {
272
- if (!card.isConnected || !window.ethereum) return;
259
+ if (!card.isConnected || !window.ethereum || !options.gatewayBalanceUrl) return;
273
260
  try {
274
261
  const accts = await window.ethereum.request({ method: 'eth_accounts' });
275
262
  const addr = Array.isArray(accts) && accts[0] ? accts[0] : null;
276
263
  if (!addr) return;
277
264
  const t = ensureBal().querySelector('[data-nibgate-bal-txt]');
278
- if (t) t.textContent = await fetchBalance(addr);
265
+ if (!t) return;
266
+ const r = await fetch(options.gatewayBalanceUrl, {
267
+ method: 'POST',
268
+ headers: { 'Content-Type': 'application/json' },
269
+ body: JSON.stringify({ address: addr }),
270
+ });
271
+ const data = await r.json();
272
+ t.textContent = data?.balance || '';
279
273
  } catch {}
280
274
  }
281
275