@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.
- package/dist/core/index.cjs +36 -7
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +4 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +36 -7
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +19 -4
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +19 -4
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +19 -4
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.js +19 -4
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +36 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +36 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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(
|
|
29340
|
-
this.storage.get(
|
|
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(
|
|
29365
|
-
this.storage.set(
|
|
29379
|
+
this.storage.set(dataKey, JSON.stringify(definitions)),
|
|
29380
|
+
this.storage.set(tsKey, String(Date.now()))
|
|
29366
29381
|
]);
|
|
29367
29382
|
} catch {
|
|
29368
29383
|
}
|