@ecency/sdk 1.3.1 → 1.3.2

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.
@@ -387,19 +387,25 @@ declare function getSearchAccountsByUsernameQueryOptions(query: string, limit?:
387
387
  };
388
388
  };
389
389
 
390
- declare function checkUsernameWalletsPendingQueryOptions(username: string): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<{
391
- exist: boolean;
392
- }, Error, {
390
+ type AccountProfileToken = NonNullable<AccountProfile["tokens"]>[number];
391
+ type WalletMetadataCandidate = Partial<AccountProfileToken> & {
392
+ currency?: string;
393
+ show?: boolean;
394
+ address?: string;
395
+ publicKey?: string;
396
+ privateKey?: string;
397
+ username?: string;
398
+ };
399
+ interface CheckUsernameWalletsPendingResponse {
393
400
  exist: boolean;
394
- }, string[]>, "queryFn"> & {
395
- queryFn?: _tanstack_react_query.QueryFunction<{
396
- exist: boolean;
397
- }, string[], never> | undefined;
401
+ tokens?: WalletMetadataCandidate[];
402
+ wallets?: WalletMetadataCandidate[];
403
+ }
404
+ declare function checkUsernameWalletsPendingQueryOptions(username: string, code: string | undefined): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<CheckUsernameWalletsPendingResponse, Error, CheckUsernameWalletsPendingResponse, readonly unknown[]>, "queryFn"> & {
405
+ queryFn?: _tanstack_react_query.QueryFunction<CheckUsernameWalletsPendingResponse, readonly unknown[], never> | undefined;
398
406
  } & {
399
- queryKey: string[] & {
400
- [dataTagSymbol]: {
401
- exist: boolean;
402
- };
407
+ queryKey: readonly unknown[] & {
408
+ [dataTagSymbol]: CheckUsernameWalletsPendingResponse;
403
409
  [dataTagErrorSymbol]: Error;
404
410
  };
405
411
  };
@@ -1022,4 +1028,4 @@ declare function getCommunityPermissions({ communityType, userRole, subscribed,
1022
1028
  isModerator: boolean;
1023
1029
  };
1024
1030
 
1025
- export { type AccountBookmark, type AccountFavorite, type AccountFollowStats, type AccountProfile, type AccountRelationship, type AccountReputation, type Asset, CONFIG, type CantAfford, type Communities, type Community, type CommunityRole, type CommunityTeam, type CommunityType, ConfigManager, type DynamicProps, index as EcencyAnalytics, EcencyQueriesManager, type Fragment, type FullAccount, type GameClaim, type GetGameStatus, type GetRecoveriesEmailResponse, HiveSignerIntegration, keychain as Keychain, type Keys, NaiMap, type Payer, ROLES, type RcStats, type Recoveries, type StatsResponse, type StoringUser, Symbol, ThreeSpeakIntegration, type ThreeSpeakVideo, type TrendingTag, broadcastJson, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, getAccessToken, getAccountFullQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityType, getDynamicPropsQueryOptions, getFragmentsQueryOptions, getGameStatusCheckQueryOptions, getHivePoshLinksQueryOptions, getLoginType, getPostingKey, getPromotedPostsQuery, getQueryClient, getRcStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getSearchAccountsByUsernameQueryOptions, getStatsQueryOptions, getTrendingTagsQueryOptions, getUser, makeQueryClient, parseAsset, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
1031
+ export { type AccountBookmark, type AccountFavorite, type AccountFollowStats, type AccountProfile, type AccountRelationship, type AccountReputation, type Asset, CONFIG, type CantAfford, type CheckUsernameWalletsPendingResponse, type Communities, type Community, type CommunityRole, type CommunityTeam, type CommunityType, ConfigManager, type DynamicProps, index as EcencyAnalytics, EcencyQueriesManager, type Fragment, type FullAccount, type GameClaim, type GetGameStatus, type GetRecoveriesEmailResponse, HiveSignerIntegration, keychain as Keychain, type Keys, NaiMap, type Payer, ROLES, type RcStats, type Recoveries, type StatsResponse, type StoringUser, Symbol, ThreeSpeakIntegration, type ThreeSpeakVideo, type TrendingTag, type WalletMetadataCandidate, broadcastJson, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, getAccessToken, getAccountFullQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityType, getDynamicPropsQueryOptions, getFragmentsQueryOptions, getGameStatusCheckQueryOptions, getHivePoshLinksQueryOptions, getLoginType, getPostingKey, getPromotedPostsQuery, getQueryClient, getRcStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getSearchAccountsByUsernameQueryOptions, getStatsQueryOptions, getTrendingTagsQueryOptions, getUser, makeQueryClient, parseAsset, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
@@ -491,26 +491,99 @@ function getSearchAccountsByUsernameQueryOptions(query, limit = 5, excludeList =
491
491
  }
492
492
  });
493
493
  }
494
- function checkUsernameWalletsPendingQueryOptions(username) {
494
+ var RESERVED_META_KEYS = /* @__PURE__ */ new Set([
495
+ "ownerPublicKey",
496
+ "activePublicKey",
497
+ "postingPublicKey",
498
+ "memoPublicKey"
499
+ ]);
500
+ function checkUsernameWalletsPendingQueryOptions(username, code) {
495
501
  return queryOptions({
496
- queryKey: ["accounts", "check-wallet-pending", username],
502
+ queryKey: [
503
+ "accounts",
504
+ "check-wallet-pending",
505
+ username,
506
+ code ?? null
507
+ ],
497
508
  queryFn: async () => {
509
+ if (!username || !code) {
510
+ return { exist: false };
511
+ }
498
512
  const fetchApi = getBoundFetch();
499
513
  const response = await fetchApi(
500
- CONFIG.privateApiHost + "/private-api/wallets-chkuser",
514
+ CONFIG.privateApiHost + "/private-api/wallets",
501
515
  {
502
516
  method: "POST",
503
517
  headers: {
504
518
  "Content-Type": "application/json"
505
519
  },
506
520
  body: JSON.stringify({
507
- username
521
+ username,
522
+ code
508
523
  })
509
524
  }
510
525
  );
511
- return await response.json();
526
+ if (!response.ok) {
527
+ return { exist: false };
528
+ }
529
+ const payload = await response.json();
530
+ const wallets = Array.isArray(payload) ? payload.flatMap((item) => {
531
+ if (!item || typeof item !== "object") {
532
+ return [];
533
+ }
534
+ const walletItem = item;
535
+ const symbol = typeof walletItem.token === "string" ? walletItem.token : void 0;
536
+ if (!symbol) {
537
+ return [];
538
+ }
539
+ const meta = walletItem.meta && typeof walletItem.meta === "object" ? { ...walletItem.meta } : {};
540
+ const sanitizedMeta = {};
541
+ const address = typeof walletItem.address === "string" && walletItem.address ? walletItem.address : void 0;
542
+ const statusShow = typeof walletItem.status === "number" ? walletItem.status === 3 : void 0;
543
+ const showFlag = statusShow ?? false;
544
+ if (address) {
545
+ sanitizedMeta.address = address;
546
+ }
547
+ sanitizedMeta.show = showFlag;
548
+ const baseCandidate = {
549
+ symbol,
550
+ currency: symbol,
551
+ address,
552
+ show: showFlag,
553
+ type: "CHAIN",
554
+ meta: sanitizedMeta
555
+ };
556
+ const metaTokenCandidates = [];
557
+ for (const [metaSymbol, metaValue] of Object.entries(meta)) {
558
+ if (typeof metaSymbol !== "string") {
559
+ continue;
560
+ }
561
+ if (RESERVED_META_KEYS.has(metaSymbol)) {
562
+ continue;
563
+ }
564
+ if (typeof metaValue !== "string" || !metaValue) {
565
+ continue;
566
+ }
567
+ if (!/^[A-Z0-9]{2,10}$/.test(metaSymbol)) {
568
+ continue;
569
+ }
570
+ metaTokenCandidates.push({
571
+ symbol: metaSymbol,
572
+ currency: metaSymbol,
573
+ address: metaValue,
574
+ show: showFlag,
575
+ type: "CHAIN",
576
+ meta: { address: metaValue, show: showFlag }
577
+ });
578
+ }
579
+ return [baseCandidate, ...metaTokenCandidates];
580
+ }) : [];
581
+ return {
582
+ exist: wallets.length > 0,
583
+ tokens: wallets.length ? wallets : void 0,
584
+ wallets: wallets.length ? wallets : void 0
585
+ };
512
586
  },
513
- enabled: !!username,
514
587
  refetchOnMount: true
515
588
  });
516
589
  }