@toon-protocol/client 0.29.4 → 0.29.5

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/index.js CHANGED
@@ -5199,6 +5199,30 @@ async function initializeHttpMode(config, hooks = {}) {
5199
5199
  };
5200
5200
  }
5201
5201
 
5202
+ // src/discovery-subscription.ts
5203
+ import { ILP_PEER_INFO_KIND } from "@toon-protocol/core";
5204
+ async function subscribeToDiscovery(relayUrls, tracker) {
5205
+ const urls = Array.from(new Set(relayUrls.filter((url) => url !== "")));
5206
+ if (urls.length === 0) {
5207
+ return { close: () => void 0 };
5208
+ }
5209
+ const { SimplePool } = await import("nostr-tools/pool");
5210
+ const pool = new SimplePool();
5211
+ const sub = pool.subscribeMany(
5212
+ urls,
5213
+ { kinds: [ILP_PEER_INFO_KIND] },
5214
+ {
5215
+ onevent: (event) => tracker.processEvent(event)
5216
+ }
5217
+ );
5218
+ return {
5219
+ close: () => {
5220
+ sub.close();
5221
+ pool.close(urls);
5222
+ }
5223
+ };
5224
+ }
5225
+
5202
5226
  // src/signing/solana-signer.ts
5203
5227
  import { ed25519 as ed255193 } from "@noble/curves/ed25519.js";
5204
5228
  import { base58Encode as base58Encode3, base58Decode as base58Decode2 } from "@toon-protocol/core";
@@ -8113,6 +8137,13 @@ var ToonClient = class {
8113
8137
  btpClient,
8114
8138
  btpSession
8115
8139
  } = initialization;
8140
+ const discoverySubscription = await subscribeToDiscovery(
8141
+ [
8142
+ this.config.relayUrl,
8143
+ ...(this.config.knownPeers ?? []).map((peer) => peer.relayUrl)
8144
+ ],
8145
+ discoveryTracker
8146
+ );
8116
8147
  if (this.channelManager) {
8117
8148
  const cm = this.channelManager;
8118
8149
  const nostrPubkey = this.getPublicKey();
@@ -8208,6 +8239,7 @@ var ToonClient = class {
8208
8239
  this.state = {
8209
8240
  bootstrapService,
8210
8241
  discoveryTracker,
8242
+ discoverySubscription,
8211
8243
  runtimeClient,
8212
8244
  peersDiscovered: bootstrapResults.length,
8213
8245
  btpClient: btpClient ?? void 0,
@@ -9672,6 +9704,7 @@ var ToonClient = class {
9672
9704
  throw new ToonClientError("Client not started", "INVALID_STATE");
9673
9705
  }
9674
9706
  try {
9707
+ this.state.discoverySubscription.close();
9675
9708
  if (this.state.btpClient) {
9676
9709
  await this.state.btpClient.disconnect();
9677
9710
  }