@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
|
@@ -29299,6 +29299,19 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
29299
29299
|
// ===========================================================================
|
|
29300
29300
|
// Cache (StorageProvider)
|
|
29301
29301
|
// ===========================================================================
|
|
29302
|
+
/**
|
|
29303
|
+
* Per-network cache keys. The registry cache MUST be namespaced by remoteUrl:
|
|
29304
|
+
* testnet and testnet2 ship DIFFERENT coinIds for the same symbol, so a single
|
|
29305
|
+
* global key let a stale testnet snapshot be served for a testnet2 request —
|
|
29306
|
+
* wrong/missing icons AND self-mint resolving the wrong-network coinId. Keying
|
|
29307
|
+
* by remoteUrl isolates the snapshots so a network can never read another's.
|
|
29308
|
+
*/
|
|
29309
|
+
cacheKeys() {
|
|
29310
|
+
const base = STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE;
|
|
29311
|
+
const baseTs = STORAGE_KEYS_GLOBAL.TOKEN_REGISTRY_CACHE_TS;
|
|
29312
|
+
if (!this.remoteUrl) return { data: base, ts: baseTs };
|
|
29313
|
+
return { data: `${base}:${this.remoteUrl}`, ts: `${baseTs}:${this.remoteUrl}` };
|
|
29314
|
+
}
|
|
29302
29315
|
/**
|
|
29303
29316
|
* Load definitions from StorageProvider cache.
|
|
29304
29317
|
* Only applies if cache exists and is fresh (within refreshIntervalMs).
|
|
@@ -29306,9 +29319,10 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
29306
29319
|
async loadFromCache() {
|
|
29307
29320
|
if (!this.storage) return false;
|
|
29308
29321
|
try {
|
|
29322
|
+
const { data: dataKey, ts: tsKey } = this.cacheKeys();
|
|
29309
29323
|
const [cached, cachedTs] = await Promise.all([
|
|
29310
|
-
this.storage.get(
|
|
29311
|
-
this.storage.get(
|
|
29324
|
+
this.storage.get(dataKey),
|
|
29325
|
+
this.storage.get(tsKey)
|
|
29312
29326
|
]);
|
|
29313
29327
|
if (!cached || !cachedTs) return false;
|
|
29314
29328
|
const ts = parseInt(cachedTs, 10);
|
|
@@ -29331,9 +29345,10 @@ var TokenRegistry = class _TokenRegistry {
|
|
|
29331
29345
|
async saveToCache(definitions) {
|
|
29332
29346
|
if (!this.storage) return;
|
|
29333
29347
|
try {
|
|
29348
|
+
const { data: dataKey, ts: tsKey } = this.cacheKeys();
|
|
29334
29349
|
await Promise.all([
|
|
29335
|
-
this.storage.set(
|
|
29336
|
-
this.storage.set(
|
|
29350
|
+
this.storage.set(dataKey, JSON.stringify(definitions)),
|
|
29351
|
+
this.storage.set(tsKey, String(Date.now()))
|
|
29337
29352
|
]);
|
|
29338
29353
|
} catch {
|
|
29339
29354
|
}
|