@talismn/chaindata-provider 2.3.0 → 2.3.1
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/index.d.mts +105 -105
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +28 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8790,6 +8790,11 @@ var ChaindataProvider = class {
|
|
|
8790
8790
|
this.#dynamicTokensWriteQueue = result.catch(() => void 0);
|
|
8791
8791
|
return result;
|
|
8792
8792
|
}
|
|
8793
|
+
/** ids of the tokens in the default (curated) chaindata */
|
|
8794
|
+
async #getCuratedTokenIds() {
|
|
8795
|
+
const defaultStorage = await (0, rxjs.firstValueFrom)(this.#storage$);
|
|
8796
|
+
return new Set(defaultStorage.tokens.map((t) => t.id));
|
|
8797
|
+
}
|
|
8793
8798
|
/**
|
|
8794
8799
|
* Registers token dynamically a runtime. used for SPL and dTAO tokens.
|
|
8795
8800
|
* @param tokens
|
|
@@ -8798,9 +8803,12 @@ var ChaindataProvider = class {
|
|
|
8798
8803
|
if (!tokens.length) return;
|
|
8799
8804
|
await (0, _talismn_util.forEachWithYield)(tokens, (t) => void TokenSchema.parse(t));
|
|
8800
8805
|
await this.#enqueueDynamicTokensWrite(async () => {
|
|
8806
|
+
const curatedTokenIds = await this.#getCuratedTokenIds();
|
|
8807
|
+
const newTokens = tokens.filter((t) => !isShadowingCuratedToken(t, curatedTokenIds));
|
|
8808
|
+
if (!newTokens.length) return;
|
|
8801
8809
|
const currentStorage = await (0, rxjs.firstValueFrom)(this.#dynamicTokens$);
|
|
8802
8810
|
const currentById = (0, lodash_es.keyBy)(currentStorage, (t) => t.id);
|
|
8803
|
-
const newById = (0, lodash_es.keyBy)(
|
|
8811
|
+
const newById = (0, lodash_es.keyBy)(newTokens, (t) => t.id);
|
|
8804
8812
|
const dynamicTokens = (0, lodash_es.values)({
|
|
8805
8813
|
...currentById,
|
|
8806
8814
|
...newById
|
|
@@ -8817,12 +8825,11 @@ var ChaindataProvider = class {
|
|
|
8817
8825
|
await this.#enqueueDynamicTokensWrite(async () => {
|
|
8818
8826
|
const dynamicTokens = await (0, rxjs.firstValueFrom)(this.#dynamicTokens$);
|
|
8819
8827
|
if (!dynamicTokens.length) return;
|
|
8820
|
-
const
|
|
8821
|
-
const defaultTokenIds = new Set(defaultStorage.tokens.map((t) => t.id));
|
|
8828
|
+
const defaultTokenIds = await this.#getCuratedTokenIds();
|
|
8822
8829
|
const next = [];
|
|
8823
8830
|
let changed = false;
|
|
8824
8831
|
for (const token of dynamicTokens) {
|
|
8825
|
-
if ((token
|
|
8832
|
+
if (isShadowingCuratedToken(token, defaultTokenIds)) {
|
|
8826
8833
|
changed = true;
|
|
8827
8834
|
continue;
|
|
8828
8835
|
}
|
|
@@ -8921,6 +8928,11 @@ const withErrorReason = async (reason, task) => {
|
|
|
8921
8928
|
throw new Error(reason, { cause });
|
|
8922
8929
|
}
|
|
8923
8930
|
};
|
|
8931
|
+
/**
|
|
8932
|
+
* A dynamic Solana token whose id is also in the curated chaindata. Combined chaindata
|
|
8933
|
+
* keeps the last token per id, so such an entry would replace the curated one.
|
|
8934
|
+
*/
|
|
8935
|
+
const isShadowingCuratedToken = (token, curatedTokenIds) => (token.type === "sol-spl" || token.type === "sol-token2022") && curatedTokenIds.has(token.id);
|
|
8924
8936
|
//#endregion
|
|
8925
8937
|
//#region src/state/schema.ts
|
|
8926
8938
|
const ChaindataFileSchema = zod_v4.default.object({
|