@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
|
@@ -6367,6 +6367,19 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
6367
6367
|
// ===========================================================================
|
|
6368
6368
|
// Cache (StorageProvider)
|
|
6369
6369
|
// ===========================================================================
|
|
6370
|
+
/**
|
|
6371
|
+
* Per-network cache keys. The registry cache MUST be namespaced by remoteUrl:
|
|
6372
|
+
* testnet and testnet2 ship DIFFERENT coinIds for the same symbol, so a single
|
|
6373
|
+
* global key let a stale testnet snapshot be served for a testnet2 request —
|
|
6374
|
+
* wrong/missing icons AND self-mint resolving the wrong-network coinId. Keying
|
|
6375
|
+
* by remoteUrl isolates the snapshots so a network can never read another's.
|
|
6376
|
+
*/
|
|
6377
|
+
cacheKeys() {
|
|
6378
|
+
const base = STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE;
|
|
6379
|
+
const baseTs = STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE_TS;
|
|
6380
|
+
if (!this.remoteUrl) return { data: base, ts: baseTs };
|
|
6381
|
+
return { data: `${base}:${this.remoteUrl}`, ts: `${baseTs}:${this.remoteUrl}` };
|
|
6382
|
+
}
|
|
6370
6383
|
/**
|
|
6371
6384
|
* Load definitions from StorageProvider cache.
|
|
6372
6385
|
* Only applies if cache exists and is fresh (within refreshIntervalMs).
|
|
@@ -6374,9 +6387,10 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
6374
6387
|
async loadFromCache() {
|
|
6375
6388
|
if (!this.storage) return false;
|
|
6376
6389
|
try {
|
|
6390
|
+
const { data: dataKey, ts: tsKey } = this.cacheKeys();
|
|
6377
6391
|
const [cached, cachedTs] = await Promise.all([
|
|
6378
|
-
this.storage.get(
|
|
6379
|
-
this.storage.get(
|
|
6392
|
+
this.storage.get(dataKey),
|
|
6393
|
+
this.storage.get(tsKey)
|
|
6380
6394
|
]);
|
|
6381
6395
|
if (!cached || !cachedTs) return false;
|
|
6382
6396
|
const ts = parseInt(cachedTs, 10);
|
|
@@ -6399,9 +6413,10 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
6399
6413
|
async saveToCache(definitions) {
|
|
6400
6414
|
if (!this.storage) return;
|
|
6401
6415
|
try {
|
|
6416
|
+
const { data: dataKey, ts: tsKey } = this.cacheKeys();
|
|
6402
6417
|
await Promise.all([
|
|
6403
|
-
this.storage.set(
|
|
6404
|
-
this.storage.set(
|
|
6418
|
+
this.storage.set(dataKey, JSON.stringify(definitions)),
|
|
6419
|
+
this.storage.set(tsKey, String(Date.now()))
|
|
6405
6420
|
]);
|
|
6406
6421
|
} catch {
|
|
6407
6422
|
}
|