@unicitylabs/sphere-sdk 0.8.0-dev.2 → 0.8.0-dev.4

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.
@@ -29328,6 +29328,19 @@ var TokenRegistry = class _TokenRegistry {
29328
29328
  // ===========================================================================
29329
29329
  // Cache (StorageProvider)
29330
29330
  // ===========================================================================
29331
+ /**
29332
+ * Per-network cache keys. The registry cache MUST be namespaced by remoteUrl:
29333
+ * testnet and testnet2 ship DIFFERENT coinIds for the same symbol, so a single
29334
+ * global key let a stale testnet snapshot be served for a testnet2 request —
29335
+ * wrong/missing icons AND self-mint resolving the wrong-network coinId. Keying
29336
+ * by remoteUrl isolates the snapshots so a network can never read another's.
29337
+ */
29338
+ cacheKeys() {
29339
+ const base = STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE;
29340
+ const baseTs = STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE_TS;
29341
+ if (!this.remoteUrl) return { data: base, ts: baseTs };
29342
+ return { data: `${base}:${this.remoteUrl}`, ts: `${baseTs}:${this.remoteUrl}` };
29343
+ }
29331
29344
  /**
29332
29345
  * Load definitions from StorageProvider cache.
29333
29346
  * Only applies if cache exists and is fresh (within refreshIntervalMs).
@@ -29335,9 +29348,10 @@ var TokenRegistry = class _TokenRegistry {
29335
29348
  async loadFromCache() {
29336
29349
  if (!this.storage) return false;
29337
29350
  try {
29351
+ const { data: dataKey, ts: tsKey } = this.cacheKeys();
29338
29352
  const [cached, cachedTs] = await Promise.all([
29339
- this.storage.get(STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE),
29340
- this.storage.get(STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE_TS)
29353
+ this.storage.get(dataKey),
29354
+ this.storage.get(tsKey)
29341
29355
  ]);
29342
29356
  if (!cached || !cachedTs) return false;
29343
29357
  const ts = parseInt(cachedTs, 10);
@@ -29360,9 +29374,10 @@ var TokenRegistry = class _TokenRegistry {
29360
29374
  async saveToCache(definitions) {
29361
29375
  if (!this.storage) return;
29362
29376
  try {
29377
+ const { data: dataKey, ts: tsKey } = this.cacheKeys();
29363
29378
  await Promise.all([
29364
- this.storage.set(STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE, JSON.stringify(definitions)),
29365
- this.storage.set(STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE_TS, String(Date.now()))
29379
+ this.storage.set(dataKey, JSON.stringify(definitions)),
29380
+ this.storage.set(tsKey, String(Date.now()))
29366
29381
  ]);
29367
29382
  } catch {
29368
29383
  }