@ecency/sdk 1.5.23 → 1.5.24

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.
@@ -422,41 +422,30 @@ function getDynamicPropsQueryOptions() {
422
422
  staleTime: 6e4,
423
423
  refetchOnMount: true,
424
424
  queryFn: async () => {
425
- const globalDynamic = await CONFIG.hiveClient.database.getDynamicGlobalProperties().then((r) => ({
426
- total_vesting_fund_hive: r.total_vesting_fund_hive || r.total_vesting_fund_steem,
427
- total_vesting_shares: r.total_vesting_shares,
428
- hbd_print_rate: r.hbd_print_rate || r.sbd_print_rate,
429
- hbd_interest_rate: r.hbd_interest_rate,
430
- head_block_number: r.head_block_number,
431
- vesting_reward_percent: r.vesting_reward_percent,
432
- virtual_supply: r.virtual_supply
433
- }));
434
- const feedHistory = await CONFIG.hiveClient.database.call("get_feed_history");
435
- const chainProps = await CONFIG.hiveClient.database.call(
436
- "get_chain_properties"
437
- );
438
- const rewardFund = await CONFIG.hiveClient.database.call(
439
- "get_reward_fund",
440
- ["post"]
441
- );
442
- const hivePerMVests = parseAsset(globalDynamic.total_vesting_fund_hive).amount / parseAsset(globalDynamic.total_vesting_shares).amount * 1e6;
443
- const base = parseAsset(feedHistory.current_median_history.base).amount;
444
- const quote = parseAsset(feedHistory.current_median_history.quote).amount;
445
- const fundRecentClaims = parseFloat(rewardFund.recent_claims);
446
- const fundRewardBalance = parseAsset(rewardFund.reward_balance).amount;
447
- const hbdPrintRate = globalDynamic.hbd_print_rate;
448
- const hbdInterestRate = globalDynamic.hbd_interest_rate;
449
- const headBlock = globalDynamic.head_block_number;
450
- const totalVestingFund = parseAsset(
451
- globalDynamic.total_vesting_fund_hive
452
- ).amount;
453
- const totalVestingShares = parseAsset(
454
- globalDynamic.total_vesting_shares
455
- ).amount;
456
- const virtualSupply = parseAsset(globalDynamic.virtual_supply).amount;
457
- const vestingRewardPercent = globalDynamic.vesting_reward_percent;
458
- const accountCreationFee = chainProps.account_creation_fee;
425
+ const rawGlobalDynamic = await CONFIG.hiveClient.database.getDynamicGlobalProperties();
426
+ const rawFeedHistory = await CONFIG.hiveClient.database.call("get_feed_history");
427
+ const rawChainProps = await CONFIG.hiveClient.database.call("get_chain_properties");
428
+ const rawRewardFund = await CONFIG.hiveClient.database.call("get_reward_fund", ["post"]);
429
+ const totalVestingSharesAmount = parseAsset(rawGlobalDynamic.total_vesting_shares).amount;
430
+ const totalVestingFundAmount = parseAsset(rawGlobalDynamic.total_vesting_fund_hive).amount;
431
+ let hivePerMVests = 0;
432
+ if (Number.isFinite(totalVestingSharesAmount) && totalVestingSharesAmount !== 0 && Number.isFinite(totalVestingFundAmount)) {
433
+ hivePerMVests = totalVestingFundAmount / totalVestingSharesAmount * 1e6;
434
+ }
435
+ const base = parseAsset(rawFeedHistory.current_median_history.base).amount;
436
+ const quote = parseAsset(rawFeedHistory.current_median_history.quote).amount;
437
+ const fundRecentClaims = parseFloat(rawRewardFund.recent_claims);
438
+ const fundRewardBalance = parseAsset(rawRewardFund.reward_balance).amount;
439
+ const hbdPrintRate = rawGlobalDynamic.hbd_print_rate;
440
+ const hbdInterestRate = rawGlobalDynamic.hbd_interest_rate;
441
+ const headBlock = rawGlobalDynamic.head_block_number;
442
+ const totalVestingFund = totalVestingFundAmount;
443
+ const totalVestingShares = totalVestingSharesAmount;
444
+ const virtualSupply = parseAsset(rawGlobalDynamic.virtual_supply).amount;
445
+ const vestingRewardPercent = rawGlobalDynamic.vesting_reward_percent || 0;
446
+ const accountCreationFee = rawChainProps.account_creation_fee;
459
447
  return {
448
+ // Backward compatible transformed fields (camelCase, parsed)
460
449
  hivePerMVests,
461
450
  base,
462
451
  quote,
@@ -469,11 +458,27 @@ function getDynamicPropsQueryOptions() {
469
458
  totalVestingShares,
470
459
  virtualSupply,
471
460
  vestingRewardPercent,
472
- accountCreationFee
461
+ accountCreationFee,
462
+ // Raw blockchain data (snake_case, unparsed) for direct use
463
+ // Includes ALL fields from the blockchain responses
464
+ raw: {
465
+ globalDynamic: rawGlobalDynamic,
466
+ feedHistory: rawFeedHistory,
467
+ chainProps: rawChainProps,
468
+ rewardFund: rawRewardFund
469
+ }
473
470
  };
474
471
  }
475
472
  });
476
473
  }
474
+ function getRewardFundQueryOptions(fundName = "post") {
475
+ return queryOptions({
476
+ queryKey: ["core", "reward-fund", fundName],
477
+ queryFn: () => CONFIG.hiveClient.database.call("get_reward_fund", [
478
+ fundName
479
+ ])
480
+ });
481
+ }
477
482
  function getAccountFullQueryOptions(username) {
478
483
  return queryOptions({
479
484
  queryKey: ["get-account-full", username],
@@ -1009,6 +1014,46 @@ function getFavouritesInfiniteQueryOptions(activeUsername, code, limit = 10) {
1009
1014
  enabled: !!activeUsername && !!code
1010
1015
  });
1011
1016
  }
1017
+ function checkFavouriteQueryOptions(activeUsername, code, targetUsername) {
1018
+ return queryOptions({
1019
+ queryKey: ["accounts", "favourites", "check", activeUsername, targetUsername],
1020
+ enabled: !!activeUsername && !!code && !!targetUsername,
1021
+ queryFn: async () => {
1022
+ if (!activeUsername || !code) {
1023
+ throw new Error("[SDK][Accounts][Favourites] \u2013 missing auth");
1024
+ }
1025
+ if (!targetUsername) {
1026
+ throw new Error("[SDK][Accounts][Favourites] \u2013 no target username");
1027
+ }
1028
+ const fetchApi = getBoundFetch();
1029
+ const response = await fetchApi(
1030
+ CONFIG.privateApiHost + "/private-api/favorites-check",
1031
+ {
1032
+ method: "POST",
1033
+ headers: {
1034
+ "Content-Type": "application/json"
1035
+ },
1036
+ body: JSON.stringify({
1037
+ code,
1038
+ account: targetUsername
1039
+ })
1040
+ }
1041
+ );
1042
+ if (!response.ok) {
1043
+ throw new Error(
1044
+ `[SDK][Accounts][Favourites] \u2013 favorites-check failed with status ${response.status}: ${response.statusText}`
1045
+ );
1046
+ }
1047
+ const result = await response.json();
1048
+ if (typeof result !== "boolean") {
1049
+ throw new Error(
1050
+ `[SDK][Accounts][Favourites] \u2013 favorites-check returned invalid type: expected boolean, got ${typeof result}`
1051
+ );
1052
+ }
1053
+ return result;
1054
+ }
1055
+ });
1056
+ }
1012
1057
  function getAccountRecoveriesQueryOptions(username, code) {
1013
1058
  return queryOptions({
1014
1059
  enabled: !!username && !!code,
@@ -2353,8 +2398,8 @@ function toEntryArray(x) {
2353
2398
  return Array.isArray(x) ? x : [];
2354
2399
  }
2355
2400
  async function getVisibleFirstLevelThreadItems(container) {
2356
- const queryOptions89 = getDiscussionsQueryOptions(container, "created" /* created */, true);
2357
- const discussionItemsRaw = await CONFIG.queryClient.fetchQuery(queryOptions89);
2401
+ const queryOptions93 = getDiscussionsQueryOptions(container, "created" /* created */, true);
2402
+ const discussionItemsRaw = await CONFIG.queryClient.fetchQuery(queryOptions93);
2358
2403
  const discussionItems = toEntryArray(discussionItemsRaw);
2359
2404
  if (discussionItems.length <= 1) {
2360
2405
  return [];
@@ -5185,6 +5230,34 @@ function getTradeHistoryQueryOptions(limit = 1e3, startDate, endDate) {
5185
5230
  ])
5186
5231
  });
5187
5232
  }
5233
+ function getFeedHistoryQueryOptions() {
5234
+ return queryOptions({
5235
+ queryKey: ["market", "feed-history"],
5236
+ queryFn: async () => {
5237
+ try {
5238
+ const feedHistory = await CONFIG.hiveClient.database.call("get_feed_history");
5239
+ return feedHistory;
5240
+ } catch (error) {
5241
+ throw error;
5242
+ }
5243
+ }
5244
+ });
5245
+ }
5246
+ function getCurrentMedianHistoryPriceQueryOptions() {
5247
+ return queryOptions({
5248
+ queryKey: ["market", "current-median-history-price"],
5249
+ queryFn: async () => {
5250
+ try {
5251
+ const price = await CONFIG.hiveClient.database.call(
5252
+ "get_current_median_history_price"
5253
+ );
5254
+ return price;
5255
+ } catch (error) {
5256
+ throw error;
5257
+ }
5258
+ }
5259
+ });
5260
+ }
5188
5261
 
5189
5262
  // src/modules/market/requests.ts
5190
5263
  async function parseJsonResponse2(response) {
@@ -5956,6 +6029,6 @@ async function getSpkMarkets() {
5956
6029
  return await response.json();
5957
6030
  }
5958
6031
 
5959
- export { ACCOUNT_OPERATION_GROUPS, ALL_ACCOUNT_OPERATIONS, ALL_NOTIFY_TYPES, CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, NaiMap, NotificationFilter, NotificationViewType, NotifyTypes, ROLES, SortOrder, Symbol2 as Symbol, ThreeSpeakIntegration, addDraft, addImage, addSchedule, bridgeApiCall, broadcastJson, buildProfileMetadata, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, deleteDraft, deleteImage, deleteSchedule, downVotingPower, encodeObj, extractAccountProfile, getAccountFullQueryOptions, getAccountNotificationsInfiniteQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountPosts, getAccountPostsInfiniteQueryOptions, getAccountPostsQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountReputationsQueryOptions, getAccountSubscriptionsQueryOptions, getAccountVoteHistoryInfiniteQueryOptions, getAccountsQueryOptions, getAnnouncementsQueryOptions, getBookmarksInfiniteQueryOptions, getBookmarksQueryOptions, getBoostPlusAccountPricesQueryOptions, getBoostPlusPricesQueryOptions, getBotsQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCollateralizedConversionRequestsQueryOptions, getCommentHistoryQueryOptions, getCommunities, getCommunitiesQueryOptions, getCommunity, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityQueryOptions, getCommunitySubscribersQueryOptions, getCommunityType, getContentQueryOptions, getContentRepliesQueryOptions, getControversialRisingInfiniteQueryOptions, getConversionRequestsQueryOptions, getCurrencyRate, getCurrencyRates, getCurrencyTokenRate, getDeletedEntryQueryOptions, getDiscoverCurationQueryOptions, getDiscoverLeaderboardQueryOptions, getDiscussion, getDiscussionQueryOptions, getDiscussionsQueryOptions, getDraftsInfiniteQueryOptions, getDraftsQueryOptions, getDynamicPropsQueryOptions, getEntryActiveVotesQueryOptions, getFavouritesInfiniteQueryOptions, getFavouritesQueryOptions, getFollowCountQueryOptions, getFollowersQueryOptions, getFollowingQueryOptions, getFragmentsInfiniteQueryOptions, getFragmentsQueryOptions, getFriendsInfiniteQueryOptions, getGalleryImagesQueryOptions, getGameStatusCheckQueryOptions, getHiveEngineMetrics, getHiveEngineOpenOrders, getHiveEngineOrderBook, getHiveEngineTokenMetrics, getHiveEngineTokenTransactions, getHiveEngineTokensBalances, getHiveEngineTokensMarket, getHiveEngineTokensMetadata, getHiveEngineTradeHistory, getHiveEngineUnclaimedRewards, getHiveHbdStatsQueryOptions, getHivePoshLinksQueryOptions, getHivePrice, getImagesInfiniteQueryOptions, getImagesQueryOptions, getIncomingRcQueryOptions, getMarketData, getMarketDataQueryOptions, getMarketHistoryQueryOptions, getMarketStatisticsQueryOptions, getMutedUsersQueryOptions, getNormalizePostQueryOptions, getNotificationSetting, getNotifications, getNotificationsInfiniteQueryOptions, getNotificationsSettingsQueryOptions, getNotificationsUnreadCountQueryOptions, getOpenOrdersQueryOptions, getOrderBookQueryOptions, getOutgoingRcDelegationsInfiniteQueryOptions, getPageStatsQueryOptions, getPointsQueryOptions, getPortfolioQueryOptions, getPost, getPostHeader, getPostHeaderQueryOptions, getPostQueryOptions, getPostTipsQueryOptions, getPostsRanked, getPostsRankedInfiniteQueryOptions, getPostsRankedQueryOptions, getProfiles, getProfilesQueryOptions, getPromotePriceQueryOptions, getPromotedPost, getPromotedPostsQuery, getProposalQueryOptions, getProposalVotesInfiniteQueryOptions, getProposalsQueryOptions, getQueryClient, getRcStatsQueryOptions, getReblogsQueryOptions, getReceivedVestingSharesQueryOptions, getRecurrentTransfersQueryOptions, getReferralsInfiniteQueryOptions, getReferralsStatsQueryOptions, getRelationshipBetweenAccounts, getRelationshipBetweenAccountsQueryOptions, getRewardedCommunitiesQueryOptions, getSavingsWithdrawFromQueryOptions, getSchedulesInfiniteQueryOptions, getSchedulesQueryOptions, getSearchAccountQueryOptions, getSearchAccountsByUsernameQueryOptions, getSearchApiInfiniteQueryOptions, getSearchFriendsQueryOptions, getSearchPathQueryOptions, getSearchTopicsQueryOptions, getSimilarEntriesQueryOptions, getSpkMarkets, getSpkWallet, getStatsQueryOptions, getSubscribers, getSubscriptions, getTradeHistoryQueryOptions, getTransactionsInfiniteQueryOptions, getTrendingTagsQueryOptions, getTrendingTagsWithStatsQueryOptions, getUserPostVoteQueryOptions, getUserProposalVotesQueryOptions, getVestingDelegationsQueryOptions, getVisibleFirstLevelThreadItems, getWavesByHostQueryOptions, getWavesByTagQueryOptions, getWavesFollowingQueryOptions, getWavesTrendingTagsQueryOptions, getWithdrawRoutesQueryOptions, getWitnessesInfiniteQueryOptions, hsTokenRenew, isCommunity, isWrappedResponse, lookupAccountsQueryOptions, makeQueryClient, mapThreadItemsToWaveEntries, markNotifications, moveSchedule, normalizePost, normalizeToWrappedResponse, normalizeWaveEntryFromApi, onboardEmail, parseAccounts, parseAsset, parseProfileMetadata, powerRechargeTime, rcPower, resolvePost, roleMap, saveNotificationSetting, search, searchAccount, searchPath, searchQueryOptions, searchTag, signUp, sortDiscussions, subscribeEmail, toEntryArray, updateDraft, uploadImage, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddDraft, useAddFragment, useAddImage, useAddSchedule, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useDeleteDraft, useDeleteImage, useDeleteSchedule, useEditFragment, useGameClaim, useMarkNotificationsRead, useMoveSchedule, useRecordActivity, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain, useUpdateDraft, useUploadImage, usrActivity, validatePostCreating, votingPower, votingValue };
6032
+ export { ACCOUNT_OPERATION_GROUPS, ALL_ACCOUNT_OPERATIONS, ALL_NOTIFY_TYPES, CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, NaiMap, NotificationFilter, NotificationViewType, NotifyTypes, ROLES, SortOrder, Symbol2 as Symbol, ThreeSpeakIntegration, addDraft, addImage, addSchedule, bridgeApiCall, broadcastJson, buildProfileMetadata, checkFavouriteQueryOptions, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, deleteDraft, deleteImage, deleteSchedule, downVotingPower, encodeObj, extractAccountProfile, getAccountFullQueryOptions, getAccountNotificationsInfiniteQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountPosts, getAccountPostsInfiniteQueryOptions, getAccountPostsQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountReputationsQueryOptions, getAccountSubscriptionsQueryOptions, getAccountVoteHistoryInfiniteQueryOptions, getAccountsQueryOptions, getAnnouncementsQueryOptions, getBookmarksInfiniteQueryOptions, getBookmarksQueryOptions, getBoostPlusAccountPricesQueryOptions, getBoostPlusPricesQueryOptions, getBotsQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCollateralizedConversionRequestsQueryOptions, getCommentHistoryQueryOptions, getCommunities, getCommunitiesQueryOptions, getCommunity, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityQueryOptions, getCommunitySubscribersQueryOptions, getCommunityType, getContentQueryOptions, getContentRepliesQueryOptions, getControversialRisingInfiniteQueryOptions, getConversionRequestsQueryOptions, getCurrencyRate, getCurrencyRates, getCurrencyTokenRate, getCurrentMedianHistoryPriceQueryOptions, getDeletedEntryQueryOptions, getDiscoverCurationQueryOptions, getDiscoverLeaderboardQueryOptions, getDiscussion, getDiscussionQueryOptions, getDiscussionsQueryOptions, getDraftsInfiniteQueryOptions, getDraftsQueryOptions, getDynamicPropsQueryOptions, getEntryActiveVotesQueryOptions, getFavouritesInfiniteQueryOptions, getFavouritesQueryOptions, getFeedHistoryQueryOptions, getFollowCountQueryOptions, getFollowersQueryOptions, getFollowingQueryOptions, getFragmentsInfiniteQueryOptions, getFragmentsQueryOptions, getFriendsInfiniteQueryOptions, getGalleryImagesQueryOptions, getGameStatusCheckQueryOptions, getHiveEngineMetrics, getHiveEngineOpenOrders, getHiveEngineOrderBook, getHiveEngineTokenMetrics, getHiveEngineTokenTransactions, getHiveEngineTokensBalances, getHiveEngineTokensMarket, getHiveEngineTokensMetadata, getHiveEngineTradeHistory, getHiveEngineUnclaimedRewards, getHiveHbdStatsQueryOptions, getHivePoshLinksQueryOptions, getHivePrice, getImagesInfiniteQueryOptions, getImagesQueryOptions, getIncomingRcQueryOptions, getMarketData, getMarketDataQueryOptions, getMarketHistoryQueryOptions, getMarketStatisticsQueryOptions, getMutedUsersQueryOptions, getNormalizePostQueryOptions, getNotificationSetting, getNotifications, getNotificationsInfiniteQueryOptions, getNotificationsSettingsQueryOptions, getNotificationsUnreadCountQueryOptions, getOpenOrdersQueryOptions, getOrderBookQueryOptions, getOutgoingRcDelegationsInfiniteQueryOptions, getPageStatsQueryOptions, getPointsQueryOptions, getPortfolioQueryOptions, getPost, getPostHeader, getPostHeaderQueryOptions, getPostQueryOptions, getPostTipsQueryOptions, getPostsRanked, getPostsRankedInfiniteQueryOptions, getPostsRankedQueryOptions, getProfiles, getProfilesQueryOptions, getPromotePriceQueryOptions, getPromotedPost, getPromotedPostsQuery, getProposalQueryOptions, getProposalVotesInfiniteQueryOptions, getProposalsQueryOptions, getQueryClient, getRcStatsQueryOptions, getReblogsQueryOptions, getReceivedVestingSharesQueryOptions, getRecurrentTransfersQueryOptions, getReferralsInfiniteQueryOptions, getReferralsStatsQueryOptions, getRelationshipBetweenAccounts, getRelationshipBetweenAccountsQueryOptions, getRewardFundQueryOptions, getRewardedCommunitiesQueryOptions, getSavingsWithdrawFromQueryOptions, getSchedulesInfiniteQueryOptions, getSchedulesQueryOptions, getSearchAccountQueryOptions, getSearchAccountsByUsernameQueryOptions, getSearchApiInfiniteQueryOptions, getSearchFriendsQueryOptions, getSearchPathQueryOptions, getSearchTopicsQueryOptions, getSimilarEntriesQueryOptions, getSpkMarkets, getSpkWallet, getStatsQueryOptions, getSubscribers, getSubscriptions, getTradeHistoryQueryOptions, getTransactionsInfiniteQueryOptions, getTrendingTagsQueryOptions, getTrendingTagsWithStatsQueryOptions, getUserPostVoteQueryOptions, getUserProposalVotesQueryOptions, getVestingDelegationsQueryOptions, getVisibleFirstLevelThreadItems, getWavesByHostQueryOptions, getWavesByTagQueryOptions, getWavesFollowingQueryOptions, getWavesTrendingTagsQueryOptions, getWithdrawRoutesQueryOptions, getWitnessesInfiniteQueryOptions, hsTokenRenew, isCommunity, isWrappedResponse, lookupAccountsQueryOptions, makeQueryClient, mapThreadItemsToWaveEntries, markNotifications, moveSchedule, normalizePost, normalizeToWrappedResponse, normalizeWaveEntryFromApi, onboardEmail, parseAccounts, parseAsset, parseProfileMetadata, powerRechargeTime, rcPower, resolvePost, roleMap, saveNotificationSetting, search, searchAccount, searchPath, searchQueryOptions, searchTag, signUp, sortDiscussions, subscribeEmail, toEntryArray, updateDraft, uploadImage, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddDraft, useAddFragment, useAddImage, useAddSchedule, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useDeleteDraft, useDeleteImage, useDeleteSchedule, useEditFragment, useGameClaim, useMarkNotificationsRead, useMoveSchedule, useRecordActivity, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain, useUpdateDraft, useUploadImage, usrActivity, validatePostCreating, votingPower, votingValue };
5960
6033
  //# sourceMappingURL=index.mjs.map
5961
6034
  //# sourceMappingURL=index.mjs.map