@unicitylabs/sphere-sdk 0.1.7 → 0.1.9

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.
@@ -431,6 +431,20 @@ var FileTokenStorageProvider = class {
431
431
  error: saveResult.error
432
432
  };
433
433
  }
434
+ async clear() {
435
+ try {
436
+ if (!fs2.existsSync(this.tokensDir)) {
437
+ return true;
438
+ }
439
+ const files = fs2.readdirSync(this.tokensDir).filter((f) => f.endsWith(".json"));
440
+ for (const file of files) {
441
+ fs2.unlinkSync(path2.join(this.tokensDir, file));
442
+ }
443
+ return true;
444
+ } catch {
445
+ return false;
446
+ }
447
+ }
434
448
  async deleteToken(tokenId) {
435
449
  const filePath = path2.join(this.tokensDir, `${tokenId}.json`);
436
450
  if (fs2.existsSync(filePath)) {
@@ -1483,15 +1497,17 @@ var NostrTransportProvider = class {
1483
1497
  const bindingEvent = events[0];
1484
1498
  try {
1485
1499
  const content = JSON.parse(bindingEvent.content);
1500
+ const { ProxyAddress } = await import("@unicitylabs/state-transition-sdk/lib/address/ProxyAddress");
1501
+ const proxyAddr = await ProxyAddress.fromNameTag(nametag);
1502
+ const proxyAddress = proxyAddr.toString();
1486
1503
  if (content.public_key && content.l1_address) {
1487
- const l3Address = `PROXY:${hashedNametag}`;
1488
1504
  return {
1489
1505
  nametag,
1490
1506
  transportPubkey: bindingEvent.pubkey,
1491
1507
  chainPubkey: content.public_key,
1492
1508
  l1Address: content.l1_address,
1493
1509
  directAddress: content.direct_address || "",
1494
- proxyAddress: l3Address,
1510
+ proxyAddress,
1495
1511
  timestamp: bindingEvent.created_at * 1e3
1496
1512
  };
1497
1513
  }
@@ -1499,14 +1515,13 @@ var NostrTransportProvider = class {
1499
1515
  const pubkeyTag = bindingEvent.tags.find((t) => t[0] === "pubkey");
1500
1516
  const l1Tag = bindingEvent.tags.find((t) => t[0] === "l1");
1501
1517
  if (pubkeyTag?.[1] && l1Tag?.[1]) {
1502
- const l3Address = `PROXY:${hashedNametag}`;
1503
1518
  return {
1504
1519
  nametag,
1505
1520
  transportPubkey: bindingEvent.pubkey,
1506
1521
  chainPubkey: pubkeyTag[1],
1507
1522
  l1Address: l1Tag[1],
1508
1523
  directAddress: "",
1509
- proxyAddress: l3Address,
1524
+ proxyAddress,
1510
1525
  timestamp: bindingEvent.created_at * 1e3
1511
1526
  };
1512
1527
  }
@@ -1518,17 +1533,19 @@ var NostrTransportProvider = class {
1518
1533
  l1Address: "",
1519
1534
  // Cannot derive without 33-byte pubkey
1520
1535
  directAddress: "",
1521
- proxyAddress: `PROXY:${hashedNametag}`,
1536
+ proxyAddress,
1522
1537
  timestamp: bindingEvent.created_at * 1e3
1523
1538
  };
1524
1539
  } catch {
1540
+ const { ProxyAddress } = await import("@unicitylabs/state-transition-sdk/lib/address/ProxyAddress");
1541
+ const proxyAddr = await ProxyAddress.fromNameTag(nametag);
1525
1542
  return {
1526
1543
  nametag,
1527
1544
  transportPubkey: bindingEvent.pubkey,
1528
1545
  chainPubkey: "",
1529
1546
  l1Address: "",
1530
1547
  directAddress: "",
1531
- proxyAddress: `PROXY:${hashedNametag}`,
1548
+ proxyAddress: proxyAddr.toString(),
1532
1549
  timestamp: bindingEvent.created_at * 1e3
1533
1550
  };
1534
1551
  }