@nibgate/sdk 0.2.26 → 0.2.27

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.26",
3
+ "version": "0.2.27",
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,20 +225,17 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
225
225
  card.addEventListener('remove', cleanup);
226
226
 
227
227
  // ── Gateway balance + deposit icon ─────────────────────────────────────
228
- const ARC_RPC = 'https://arc-testnet.drpc.org';
229
- const GATEWAY_WALLET = '0x0077777d7EBA4688BDeF3E311b846F25870A19B9';
230
- const USDC_ADDRESS = '0x3600000000000000000000000000000000000000';
231
-
232
228
  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';
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'; }
242
239
  }
243
240
 
244
241
  let balEl = null, gwOverlay = null, balTimer = null;