@unicitylabs/sphere-sdk 0.8.0-dev.3 → 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 +31 -5
- 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 +31 -5
- 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 +31 -5
- 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 +31 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -6319,6 +6319,19 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
6319
6319
|
// ===========================================================================
|
|
6320
6320
|
// Cache (StorageProvider)
|
|
6321
6321
|
// ===========================================================================
|
|
6322
|
+
/**
|
|
6323
|
+
* Per-network cache keys. The registry cache MUST be namespaced by remoteUrl:
|
|
6324
|
+
* testnet and testnet2 ship DIFFERENT coinIds for the same symbol, so a single
|
|
6325
|
+
* global key let a stale testnet snapshot be served for a testnet2 request —
|
|
6326
|
+
* wrong/missing icons AND self-mint resolving the wrong-network coinId. Keying
|
|
6327
|
+
* by remoteUrl isolates the snapshots so a network can never read another's.
|
|
6328
|
+
*/
|
|
6329
|
+
cacheKeys() {
|
|
6330
|
+
const base = STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE;
|
|
6331
|
+
const baseTs = STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE_TS;
|
|
6332
|
+
if (!this.remoteUrl) return { data: base, ts: baseTs };
|
|
6333
|
+
return { data: `${base}:${this.remoteUrl}`, ts: `${baseTs}:${this.remoteUrl}` };
|
|
6334
|
+
}
|
|
6322
6335
|
/**
|
|
6323
6336
|
* Load definitions from StorageProvider cache.
|
|
6324
6337
|
* Only applies if cache exists and is fresh (within refreshIntervalMs).
|
|
@@ -6326,9 +6339,10 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
6326
6339
|
async loadFromCache() {
|
|
6327
6340
|
if (!this.storage) return false;
|
|
6328
6341
|
try {
|
|
6342
|
+
const { data: dataKey, ts: tsKey } = this.cacheKeys();
|
|
6329
6343
|
const [cached, cachedTs] = await Promise.all([
|
|
6330
|
-
this.storage.get(
|
|
6331
|
-
this.storage.get(
|
|
6344
|
+
this.storage.get(dataKey),
|
|
6345
|
+
this.storage.get(tsKey)
|
|
6332
6346
|
]);
|
|
6333
6347
|
if (!cached || !cachedTs) return false;
|
|
6334
6348
|
const ts = parseInt(cachedTs, 10);
|
|
@@ -6351,9 +6365,10 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
6351
6365
|
async saveToCache(definitions) {
|
|
6352
6366
|
if (!this.storage) return;
|
|
6353
6367
|
try {
|
|
6368
|
+
const { data: dataKey, ts: tsKey } = this.cacheKeys();
|
|
6354
6369
|
await Promise.all([
|
|
6355
|
-
this.storage.set(
|
|
6356
|
-
this.storage.set(
|
|
6370
|
+
this.storage.set(dataKey, JSON.stringify(definitions)),
|
|
6371
|
+
this.storage.set(tsKey, String(Date.now()))
|
|
6357
6372
|
]);
|
|
6358
6373
|
} catch {
|
|
6359
6374
|
}
|