@ecency/sdk 1.5.22 → 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.
@@ -447,41 +447,30 @@ function getDynamicPropsQueryOptions() {
447
447
  staleTime: 6e4,
448
448
  refetchOnMount: true,
449
449
  queryFn: async () => {
450
- const globalDynamic = await CONFIG.hiveClient.database.getDynamicGlobalProperties().then((r) => ({
451
- total_vesting_fund_hive: r.total_vesting_fund_hive || r.total_vesting_fund_steem,
452
- total_vesting_shares: r.total_vesting_shares,
453
- hbd_print_rate: r.hbd_print_rate || r.sbd_print_rate,
454
- hbd_interest_rate: r.hbd_interest_rate,
455
- head_block_number: r.head_block_number,
456
- vesting_reward_percent: r.vesting_reward_percent,
457
- virtual_supply: r.virtual_supply
458
- }));
459
- const feedHistory = await CONFIG.hiveClient.database.call("get_feed_history");
460
- const chainProps = await CONFIG.hiveClient.database.call(
461
- "get_chain_properties"
462
- );
463
- const rewardFund = await CONFIG.hiveClient.database.call(
464
- "get_reward_fund",
465
- ["post"]
466
- );
467
- const hivePerMVests = parseAsset(globalDynamic.total_vesting_fund_hive).amount / parseAsset(globalDynamic.total_vesting_shares).amount * 1e6;
468
- const base = parseAsset(feedHistory.current_median_history.base).amount;
469
- const quote = parseAsset(feedHistory.current_median_history.quote).amount;
470
- const fundRecentClaims = parseFloat(rewardFund.recent_claims);
471
- const fundRewardBalance = parseAsset(rewardFund.reward_balance).amount;
472
- const hbdPrintRate = globalDynamic.hbd_print_rate;
473
- const hbdInterestRate = globalDynamic.hbd_interest_rate;
474
- const headBlock = globalDynamic.head_block_number;
475
- const totalVestingFund = parseAsset(
476
- globalDynamic.total_vesting_fund_hive
477
- ).amount;
478
- const totalVestingShares = parseAsset(
479
- globalDynamic.total_vesting_shares
480
- ).amount;
481
- const virtualSupply = parseAsset(globalDynamic.virtual_supply).amount;
482
- const vestingRewardPercent = globalDynamic.vesting_reward_percent;
483
- const accountCreationFee = chainProps.account_creation_fee;
450
+ const rawGlobalDynamic = await CONFIG.hiveClient.database.getDynamicGlobalProperties();
451
+ const rawFeedHistory = await CONFIG.hiveClient.database.call("get_feed_history");
452
+ const rawChainProps = await CONFIG.hiveClient.database.call("get_chain_properties");
453
+ const rawRewardFund = await CONFIG.hiveClient.database.call("get_reward_fund", ["post"]);
454
+ const totalVestingSharesAmount = parseAsset(rawGlobalDynamic.total_vesting_shares).amount;
455
+ const totalVestingFundAmount = parseAsset(rawGlobalDynamic.total_vesting_fund_hive).amount;
456
+ let hivePerMVests = 0;
457
+ if (Number.isFinite(totalVestingSharesAmount) && totalVestingSharesAmount !== 0 && Number.isFinite(totalVestingFundAmount)) {
458
+ hivePerMVests = totalVestingFundAmount / totalVestingSharesAmount * 1e6;
459
+ }
460
+ const base = parseAsset(rawFeedHistory.current_median_history.base).amount;
461
+ const quote = parseAsset(rawFeedHistory.current_median_history.quote).amount;
462
+ const fundRecentClaims = parseFloat(rawRewardFund.recent_claims);
463
+ const fundRewardBalance = parseAsset(rawRewardFund.reward_balance).amount;
464
+ const hbdPrintRate = rawGlobalDynamic.hbd_print_rate;
465
+ const hbdInterestRate = rawGlobalDynamic.hbd_interest_rate;
466
+ const headBlock = rawGlobalDynamic.head_block_number;
467
+ const totalVestingFund = totalVestingFundAmount;
468
+ const totalVestingShares = totalVestingSharesAmount;
469
+ const virtualSupply = parseAsset(rawGlobalDynamic.virtual_supply).amount;
470
+ const vestingRewardPercent = rawGlobalDynamic.vesting_reward_percent || 0;
471
+ const accountCreationFee = rawChainProps.account_creation_fee;
484
472
  return {
473
+ // Backward compatible transformed fields (camelCase, parsed)
485
474
  hivePerMVests,
486
475
  base,
487
476
  quote,
@@ -494,11 +483,27 @@ function getDynamicPropsQueryOptions() {
494
483
  totalVestingShares,
495
484
  virtualSupply,
496
485
  vestingRewardPercent,
497
- accountCreationFee
486
+ accountCreationFee,
487
+ // Raw blockchain data (snake_case, unparsed) for direct use
488
+ // Includes ALL fields from the blockchain responses
489
+ raw: {
490
+ globalDynamic: rawGlobalDynamic,
491
+ feedHistory: rawFeedHistory,
492
+ chainProps: rawChainProps,
493
+ rewardFund: rawRewardFund
494
+ }
498
495
  };
499
496
  }
500
497
  });
501
498
  }
499
+ function getRewardFundQueryOptions(fundName = "post") {
500
+ return reactQuery.queryOptions({
501
+ queryKey: ["core", "reward-fund", fundName],
502
+ queryFn: () => CONFIG.hiveClient.database.call("get_reward_fund", [
503
+ fundName
504
+ ])
505
+ });
506
+ }
502
507
  function getAccountFullQueryOptions(username) {
503
508
  return reactQuery.queryOptions({
504
509
  queryKey: ["get-account-full", username],
@@ -1034,6 +1039,46 @@ function getFavouritesInfiniteQueryOptions(activeUsername, code, limit = 10) {
1034
1039
  enabled: !!activeUsername && !!code
1035
1040
  });
1036
1041
  }
1042
+ function checkFavouriteQueryOptions(activeUsername, code, targetUsername) {
1043
+ return reactQuery.queryOptions({
1044
+ queryKey: ["accounts", "favourites", "check", activeUsername, targetUsername],
1045
+ enabled: !!activeUsername && !!code && !!targetUsername,
1046
+ queryFn: async () => {
1047
+ if (!activeUsername || !code) {
1048
+ throw new Error("[SDK][Accounts][Favourites] \u2013 missing auth");
1049
+ }
1050
+ if (!targetUsername) {
1051
+ throw new Error("[SDK][Accounts][Favourites] \u2013 no target username");
1052
+ }
1053
+ const fetchApi = getBoundFetch();
1054
+ const response = await fetchApi(
1055
+ CONFIG.privateApiHost + "/private-api/favorites-check",
1056
+ {
1057
+ method: "POST",
1058
+ headers: {
1059
+ "Content-Type": "application/json"
1060
+ },
1061
+ body: JSON.stringify({
1062
+ code,
1063
+ account: targetUsername
1064
+ })
1065
+ }
1066
+ );
1067
+ if (!response.ok) {
1068
+ throw new Error(
1069
+ `[SDK][Accounts][Favourites] \u2013 favorites-check failed with status ${response.status}: ${response.statusText}`
1070
+ );
1071
+ }
1072
+ const result = await response.json();
1073
+ if (typeof result !== "boolean") {
1074
+ throw new Error(
1075
+ `[SDK][Accounts][Favourites] \u2013 favorites-check returned invalid type: expected boolean, got ${typeof result}`
1076
+ );
1077
+ }
1078
+ return result;
1079
+ }
1080
+ });
1081
+ }
1037
1082
  function getAccountRecoveriesQueryOptions(username, code) {
1038
1083
  return reactQuery.queryOptions({
1039
1084
  enabled: !!username && !!code,
@@ -2378,8 +2423,8 @@ function toEntryArray(x) {
2378
2423
  return Array.isArray(x) ? x : [];
2379
2424
  }
2380
2425
  async function getVisibleFirstLevelThreadItems(container) {
2381
- const queryOptions89 = getDiscussionsQueryOptions(container, "created" /* created */, true);
2382
- const discussionItemsRaw = await CONFIG.queryClient.fetchQuery(queryOptions89);
2426
+ const queryOptions93 = getDiscussionsQueryOptions(container, "created" /* created */, true);
2427
+ const discussionItemsRaw = await CONFIG.queryClient.fetchQuery(queryOptions93);
2383
2428
  const discussionItems = toEntryArray(discussionItemsRaw);
2384
2429
  if (discussionItems.length <= 1) {
2385
2430
  return [];
@@ -5210,6 +5255,34 @@ function getTradeHistoryQueryOptions(limit = 1e3, startDate, endDate) {
5210
5255
  ])
5211
5256
  });
5212
5257
  }
5258
+ function getFeedHistoryQueryOptions() {
5259
+ return reactQuery.queryOptions({
5260
+ queryKey: ["market", "feed-history"],
5261
+ queryFn: async () => {
5262
+ try {
5263
+ const feedHistory = await CONFIG.hiveClient.database.call("get_feed_history");
5264
+ return feedHistory;
5265
+ } catch (error) {
5266
+ throw error;
5267
+ }
5268
+ }
5269
+ });
5270
+ }
5271
+ function getCurrentMedianHistoryPriceQueryOptions() {
5272
+ return reactQuery.queryOptions({
5273
+ queryKey: ["market", "current-median-history-price"],
5274
+ queryFn: async () => {
5275
+ try {
5276
+ const price = await CONFIG.hiveClient.database.call(
5277
+ "get_current_median_history_price"
5278
+ );
5279
+ return price;
5280
+ } catch (error) {
5281
+ throw error;
5282
+ }
5283
+ }
5284
+ });
5285
+ }
5213
5286
 
5214
5287
  // src/modules/market/requests.ts
5215
5288
  async function parseJsonResponse2(response) {
@@ -6001,6 +6074,7 @@ exports.addSchedule = addSchedule;
6001
6074
  exports.bridgeApiCall = bridgeApiCall;
6002
6075
  exports.broadcastJson = broadcastJson;
6003
6076
  exports.buildProfileMetadata = buildProfileMetadata;
6077
+ exports.checkFavouriteQueryOptions = checkFavouriteQueryOptions;
6004
6078
  exports.checkUsernameWalletsPendingQueryOptions = checkUsernameWalletsPendingQueryOptions;
6005
6079
  exports.decodeObj = decodeObj;
6006
6080
  exports.dedupeAndSortKeyAuths = dedupeAndSortKeyAuths;
@@ -6047,6 +6121,7 @@ exports.getConversionRequestsQueryOptions = getConversionRequestsQueryOptions;
6047
6121
  exports.getCurrencyRate = getCurrencyRate;
6048
6122
  exports.getCurrencyRates = getCurrencyRates;
6049
6123
  exports.getCurrencyTokenRate = getCurrencyTokenRate;
6124
+ exports.getCurrentMedianHistoryPriceQueryOptions = getCurrentMedianHistoryPriceQueryOptions;
6050
6125
  exports.getDeletedEntryQueryOptions = getDeletedEntryQueryOptions;
6051
6126
  exports.getDiscoverCurationQueryOptions = getDiscoverCurationQueryOptions;
6052
6127
  exports.getDiscoverLeaderboardQueryOptions = getDiscoverLeaderboardQueryOptions;
@@ -6059,6 +6134,7 @@ exports.getDynamicPropsQueryOptions = getDynamicPropsQueryOptions;
6059
6134
  exports.getEntryActiveVotesQueryOptions = getEntryActiveVotesQueryOptions;
6060
6135
  exports.getFavouritesInfiniteQueryOptions = getFavouritesInfiniteQueryOptions;
6061
6136
  exports.getFavouritesQueryOptions = getFavouritesQueryOptions;
6137
+ exports.getFeedHistoryQueryOptions = getFeedHistoryQueryOptions;
6062
6138
  exports.getFollowCountQueryOptions = getFollowCountQueryOptions;
6063
6139
  exports.getFollowersQueryOptions = getFollowersQueryOptions;
6064
6140
  exports.getFollowingQueryOptions = getFollowingQueryOptions;
@@ -6125,6 +6201,7 @@ exports.getReferralsInfiniteQueryOptions = getReferralsInfiniteQueryOptions;
6125
6201
  exports.getReferralsStatsQueryOptions = getReferralsStatsQueryOptions;
6126
6202
  exports.getRelationshipBetweenAccounts = getRelationshipBetweenAccounts;
6127
6203
  exports.getRelationshipBetweenAccountsQueryOptions = getRelationshipBetweenAccountsQueryOptions;
6204
+ exports.getRewardFundQueryOptions = getRewardFundQueryOptions;
6128
6205
  exports.getRewardedCommunitiesQueryOptions = getRewardedCommunitiesQueryOptions;
6129
6206
  exports.getSavingsWithdrawFromQueryOptions = getSavingsWithdrawFromQueryOptions;
6130
6207
  exports.getSchedulesInfiniteQueryOptions = getSchedulesInfiniteQueryOptions;