@basedone/core 0.1.4 → 0.1.5
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.js +29 -1
- package/dist/index.mjs +29 -1
- package/lib/meta/metadata.ts +32 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37735,6 +37735,9 @@ var MetadataClient = class {
|
|
|
37735
37735
|
if (this.initialized) return;
|
|
37736
37736
|
if (this.initializing) return this.initializing;
|
|
37737
37737
|
this.initializing = new Promise(async (resolve, reject) => {
|
|
37738
|
+
if (this.config.debug) {
|
|
37739
|
+
console.info("[MetadataClient] Initializing...", this.config);
|
|
37740
|
+
}
|
|
37738
37741
|
await this.loadStaticMetaOverrides();
|
|
37739
37742
|
if (this.config.onlyUseStaticFallback) {
|
|
37740
37743
|
await this.loadStaticMetadata();
|
|
@@ -37754,6 +37757,14 @@ var MetadataClient = class {
|
|
|
37754
37757
|
this.infoClient.meta(),
|
|
37755
37758
|
this.infoClient.perpDexs()
|
|
37756
37759
|
]);
|
|
37760
|
+
if (this.config.debug) {
|
|
37761
|
+
console.info(
|
|
37762
|
+
"[MetadataClient] Core metadata",
|
|
37763
|
+
this.spotMeta,
|
|
37764
|
+
this.perpsMeta,
|
|
37765
|
+
this.perpDexs
|
|
37766
|
+
);
|
|
37767
|
+
}
|
|
37757
37768
|
this.buildLookupMaps();
|
|
37758
37769
|
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
37759
37770
|
await Promise.all(
|
|
@@ -37761,6 +37772,9 @@ var MetadataClient = class {
|
|
|
37761
37772
|
);
|
|
37762
37773
|
}
|
|
37763
37774
|
this.initialized = true;
|
|
37775
|
+
if (this.config.debug) {
|
|
37776
|
+
console.info("[MetadataClient] Initialized");
|
|
37777
|
+
}
|
|
37764
37778
|
resolve();
|
|
37765
37779
|
} catch (error) {
|
|
37766
37780
|
if (this.config.useStaticFallback) {
|
|
@@ -37791,6 +37805,12 @@ var MetadataClient = class {
|
|
|
37791
37805
|
try {
|
|
37792
37806
|
const staticMetaModule = await globImport_data_staticMeta_json(`./data/${network}/staticMeta.json`);
|
|
37793
37807
|
this.staticMeta = staticMetaModule.default;
|
|
37808
|
+
if (this.config.debug) {
|
|
37809
|
+
console.info(
|
|
37810
|
+
"[MetadataClient] Loaded static metadata overrides",
|
|
37811
|
+
this.staticMeta
|
|
37812
|
+
);
|
|
37813
|
+
}
|
|
37794
37814
|
} catch (error) {
|
|
37795
37815
|
console.warn(`Failed to load staticMeta.json for ${network}:`, error);
|
|
37796
37816
|
this.staticMeta = null;
|
|
@@ -37817,7 +37837,7 @@ var MetadataClient = class {
|
|
|
37817
37837
|
this.perpsMeta = perpsMetaModule.default;
|
|
37818
37838
|
this.perpDexs = perpDexsModule.default;
|
|
37819
37839
|
this.staticMeta = staticMetaModule.default;
|
|
37820
|
-
console.warn(`Using static ${network} metadata`);
|
|
37840
|
+
console.warn(`[MetadataClient] Using static ${network} metadata`);
|
|
37821
37841
|
} catch (error) {
|
|
37822
37842
|
console.error(`Failed to load static ${network} metadata:`, error);
|
|
37823
37843
|
throw new Error(`Could not load metadata for ${network}`);
|
|
@@ -37924,6 +37944,14 @@ var MetadataClient = class {
|
|
|
37924
37944
|
const [meta, contexts] = await this.infoClient.metaAndAssetCtxs({
|
|
37925
37945
|
dex: dexName
|
|
37926
37946
|
});
|
|
37947
|
+
if (this.config.debug) {
|
|
37948
|
+
console.info(
|
|
37949
|
+
"[MetadataClient] Loaded HIP-3 metadata",
|
|
37950
|
+
dexName,
|
|
37951
|
+
meta,
|
|
37952
|
+
contexts
|
|
37953
|
+
);
|
|
37954
|
+
}
|
|
37927
37955
|
let dexIndex = this.dexNameToIndex.get(dexName.toLowerCase());
|
|
37928
37956
|
if (dexIndex === void 0) {
|
|
37929
37957
|
dexIndex = this.perpDexs.findIndex(
|
package/dist/index.mjs
CHANGED
|
@@ -678,6 +678,9 @@ var MetadataClient = class {
|
|
|
678
678
|
if (this.initialized) return;
|
|
679
679
|
if (this.initializing) return this.initializing;
|
|
680
680
|
this.initializing = new Promise(async (resolve, reject) => {
|
|
681
|
+
if (this.config.debug) {
|
|
682
|
+
console.info("[MetadataClient] Initializing...", this.config);
|
|
683
|
+
}
|
|
681
684
|
await this.loadStaticMetaOverrides();
|
|
682
685
|
if (this.config.onlyUseStaticFallback) {
|
|
683
686
|
await this.loadStaticMetadata();
|
|
@@ -697,6 +700,14 @@ var MetadataClient = class {
|
|
|
697
700
|
this.infoClient.meta(),
|
|
698
701
|
this.infoClient.perpDexs()
|
|
699
702
|
]);
|
|
703
|
+
if (this.config.debug) {
|
|
704
|
+
console.info(
|
|
705
|
+
"[MetadataClient] Core metadata",
|
|
706
|
+
this.spotMeta,
|
|
707
|
+
this.perpsMeta,
|
|
708
|
+
this.perpDexs
|
|
709
|
+
);
|
|
710
|
+
}
|
|
700
711
|
this.buildLookupMaps();
|
|
701
712
|
if (this.config.hip3Dexs && this.config.hip3Dexs.length > 0) {
|
|
702
713
|
await Promise.all(
|
|
@@ -704,6 +715,9 @@ var MetadataClient = class {
|
|
|
704
715
|
);
|
|
705
716
|
}
|
|
706
717
|
this.initialized = true;
|
|
718
|
+
if (this.config.debug) {
|
|
719
|
+
console.info("[MetadataClient] Initialized");
|
|
720
|
+
}
|
|
707
721
|
resolve();
|
|
708
722
|
} catch (error) {
|
|
709
723
|
if (this.config.useStaticFallback) {
|
|
@@ -734,6 +748,12 @@ var MetadataClient = class {
|
|
|
734
748
|
try {
|
|
735
749
|
const staticMetaModule = await globImport_data_staticMeta_json(`./data/${network}/staticMeta.json`);
|
|
736
750
|
this.staticMeta = staticMetaModule.default;
|
|
751
|
+
if (this.config.debug) {
|
|
752
|
+
console.info(
|
|
753
|
+
"[MetadataClient] Loaded static metadata overrides",
|
|
754
|
+
this.staticMeta
|
|
755
|
+
);
|
|
756
|
+
}
|
|
737
757
|
} catch (error) {
|
|
738
758
|
console.warn(`Failed to load staticMeta.json for ${network}:`, error);
|
|
739
759
|
this.staticMeta = null;
|
|
@@ -760,7 +780,7 @@ var MetadataClient = class {
|
|
|
760
780
|
this.perpsMeta = perpsMetaModule.default;
|
|
761
781
|
this.perpDexs = perpDexsModule.default;
|
|
762
782
|
this.staticMeta = staticMetaModule.default;
|
|
763
|
-
console.warn(`Using static ${network} metadata`);
|
|
783
|
+
console.warn(`[MetadataClient] Using static ${network} metadata`);
|
|
764
784
|
} catch (error) {
|
|
765
785
|
console.error(`Failed to load static ${network} metadata:`, error);
|
|
766
786
|
throw new Error(`Could not load metadata for ${network}`);
|
|
@@ -867,6 +887,14 @@ var MetadataClient = class {
|
|
|
867
887
|
const [meta, contexts] = await this.infoClient.metaAndAssetCtxs({
|
|
868
888
|
dex: dexName
|
|
869
889
|
});
|
|
890
|
+
if (this.config.debug) {
|
|
891
|
+
console.info(
|
|
892
|
+
"[MetadataClient] Loaded HIP-3 metadata",
|
|
893
|
+
dexName,
|
|
894
|
+
meta,
|
|
895
|
+
contexts
|
|
896
|
+
);
|
|
897
|
+
}
|
|
870
898
|
let dexIndex = this.dexNameToIndex.get(dexName.toLowerCase());
|
|
871
899
|
if (dexIndex === void 0) {
|
|
872
900
|
dexIndex = this.perpDexs.findIndex(
|
package/lib/meta/metadata.ts
CHANGED
|
@@ -176,6 +176,7 @@ export class MetadataClient {
|
|
|
176
176
|
useStaticFallback: config.useStaticFallback ?? true,
|
|
177
177
|
};
|
|
178
178
|
this.isTestnet = config.isTestnet ?? false;
|
|
179
|
+
|
|
179
180
|
this.initialize();
|
|
180
181
|
}
|
|
181
182
|
|
|
@@ -186,6 +187,9 @@ export class MetadataClient {
|
|
|
186
187
|
if (this.initialized) return;
|
|
187
188
|
if (this.initializing) return this.initializing;
|
|
188
189
|
this.initializing = new Promise(async (resolve, reject) => {
|
|
190
|
+
if (this.config.debug) {
|
|
191
|
+
console.info("[MetadataClient] Initializing...", this.config);
|
|
192
|
+
}
|
|
189
193
|
// Always load staticMeta.json regardless of config.useStaticFallback
|
|
190
194
|
await this.loadStaticMetaOverrides();
|
|
191
195
|
|
|
@@ -212,6 +216,15 @@ export class MetadataClient {
|
|
|
212
216
|
this.infoClient.perpDexs() as Promise<PerpDex[] | null[]>,
|
|
213
217
|
]);
|
|
214
218
|
|
|
219
|
+
if (this.config.debug) {
|
|
220
|
+
console.info(
|
|
221
|
+
"[MetadataClient] Core metadata",
|
|
222
|
+
this.spotMeta,
|
|
223
|
+
this.perpsMeta,
|
|
224
|
+
this.perpDexs,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
215
228
|
// Build optimized lookup maps
|
|
216
229
|
this.buildLookupMaps();
|
|
217
230
|
|
|
@@ -222,6 +235,9 @@ export class MetadataClient {
|
|
|
222
235
|
);
|
|
223
236
|
}
|
|
224
237
|
this.initialized = true;
|
|
238
|
+
if (this.config.debug) {
|
|
239
|
+
console.info("[MetadataClient] Initialized");
|
|
240
|
+
}
|
|
225
241
|
resolve();
|
|
226
242
|
} catch (error) {
|
|
227
243
|
// Fall back to static data if API fetch fails and fallback is enabled
|
|
@@ -257,6 +273,12 @@ export class MetadataClient {
|
|
|
257
273
|
`./data/${network}/staticMeta.json`
|
|
258
274
|
);
|
|
259
275
|
this.staticMeta = staticMetaModule.default as StaticMetadata;
|
|
276
|
+
if (this.config.debug) {
|
|
277
|
+
console.info(
|
|
278
|
+
"[MetadataClient] Loaded static metadata overrides",
|
|
279
|
+
this.staticMeta,
|
|
280
|
+
);
|
|
281
|
+
}
|
|
260
282
|
} catch (error) {
|
|
261
283
|
console.warn(`Failed to load staticMeta.json for ${network}:`, error);
|
|
262
284
|
this.staticMeta = null;
|
|
@@ -288,7 +310,7 @@ export class MetadataClient {
|
|
|
288
310
|
this.perpDexs = perpDexsModule.default as (PerpDex | null)[];
|
|
289
311
|
this.staticMeta = staticMetaModule.default as StaticMetadata;
|
|
290
312
|
|
|
291
|
-
console.warn(`Using static ${network} metadata`);
|
|
313
|
+
console.warn(`[MetadataClient] Using static ${network} metadata`);
|
|
292
314
|
} catch (error) {
|
|
293
315
|
console.error(`Failed to load static ${network} metadata:`, error);
|
|
294
316
|
throw new Error(`Could not load metadata for ${network}`);
|
|
@@ -436,6 +458,15 @@ export class MetadataClient {
|
|
|
436
458
|
dex: dexName,
|
|
437
459
|
});
|
|
438
460
|
|
|
461
|
+
if (this.config.debug) {
|
|
462
|
+
console.info(
|
|
463
|
+
"[MetadataClient] Loaded HIP-3 metadata",
|
|
464
|
+
dexName,
|
|
465
|
+
meta,
|
|
466
|
+
contexts,
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
439
470
|
// O(1) lookup using pre-computed map
|
|
440
471
|
let dexIndex = this.dexNameToIndex.get(dexName.toLowerCase());
|
|
441
472
|
|