@ecency/wallets 1.4.11 → 1.4.12

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.
@@ -2360,26 +2360,73 @@ var PointTransactionType = /* @__PURE__ */ ((PointTransactionType2) => {
2360
2360
  PointTransactionType2[PointTransactionType2["MINTED"] = 991] = "MINTED";
2361
2361
  return PointTransactionType2;
2362
2362
  })(PointTransactionType || {});
2363
- function getAllTokensListQueryOptions(query) {
2363
+ function createFallbackTokenMetadata(symbol) {
2364
+ return {
2365
+ issuer: "",
2366
+ symbol,
2367
+ name: symbol,
2368
+ metadata: "{}",
2369
+ precision: 0,
2370
+ maxSupply: "0",
2371
+ supply: "0",
2372
+ circulatingSupply: "0",
2373
+ stakingEnabled: false,
2374
+ unstakingCooldown: 0,
2375
+ delegationEnabled: false,
2376
+ undelegationCooldown: 0,
2377
+ numberTransactions: 0,
2378
+ totalStaked: "0"
2379
+ };
2380
+ }
2381
+ async function getLayer2TokensMetadata(username) {
2382
+ if (!username) {
2383
+ return [];
2384
+ }
2385
+ let balances = [];
2386
+ try {
2387
+ balances = await getQueryClient().fetchQuery(
2388
+ getHiveEngineTokensBalancesQueryOptions(username)
2389
+ );
2390
+ } catch {
2391
+ balances = [];
2392
+ }
2393
+ const uniqueSymbols = Array.from(
2394
+ new Set(
2395
+ balances.map((balance) => balance.symbol).filter((symbol) => Boolean(symbol))
2396
+ )
2397
+ );
2398
+ if (uniqueSymbols.length === 0) {
2399
+ return [];
2400
+ }
2401
+ let metadataList = [];
2402
+ try {
2403
+ metadataList = await getQueryClient().fetchQuery(
2404
+ getHiveEngineTokensMetadataQueryOptions(uniqueSymbols)
2405
+ );
2406
+ } catch {
2407
+ metadataList = [];
2408
+ }
2409
+ const metadataBySymbol = new Map(
2410
+ metadataList.map((token) => [token.symbol, token])
2411
+ );
2412
+ return uniqueSymbols.map(
2413
+ (symbol) => metadataBySymbol.get(symbol) ?? createFallbackTokenMetadata(symbol)
2414
+ );
2415
+ }
2416
+ function getAllTokensListQueryOptions(username) {
2364
2417
  return queryOptions({
2365
- queryKey: ["ecency-wallets", "all-tokens-list", query],
2418
+ queryKey: ["ecency-wallets", "all-tokens-list", username ?? null],
2366
2419
  queryFn: async () => {
2367
- await getQueryClient().prefetchQuery(
2368
- getHiveEngineTokensMetadataQueryOptions(HiveEngineTokens)
2369
- );
2370
- const metadataList = getQueryClient().getQueryData(getHiveEngineTokensMetadataQueryOptions(HiveEngineTokens).queryKey);
2371
2420
  return {
2372
2421
  basic: [
2373
2422
  "POINTS" /* Points */,
2374
2423
  "HIVE" /* Hive */,
2375
2424
  "HP" /* HivePower */,
2376
2425
  "HBD" /* HiveDollar */
2377
- ].filter((token) => token.toLowerCase().includes(query.toLowerCase())),
2378
- external: Object.values(EcencyWalletCurrency).filter(
2379
- (token) => token.toLowerCase().includes(query.toLowerCase())
2380
- ),
2426
+ ],
2427
+ external: Object.values(EcencyWalletCurrency),
2381
2428
  spk: ["SPK" /* Spk */, "LARYNX", "LP"],
2382
- layer2: metadataList
2429
+ layer2: await getLayer2TokensMetadata(username)
2383
2430
  };
2384
2431
  }
2385
2432
  });