@ecency/wallets 1.4.0 → 1.4.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.
Files changed (162) hide show
  1. package/dist/index.cjs +3396 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +1627 -0
  4. package/dist/index.d.ts +1627 -2
  5. package/dist/index.mjs +3283 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +28 -15
  8. package/dist/ecency-sdk.es.js +0 -23215
  9. package/dist/internal/scrypt-guard.d.ts +0 -1
  10. package/dist/modules/assets/external/apt/get-apt-asset-balance-query-options.d.ts +0 -8
  11. package/dist/modules/assets/external/apt/get-apt-asset-general-info-query-options.d.ts +0 -28
  12. package/dist/modules/assets/external/apt/index.d.ts +0 -2
  13. package/dist/modules/assets/external/bnb/get-bnb-asset-balance-query-options.d.ts +0 -8
  14. package/dist/modules/assets/external/bnb/get-bnb-asset-general-info-query-options.d.ts +0 -28
  15. package/dist/modules/assets/external/bnb/index.d.ts +0 -2
  16. package/dist/modules/assets/external/btc/get-btc-asset-balance-query-options.d.ts +0 -8
  17. package/dist/modules/assets/external/btc/get-btc-asset-general-info-query-options.d.ts +0 -28
  18. package/dist/modules/assets/external/btc/index.d.ts +0 -2
  19. package/dist/modules/assets/external/common/index.d.ts +0 -1
  20. package/dist/modules/assets/external/common/parse-private-api-balance.d.ts +0 -23
  21. package/dist/modules/assets/external/eth/get-eth-asset-balance-query-options.d.ts +0 -8
  22. package/dist/modules/assets/external/eth/get-eth-asset-general-info-query-options.d.ts +0 -28
  23. package/dist/modules/assets/external/eth/index.d.ts +0 -2
  24. package/dist/modules/assets/external/index.d.ts +0 -7
  25. package/dist/modules/assets/external/sol/get-sol-asset-balance-query-options.d.ts +0 -8
  26. package/dist/modules/assets/external/sol/get-sol-asset-general-info-query-options.d.ts +0 -28
  27. package/dist/modules/assets/external/sol/index.d.ts +0 -2
  28. package/dist/modules/assets/external/ton/get-ton-asset-balance-query-options.d.ts +0 -8
  29. package/dist/modules/assets/external/ton/get-ton-asset-general-info-query-options.d.ts +0 -28
  30. package/dist/modules/assets/external/ton/index.d.ts +0 -2
  31. package/dist/modules/assets/external/tron/get-tron-asset-balance-query-options.d.ts +0 -8
  32. package/dist/modules/assets/external/tron/get-tron-asset-general-info-query-options.d.ts +0 -28
  33. package/dist/modules/assets/external/tron/index.d.ts +0 -2
  34. package/dist/modules/assets/hive/consts/hive-account-operation-groups.d.ts +0 -2
  35. package/dist/modules/assets/hive/consts/index.d.ts +0 -1
  36. package/dist/modules/assets/hive/index.d.ts +0 -2
  37. package/dist/modules/assets/hive/mutations/claim-rewards.d.ts +0 -1
  38. package/dist/modules/assets/hive/mutations/delegate.d.ts +0 -13
  39. package/dist/modules/assets/hive/mutations/index.d.ts +0 -7
  40. package/dist/modules/assets/hive/mutations/power-down.d.ts +0 -11
  41. package/dist/modules/assets/hive/mutations/power-up.d.ts +0 -13
  42. package/dist/modules/assets/hive/mutations/transfer-to-savings.d.ts +0 -13
  43. package/dist/modules/assets/hive/mutations/transfer.d.ts +0 -12
  44. package/dist/modules/assets/hive/mutations/withdraw-route.d.ts +0 -13
  45. package/dist/modules/assets/hive/queries/get-hbd-asset-general-info-query-options.d.ts +0 -76
  46. package/dist/modules/assets/hive/queries/get-hbd-asset-transactions-query-options.d.ts +0 -9
  47. package/dist/modules/assets/hive/queries/get-hive-asset-general-info-query-options.d.ts +0 -28
  48. package/dist/modules/assets/hive/queries/get-hive-asset-metric-query-options.d.ts +0 -43
  49. package/dist/modules/assets/hive/queries/get-hive-asset-transactions-query-options.d.ts +0 -9
  50. package/dist/modules/assets/hive/queries/get-hive-asset-withdrawal-routes-query-options.d.ts +0 -9
  51. package/dist/modules/assets/hive/queries/get-hive-power-asset-general-info-query-options.d.ts +0 -76
  52. package/dist/modules/assets/hive/queries/get-hive-power-asset-transactions-query-options.d.ts +0 -9
  53. package/dist/modules/assets/hive/queries/get-hive-power-delegates-query-options.d.ts +0 -9
  54. package/dist/modules/assets/hive/queries/get-hive-power-delegatings-query-options.d.ts +0 -9
  55. package/dist/modules/assets/hive/queries/index.d.ts +0 -10
  56. package/dist/modules/assets/hive/types/delegated-vesting-share.d.ts +0 -7
  57. package/dist/modules/assets/hive/types/hive-market-metric.d.ts +0 -19
  58. package/dist/modules/assets/hive/types/hive-operation-group.d.ts +0 -1
  59. package/dist/modules/assets/hive/types/hive-transaction.d.ts +0 -198
  60. package/dist/modules/assets/hive/types/hive-withdraw-route.d.ts +0 -7
  61. package/dist/modules/assets/hive/types/index.d.ts +0 -6
  62. package/dist/modules/assets/hive/types/received-vesting-share.d.ts +0 -6
  63. package/dist/modules/assets/hive-engine/index.d.ts +0 -3
  64. package/dist/modules/assets/hive-engine/mutations/delegate.d.ts +0 -12
  65. package/dist/modules/assets/hive-engine/mutations/index.d.ts +0 -5
  66. package/dist/modules/assets/hive-engine/mutations/stake.d.ts +0 -12
  67. package/dist/modules/assets/hive-engine/mutations/transfer.d.ts +0 -13
  68. package/dist/modules/assets/hive-engine/mutations/undelegate.d.ts +0 -12
  69. package/dist/modules/assets/hive-engine/mutations/unstake.d.ts +0 -12
  70. package/dist/modules/assets/hive-engine/queries/get-hive-engine-token-general-info-query-options.d.ts +0 -32
  71. package/dist/modules/assets/hive-engine/queries/get-hive-engine-token-metrics-query-options.d.ts +0 -9
  72. package/dist/modules/assets/hive-engine/queries/get-hive-engine-token-transactions-query-options.d.ts +0 -9
  73. package/dist/modules/assets/hive-engine/queries/get-hive-engine-tokens-balances-query-options.d.ts +0 -9
  74. package/dist/modules/assets/hive-engine/queries/get-hive-engine-tokens-market-query-options.d.ts +0 -9
  75. package/dist/modules/assets/hive-engine/queries/get-hive-engine-tokens-metadata-query-options.d.ts +0 -9
  76. package/dist/modules/assets/hive-engine/queries/index.d.ts +0 -6
  77. package/dist/modules/assets/hive-engine/types/hive-engine-list-response.d.ts +0 -13
  78. package/dist/modules/assets/hive-engine/types/hive-engine-metric.d.ts +0 -9
  79. package/dist/modules/assets/hive-engine/types/hive-engine-token-balance.d.ts +0 -10
  80. package/dist/modules/assets/hive-engine/types/hive-engine-token-metadata-response.d.ts +0 -16
  81. package/dist/modules/assets/hive-engine/types/hive-engine-transaction.d.ts +0 -14
  82. package/dist/modules/assets/hive-engine/types/index.d.ts +0 -6
  83. package/dist/modules/assets/index.d.ts +0 -6
  84. package/dist/modules/assets/points/index.d.ts +0 -3
  85. package/dist/modules/assets/points/mutations/claim-points.d.ts +0 -2
  86. package/dist/modules/assets/points/mutations/gift.d.ts +0 -14
  87. package/dist/modules/assets/points/mutations/index.d.ts +0 -2
  88. package/dist/modules/assets/points/queries/get-points-asset-general-info-query-options.d.ts +0 -28
  89. package/dist/modules/assets/points/queries/get-points-asset-transactions-query-options.d.ts +0 -41
  90. package/dist/modules/assets/points/queries/get-points-query-options.d.ts +0 -20
  91. package/dist/modules/assets/points/queries/index.d.ts +0 -3
  92. package/dist/modules/assets/points/types/index.d.ts +0 -4
  93. package/dist/modules/assets/points/types/point-transaction-type.d.ts +0 -15
  94. package/dist/modules/assets/points/types/point-transaction.d.ts +0 -10
  95. package/dist/modules/assets/points/types/points-response.d.ts +0 -4
  96. package/dist/modules/assets/points/types/points.d.ts +0 -4
  97. package/dist/modules/assets/spk/index.d.ts +0 -2
  98. package/dist/modules/assets/spk/mutations/index.d.ts +0 -4
  99. package/dist/modules/assets/spk/mutations/lock.d.ts +0 -12
  100. package/dist/modules/assets/spk/mutations/power-up.d.ts +0 -12
  101. package/dist/modules/assets/spk/mutations/transfer.d.ts +0 -14
  102. package/dist/modules/assets/spk/queries/get-larynx-asset-general-info-query-options.d.ts +0 -56
  103. package/dist/modules/assets/spk/queries/get-larynx-power-asset-general-info-query-options.d.ts +0 -76
  104. package/dist/modules/assets/spk/queries/get-spk-asset-general-info-query-options.d.ts +0 -28
  105. package/dist/modules/assets/spk/queries/get-spk-markets-query-options.d.ts +0 -33
  106. package/dist/modules/assets/spk/queries/get-spk-wallet-query-options.d.ts +0 -9
  107. package/dist/modules/assets/spk/queries/index.d.ts +0 -4
  108. package/dist/modules/assets/types/asset-operation.d.ts +0 -17
  109. package/dist/modules/assets/types/general-asset-info.d.ts +0 -12
  110. package/dist/modules/assets/types/general-asset-transaction.d.ts +0 -13
  111. package/dist/modules/assets/types/hive-based-asset-sign-type.d.ts +0 -1
  112. package/dist/modules/assets/types/index.d.ts +0 -5
  113. package/dist/modules/assets/types/spk-wallet.d.ts +0 -60
  114. package/dist/modules/assets/utils/index.d.ts +0 -4
  115. package/dist/modules/assets/utils/is-empty-date.d.ts +0 -1
  116. package/dist/modules/assets/utils/parse-asset.d.ts +0 -17
  117. package/dist/modules/assets/utils/reward-spk.d.ts +0 -2
  118. package/dist/modules/assets/utils/vests-to-hp.d.ts +0 -1
  119. package/dist/modules/wallets/consts/hive-engine-tokens.d.ts +0 -1
  120. package/dist/modules/wallets/consts/index.d.ts +0 -1
  121. package/dist/modules/wallets/enums/ecency-wallet-basic-tokens.d.ts +0 -7
  122. package/dist/modules/wallets/enums/ecency-wallet-currency.d.ts +0 -9
  123. package/dist/modules/wallets/enums/index.d.ts +0 -2
  124. package/dist/modules/wallets/functions/get-keys-from-seed.d.ts +0 -3
  125. package/dist/modules/wallets/functions/index.d.ts +0 -1
  126. package/dist/modules/wallets/index.d.ts +0 -5
  127. package/dist/modules/wallets/mutations/index.d.ts +0 -5
  128. package/dist/modules/wallets/mutations/private-api/check-wallet-existence.d.ts +0 -7
  129. package/dist/modules/wallets/mutations/private-api/create-account-with-wallets.d.ts +0 -6
  130. package/dist/modules/wallets/mutations/private-api/index.d.ts +0 -2
  131. package/dist/modules/wallets/mutations/private-api-namespace.d.ts +0 -2
  132. package/dist/modules/wallets/mutations/save-wallet-information-to-metadata.d.ts +0 -9
  133. package/dist/modules/wallets/mutations/use-import-wallet.d.ts +0 -15
  134. package/dist/modules/wallets/mutations/use-wallet-create.d.ts +0 -11
  135. package/dist/modules/wallets/mutations/wallet-operation.d.ts +0 -2
  136. package/dist/modules/wallets/queries/get-account-wallet-asset-info-query-options.d.ts +0 -13
  137. package/dist/modules/wallets/queries/get-all-tokens-list-query-options.d.ts +0 -30
  138. package/dist/modules/wallets/queries/get-coingecko-price-query-options.d.ts +0 -8
  139. package/dist/modules/wallets/queries/get-tokens-operations-query-options.d.ts +0 -9
  140. package/dist/modules/wallets/queries/index.d.ts +0 -8
  141. package/dist/modules/wallets/queries/use-get-account-wallet-list-query.d.ts +0 -8
  142. package/dist/modules/wallets/queries/use-get-external-wallet-query.d.ts +0 -17
  143. package/dist/modules/wallets/queries/use-hive-keys-query.d.ts +0 -2
  144. package/dist/modules/wallets/queries/use-seed-phrase.d.ts +0 -1
  145. package/dist/modules/wallets/types/account-points-response.d.ts +0 -4
  146. package/dist/modules/wallets/types/ecency-create-wallet-information.d.ts +0 -13
  147. package/dist/modules/wallets/types/ecency-hive-keys.d.ts +0 -12
  148. package/dist/modules/wallets/types/index.d.ts +0 -3
  149. package/dist/modules/wallets/utils/build-external-transaction.d.ts +0 -48
  150. package/dist/modules/wallets/utils/decrypt-memo.d.ts +0 -12
  151. package/dist/modules/wallets/utils/delay.d.ts +0 -1
  152. package/dist/modules/wallets/utils/derive-hive-bip44-keys.d.ts +0 -15
  153. package/dist/modules/wallets/utils/derive-hive-master-password-keys.d.ts +0 -15
  154. package/dist/modules/wallets/utils/detect-hive-key-derivation.d.ts +0 -2
  155. package/dist/modules/wallets/utils/encrypt-memo.d.ts +0 -16
  156. package/dist/modules/wallets/utils/get-wallet.d.ts +0 -3
  157. package/dist/modules/wallets/utils/index.d.ts +0 -12
  158. package/dist/modules/wallets/utils/mnemonic-to-seed-bip-39.d.ts +0 -1
  159. package/dist/modules/wallets/utils/sign-digest.d.ts +0 -7
  160. package/dist/modules/wallets/utils/sign-external-transaction.d.ts +0 -18
  161. package/dist/modules/wallets/utils/sign-transaction.d.ts +0 -23
  162. package/dist/vite.config.d.ts +0 -2
package/dist/index.mjs ADDED
@@ -0,0 +1,3283 @@
1
+ import { CONFIG, getAccountFullQueryOptions, getQueryClient, getDynamicPropsQueryOptions, Keychain, useBroadcastMutation, EcencyAnalytics, getAccessToken, useAccountUpdate } from '@ecency/sdk';
2
+ import { useQuery, queryOptions, infiniteQueryOptions, useQueryClient, useMutation } from '@tanstack/react-query';
3
+ import bip39, { mnemonicToSeedSync } from 'bip39';
4
+ import { LRUCache } from 'lru-cache';
5
+ import { BtcWallet, buildPsbt as buildPsbt$1 } from '@okxweb3/coin-bitcoin';
6
+ import { EthWallet } from '@okxweb3/coin-ethereum';
7
+ import { TrxWallet } from '@okxweb3/coin-tron';
8
+ import { TonWallet } from '@okxweb3/coin-ton';
9
+ import { SolWallet } from '@okxweb3/coin-solana';
10
+ import { AptosWallet } from '@okxweb3/coin-aptos';
11
+ import { bip32 } from '@okxweb3/crypto-lib';
12
+ import { utils, PrivateKey } from '@hiveio/dhive';
13
+ import { cryptoUtils } from '@hiveio/dhive/lib/crypto';
14
+ import { Memo } from '@hiveio/dhive/lib/memo';
15
+ import dayjs from 'dayjs';
16
+ import hs from 'hivesigner';
17
+ import { useCallback } from 'react';
18
+ import * as R from 'remeda';
19
+
20
+ var __defProp = Object.defineProperty;
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+
26
+ // src/internal/scrypt-guard.ts
27
+ var globalLike = globalThis;
28
+ if (typeof globalLike._scrypt_bsv !== "undefined") {
29
+ if (typeof globalLike._scrypt_bsv === "string") {
30
+ globalLike.__scryptBsvPreviousVersion = globalLike._scrypt_bsv;
31
+ }
32
+ try {
33
+ delete globalLike._scrypt_bsv;
34
+ } catch {
35
+ globalLike._scrypt_bsv = void 0;
36
+ }
37
+ }
38
+ function rememberScryptBsvVersion() {
39
+ if (typeof globalLike._scrypt_bsv === "string") {
40
+ globalLike.__scryptBsvPreviousVersion = globalLike._scrypt_bsv;
41
+ }
42
+ }
43
+
44
+ // src/modules/wallets/enums/ecency-wallet-currency.ts
45
+ var EcencyWalletCurrency = /* @__PURE__ */ ((EcencyWalletCurrency2) => {
46
+ EcencyWalletCurrency2["BTC"] = "BTC";
47
+ EcencyWalletCurrency2["ETH"] = "ETH";
48
+ EcencyWalletCurrency2["BNB"] = "BNB";
49
+ EcencyWalletCurrency2["APT"] = "APT";
50
+ EcencyWalletCurrency2["TON"] = "TON";
51
+ EcencyWalletCurrency2["TRON"] = "TRX";
52
+ EcencyWalletCurrency2["SOL"] = "SOL";
53
+ return EcencyWalletCurrency2;
54
+ })(EcencyWalletCurrency || {});
55
+
56
+ // src/modules/wallets/enums/ecency-wallet-basic-tokens.ts
57
+ var EcencyWalletBasicTokens = /* @__PURE__ */ ((EcencyWalletBasicTokens2) => {
58
+ EcencyWalletBasicTokens2["Points"] = "POINTS";
59
+ EcencyWalletBasicTokens2["HivePower"] = "HP";
60
+ EcencyWalletBasicTokens2["Hive"] = "HIVE";
61
+ EcencyWalletBasicTokens2["HiveDollar"] = "HBD";
62
+ EcencyWalletBasicTokens2["Spk"] = "SPK";
63
+ return EcencyWalletBasicTokens2;
64
+ })(EcencyWalletBasicTokens || {});
65
+ var currencyChainMap = {
66
+ ["BTC" /* BTC */]: "btc",
67
+ ["ETH" /* ETH */]: "eth",
68
+ ["BNB" /* BNB */]: "bnb",
69
+ ["SOL" /* SOL */]: "sol",
70
+ ["TRX" /* TRON */]: "tron",
71
+ ["TON" /* TON */]: "ton",
72
+ ["APT" /* APT */]: "apt"
73
+ };
74
+ function normalizeBalance(balance) {
75
+ if (typeof balance === "number") {
76
+ if (!Number.isFinite(balance)) {
77
+ throw new Error("Private API returned a non-finite numeric balance");
78
+ }
79
+ return Math.trunc(balance).toString();
80
+ }
81
+ if (typeof balance === "string") {
82
+ const trimmed = balance.trim();
83
+ if (trimmed === "") {
84
+ throw new Error("Private API returned an empty balance string");
85
+ }
86
+ return trimmed;
87
+ }
88
+ throw new Error("Private API returned balance in an unexpected format");
89
+ }
90
+ function parsePrivateApiBalance(result, expectedChain) {
91
+ if (!result || typeof result !== "object") {
92
+ throw new Error("Private API returned an unexpected response");
93
+ }
94
+ const { chain, balance, unit, raw, nodeId } = result;
95
+ if (typeof chain !== "string" || chain !== expectedChain) {
96
+ throw new Error("Private API response chain did not match request");
97
+ }
98
+ if (typeof unit !== "string" || unit.length === 0) {
99
+ throw new Error("Private API response is missing unit information");
100
+ }
101
+ if (balance === void 0 || balance === null) {
102
+ throw new Error("Private API response is missing balance information");
103
+ }
104
+ const balanceString = normalizeBalance(balance);
105
+ let balanceBigInt;
106
+ try {
107
+ balanceBigInt = BigInt(balanceString);
108
+ } catch (error) {
109
+ throw new Error("Private API returned a balance that is not an integer");
110
+ }
111
+ return {
112
+ chain,
113
+ unit,
114
+ raw,
115
+ nodeId: typeof nodeId === "string" && nodeId.length > 0 ? nodeId : void 0,
116
+ balanceBigInt,
117
+ balanceString
118
+ };
119
+ }
120
+ function useGetExternalWalletBalanceQuery(currency, address) {
121
+ return useQuery({
122
+ queryKey: ["ecency-wallets", "external-wallet-balance", currency, address],
123
+ queryFn: async () => {
124
+ const chain = currencyChainMap[currency];
125
+ if (!chain) {
126
+ throw new Error(`Unsupported currency ${currency}`);
127
+ }
128
+ if (!CONFIG.privateApiHost) {
129
+ throw new Error("Private API host is not configured");
130
+ }
131
+ const baseUrl = `${CONFIG.privateApiHost}/private-api/balance/${chain}/${encodeURIComponent(
132
+ address
133
+ )}`;
134
+ let primaryResponse;
135
+ let primaryError;
136
+ try {
137
+ primaryResponse = await fetch(baseUrl);
138
+ } catch (error) {
139
+ primaryError = error;
140
+ }
141
+ let response = primaryResponse;
142
+ if (!response || !response.ok) {
143
+ const fallbackUrl = `${baseUrl}?provider=chainz`;
144
+ let fallbackError;
145
+ try {
146
+ const fallbackResponse = await fetch(fallbackUrl);
147
+ if (fallbackResponse.ok) {
148
+ response = fallbackResponse;
149
+ } else {
150
+ fallbackError = new Error(
151
+ `Fallback provider responded with status ${fallbackResponse.status}`
152
+ );
153
+ }
154
+ } catch (error) {
155
+ fallbackError = error;
156
+ }
157
+ if (!response || !response.ok) {
158
+ const failureReasons = [];
159
+ if (primaryError) {
160
+ const message = primaryError instanceof Error ? primaryError.message : String(primaryError);
161
+ failureReasons.push(`primary provider failed: ${message}`);
162
+ } else if (primaryResponse && !primaryResponse.ok) {
163
+ failureReasons.push(
164
+ `primary provider status ${primaryResponse.status}`
165
+ );
166
+ }
167
+ if (fallbackError) {
168
+ const message = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
169
+ failureReasons.push(`fallback provider failed: ${message}`);
170
+ }
171
+ if (failureReasons.length === 0) {
172
+ failureReasons.push("unknown error");
173
+ }
174
+ throw new Error(
175
+ `Private API request failed (${failureReasons.join(", ")})`
176
+ );
177
+ }
178
+ }
179
+ const result = await response.json();
180
+ return parsePrivateApiBalance(result, chain);
181
+ }
182
+ });
183
+ }
184
+ function useSeedPhrase(username) {
185
+ return useQuery({
186
+ queryKey: ["ecency-wallets", "seed", username],
187
+ queryFn: async () => bip39.generateMnemonic(128)
188
+ });
189
+ }
190
+ var options = {
191
+ max: 500,
192
+ // how long to live in ms
193
+ ttl: 1e3 * 60 * 5,
194
+ // return stale items before removing from cache?
195
+ allowStale: false,
196
+ updateAgeOnGet: false,
197
+ updateAgeOnHas: false
198
+ };
199
+ var cache = new LRUCache(options);
200
+ var undefinedValue = Symbol("undefined");
201
+ var cacheSet = (key, value) => cache.set(key, value === void 0 ? undefinedValue : value);
202
+ var cacheGet = (key) => {
203
+ const v = cache.get(key);
204
+ return v === undefinedValue ? void 0 : v;
205
+ };
206
+ function getCoinGeckoPriceQueryOptions(currency) {
207
+ return queryOptions({
208
+ queryKey: ["ecency-wallets", "coingecko-price", currency],
209
+ queryFn: async () => {
210
+ let curr = currency;
211
+ switch (currency) {
212
+ case "BTC" /* BTC */:
213
+ curr = "binance-wrapped-btc";
214
+ break;
215
+ case "ETH" /* ETH */:
216
+ curr = "ethereum";
217
+ break;
218
+ case "SOL" /* SOL */:
219
+ curr = "solana";
220
+ break;
221
+ case "TON" /* TON */:
222
+ curr = "ton";
223
+ break;
224
+ case "TRX" /* TRON */:
225
+ curr = "tron";
226
+ break;
227
+ case "APT" /* APT */:
228
+ curr = "aptos";
229
+ break;
230
+ case "BNB" /* BNB */:
231
+ curr = "binancecoin";
232
+ break;
233
+ case "TON" /* TON */:
234
+ curr = "the-open-network";
235
+ break;
236
+ default:
237
+ curr = currency;
238
+ }
239
+ let rate = cacheGet("gecko");
240
+ let response;
241
+ if (rate) {
242
+ response = rate;
243
+ } else {
244
+ const httpResponse = await fetch(
245
+ `https://api.coingecko.com/api/v3/simple/price?ids=${curr}&vs_currencies=usd`,
246
+ {
247
+ method: "GET"
248
+ }
249
+ );
250
+ const data = await httpResponse.json();
251
+ cacheSet("gecko", data === void 0 ? undefinedValue : data);
252
+ response = data;
253
+ }
254
+ return +response[curr].usd;
255
+ },
256
+ enabled: !!currency
257
+ });
258
+ }
259
+
260
+ // src/modules/wallets/utils/delay.ts
261
+ function delay(ms) {
262
+ return new Promise((resolve) => setTimeout(resolve, ms));
263
+ }
264
+ function getWallet(currency) {
265
+ switch (currency) {
266
+ case "BTC" /* BTC */:
267
+ return new BtcWallet();
268
+ case "ETH" /* ETH */:
269
+ case "BNB" /* BNB */:
270
+ return new EthWallet();
271
+ case "TRX" /* TRON */:
272
+ return new TrxWallet();
273
+ case "TON" /* TON */:
274
+ return new TonWallet();
275
+ case "SOL" /* SOL */:
276
+ return new SolWallet();
277
+ case "APT" /* APT */:
278
+ return new AptosWallet();
279
+ default:
280
+ return void 0;
281
+ }
282
+ }
283
+ function mnemonicToSeedBip39(value) {
284
+ return mnemonicToSeedSync(value).toString("hex");
285
+ }
286
+ var ROLE_INDEX = {
287
+ owner: 0,
288
+ active: 1,
289
+ posting: 2,
290
+ memo: 3
291
+ };
292
+ function deriveHiveKey(mnemonic, role, accountIndex = 0) {
293
+ const seed = mnemonicToSeedSync(mnemonic);
294
+ const master = bip32.fromSeed(seed);
295
+ const path = `m/44'/3054'/${accountIndex}'/0'/${ROLE_INDEX[role]}'`;
296
+ const child = master.derivePath(path);
297
+ if (!child.privateKey) {
298
+ throw new Error("[Ecency][Wallets] - hive key derivation failed");
299
+ }
300
+ const pk = PrivateKey.from(child.privateKey);
301
+ return {
302
+ privateKey: pk.toString(),
303
+ publicKey: pk.createPublic().toString()
304
+ };
305
+ }
306
+ function deriveHiveKeys(mnemonic, accountIndex = 0) {
307
+ const owner = deriveHiveKey(mnemonic, "owner", accountIndex);
308
+ const active = deriveHiveKey(mnemonic, "active", accountIndex);
309
+ const posting = deriveHiveKey(mnemonic, "posting", accountIndex);
310
+ const memo = deriveHiveKey(mnemonic, "memo", accountIndex);
311
+ return {
312
+ owner: owner.privateKey,
313
+ active: active.privateKey,
314
+ posting: posting.privateKey,
315
+ memo: memo.privateKey,
316
+ ownerPubkey: owner.publicKey,
317
+ activePubkey: active.publicKey,
318
+ postingPubkey: posting.publicKey,
319
+ memoPubkey: memo.publicKey
320
+ };
321
+ }
322
+ function deriveHiveMasterPasswordKey(username, masterPassword, role) {
323
+ const pk = PrivateKey.fromLogin(username, masterPassword, role);
324
+ return {
325
+ privateKey: pk.toString(),
326
+ publicKey: pk.createPublic().toString()
327
+ };
328
+ }
329
+ function deriveHiveMasterPasswordKeys(username, masterPassword) {
330
+ const owner = deriveHiveMasterPasswordKey(username, masterPassword, "owner");
331
+ const active = deriveHiveMasterPasswordKey(username, masterPassword, "active");
332
+ const posting = deriveHiveMasterPasswordKey(
333
+ username,
334
+ masterPassword,
335
+ "posting"
336
+ );
337
+ const memo = deriveHiveMasterPasswordKey(username, masterPassword, "memo");
338
+ return {
339
+ owner: owner.privateKey,
340
+ active: active.privateKey,
341
+ posting: posting.privateKey,
342
+ memo: memo.privateKey,
343
+ ownerPubkey: owner.publicKey,
344
+ activePubkey: active.publicKey,
345
+ postingPubkey: posting.publicKey,
346
+ memoPubkey: memo.publicKey
347
+ };
348
+ }
349
+ async function detectHiveKeyDerivation(username, seed, type = "active") {
350
+ await CONFIG.queryClient.prefetchQuery(getAccountFullQueryOptions(username));
351
+ const account = CONFIG.queryClient.getQueryData(
352
+ getAccountFullQueryOptions(username).queryKey
353
+ );
354
+ if (!account) {
355
+ throw new Error(`[Ecency][Wallets] - account ${username} not found`);
356
+ }
357
+ const bip44 = deriveHiveKeys(seed);
358
+ const bip44Active = bip44.activePubkey;
359
+ const matchBip44 = account.active.key_auths.some(
360
+ ([pub]) => pub.toString() === bip44Active
361
+ );
362
+ if (matchBip44) {
363
+ return "bip44";
364
+ }
365
+ const legacyActive = PrivateKey.fromLogin(username, seed, type).createPublic().toString();
366
+ const matchLegacy = account[type].key_auths.some(
367
+ ([pub]) => pub.toString() === legacyActive
368
+ );
369
+ if (matchLegacy) {
370
+ return "master-password";
371
+ }
372
+ return "unknown";
373
+ }
374
+ function signDigest(digest, privateKey) {
375
+ const key = PrivateKey.fromString(privateKey);
376
+ const buf = typeof digest === "string" ? Buffer.from(digest, "hex") : digest;
377
+ return key.sign(buf).toString();
378
+ }
379
+ function signTx(tx, privateKey, chainId) {
380
+ const key = PrivateKey.fromString(privateKey);
381
+ const chain = chainId ? Buffer.from(chainId, "hex") : void 0;
382
+ return cryptoUtils.signTransaction(tx, key, chain);
383
+ }
384
+ async function signTxAndBroadcast(client, tx, privateKey, chainId) {
385
+ const signed = signTx(tx, privateKey, chainId);
386
+ return client.broadcast.send(signed);
387
+ }
388
+ function encryptMemoWithKeys(privateKey, publicKey, memo) {
389
+ return Memo.encode(PrivateKey.fromString(privateKey), publicKey, memo);
390
+ }
391
+ async function encryptMemoWithAccounts(client, fromPrivateKey, toAccount, memo) {
392
+ const [account] = await client.database.getAccounts([toAccount]);
393
+ if (!account) {
394
+ throw new Error("Account not found");
395
+ }
396
+ return Memo.encode(PrivateKey.fromString(fromPrivateKey), account.memo_key, memo);
397
+ }
398
+ function decryptMemoWithKeys(privateKey, memo) {
399
+ return Memo.decode(PrivateKey.fromString(privateKey), memo);
400
+ }
401
+ var decryptMemoWithAccounts = decryptMemoWithKeys;
402
+ async function signExternalTx(currency, params) {
403
+ const wallet = getWallet(currency);
404
+ if (!wallet) throw new Error("Unsupported currency");
405
+ return wallet.signTransaction(params);
406
+ }
407
+ async function signExternalTxAndBroadcast(currency, params) {
408
+ const signed = await signExternalTx(currency, params);
409
+ switch (currency) {
410
+ case "BTC" /* BTC */: {
411
+ const res = await fetch("https://mempool.space/api/tx", {
412
+ method: "POST",
413
+ body: signed
414
+ });
415
+ if (!res.ok) throw new Error("Broadcast failed");
416
+ return res.text();
417
+ }
418
+ case "ETH" /* ETH */:
419
+ case "BNB" /* BNB */: {
420
+ const rpcUrl = currency === "ETH" /* ETH */ ? "https://rpc.ankr.com/eth" : "https://bsc-dataseed.binance.org";
421
+ const res = await fetch(rpcUrl, {
422
+ method: "POST",
423
+ headers: { "Content-Type": "application/json" },
424
+ body: JSON.stringify({
425
+ jsonrpc: "2.0",
426
+ id: 1,
427
+ method: "eth_sendRawTransaction",
428
+ params: [signed]
429
+ })
430
+ });
431
+ const json = await res.json();
432
+ if (json.error) throw new Error(json.error.message);
433
+ return json.result;
434
+ }
435
+ case "SOL" /* SOL */: {
436
+ const res = await fetch(
437
+ `https://rpc.helius.xyz/?api-key=${CONFIG.heliusApiKey}`,
438
+ {
439
+ method: "POST",
440
+ headers: { "Content-Type": "application/json" },
441
+ body: JSON.stringify({
442
+ jsonrpc: "2.0",
443
+ id: 1,
444
+ method: "sendTransaction",
445
+ params: [signed]
446
+ })
447
+ }
448
+ );
449
+ const json = await res.json();
450
+ if (json.error) throw new Error(json.error.message);
451
+ return json.result;
452
+ }
453
+ case "TRX" /* TRON */: {
454
+ const res = await fetch(
455
+ "https://api.trongrid.io/wallet/broadcasttransaction",
456
+ {
457
+ method: "POST",
458
+ headers: { "Content-Type": "application/json" },
459
+ body: typeof signed === "string" ? signed : JSON.stringify(signed)
460
+ }
461
+ );
462
+ const json = await res.json();
463
+ if (json.result === false) throw new Error(json.message);
464
+ return json.txid || json.result;
465
+ }
466
+ case "TON" /* TON */: {
467
+ const res = await fetch("https://toncenter.com/api/v2/sendTransaction", {
468
+ method: "POST",
469
+ headers: { "Content-Type": "application/json" },
470
+ body: JSON.stringify({ boc: signed })
471
+ });
472
+ const json = await res.json();
473
+ if (json.error) throw new Error(json.error.message || json.result);
474
+ return json.result;
475
+ }
476
+ case "APT" /* APT */: {
477
+ const res = await fetch(
478
+ "https://fullnode.mainnet.aptoslabs.com/v1/transactions",
479
+ {
480
+ method: "POST",
481
+ headers: { "Content-Type": "application/json" },
482
+ body: typeof signed === "string" ? signed : JSON.stringify(signed)
483
+ }
484
+ );
485
+ if (!res.ok) throw new Error("Broadcast failed");
486
+ return res.json();
487
+ }
488
+ default:
489
+ throw new Error("Unsupported currency");
490
+ }
491
+ }
492
+ function buildPsbt(tx, network, maximumFeeRate) {
493
+ return buildPsbt$1(tx, network, maximumFeeRate);
494
+ }
495
+ function buildEthTx(data) {
496
+ return data;
497
+ }
498
+ function buildSolTx(data) {
499
+ return data;
500
+ }
501
+ function buildTronTx(data) {
502
+ return data;
503
+ }
504
+ function buildTonTx(data) {
505
+ return data;
506
+ }
507
+ function buildAptTx(data) {
508
+ return data;
509
+ }
510
+ function buildExternalTx(currency, tx) {
511
+ switch (currency) {
512
+ case "BTC" /* BTC */:
513
+ return buildPsbt(tx);
514
+ case "ETH" /* ETH */:
515
+ case "BNB" /* BNB */:
516
+ return buildEthTx(tx);
517
+ case "SOL" /* SOL */:
518
+ return buildSolTx(tx);
519
+ case "TRX" /* TRON */:
520
+ return buildTronTx(tx);
521
+ case "TON" /* TON */:
522
+ return buildTonTx(tx);
523
+ case "APT" /* APT */:
524
+ return buildAptTx(tx);
525
+ default:
526
+ throw new Error("Unsupported currency");
527
+ }
528
+ }
529
+
530
+ // src/modules/wallets/queries/use-hive-keys-query.ts
531
+ function useHiveKeysQuery(username) {
532
+ const { data: seed } = useSeedPhrase(username);
533
+ return useQuery({
534
+ queryKey: ["ecenc\u0443-wallets", "hive-keys", username, seed],
535
+ staleTime: Infinity,
536
+ queryFn: async () => {
537
+ if (!seed) {
538
+ throw new Error("[Ecency][Wallets] - no seed to create Hive account");
539
+ }
540
+ const method = await detectHiveKeyDerivation(username, seed).catch(
541
+ () => "bip44"
542
+ );
543
+ const keys = method === "master-password" ? deriveHiveMasterPasswordKeys(username, seed) : deriveHiveKeys(seed);
544
+ return {
545
+ username,
546
+ ...keys
547
+ };
548
+ }
549
+ });
550
+ }
551
+
552
+ // src/modules/assets/utils/parse-asset.ts
553
+ var Symbol2 = /* @__PURE__ */ ((Symbol3) => {
554
+ Symbol3["HIVE"] = "HIVE";
555
+ Symbol3["HBD"] = "HBD";
556
+ Symbol3["VESTS"] = "VESTS";
557
+ Symbol3["SPK"] = "SPK";
558
+ return Symbol3;
559
+ })(Symbol2 || {});
560
+ var NaiMap = /* @__PURE__ */ ((NaiMap2) => {
561
+ NaiMap2["@@000000021"] = "HIVE";
562
+ NaiMap2["@@000000013"] = "HBD";
563
+ NaiMap2["@@000000037"] = "VESTS";
564
+ return NaiMap2;
565
+ })(NaiMap || {});
566
+ function parseAsset(sval) {
567
+ if (typeof sval === "string") {
568
+ const sp = sval.split(" ");
569
+ return {
570
+ amount: parseFloat(sp[0]),
571
+ // @ts-ignore
572
+ symbol: Symbol2[sp[1]]
573
+ };
574
+ } else {
575
+ return {
576
+ amount: parseFloat(sval.amount.toString()) / Math.pow(10, sval.precision),
577
+ // @ts-ignore
578
+ symbol: NaiMap[sval.nai]
579
+ };
580
+ }
581
+ }
582
+
583
+ // src/modules/assets/utils/is-empty-date.ts
584
+ function isEmptyDate(s) {
585
+ if (s === void 0) {
586
+ return true;
587
+ }
588
+ return parseInt(s.split("-")[0], 10) < 1980;
589
+ }
590
+
591
+ // src/modules/assets/utils/vests-to-hp.ts
592
+ function vestsToHp(vests, hivePerMVests) {
593
+ return vests / 1e6 * hivePerMVests;
594
+ }
595
+
596
+ // src/modules/assets/utils/reward-spk.ts
597
+ function rewardSpk(data, sstats) {
598
+ let a = 0, b = 0, c = 0, t = 0, diff = data.head_block - data.spk_block;
599
+ if (!data.spk_block) {
600
+ return 0;
601
+ } else if (diff < 28800) {
602
+ return 0;
603
+ } else {
604
+ t = diff / 28800;
605
+ a = data.gov ? simpleInterest(data.gov, t, sstats.spk_rate_lgov) : 0;
606
+ b = data.pow ? simpleInterest(data.pow, t, sstats.spk_rate_lpow) : 0;
607
+ c = simpleInterest(
608
+ (data.granted.t > 0 ? data.granted.t : 0) + (data.granting.t && data.granting.t > 0 ? data.granting.t : 0),
609
+ t,
610
+ sstats.spk_rate_ldel
611
+ );
612
+ const i = a + b + c;
613
+ if (i) {
614
+ return i;
615
+ } else {
616
+ return 0;
617
+ }
618
+ }
619
+ function simpleInterest(p, t2, r) {
620
+ const amount = p * (1 + r / 365);
621
+ const interest = amount - p;
622
+ return interest * t2;
623
+ }
624
+ }
625
+
626
+ // src/modules/assets/hive/queries/get-hive-asset-general-info-query-options.ts
627
+ function getHiveAssetGeneralInfoQueryOptions(username) {
628
+ return queryOptions({
629
+ queryKey: ["assets", "hive", "general-info", username],
630
+ staleTime: 6e4,
631
+ refetchInterval: 9e4,
632
+ queryFn: async () => {
633
+ await getQueryClient().prefetchQuery(getDynamicPropsQueryOptions());
634
+ await getQueryClient().prefetchQuery(
635
+ getAccountFullQueryOptions(username)
636
+ );
637
+ const dynamicProps = getQueryClient().getQueryData(
638
+ getDynamicPropsQueryOptions().queryKey
639
+ );
640
+ const accountData = getQueryClient().getQueryData(
641
+ getAccountFullQueryOptions(username).queryKey
642
+ );
643
+ return {
644
+ name: "HIVE",
645
+ title: "Hive",
646
+ price: dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
647
+ accountBalance: accountData ? parseAsset(accountData.balance).amount : 0
648
+ };
649
+ }
650
+ });
651
+ }
652
+ function getAPR(dynamicProps) {
653
+ const initialInflationRate = 9.5;
654
+ const initialBlock = 7e6;
655
+ const decreaseRate = 25e4;
656
+ const decreasePercentPerIncrement = 0.01;
657
+ const headBlock = dynamicProps.headBlock;
658
+ const deltaBlocks = headBlock - initialBlock;
659
+ const decreaseIncrements = deltaBlocks / decreaseRate;
660
+ let currentInflationRate = initialInflationRate - decreaseIncrements * decreasePercentPerIncrement;
661
+ if (currentInflationRate < 0.95) {
662
+ currentInflationRate = 0.95;
663
+ }
664
+ const vestingRewardPercent = dynamicProps.vestingRewardPercent / 1e4;
665
+ const virtualSupply = dynamicProps.virtualSupply;
666
+ const totalVestingFunds = dynamicProps.totalVestingFund;
667
+ return (virtualSupply * currentInflationRate * vestingRewardPercent / totalVestingFunds).toFixed(3);
668
+ }
669
+ function getHivePowerAssetGeneralInfoQueryOptions(username) {
670
+ return queryOptions({
671
+ queryKey: ["assets", "hive-power", "general-info", username],
672
+ staleTime: 6e4,
673
+ refetchInterval: 9e4,
674
+ queryFn: async () => {
675
+ await getQueryClient().prefetchQuery(getDynamicPropsQueryOptions());
676
+ await getQueryClient().prefetchQuery(
677
+ getAccountFullQueryOptions(username)
678
+ );
679
+ const dynamicProps = getQueryClient().getQueryData(
680
+ getDynamicPropsQueryOptions().queryKey
681
+ );
682
+ const accountData = getQueryClient().getQueryData(
683
+ getAccountFullQueryOptions(username).queryKey
684
+ );
685
+ if (!dynamicProps || !accountData) {
686
+ return {
687
+ name: "HP",
688
+ title: "Hive Power",
689
+ price: 0,
690
+ accountBalance: 0
691
+ };
692
+ }
693
+ return {
694
+ name: "HP",
695
+ title: "Hive Power",
696
+ price: dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
697
+ accountBalance: +vestsToHp(
698
+ parseAsset(accountData.vesting_shares).amount,
699
+ // parseAsset(accountData.delegated_vesting_shares).amount +
700
+ // parseAsset(accountData.received_vesting_shares).amount -
701
+ // nextVestingSharesWithdrawal,
702
+ dynamicProps.hivePerMVests
703
+ ).toFixed(3),
704
+ apr: getAPR(dynamicProps),
705
+ parts: [
706
+ {
707
+ name: "delegating",
708
+ balance: +vestsToHp(
709
+ parseAsset(accountData.delegated_vesting_shares).amount,
710
+ dynamicProps.hivePerMVests
711
+ ).toFixed(3)
712
+ },
713
+ {
714
+ name: "received",
715
+ balance: +vestsToHp(
716
+ parseAsset(accountData.received_vesting_shares).amount,
717
+ dynamicProps.hivePerMVests
718
+ ).toFixed(3)
719
+ }
720
+ ]
721
+ };
722
+ }
723
+ });
724
+ }
725
+ function getHbdAssetGeneralInfoQueryOptions(username) {
726
+ return queryOptions({
727
+ queryKey: ["assets", "hbd", "general-info", username],
728
+ staleTime: 6e4,
729
+ refetchInterval: 9e4,
730
+ queryFn: async () => {
731
+ await getQueryClient().prefetchQuery(getDynamicPropsQueryOptions());
732
+ await getQueryClient().prefetchQuery(
733
+ getAccountFullQueryOptions(username)
734
+ );
735
+ const accountData = getQueryClient().getQueryData(
736
+ getAccountFullQueryOptions(username).queryKey
737
+ );
738
+ const dynamicProps = getQueryClient().getQueryData(
739
+ getDynamicPropsQueryOptions().queryKey
740
+ );
741
+ if (!accountData) {
742
+ return {
743
+ name: "HBD",
744
+ title: "Hive-based dollar",
745
+ price: 1,
746
+ accountBalance: 0
747
+ };
748
+ }
749
+ return {
750
+ name: "HBD",
751
+ title: "Hive-based dollar",
752
+ price: 1,
753
+ accountBalance: parseAsset(accountData.hbd_balance).amount + parseAsset(accountData?.savings_hbd_balance).amount,
754
+ apr: ((dynamicProps?.hbdInterestRate ?? 0) / 100).toFixed(3),
755
+ parts: [
756
+ {
757
+ name: "account",
758
+ balance: parseAsset(accountData.hbd_balance).amount
759
+ },
760
+ {
761
+ name: "savings",
762
+ balance: parseAsset(accountData.savings_hbd_balance).amount
763
+ }
764
+ ]
765
+ };
766
+ }
767
+ });
768
+ }
769
+ var ops = utils.operationOrders;
770
+ var HIVE_ACCOUNT_OPERATION_GROUPS = {
771
+ transfers: [
772
+ ops.transfer,
773
+ ops.transfer_to_savings,
774
+ ops.transfer_from_savings,
775
+ ops.cancel_transfer_from_savings,
776
+ ops.recurrent_transfer,
777
+ ops.fill_recurrent_transfer,
778
+ ops.escrow_transfer,
779
+ ops.fill_recurrent_transfer
780
+ ],
781
+ "market-orders": [
782
+ ops.fill_convert_request,
783
+ ops.fill_order,
784
+ ops.fill_collateralized_convert_request,
785
+ ops.limit_order_create2,
786
+ ops.limit_order_create,
787
+ ops.limit_order_cancel
788
+ ],
789
+ interests: [ops.interest],
790
+ "stake-operations": [
791
+ ops.return_vesting_delegation,
792
+ ops.withdraw_vesting,
793
+ ops.transfer_to_vesting,
794
+ ops.set_withdraw_vesting_route,
795
+ ops.update_proposal_votes,
796
+ ops.fill_vesting_withdraw,
797
+ ops.account_witness_proxy,
798
+ ops.delegate_vesting_shares
799
+ ],
800
+ rewards: [
801
+ ops.author_reward,
802
+ ops.curation_reward,
803
+ ops.producer_reward,
804
+ ops.claim_reward_balance,
805
+ ops.comment_benefactor_reward,
806
+ ops.liquidity_reward,
807
+ ops.proposal_pay
808
+ ]};
809
+
810
+ // src/modules/assets/hive/queries/get-hive-asset-transactions-query-options.ts
811
+ function getHiveAssetTransactionsQueryOptions(username, limit = 20, group) {
812
+ return infiniteQueryOptions({
813
+ queryKey: ["assets", "hive", "transactions", username, limit, group],
814
+ initialData: { pages: [], pageParams: [] },
815
+ initialPageParam: -1,
816
+ getNextPageParam: (lastPage, __) => lastPage ? +(lastPage[lastPage.length - 1]?.num ?? 0) - 1 : -1,
817
+ queryFn: async ({ pageParam }) => {
818
+ let filters = [];
819
+ switch (group) {
820
+ case "transfers":
821
+ filters = utils.makeBitMaskFilter(
822
+ HIVE_ACCOUNT_OPERATION_GROUPS["transfers"]
823
+ );
824
+ break;
825
+ case "market-orders":
826
+ filters = utils.makeBitMaskFilter(
827
+ HIVE_ACCOUNT_OPERATION_GROUPS["market-orders"]
828
+ );
829
+ break;
830
+ case "interests":
831
+ filters = utils.makeBitMaskFilter(
832
+ HIVE_ACCOUNT_OPERATION_GROUPS["interests"]
833
+ );
834
+ break;
835
+ case "stake-operations":
836
+ filters = utils.makeBitMaskFilter(
837
+ HIVE_ACCOUNT_OPERATION_GROUPS["stake-operations"]
838
+ );
839
+ break;
840
+ case "rewards":
841
+ filters = utils.makeBitMaskFilter(
842
+ HIVE_ACCOUNT_OPERATION_GROUPS["rewards"]
843
+ );
844
+ break;
845
+ default:
846
+ filters = utils.makeBitMaskFilter([]);
847
+ }
848
+ const response = await CONFIG.hiveClient.call(
849
+ "condenser_api",
850
+ "get_account_history",
851
+ [username, pageParam, limit, ...filters]
852
+ );
853
+ return response.map(
854
+ (x) => ({
855
+ num: x[0],
856
+ type: x[1].op[0],
857
+ timestamp: x[1].timestamp,
858
+ trx_id: x[1].trx_id,
859
+ ...x[1].op[1]
860
+ })
861
+ );
862
+ },
863
+ select: ({ pages, pageParams }) => ({
864
+ pageParams,
865
+ pages: pages.map(
866
+ (page) => page.filter((item) => {
867
+ switch (item.type) {
868
+ case "author_reward":
869
+ case "comment_benefactor_reward":
870
+ const hivePayout = parseAsset(item.hive_payout);
871
+ return hivePayout.amount > 0;
872
+ case "transfer":
873
+ case "transfer_to_savings":
874
+ case "transfer_to_vesting":
875
+ case "recurrent_transfer":
876
+ return ["HIVE"].includes(item.amount);
877
+ case "fill_recurrent_transfer":
878
+ const asset = parseAsset(item.amount);
879
+ return ["HIVE"].includes(asset.symbol);
880
+ case "claim_reward_balance":
881
+ const rewardHive = parseAsset(
882
+ item.reward_hive
883
+ );
884
+ return rewardHive.amount > 0;
885
+ case "cancel_transfer_from_savings":
886
+ case "fill_order":
887
+ case "limit_order_create":
888
+ case "limit_order_cancel":
889
+ case "interest":
890
+ case "fill_convert_request":
891
+ case "fill_collateralized_convert_request":
892
+ case "proposal_pay":
893
+ case "update_proposal_votes":
894
+ case "comment_payout_update":
895
+ case "collateralized_convert":
896
+ case "account_witness_proxy":
897
+ return true;
898
+ default:
899
+ return false;
900
+ }
901
+ })
902
+ )
903
+ })
904
+ });
905
+ }
906
+ function getHivePowerAssetTransactionsQueryOptions(username, limit = 20, group) {
907
+ return infiniteQueryOptions({
908
+ ...getHiveAssetTransactionsQueryOptions(username, limit, group),
909
+ queryKey: ["assets", "hive-power", "transactions", username, limit, group],
910
+ select: ({ pages, pageParams }) => ({
911
+ pageParams,
912
+ pages: pages.map(
913
+ (page) => page.filter((item) => {
914
+ switch (item.type) {
915
+ case "author_reward":
916
+ case "comment_benefactor_reward":
917
+ const vestingPayout = parseAsset(
918
+ item.vesting_payout
919
+ );
920
+ return vestingPayout.amount > 0;
921
+ case "claim_reward_balance":
922
+ const rewardVests = parseAsset(
923
+ item.reward_vests
924
+ );
925
+ return rewardVests.amount > 0;
926
+ case "transfer":
927
+ case "transfer_to_savings":
928
+ case "transfer_to_vesting":
929
+ case "recurrent_transfer":
930
+ return ["VESTS", "HP"].includes(item.amount);
931
+ case "fill_recurrent_transfer":
932
+ const asset = parseAsset(item.amount);
933
+ return ["VESTS", "HP"].includes(asset.symbol);
934
+ case "curation_reward":
935
+ case "withdraw_vesting":
936
+ case "delegate_vesting_shares":
937
+ case "fill_vesting_withdraw":
938
+ case "return_vesting_delegation":
939
+ case "producer_reward":
940
+ case "set_withdraw_vesting_route":
941
+ return true;
942
+ default:
943
+ return false;
944
+ }
945
+ })
946
+ )
947
+ })
948
+ });
949
+ }
950
+ function getHbdAssetTransactionsQueryOptions(username, limit = 20, group) {
951
+ return infiniteQueryOptions({
952
+ ...getHiveAssetTransactionsQueryOptions(username, limit, group),
953
+ queryKey: ["assets", "hbd", "transactions", username, limit, group],
954
+ select: ({ pages, pageParams }) => ({
955
+ pageParams,
956
+ pages: pages.map(
957
+ (page) => page.filter((item) => {
958
+ switch (item.type) {
959
+ case "author_reward":
960
+ case "comment_benefactor_reward":
961
+ const hbdPayout = parseAsset(item.hbd_payout);
962
+ return hbdPayout.amount > 0;
963
+ case "claim_reward_balance":
964
+ const rewardHbd = parseAsset(
965
+ item.reward_hbd
966
+ );
967
+ return rewardHbd.amount > 0;
968
+ case "transfer":
969
+ case "transfer_to_savings":
970
+ case "transfer_to_vesting":
971
+ case "recurrent_transfer":
972
+ return ["HBD"].includes(item.amount);
973
+ case "fill_recurrent_transfer":
974
+ const asset = parseAsset(item.amount);
975
+ return ["HBD"].includes(asset.symbol);
976
+ case "comment_reward":
977
+ case "effective_comment_vote":
978
+ return true;
979
+ default:
980
+ return false;
981
+ }
982
+ })
983
+ )
984
+ })
985
+ });
986
+ }
987
+ function getHiveAssetMetricQueryOptions(bucketSeconds = 86400) {
988
+ return infiniteQueryOptions({
989
+ queryKey: ["assets", "hive", "metrics", bucketSeconds],
990
+ queryFn: async ({ pageParam: [startDate, endDate] }) => {
991
+ const apiData = await CONFIG.hiveClient.call(
992
+ "condenser_api",
993
+ "get_market_history",
994
+ [
995
+ bucketSeconds,
996
+ dayjs(startDate).format("YYYY-MM-DDTHH:mm:ss"),
997
+ dayjs(endDate).format("YYYY-MM-DDTHH:mm:ss")
998
+ ]
999
+ );
1000
+ return apiData.map(({ hive, non_hive, open }) => ({
1001
+ close: non_hive.close / hive.close,
1002
+ open: non_hive.open / hive.open,
1003
+ low: non_hive.low / hive.low,
1004
+ high: non_hive.high / hive.high,
1005
+ volume: hive.volume,
1006
+ time: new Date(open)
1007
+ }));
1008
+ },
1009
+ initialPageParam: [
1010
+ // Fetch at least 8 hours or given interval
1011
+ dayjs().subtract(Math.max(100 * bucketSeconds, 28800), "second").toDate(),
1012
+ /* @__PURE__ */ new Date()
1013
+ ],
1014
+ getNextPageParam: (_, __, [prevStartDate]) => [
1015
+ dayjs(prevStartDate.getTime()).subtract(Math.max(100 * bucketSeconds, 28800), "second").toDate(),
1016
+ dayjs(prevStartDate.getTime()).subtract(bucketSeconds, "second").toDate()
1017
+ ]
1018
+ });
1019
+ }
1020
+ function getHiveAssetWithdrawalRoutesQueryOptions(username) {
1021
+ return queryOptions({
1022
+ queryKey: ["assets", "hive", "withdrawal-routes", username],
1023
+ queryFn: () => CONFIG.hiveClient.database.call("get_withdraw_routes", [
1024
+ username,
1025
+ "outgoing"
1026
+ ])
1027
+ });
1028
+ }
1029
+ function getHivePowerDelegatesInfiniteQueryOptions(username, limit = 50) {
1030
+ return queryOptions({
1031
+ queryKey: ["assets", "hive-power", "delegates", username],
1032
+ enabled: !!username,
1033
+ queryFn: () => CONFIG.hiveClient.database.call("get_vesting_delegations", [
1034
+ username,
1035
+ "",
1036
+ limit
1037
+ ])
1038
+ });
1039
+ }
1040
+ function getHivePowerDelegatingsQueryOptions(username) {
1041
+ return queryOptions({
1042
+ queryKey: ["assets", "hive-power", "delegatings", username],
1043
+ queryFn: async () => {
1044
+ const response = await fetch(
1045
+ CONFIG.privateApiHost + `/private-api/received-vesting/${username}`,
1046
+ {
1047
+ headers: {
1048
+ "Content-Type": "application/json"
1049
+ }
1050
+ }
1051
+ );
1052
+ return (await response.json()).list;
1053
+ },
1054
+ select: (data) => data.sort(
1055
+ (a, b) => parseAsset(b.vesting_shares).amount - parseAsset(a.vesting_shares).amount
1056
+ )
1057
+ });
1058
+ }
1059
+ async function transferHive(payload) {
1060
+ const parsedAsset = parseAsset(payload.amount);
1061
+ const token = parsedAsset.symbol;
1062
+ if (payload.type === "key" && "key" in payload) {
1063
+ const { key, type, ...params } = payload;
1064
+ return CONFIG.hiveClient.broadcast.transfer(
1065
+ {
1066
+ from: params.from,
1067
+ to: params.to,
1068
+ amount: params.amount,
1069
+ memo: params.memo
1070
+ },
1071
+ key
1072
+ );
1073
+ } else if (payload.type === "keychain") {
1074
+ return new Promise(
1075
+ (resolve, reject) => window.hive_keychain?.requestTransfer(
1076
+ payload.from,
1077
+ payload.to,
1078
+ payload.amount,
1079
+ payload.memo,
1080
+ token,
1081
+ (resp) => {
1082
+ if (!resp.success) {
1083
+ reject({ message: "Operation cancelled" });
1084
+ }
1085
+ resolve(resp);
1086
+ },
1087
+ true,
1088
+ null
1089
+ )
1090
+ );
1091
+ } else {
1092
+ return hs.sendOperation(
1093
+ [
1094
+ "transfer",
1095
+ {
1096
+ from: payload.from,
1097
+ to: payload.to,
1098
+ amount: payload.amount,
1099
+ memo: payload.memo
1100
+ }
1101
+ ],
1102
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
1103
+ () => {
1104
+ }
1105
+ );
1106
+ }
1107
+ }
1108
+ async function transferToSavingsHive(payload) {
1109
+ if (payload.type === "key" && "key" in payload) {
1110
+ const { key, type, ...params } = payload;
1111
+ return CONFIG.hiveClient.broadcast.sendOperations(
1112
+ [["transfer_to_savings", params]],
1113
+ key
1114
+ );
1115
+ } else if (payload.type === "keychain") {
1116
+ return Keychain.broadcast(
1117
+ payload.from,
1118
+ [["transfer_to_savings", payload]],
1119
+ "Active"
1120
+ );
1121
+ } else {
1122
+ return hs.sendOperation(
1123
+ ["transfer_to_savings", payload],
1124
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
1125
+ () => {
1126
+ }
1127
+ );
1128
+ }
1129
+ }
1130
+ async function powerUpHive(payload) {
1131
+ if (payload.type === "key" && "key" in payload) {
1132
+ const { key, type, ...params } = payload;
1133
+ return CONFIG.hiveClient.broadcast.sendOperations(
1134
+ [["transfer_to_vesting", params]],
1135
+ key
1136
+ );
1137
+ } else if (payload.type === "keychain") {
1138
+ return Keychain.broadcast(
1139
+ payload.from,
1140
+ [["transfer_to_vesting", payload]],
1141
+ "Active"
1142
+ );
1143
+ } else {
1144
+ return hs.sendOperation(
1145
+ ["transfer_to_vesting", payload],
1146
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
1147
+ () => {
1148
+ }
1149
+ );
1150
+ }
1151
+ }
1152
+ async function delegateHive(payload) {
1153
+ const operationPayload = {
1154
+ delegator: payload.from,
1155
+ delegatee: payload.to,
1156
+ vesting_shares: payload.amount
1157
+ };
1158
+ if (payload.type === "key" && "key" in payload) {
1159
+ const { key } = payload;
1160
+ return CONFIG.hiveClient.broadcast.sendOperations(
1161
+ [["delegate_vesting_shares", operationPayload]],
1162
+ key
1163
+ );
1164
+ } else if (payload.type === "keychain") {
1165
+ return Keychain.broadcast(
1166
+ payload.from,
1167
+ [["delegate_vesting_shares", operationPayload]],
1168
+ "Active"
1169
+ );
1170
+ } else {
1171
+ return hs.sendOperation(
1172
+ ["delegate_vesting_shares", operationPayload],
1173
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
1174
+ () => {
1175
+ }
1176
+ );
1177
+ }
1178
+ }
1179
+ async function powerDownHive(payload) {
1180
+ const operationPayload = {
1181
+ account: payload.from,
1182
+ vesting_shares: payload.amount
1183
+ };
1184
+ if (payload.type === "key" && "key" in payload) {
1185
+ const { key } = payload;
1186
+ return CONFIG.hiveClient.broadcast.sendOperations(
1187
+ [["withdraw_vesting", operationPayload]],
1188
+ key
1189
+ );
1190
+ } else if (payload.type === "keychain") {
1191
+ return Keychain.broadcast(
1192
+ payload.from,
1193
+ [["withdraw_vesting", operationPayload]],
1194
+ "Active"
1195
+ );
1196
+ } else {
1197
+ return hs.sendOperation(
1198
+ ["withdraw_vesting", operationPayload],
1199
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
1200
+ () => {
1201
+ }
1202
+ );
1203
+ }
1204
+ }
1205
+ async function withdrawVestingRouteHive(payload) {
1206
+ if (payload.type === "key" && "key" in payload) {
1207
+ const { key, type: type2, ...params2 } = payload;
1208
+ return CONFIG.hiveClient.broadcast.sendOperations(
1209
+ [["set_withdraw_vesting_route", params2]],
1210
+ key
1211
+ );
1212
+ }
1213
+ if (payload.type === "keychain") {
1214
+ const { type: type2, ...params2 } = payload;
1215
+ return Keychain.broadcast(
1216
+ params2.from_account,
1217
+ [["set_withdraw_vesting_route", params2]],
1218
+ "Active"
1219
+ );
1220
+ }
1221
+ const { type, ...params } = payload;
1222
+ return hs.sendOperation(
1223
+ ["set_withdraw_vesting_route", params],
1224
+ { callback: `https://ecency.com/@${params.from_account}/wallet` },
1225
+ () => {
1226
+ }
1227
+ );
1228
+ }
1229
+ function useClaimRewards(username, onSuccess) {
1230
+ const { data } = useQuery(getAccountFullQueryOptions(username));
1231
+ const queryClient = useQueryClient();
1232
+ return useBroadcastMutation(
1233
+ ["assets", "hive", "claim-rewards", data?.name],
1234
+ username,
1235
+ () => {
1236
+ if (!data) {
1237
+ throw new Error("Failed to fetch account while claiming balance");
1238
+ }
1239
+ const {
1240
+ reward_hive_balance: hiveBalance,
1241
+ reward_hbd_balance: hbdBalance,
1242
+ reward_vesting_balance: vestingBalance
1243
+ } = data;
1244
+ return [
1245
+ [
1246
+ "claim_reward_balance",
1247
+ {
1248
+ account: username,
1249
+ reward_hive: hiveBalance,
1250
+ reward_hbd: hbdBalance,
1251
+ reward_vests: vestingBalance
1252
+ }
1253
+ ]
1254
+ ];
1255
+ },
1256
+ async () => {
1257
+ onSuccess();
1258
+ await delay(1e3);
1259
+ queryClient.invalidateQueries({
1260
+ queryKey: getAccountFullQueryOptions(username).queryKey
1261
+ });
1262
+ queryClient.invalidateQueries({
1263
+ queryKey: getHivePowerAssetGeneralInfoQueryOptions(username).queryKey
1264
+ });
1265
+ }
1266
+ );
1267
+ }
1268
+
1269
+ // src/modules/assets/types/asset-operation.ts
1270
+ var AssetOperation = /* @__PURE__ */ ((AssetOperation2) => {
1271
+ AssetOperation2["Transfer"] = "transfer";
1272
+ AssetOperation2["TransferToSavings"] = "transfer-saving";
1273
+ AssetOperation2["Delegate"] = "delegate";
1274
+ AssetOperation2["PowerUp"] = "power-up";
1275
+ AssetOperation2["PowerDown"] = "power-down";
1276
+ AssetOperation2["WithdrawRoutes"] = "withdraw-saving";
1277
+ AssetOperation2["Swap"] = "swap";
1278
+ AssetOperation2["Gift"] = "gift";
1279
+ AssetOperation2["Promote"] = "promote";
1280
+ AssetOperation2["Claim"] = "claim";
1281
+ AssetOperation2["Buy"] = "buy";
1282
+ AssetOperation2["LockLiquidity"] = "lock";
1283
+ AssetOperation2["Stake"] = "stake";
1284
+ AssetOperation2["Unstake"] = "unstake";
1285
+ AssetOperation2["Undelegate"] = "undelegate";
1286
+ return AssetOperation2;
1287
+ })(AssetOperation || {});
1288
+ async function transferSpk(payload) {
1289
+ const json = JSON.stringify({
1290
+ to: payload.to,
1291
+ amount: +payload.amount * 1e3,
1292
+ ...typeof payload.memo === "string" ? { memo: payload.memo } : {}
1293
+ });
1294
+ const op = {
1295
+ id: payload.id,
1296
+ json,
1297
+ required_auths: [payload.from],
1298
+ required_posting_auths: []
1299
+ };
1300
+ if (payload.type === "key" && "key" in payload) {
1301
+ const { key } = payload;
1302
+ return CONFIG.hiveClient.broadcast.json(op, key);
1303
+ } else if (payload.type === "keychain") {
1304
+ return Keychain.customJson(
1305
+ payload.from,
1306
+ payload.id,
1307
+ "Active",
1308
+ json,
1309
+ payload.to
1310
+ );
1311
+ } else {
1312
+ const { amount } = parseAsset(payload.amount);
1313
+ return hs.sign(
1314
+ "custom_json",
1315
+ {
1316
+ authority: "active",
1317
+ required_auths: `["${payload.from}"]`,
1318
+ required_posting_auths: "[]",
1319
+ id: payload.id,
1320
+ json: JSON.stringify({
1321
+ to: payload.to,
1322
+ amount: +amount * 1e3,
1323
+ ...typeof payload.memo === "string" ? { memo: payload.memo } : {}
1324
+ })
1325
+ },
1326
+ `https://ecency.com/@${payload.from}/wallet`
1327
+ );
1328
+ }
1329
+ }
1330
+ var lockLarynx = async (payload) => {
1331
+ const json = JSON.stringify({ amount: +payload.amount * 1e3 });
1332
+ const op = {
1333
+ id: payload.mode === "lock" ? "spkcc_gov_up" : "spkcc_gov_down",
1334
+ json,
1335
+ required_auths: [payload.from],
1336
+ required_posting_auths: []
1337
+ };
1338
+ if (payload.type === "key" && "key" in payload) {
1339
+ const { key } = payload;
1340
+ return CONFIG.hiveClient.broadcast.json(op, key);
1341
+ } else if (payload.type === "keychain") {
1342
+ return Keychain.customJson(
1343
+ payload.from,
1344
+ op.id,
1345
+ "Active",
1346
+ json,
1347
+ payload.from
1348
+ );
1349
+ } else {
1350
+ const { amount } = parseAsset(payload.amount);
1351
+ return hs.sign(
1352
+ "custom_json",
1353
+ {
1354
+ authority: "active",
1355
+ required_auths: `["${payload.from}"]`,
1356
+ required_posting_auths: "[]",
1357
+ id: op.id,
1358
+ json: JSON.stringify({ amount: +amount * 1e3 })
1359
+ },
1360
+ `https://ecency.com/@${payload.from}/wallet`
1361
+ );
1362
+ }
1363
+ };
1364
+ async function powerUpLarynx(payload) {
1365
+ const json = JSON.stringify({ amount: +payload.amount * 1e3 });
1366
+ const op = {
1367
+ id: `spkcc_power_${payload.mode}`,
1368
+ json,
1369
+ required_auths: [payload.from],
1370
+ required_posting_auths: []
1371
+ };
1372
+ if (payload.type === "key" && "key" in payload) {
1373
+ const { key } = payload;
1374
+ return CONFIG.hiveClient.broadcast.json(op, key);
1375
+ } else if (payload.type === "keychain") {
1376
+ return Keychain.customJson(
1377
+ payload.from,
1378
+ `spkcc_power_${payload.mode}`,
1379
+ "Active",
1380
+ json,
1381
+ ""
1382
+ );
1383
+ } else {
1384
+ const { amount } = parseAsset(payload.amount);
1385
+ return hs.sign(
1386
+ "custom_json",
1387
+ {
1388
+ authority: "active",
1389
+ required_auths: `["${payload.from}"]`,
1390
+ required_posting_auths: "[]",
1391
+ id: `spkcc_power_${payload.mode}`,
1392
+ json: JSON.stringify({ amount: +amount * 1e3 })
1393
+ },
1394
+ `https://ecency.com/@${payload.from}/wallet`
1395
+ );
1396
+ }
1397
+ }
1398
+ function getSpkMarketsQueryOptions() {
1399
+ return queryOptions({
1400
+ queryKey: ["assets", "spk", "markets"],
1401
+ staleTime: 6e4,
1402
+ refetchInterval: 9e4,
1403
+ queryFn: async () => {
1404
+ const response = await fetch(`${CONFIG.spkNode}/markets`);
1405
+ const data = await response.json();
1406
+ return {
1407
+ list: Object.entries(data.markets.node).map(([name, node]) => ({
1408
+ name,
1409
+ status: node.lastGood >= data.head_block - 1200 ? "\u{1F7E9}" : node.lastGood > data.head_block - 28800 ? "\u{1F7E8}" : "\u{1F7E5}"
1410
+ })),
1411
+ raw: data
1412
+ };
1413
+ }
1414
+ });
1415
+ }
1416
+ function getSpkWalletQueryOptions(username) {
1417
+ return queryOptions({
1418
+ queryKey: ["assets", "spk", "wallet", username],
1419
+ queryFn: async () => {
1420
+ const response = await fetch(CONFIG.spkNode + `/@${username}`);
1421
+ return response.json();
1422
+ },
1423
+ enabled: !!username,
1424
+ staleTime: 6e4,
1425
+ refetchInterval: 9e4
1426
+ });
1427
+ }
1428
+
1429
+ // src/modules/assets/spk/queries/get-larynx-asset-general-info-query-options.ts
1430
+ function format(value) {
1431
+ return value.toFixed(3);
1432
+ }
1433
+ function getLarynxAssetGeneralInfoQueryOptions(username) {
1434
+ return queryOptions({
1435
+ queryKey: ["assets", "larynx", "general-info", username],
1436
+ staleTime: 6e4,
1437
+ refetchInterval: 9e4,
1438
+ queryFn: async () => {
1439
+ await getQueryClient().prefetchQuery(getSpkWalletQueryOptions(username));
1440
+ await getQueryClient().prefetchQuery(getSpkMarketsQueryOptions());
1441
+ await getQueryClient().prefetchQuery(
1442
+ getHiveAssetGeneralInfoQueryOptions(username)
1443
+ );
1444
+ const wallet = getQueryClient().getQueryData(
1445
+ getSpkWalletQueryOptions(username).queryKey
1446
+ );
1447
+ const market = getQueryClient().getQueryData(
1448
+ getSpkMarketsQueryOptions().queryKey
1449
+ );
1450
+ const hiveAsset = getQueryClient().getQueryData(
1451
+ getHiveAssetGeneralInfoQueryOptions(username).queryKey
1452
+ );
1453
+ if (!wallet || !market) {
1454
+ return {
1455
+ name: "LARYNX",
1456
+ title: "SPK Network / LARYNX",
1457
+ price: 1,
1458
+ accountBalance: 0
1459
+ };
1460
+ }
1461
+ const price = +format(
1462
+ wallet.balance / 1e3 * +wallet.tick * (hiveAsset?.price ?? 0)
1463
+ );
1464
+ const accountBalance = +format(wallet.balance / 1e3);
1465
+ return {
1466
+ name: "LARYNX",
1467
+ layer: "SPK",
1468
+ title: "LARYNX",
1469
+ price: price / accountBalance,
1470
+ accountBalance
1471
+ };
1472
+ }
1473
+ });
1474
+ }
1475
+ function format2(value) {
1476
+ return value.toFixed(3);
1477
+ }
1478
+ function getSpkAssetGeneralInfoQueryOptions(username) {
1479
+ return queryOptions({
1480
+ queryKey: ["assets", "spk", "general-info", username],
1481
+ staleTime: 6e4,
1482
+ refetchInterval: 9e4,
1483
+ queryFn: async () => {
1484
+ await getQueryClient().prefetchQuery(getSpkWalletQueryOptions(username));
1485
+ await getQueryClient().prefetchQuery(getSpkMarketsQueryOptions());
1486
+ await getQueryClient().prefetchQuery(
1487
+ getHiveAssetGeneralInfoQueryOptions(username)
1488
+ );
1489
+ const wallet = getQueryClient().getQueryData(
1490
+ getSpkWalletQueryOptions(username).queryKey
1491
+ );
1492
+ const market = getQueryClient().getQueryData(
1493
+ getSpkMarketsQueryOptions().queryKey
1494
+ );
1495
+ const hiveAsset = getQueryClient().getQueryData(
1496
+ getHiveAssetGeneralInfoQueryOptions(username).queryKey
1497
+ );
1498
+ if (!wallet || !market) {
1499
+ return {
1500
+ name: "SPK",
1501
+ title: "SPK Network",
1502
+ price: 1,
1503
+ accountBalance: 0
1504
+ };
1505
+ }
1506
+ const price = +format2(
1507
+ (wallet.gov + wallet.spk) / 1e3 * +wallet.tick * (hiveAsset?.price ?? 0)
1508
+ );
1509
+ const accountBalance = +format2(
1510
+ (wallet.spk + rewardSpk(
1511
+ wallet,
1512
+ market.raw.stats || {
1513
+ spk_rate_lgov: "0.001",
1514
+ spk_rate_lpow: format2(
1515
+ parseFloat(market.raw.stats.spk_rate_lpow) * 100
1516
+ ),
1517
+ spk_rate_ldel: format2(
1518
+ parseFloat(market.raw.stats.spk_rate_ldel) * 100
1519
+ )
1520
+ }
1521
+ )) / 1e3
1522
+ );
1523
+ return {
1524
+ name: "SPK",
1525
+ title: "SPK Network",
1526
+ price: price / accountBalance,
1527
+ accountBalance
1528
+ };
1529
+ }
1530
+ });
1531
+ }
1532
+ function format3(value) {
1533
+ return value.toFixed(3);
1534
+ }
1535
+ function getLarynxPowerAssetGeneralInfoQueryOptions(username) {
1536
+ return queryOptions({
1537
+ queryKey: ["assets", "larynx-power", "general-info", username],
1538
+ staleTime: 6e4,
1539
+ refetchInterval: 9e4,
1540
+ queryFn: async () => {
1541
+ await getQueryClient().prefetchQuery(getSpkWalletQueryOptions(username));
1542
+ await getQueryClient().prefetchQuery(getSpkMarketsQueryOptions());
1543
+ await getQueryClient().prefetchQuery(
1544
+ getHiveAssetGeneralInfoQueryOptions(username)
1545
+ );
1546
+ const wallet = getQueryClient().getQueryData(
1547
+ getSpkWalletQueryOptions(username).queryKey
1548
+ );
1549
+ const market = getQueryClient().getQueryData(
1550
+ getSpkMarketsQueryOptions().queryKey
1551
+ );
1552
+ const hiveAsset = getQueryClient().getQueryData(
1553
+ getHiveAssetGeneralInfoQueryOptions(username).queryKey
1554
+ );
1555
+ if (!wallet || !market) {
1556
+ return {
1557
+ name: "LP",
1558
+ title: "SPK Network / LARYNX Power",
1559
+ price: 1,
1560
+ accountBalance: 0
1561
+ };
1562
+ }
1563
+ const price = +format3(
1564
+ wallet.poweredUp / 1e3 * +wallet.tick * (hiveAsset?.price ?? 0)
1565
+ );
1566
+ const accountBalance = +format3(wallet.poweredUp / 1e3);
1567
+ return {
1568
+ name: "LP",
1569
+ title: "LARYNX Power",
1570
+ layer: "SPK",
1571
+ price: price / accountBalance,
1572
+ accountBalance,
1573
+ parts: [
1574
+ {
1575
+ name: "delegating",
1576
+ balance: wallet.granting?.t ? +format3(wallet.granting.t / 1e3) : 0
1577
+ },
1578
+ {
1579
+ name: "recieved",
1580
+ balance: wallet.granted?.t ? +format3(wallet.granted.t / 1e3) : 0
1581
+ }
1582
+ ]
1583
+ };
1584
+ }
1585
+ });
1586
+ }
1587
+ function getHiveEngineTokensMetadataQueryOptions(tokens) {
1588
+ return queryOptions({
1589
+ queryKey: ["assets", "hive-engine", "metadata-list", tokens],
1590
+ staleTime: 6e4,
1591
+ refetchInterval: 9e4,
1592
+ queryFn: async () => {
1593
+ const response = await fetch(
1594
+ `${CONFIG.privateApiHost}/private-api/engine-api`,
1595
+ {
1596
+ method: "POST",
1597
+ body: JSON.stringify({
1598
+ jsonrpc: "2.0",
1599
+ method: "find",
1600
+ params: {
1601
+ contract: "tokens",
1602
+ table: "tokens",
1603
+ query: {
1604
+ symbol: { $in: tokens }
1605
+ }
1606
+ },
1607
+ id: 2
1608
+ }),
1609
+ headers: { "Content-type": "application/json" }
1610
+ }
1611
+ );
1612
+ const data = await response.json();
1613
+ return data.result;
1614
+ }
1615
+ });
1616
+ }
1617
+
1618
+ // src/modules/wallets/consts/hive-engine-tokens.ts
1619
+ var HiveEngineTokens = [
1620
+ "LEO",
1621
+ "ARCHON",
1622
+ "WAIV",
1623
+ "CHOISM",
1624
+ "CCC",
1625
+ "POB",
1626
+ "PHOTO",
1627
+ "LUV",
1628
+ "ALIVE",
1629
+ "LOLZ",
1630
+ "CENT",
1631
+ "FUN",
1632
+ "VYB",
1633
+ "VKBT",
1634
+ "BUIDL",
1635
+ "NEOXAG",
1636
+ "BEE",
1637
+ "PIMP",
1638
+ "PEPE",
1639
+ "PAY",
1640
+ "SPT",
1641
+ "ONEUP",
1642
+ "SPORTS",
1643
+ "CURE"
1644
+ ];
1645
+ function getHiveEngineTokensBalancesQueryOptions(username) {
1646
+ return queryOptions({
1647
+ queryKey: ["assets", "hive-engine", "balances", username],
1648
+ staleTime: 6e4,
1649
+ refetchInterval: 9e4,
1650
+ queryFn: async () => {
1651
+ const response = await fetch(
1652
+ `${CONFIG.privateApiHost}/private-api/engine-api`,
1653
+ {
1654
+ method: "POST",
1655
+ body: JSON.stringify({
1656
+ jsonrpc: "2.0",
1657
+ method: "find",
1658
+ params: {
1659
+ contract: "tokens",
1660
+ table: "balances",
1661
+ query: {
1662
+ account: username
1663
+ }
1664
+ },
1665
+ id: 1
1666
+ }),
1667
+ headers: { "Content-type": "application/json" }
1668
+ }
1669
+ );
1670
+ const data = await response.json();
1671
+ return data.result;
1672
+ }
1673
+ });
1674
+ }
1675
+ function getHiveEngineTokensMarketQueryOptions() {
1676
+ return queryOptions({
1677
+ queryKey: ["assets", "hive-engine", "markets"],
1678
+ staleTime: 6e4,
1679
+ refetchInterval: 9e4,
1680
+ queryFn: async () => {
1681
+ const response = await fetch(
1682
+ `${CONFIG.privateApiHost}/private-api/engine-api`,
1683
+ {
1684
+ method: "POST",
1685
+ body: JSON.stringify({
1686
+ jsonrpc: "2.0",
1687
+ method: "find",
1688
+ params: {
1689
+ contract: "market",
1690
+ table: "metrics",
1691
+ query: {}
1692
+ },
1693
+ id: 1
1694
+ }),
1695
+ headers: { "Content-type": "application/json" }
1696
+ }
1697
+ );
1698
+ const data = await response.json();
1699
+ return data.result;
1700
+ }
1701
+ });
1702
+ }
1703
+
1704
+ // src/modules/assets/hive-engine/queries/get-hive-engine-token-general-info-query-options.ts
1705
+ function getHiveEngineTokenGeneralInfoQueryOptions(username, symbol) {
1706
+ return queryOptions({
1707
+ queryKey: ["assets", "hive-engine", symbol, "general-info", username],
1708
+ enabled: !!symbol && !!username,
1709
+ staleTime: 6e4,
1710
+ refetchInterval: 9e4,
1711
+ queryFn: async () => {
1712
+ if (!symbol || !username) {
1713
+ throw new Error(
1714
+ "[SDK][Wallets] \u2013 hive engine token or username missed"
1715
+ );
1716
+ }
1717
+ const hiveQuery = getHiveAssetGeneralInfoQueryOptions(username);
1718
+ await getQueryClient().prefetchQuery(hiveQuery);
1719
+ const hiveData = getQueryClient().getQueryData(
1720
+ hiveQuery.queryKey
1721
+ );
1722
+ const metadataQuery = getHiveEngineTokensMetadataQueryOptions(HiveEngineTokens);
1723
+ await getQueryClient().prefetchQuery(metadataQuery);
1724
+ const metadataList = getQueryClient().getQueryData(metadataQuery.queryKey);
1725
+ const balancesQuery = getHiveEngineTokensBalancesQueryOptions(username);
1726
+ await getQueryClient().prefetchQuery(balancesQuery);
1727
+ const balanceList = getQueryClient().getQueryData(balancesQuery.queryKey);
1728
+ const marketQuery = getHiveEngineTokensMarketQueryOptions();
1729
+ await getQueryClient().prefetchQuery(marketQuery);
1730
+ const marketList = getQueryClient().getQueryData(marketQuery.queryKey);
1731
+ const metadata = metadataList?.find((i) => i.symbol === symbol);
1732
+ const balance = balanceList?.find((i) => i.symbol === symbol);
1733
+ const market = marketList?.find((i) => i.symbol === symbol);
1734
+ const lastPrice = +(market?.lastPrice ?? "0");
1735
+ return {
1736
+ name: symbol,
1737
+ title: metadata?.name ?? "",
1738
+ price: lastPrice === 0 ? 0 : Number(lastPrice * (hiveData?.price ?? 0)),
1739
+ accountBalance: parseFloat(balance?.balance ?? "0"),
1740
+ layer: "ENGINE"
1741
+ };
1742
+ }
1743
+ });
1744
+ }
1745
+ function getHiveEngineTokenTransactionsQueryOptions(username, symbol, limit = 20) {
1746
+ return infiniteQueryOptions({
1747
+ queryKey: ["assets", "hive-engine", symbol, "transactions", username],
1748
+ enabled: !!symbol && !!username,
1749
+ initialPageParam: 0,
1750
+ getNextPageParam: (lastPage) => (lastPage?.length ?? 0) + limit,
1751
+ queryFn: async ({ pageParam }) => {
1752
+ if (!symbol || !username) {
1753
+ throw new Error(
1754
+ "[SDK][Wallets] \u2013 hive engine token or username missed"
1755
+ );
1756
+ }
1757
+ const url = new URL(
1758
+ `${CONFIG.privateApiHost}/private-api/engine-account-history`
1759
+ );
1760
+ url.searchParams.set("account", username);
1761
+ url.searchParams.set("symbol", symbol);
1762
+ url.searchParams.set("limit", limit.toString());
1763
+ url.searchParams.set("offset", pageParam.toString());
1764
+ const response = await fetch(url, {
1765
+ method: "GET",
1766
+ headers: { "Content-type": "application/json" }
1767
+ });
1768
+ return await response.json();
1769
+ }
1770
+ });
1771
+ }
1772
+ function getHiveEngineTokensMetricsQueryOptions(symbol, interval = "daily") {
1773
+ return queryOptions({
1774
+ queryKey: ["assets", "hive-engine", symbol],
1775
+ staleTime: 6e4,
1776
+ refetchInterval: 9e4,
1777
+ queryFn: async () => {
1778
+ const url = new URL(
1779
+ `${CONFIG.privateApiHost}/private-api/engine-chart-api`
1780
+ );
1781
+ url.searchParams.set("symbol", symbol);
1782
+ url.searchParams.set("interval", interval);
1783
+ const response = await fetch(url, {
1784
+ headers: { "Content-type": "application/json" }
1785
+ });
1786
+ return await response.json();
1787
+ }
1788
+ });
1789
+ }
1790
+ async function delegateEngineToken(payload) {
1791
+ const parsedAsset = parseAsset(payload.amount);
1792
+ const quantity = parsedAsset.amount.toString();
1793
+ if (payload.type === "key" && "key" in payload) {
1794
+ const { key, type, ...params } = payload;
1795
+ const op = {
1796
+ id: "ssc-mainnet-hive",
1797
+ json: JSON.stringify({
1798
+ contractName: "tokens",
1799
+ contractAction: "delegate",
1800
+ contractPayload: {
1801
+ symbol: params.asset,
1802
+ to: params.to,
1803
+ quantity
1804
+ }
1805
+ }),
1806
+ required_auths: [params.from],
1807
+ required_posting_auths: []
1808
+ };
1809
+ return CONFIG.hiveClient.broadcast.json(op, key);
1810
+ } else if (payload.type === "keychain") {
1811
+ return new Promise(
1812
+ (resolve, reject) => window.hive_keychain?.requestCustomJson(
1813
+ payload.from,
1814
+ "ssc-mainnet-hive",
1815
+ "Active",
1816
+ JSON.stringify({
1817
+ contractName: "tokens",
1818
+ contractAction: "delegate",
1819
+ contractPayload: {
1820
+ symbol: payload.asset,
1821
+ to: payload.to,
1822
+ quantity
1823
+ }
1824
+ }),
1825
+ "Token Delegation",
1826
+ (resp) => {
1827
+ if (!resp.success) {
1828
+ reject({ message: "Operation cancelled" });
1829
+ }
1830
+ resolve(resp);
1831
+ }
1832
+ )
1833
+ );
1834
+ } else {
1835
+ return hs.sendOperation(
1836
+ [
1837
+ "custom_json",
1838
+ {
1839
+ id: "ssc-mainnet-hive",
1840
+ required_auths: [payload.from],
1841
+ required_posting_auths: [],
1842
+ json: JSON.stringify({
1843
+ contractName: "tokens",
1844
+ contractAction: "delegate",
1845
+ contractPayload: {
1846
+ symbol: payload.asset,
1847
+ to: payload.to,
1848
+ quantity
1849
+ }
1850
+ })
1851
+ }
1852
+ ],
1853
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
1854
+ () => {
1855
+ }
1856
+ );
1857
+ }
1858
+ }
1859
+ async function undelegateEngineToken(payload) {
1860
+ const parsedAsset = parseAsset(payload.amount);
1861
+ const quantity = parsedAsset.amount.toString();
1862
+ if (payload.type === "key" && "key" in payload) {
1863
+ const { key, type, ...params } = payload;
1864
+ const op = {
1865
+ id: "ssc-mainnet-hive",
1866
+ json: JSON.stringify({
1867
+ contractName: "tokens",
1868
+ contractAction: "undelegate",
1869
+ contractPayload: {
1870
+ symbol: params.asset,
1871
+ from: params.to,
1872
+ quantity
1873
+ }
1874
+ }),
1875
+ required_auths: [params.from],
1876
+ required_posting_auths: []
1877
+ };
1878
+ return CONFIG.hiveClient.broadcast.json(op, key);
1879
+ } else if (payload.type === "keychain") {
1880
+ return new Promise(
1881
+ (resolve, reject) => window.hive_keychain?.requestCustomJson(
1882
+ payload.from,
1883
+ "ssc-mainnet-hive",
1884
+ "Active",
1885
+ JSON.stringify({
1886
+ contractName: "tokens",
1887
+ contractAction: "undelegate",
1888
+ contractPayload: {
1889
+ symbol: payload.asset,
1890
+ from: payload.to,
1891
+ quantity
1892
+ }
1893
+ }),
1894
+ "Token Undelegation",
1895
+ (resp) => {
1896
+ if (!resp.success) {
1897
+ reject({ message: "Operation cancelled" });
1898
+ }
1899
+ resolve(resp);
1900
+ }
1901
+ )
1902
+ );
1903
+ } else {
1904
+ return hs.sendOperation(
1905
+ [
1906
+ "custom_json",
1907
+ {
1908
+ id: "ssc-mainnet-hive",
1909
+ required_auths: [payload.from],
1910
+ required_posting_auths: [],
1911
+ json: JSON.stringify({
1912
+ contractName: "tokens",
1913
+ contractAction: "undelegate",
1914
+ contractPayload: {
1915
+ symbol: payload.asset,
1916
+ from: payload.to,
1917
+ quantity
1918
+ }
1919
+ })
1920
+ }
1921
+ ],
1922
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
1923
+ () => {
1924
+ }
1925
+ );
1926
+ }
1927
+ }
1928
+ async function stakeEngineToken(payload) {
1929
+ const parsedAsset = parseAsset(payload.amount);
1930
+ const quantity = parsedAsset.amount.toString();
1931
+ if (payload.type === "key" && "key" in payload) {
1932
+ const { key, type, ...params } = payload;
1933
+ const op = {
1934
+ id: "ssc-mainnet-hive",
1935
+ json: JSON.stringify({
1936
+ contractName: "tokens",
1937
+ contractAction: "stake",
1938
+ contractPayload: {
1939
+ symbol: params.asset,
1940
+ to: params.to,
1941
+ quantity
1942
+ }
1943
+ }),
1944
+ required_auths: [params.from],
1945
+ required_posting_auths: []
1946
+ };
1947
+ return CONFIG.hiveClient.broadcast.json(op, key);
1948
+ } else if (payload.type === "keychain") {
1949
+ return new Promise(
1950
+ (resolve, reject) => window.hive_keychain?.requestCustomJson(
1951
+ payload.from,
1952
+ "ssc-mainnet-hive",
1953
+ "Active",
1954
+ JSON.stringify({
1955
+ contractName: "tokens",
1956
+ contractAction: "stake",
1957
+ contractPayload: {
1958
+ symbol: payload.asset,
1959
+ to: payload.to,
1960
+ quantity
1961
+ }
1962
+ }),
1963
+ "Token Staking",
1964
+ (resp) => {
1965
+ if (!resp.success) {
1966
+ reject({ message: "Operation cancelled" });
1967
+ }
1968
+ resolve(resp);
1969
+ }
1970
+ )
1971
+ );
1972
+ } else {
1973
+ return hs.sendOperation(
1974
+ [
1975
+ "custom_json",
1976
+ {
1977
+ id: "ssc-mainnet-hive",
1978
+ required_auths: [payload.from],
1979
+ required_posting_auths: [],
1980
+ json: JSON.stringify({
1981
+ contractName: "tokens",
1982
+ contractAction: "stake",
1983
+ contractPayload: {
1984
+ symbol: payload.asset,
1985
+ to: payload.to,
1986
+ quantity
1987
+ }
1988
+ })
1989
+ }
1990
+ ],
1991
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
1992
+ () => {
1993
+ }
1994
+ );
1995
+ }
1996
+ }
1997
+ async function unstakeEngineToken(payload) {
1998
+ const parsedAsset = parseAsset(payload.amount);
1999
+ const quantity = parsedAsset.amount.toString();
2000
+ if (payload.type === "key" && "key" in payload) {
2001
+ const { key, type, ...params } = payload;
2002
+ const op = {
2003
+ id: "ssc-mainnet-hive",
2004
+ json: JSON.stringify({
2005
+ contractName: "tokens",
2006
+ contractAction: "unstake",
2007
+ contractPayload: {
2008
+ symbol: params.asset,
2009
+ to: params.to,
2010
+ quantity
2011
+ }
2012
+ }),
2013
+ required_auths: [params.from],
2014
+ required_posting_auths: []
2015
+ };
2016
+ return CONFIG.hiveClient.broadcast.json(op, key);
2017
+ } else if (payload.type === "keychain") {
2018
+ return new Promise(
2019
+ (resolve, reject) => window.hive_keychain?.requestCustomJson(
2020
+ payload.from,
2021
+ "ssc-mainnet-hive",
2022
+ "Active",
2023
+ JSON.stringify({
2024
+ contractName: "tokens",
2025
+ contractAction: "unstake",
2026
+ contractPayload: {
2027
+ symbol: payload.asset,
2028
+ to: payload.to,
2029
+ quantity
2030
+ }
2031
+ }),
2032
+ "Token Unstaking",
2033
+ (resp) => {
2034
+ if (!resp.success) {
2035
+ reject({ message: "Operation cancelled" });
2036
+ }
2037
+ resolve(resp);
2038
+ }
2039
+ )
2040
+ );
2041
+ } else {
2042
+ return hs.sendOperation(
2043
+ [
2044
+ "custom_json",
2045
+ {
2046
+ id: "ssc-mainnet-hive",
2047
+ required_auths: [payload.from],
2048
+ required_posting_auths: [],
2049
+ json: JSON.stringify({
2050
+ contractName: "tokens",
2051
+ contractAction: "unstake",
2052
+ contractPayload: {
2053
+ symbol: payload.asset,
2054
+ to: payload.to,
2055
+ quantity
2056
+ }
2057
+ })
2058
+ }
2059
+ ],
2060
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
2061
+ () => {
2062
+ }
2063
+ );
2064
+ }
2065
+ }
2066
+ async function transferEngineToken(payload) {
2067
+ const parsedAsset = parseAsset(payload.amount);
2068
+ const quantity = parsedAsset.amount.toString();
2069
+ if (payload.type === "key" && "key" in payload) {
2070
+ const { key, type, ...params } = payload;
2071
+ const op = {
2072
+ id: "ssc-mainnet-hive",
2073
+ json: JSON.stringify({
2074
+ contractName: "tokens",
2075
+ contractAction: "transfer",
2076
+ contractPayload: {
2077
+ symbol: params.asset,
2078
+ to: params.to,
2079
+ quantity,
2080
+ memo: params.memo
2081
+ }
2082
+ }),
2083
+ required_auths: [params.from],
2084
+ required_posting_auths: []
2085
+ };
2086
+ return CONFIG.hiveClient.broadcast.json(op, key);
2087
+ } else if (payload.type === "keychain") {
2088
+ return new Promise(
2089
+ (resolve, reject) => window.hive_keychain?.requestCustomJson(
2090
+ payload.from,
2091
+ "ssc-mainnet-hive",
2092
+ "Active",
2093
+ JSON.stringify({
2094
+ contractName: "tokens",
2095
+ contractAction: "transfer",
2096
+ contractPayload: {
2097
+ symbol: payload.asset,
2098
+ to: payload.to,
2099
+ quantity,
2100
+ memo: payload.memo
2101
+ }
2102
+ }),
2103
+ "Token Transfer",
2104
+ (resp) => {
2105
+ if (!resp.success) {
2106
+ reject({ message: "Operation cancelled" });
2107
+ }
2108
+ resolve(resp);
2109
+ }
2110
+ )
2111
+ );
2112
+ } else {
2113
+ return hs.sendOperation(
2114
+ [
2115
+ "custom_json",
2116
+ {
2117
+ id: "ssc-mainnet-hive",
2118
+ required_auths: [payload.from],
2119
+ required_posting_auths: [],
2120
+ json: JSON.stringify({
2121
+ contractName: "tokens",
2122
+ contractAction: "transfer",
2123
+ contractPayload: {
2124
+ symbol: payload.asset,
2125
+ to: payload.to,
2126
+ quantity,
2127
+ memo: payload.memo
2128
+ }
2129
+ })
2130
+ }
2131
+ ],
2132
+ { callback: `https://ecency.com/@${payload.from}/wallet` },
2133
+ () => {
2134
+ }
2135
+ );
2136
+ }
2137
+ }
2138
+ function getPointsQueryOptions(username) {
2139
+ return queryOptions({
2140
+ queryKey: ["assets", "points", username],
2141
+ queryFn: async () => {
2142
+ if (!username) {
2143
+ throw new Error(
2144
+ "[SDK][Wallets][Assets][Points][Query] \u2013 username wasn`t provided"
2145
+ );
2146
+ }
2147
+ const response = await fetch(
2148
+ CONFIG.privateApiHost + "/private-api/points",
2149
+ {
2150
+ method: "POST",
2151
+ headers: {
2152
+ "Content-Type": "application/json"
2153
+ },
2154
+ body: JSON.stringify({ username })
2155
+ }
2156
+ );
2157
+ const points = await response.json();
2158
+ return {
2159
+ points: points.points,
2160
+ uPoints: points.unclaimed_points
2161
+ };
2162
+ },
2163
+ staleTime: 6e4,
2164
+ refetchInterval: 9e4,
2165
+ refetchOnMount: true,
2166
+ enabled: !!username
2167
+ });
2168
+ }
2169
+ function getPointsAssetGeneralInfoQueryOptions(username) {
2170
+ return queryOptions({
2171
+ queryKey: ["assets", "points", "general-info", username],
2172
+ staleTime: 6e4,
2173
+ refetchInterval: 9e4,
2174
+ queryFn: async () => {
2175
+ await getQueryClient().prefetchQuery(getPointsQueryOptions(username));
2176
+ const data = getQueryClient().getQueryData(
2177
+ getPointsQueryOptions(username).queryKey
2178
+ );
2179
+ return {
2180
+ name: "POINTS",
2181
+ title: "Ecency Points",
2182
+ price: 2e-3,
2183
+ accountBalance: +data?.points
2184
+ };
2185
+ }
2186
+ });
2187
+ }
2188
+ function getPointsAssetTransactionsQueryOptions(username, type) {
2189
+ return queryOptions({
2190
+ queryKey: ["assets", "points", "transactions", username, type],
2191
+ queryFn: async () => {
2192
+ const response = await fetch(
2193
+ `${CONFIG.privateApiHost}/private-api/point-list`,
2194
+ {
2195
+ method: "POST",
2196
+ body: JSON.stringify({
2197
+ username,
2198
+ type: type ?? 0
2199
+ })
2200
+ }
2201
+ );
2202
+ const data = await response.json();
2203
+ return data.map(({ created, type: type2, amount, id }) => ({
2204
+ created: new Date(created),
2205
+ type: type2,
2206
+ results: [
2207
+ {
2208
+ amount: parseInt(amount),
2209
+ asset: "POINTS"
2210
+ }
2211
+ ],
2212
+ id
2213
+ }));
2214
+ }
2215
+ });
2216
+ }
2217
+
2218
+ // src/modules/assets/points/mutations/claim-points.ts
2219
+ function useClaimPoints(username, onSuccess, onError) {
2220
+ const { mutateAsync: recordActivity } = EcencyAnalytics.useRecordActivity(
2221
+ username,
2222
+ "points-claimed"
2223
+ );
2224
+ return useMutation({
2225
+ mutationFn: async () => {
2226
+ if (!username) {
2227
+ throw new Error(
2228
+ "[SDK][Wallets][Assets][Points][Claim] \u2013 username wasn`t provided"
2229
+ );
2230
+ }
2231
+ return fetch(CONFIG.privateApiHost + "/private-api/points-claim", {
2232
+ method: "POST",
2233
+ headers: {
2234
+ "Content-Type": "application/json"
2235
+ },
2236
+ body: JSON.stringify({ code: getAccessToken(username) })
2237
+ });
2238
+ },
2239
+ onError,
2240
+ onSuccess: () => {
2241
+ recordActivity();
2242
+ CONFIG.queryClient.setQueryData(
2243
+ getPointsQueryOptions(username).queryKey,
2244
+ (data) => {
2245
+ if (!data) {
2246
+ return data;
2247
+ }
2248
+ return {
2249
+ points: (parseFloat(data.points) + parseFloat(data.uPoints)).toFixed(3),
2250
+ uPoints: "0"
2251
+ };
2252
+ }
2253
+ );
2254
+ onSuccess?.();
2255
+ }
2256
+ });
2257
+ }
2258
+ async function transferPoint({
2259
+ from,
2260
+ to,
2261
+ amount,
2262
+ memo,
2263
+ type,
2264
+ ...payload
2265
+ }) {
2266
+ const op = [
2267
+ "custom_json",
2268
+ {
2269
+ id: "ecency_point_transfer",
2270
+ json: JSON.stringify({
2271
+ sender: from,
2272
+ receiver: to,
2273
+ amount: amount.replace("POINTS", "POINT"),
2274
+ memo
2275
+ }),
2276
+ required_auths: [from],
2277
+ required_posting_auths: []
2278
+ }
2279
+ ];
2280
+ if (type === "key" && "key" in payload) {
2281
+ const { key } = payload;
2282
+ return CONFIG.hiveClient.broadcast.sendOperations([op], key);
2283
+ }
2284
+ if (type === "keychain") {
2285
+ return Keychain.broadcast(from, [op], "Active");
2286
+ }
2287
+ return hs.sendOperation(
2288
+ op,
2289
+ { callback: `https://ecency.com/@${from}/wallet` },
2290
+ () => {
2291
+ }
2292
+ );
2293
+ }
2294
+
2295
+ // src/modules/assets/points/types/point-transaction-type.ts
2296
+ var PointTransactionType = /* @__PURE__ */ ((PointTransactionType2) => {
2297
+ PointTransactionType2[PointTransactionType2["CHECKIN"] = 10] = "CHECKIN";
2298
+ PointTransactionType2[PointTransactionType2["LOGIN"] = 20] = "LOGIN";
2299
+ PointTransactionType2[PointTransactionType2["CHECKIN_EXTRA"] = 30] = "CHECKIN_EXTRA";
2300
+ PointTransactionType2[PointTransactionType2["POST"] = 100] = "POST";
2301
+ PointTransactionType2[PointTransactionType2["COMMENT"] = 110] = "COMMENT";
2302
+ PointTransactionType2[PointTransactionType2["VOTE"] = 120] = "VOTE";
2303
+ PointTransactionType2[PointTransactionType2["REBLOG"] = 130] = "REBLOG";
2304
+ PointTransactionType2[PointTransactionType2["DELEGATION"] = 150] = "DELEGATION";
2305
+ PointTransactionType2[PointTransactionType2["REFERRAL"] = 160] = "REFERRAL";
2306
+ PointTransactionType2[PointTransactionType2["COMMUNITY"] = 170] = "COMMUNITY";
2307
+ PointTransactionType2[PointTransactionType2["TRANSFER_SENT"] = 998] = "TRANSFER_SENT";
2308
+ PointTransactionType2[PointTransactionType2["TRANSFER_INCOMING"] = 999] = "TRANSFER_INCOMING";
2309
+ PointTransactionType2[PointTransactionType2["MINTED"] = 991] = "MINTED";
2310
+ return PointTransactionType2;
2311
+ })(PointTransactionType || {});
2312
+ function getAllTokensListQueryOptions(query) {
2313
+ return queryOptions({
2314
+ queryKey: ["ecency-wallets", "all-tokens-list", query],
2315
+ queryFn: async () => {
2316
+ await getQueryClient().prefetchQuery(
2317
+ getHiveEngineTokensMetadataQueryOptions(HiveEngineTokens)
2318
+ );
2319
+ const metadataList = getQueryClient().getQueryData(getHiveEngineTokensMetadataQueryOptions(HiveEngineTokens).queryKey);
2320
+ return {
2321
+ basic: [
2322
+ "POINTS" /* Points */,
2323
+ "HIVE" /* Hive */,
2324
+ "HP" /* HivePower */,
2325
+ "HBD" /* HiveDollar */
2326
+ ].filter((token) => token.toLowerCase().includes(query.toLowerCase())),
2327
+ external: Object.values(EcencyWalletCurrency).filter(
2328
+ (token) => token.toLowerCase().includes(query.toLowerCase())
2329
+ ),
2330
+ spk: ["SPK" /* Spk */, "LARYNX", "LP"],
2331
+ layer2: metadataList
2332
+ };
2333
+ }
2334
+ });
2335
+ }
2336
+ function getAccountWalletListQueryOptions(username) {
2337
+ return queryOptions({
2338
+ queryKey: ["ecency-wallets", "list", username],
2339
+ enabled: !!username,
2340
+ queryFn: async () => {
2341
+ const accountQuery = getAccountFullQueryOptions(username);
2342
+ await getQueryClient().fetchQuery({
2343
+ queryKey: accountQuery.queryKey
2344
+ });
2345
+ const account = getQueryClient().getQueryData(
2346
+ accountQuery.queryKey
2347
+ );
2348
+ if (account?.profile?.tokens instanceof Array) {
2349
+ const list = [
2350
+ "POINTS" /* Points */,
2351
+ "HIVE" /* Hive */,
2352
+ "HP" /* HivePower */,
2353
+ "HBD" /* HiveDollar */,
2354
+ ...account.profile.tokens.filter(({ meta }) => !!meta?.show).map((token) => token.symbol)
2355
+ ];
2356
+ return Array.from(new Set(list).values());
2357
+ }
2358
+ return [
2359
+ "POINTS" /* Points */,
2360
+ "HIVE" /* Hive */,
2361
+ "HP" /* HivePower */,
2362
+ "HBD" /* HiveDollar */,
2363
+ "SPK" /* Spk */
2364
+ ];
2365
+ }
2366
+ });
2367
+ }
2368
+
2369
+ // src/modules/assets/external/common/parse-private-api-balance.ts
2370
+ function normalizeBalance2(balance) {
2371
+ if (typeof balance === "number") {
2372
+ if (!Number.isFinite(balance)) {
2373
+ throw new Error("Private API returned a non-finite numeric balance");
2374
+ }
2375
+ return Math.trunc(balance).toString();
2376
+ }
2377
+ if (typeof balance === "string") {
2378
+ const trimmed = balance.trim();
2379
+ if (trimmed === "") {
2380
+ throw new Error("Private API returned an empty balance string");
2381
+ }
2382
+ return trimmed;
2383
+ }
2384
+ throw new Error("Private API returned balance in an unexpected format");
2385
+ }
2386
+ function parsePrivateApiBalance2(result, expectedChain) {
2387
+ if (!result || typeof result !== "object") {
2388
+ throw new Error("Private API returned an unexpected response");
2389
+ }
2390
+ const { chain, balance, unit, raw, nodeId } = result;
2391
+ if (typeof chain !== "string" || chain !== expectedChain) {
2392
+ throw new Error("Private API response chain did not match request");
2393
+ }
2394
+ if (typeof unit !== "string" || unit.length === 0) {
2395
+ throw new Error("Private API response is missing unit information");
2396
+ }
2397
+ if (balance === void 0 || balance === null) {
2398
+ throw new Error("Private API response is missing balance information");
2399
+ }
2400
+ const balanceString = normalizeBalance2(balance);
2401
+ let balanceBigInt;
2402
+ try {
2403
+ balanceBigInt = BigInt(balanceString);
2404
+ } catch (error) {
2405
+ throw new Error("Private API returned a balance that is not an integer");
2406
+ }
2407
+ return {
2408
+ chain,
2409
+ unit,
2410
+ raw,
2411
+ nodeId: typeof nodeId === "string" && nodeId.length > 0 ? nodeId : void 0,
2412
+ balanceBigInt,
2413
+ balanceString
2414
+ };
2415
+ }
2416
+
2417
+ // src/modules/assets/external/apt/get-apt-asset-balance-query-options.ts
2418
+ function getAptAssetBalanceQueryOptions(address) {
2419
+ return queryOptions({
2420
+ queryKey: ["assets", "apt", "balance", address],
2421
+ queryFn: async () => {
2422
+ const baseUrl = `${CONFIG.privateApiHost}/private-api/balance/apt/${encodeURIComponent(
2423
+ address
2424
+ )}`;
2425
+ try {
2426
+ const response = await fetch(baseUrl);
2427
+ if (!response.ok) {
2428
+ throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
2429
+ }
2430
+ return +parsePrivateApiBalance2(await response.json(), "apt").balanceString;
2431
+ } catch (error) {
2432
+ console.error(error);
2433
+ const response = await fetch(`${baseUrl}?provider=chainz`);
2434
+ return +parsePrivateApiBalance2(await response.json(), "apt").balanceString;
2435
+ }
2436
+ }
2437
+ });
2438
+ }
2439
+ async function getAddressFromAccount(username, tokenName) {
2440
+ await CONFIG.queryClient.prefetchQuery(getAccountFullQueryOptions(username));
2441
+ const account = CONFIG.queryClient.getQueryData(
2442
+ getAccountFullQueryOptions(username).queryKey
2443
+ );
2444
+ const address = account?.profile?.tokens?.find((t) => t.symbol === tokenName)?.meta?.address;
2445
+ if (!address) {
2446
+ throw new Error(
2447
+ "[SDK][Wallets] \u2013\xA0cannot fetch APT balance with empty adrress"
2448
+ );
2449
+ }
2450
+ return address;
2451
+ }
2452
+
2453
+ // src/modules/assets/external/apt/get-apt-asset-general-info-query-options.ts
2454
+ function getAptAssetGeneralInfoQueryOptions(username) {
2455
+ return queryOptions({
2456
+ queryKey: ["assets", "apt", "general-info", username],
2457
+ staleTime: 6e4,
2458
+ refetchInterval: 9e4,
2459
+ queryFn: async () => {
2460
+ const address = await getAddressFromAccount(username, "APT");
2461
+ await CONFIG.queryClient.fetchQuery(
2462
+ getAptAssetBalanceQueryOptions(address)
2463
+ );
2464
+ const accountBalance = (CONFIG.queryClient.getQueryData(
2465
+ getAptAssetBalanceQueryOptions(address).queryKey
2466
+ ) ?? 0) / 1e8;
2467
+ await CONFIG.queryClient.prefetchQuery(
2468
+ getCoinGeckoPriceQueryOptions("APT")
2469
+ );
2470
+ const price = CONFIG.queryClient.getQueryData(
2471
+ getCoinGeckoPriceQueryOptions("APT").queryKey
2472
+ ) ?? 0;
2473
+ return {
2474
+ name: "APT",
2475
+ title: "Aptos",
2476
+ price,
2477
+ accountBalance
2478
+ };
2479
+ }
2480
+ });
2481
+ }
2482
+ function getBnbAssetBalanceQueryOptions(address) {
2483
+ return queryOptions({
2484
+ queryKey: ["assets", "bnb", "balance", address],
2485
+ queryFn: async () => {
2486
+ const baseUrl = `${CONFIG.privateApiHost}/private-api/balance/bnb/${encodeURIComponent(
2487
+ address
2488
+ )}`;
2489
+ try {
2490
+ const response = await fetch(baseUrl);
2491
+ if (!response.ok) {
2492
+ throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
2493
+ }
2494
+ return +parsePrivateApiBalance2(await response.json(), "bnb").balanceString;
2495
+ } catch (error) {
2496
+ console.error(error);
2497
+ const response = await fetch(`${baseUrl}?provider=chainz`);
2498
+ return +parsePrivateApiBalance2(await response.json(), "bnb").balanceString;
2499
+ }
2500
+ }
2501
+ });
2502
+ }
2503
+
2504
+ // src/modules/assets/external/bnb/get-bnb-asset-general-info-query-options.ts
2505
+ function getBnbAssetGeneralInfoQueryOptions(username) {
2506
+ return queryOptions({
2507
+ queryKey: ["assets", "bnb", "general-info", username],
2508
+ staleTime: 6e4,
2509
+ refetchInterval: 9e4,
2510
+ queryFn: async () => {
2511
+ const address = await getAddressFromAccount(username, "BNB");
2512
+ await CONFIG.queryClient.fetchQuery(
2513
+ getBnbAssetBalanceQueryOptions(address)
2514
+ );
2515
+ const accountBalance = (CONFIG.queryClient.getQueryData(
2516
+ getBnbAssetBalanceQueryOptions(address).queryKey
2517
+ ) ?? 0) / 1e18;
2518
+ await CONFIG.queryClient.prefetchQuery(
2519
+ getCoinGeckoPriceQueryOptions("BNB")
2520
+ );
2521
+ const price = CONFIG.queryClient.getQueryData(
2522
+ getCoinGeckoPriceQueryOptions("BNB").queryKey
2523
+ ) ?? 0;
2524
+ return {
2525
+ name: "BNB",
2526
+ title: "Binance coin",
2527
+ price,
2528
+ accountBalance
2529
+ };
2530
+ }
2531
+ });
2532
+ }
2533
+ function getBtcAssetBalanceQueryOptions(address) {
2534
+ return queryOptions({
2535
+ queryKey: ["assets", "btc", "balance", address],
2536
+ queryFn: async () => {
2537
+ const baseUrl = `${CONFIG.privateApiHost}/private-api/balance/btc/${encodeURIComponent(
2538
+ address
2539
+ )}`;
2540
+ try {
2541
+ const response = await fetch(baseUrl);
2542
+ if (!response.ok) {
2543
+ throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
2544
+ }
2545
+ return +parsePrivateApiBalance2(await response.json(), "btc").balanceString;
2546
+ } catch (error) {
2547
+ console.error(error);
2548
+ const response = await fetch(`${baseUrl}?provider=chainz`);
2549
+ return +parsePrivateApiBalance2(await response.json(), "btc").balanceString;
2550
+ }
2551
+ }
2552
+ });
2553
+ }
2554
+
2555
+ // src/modules/assets/external/btc/get-btc-asset-general-info-query-options.ts
2556
+ function getBtcAssetGeneralInfoQueryOptions(username) {
2557
+ return queryOptions({
2558
+ queryKey: ["assets", "btc", "general-info", username],
2559
+ staleTime: 6e4,
2560
+ refetchInterval: 9e4,
2561
+ queryFn: async () => {
2562
+ const address = await getAddressFromAccount(username, "BTC");
2563
+ await CONFIG.queryClient.fetchQuery(
2564
+ getBtcAssetBalanceQueryOptions(address)
2565
+ );
2566
+ const accountBalance = (CONFIG.queryClient.getQueryData(
2567
+ getBtcAssetBalanceQueryOptions(address).queryKey
2568
+ ) ?? 0) / 1e8;
2569
+ await CONFIG.queryClient.prefetchQuery(
2570
+ getCoinGeckoPriceQueryOptions("BTC")
2571
+ );
2572
+ const price = CONFIG.queryClient.getQueryData(
2573
+ getCoinGeckoPriceQueryOptions("BTC").queryKey
2574
+ ) ?? 0;
2575
+ return {
2576
+ name: "BTC",
2577
+ title: "Bitcoin",
2578
+ price,
2579
+ accountBalance
2580
+ };
2581
+ }
2582
+ });
2583
+ }
2584
+ function getEthAssetBalanceQueryOptions(address) {
2585
+ return queryOptions({
2586
+ queryKey: ["assets", "eth", "balance", address],
2587
+ queryFn: async () => {
2588
+ const baseUrl = `${CONFIG.privateApiHost}/private-api/balance/eth/${encodeURIComponent(
2589
+ address
2590
+ )}`;
2591
+ try {
2592
+ const response = await fetch(baseUrl);
2593
+ if (!response.ok) {
2594
+ throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
2595
+ }
2596
+ return +parsePrivateApiBalance2(await response.json(), "eth").balanceString;
2597
+ } catch (error) {
2598
+ console.error(error);
2599
+ const response = await fetch(`${baseUrl}?provider=chainz`);
2600
+ return +parsePrivateApiBalance2(await response.json(), "eth").balanceString;
2601
+ }
2602
+ }
2603
+ });
2604
+ }
2605
+
2606
+ // src/modules/assets/external/eth/get-eth-asset-general-info-query-options.ts
2607
+ function getEthAssetGeneralInfoQueryOptions(username) {
2608
+ return queryOptions({
2609
+ queryKey: ["assets", "eth", "general-info", username],
2610
+ staleTime: 6e4,
2611
+ refetchInterval: 9e4,
2612
+ queryFn: async () => {
2613
+ const address = await getAddressFromAccount(username, "ETH");
2614
+ await CONFIG.queryClient.fetchQuery(
2615
+ getEthAssetBalanceQueryOptions(address)
2616
+ );
2617
+ const accountBalance = (CONFIG.queryClient.getQueryData(
2618
+ getEthAssetBalanceQueryOptions(address).queryKey
2619
+ ) ?? 0) / 1e18;
2620
+ await CONFIG.queryClient.prefetchQuery(
2621
+ getCoinGeckoPriceQueryOptions("ETH")
2622
+ );
2623
+ const price = CONFIG.queryClient.getQueryData(
2624
+ getCoinGeckoPriceQueryOptions("ETH").queryKey
2625
+ ) ?? 0;
2626
+ return {
2627
+ name: "ETH",
2628
+ title: "Ethereum",
2629
+ price,
2630
+ accountBalance
2631
+ };
2632
+ }
2633
+ });
2634
+ }
2635
+ function getSolAssetBalanceQueryOptions(address) {
2636
+ return queryOptions({
2637
+ queryKey: ["assets", "sol", "balance", address],
2638
+ queryFn: async () => {
2639
+ const baseUrl = `${CONFIG.privateApiHost}/private-api/balance/sol/${encodeURIComponent(
2640
+ address
2641
+ )}`;
2642
+ try {
2643
+ const response = await fetch(baseUrl);
2644
+ if (!response.ok) {
2645
+ throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
2646
+ }
2647
+ return +parsePrivateApiBalance2(await response.json(), "sol").balanceString;
2648
+ } catch (error) {
2649
+ console.error(error);
2650
+ const response = await fetch(`${baseUrl}?provider=chainz`);
2651
+ return +parsePrivateApiBalance2(await response.json(), "sol").balanceString;
2652
+ }
2653
+ }
2654
+ });
2655
+ }
2656
+
2657
+ // src/modules/assets/external/sol/get-sol-asset-general-info-query-options.ts
2658
+ function getSolAssetGeneralInfoQueryOptions(username) {
2659
+ return queryOptions({
2660
+ queryKey: ["assets", "sol", "general-info", username],
2661
+ staleTime: 6e4,
2662
+ refetchInterval: 9e4,
2663
+ queryFn: async () => {
2664
+ const address = await getAddressFromAccount(username, "SOL");
2665
+ await CONFIG.queryClient.fetchQuery(
2666
+ getSolAssetBalanceQueryOptions(address)
2667
+ );
2668
+ const accountBalance = (CONFIG.queryClient.getQueryData(
2669
+ getSolAssetBalanceQueryOptions(address).queryKey
2670
+ ) ?? 0) / 1e9;
2671
+ await CONFIG.queryClient.prefetchQuery(
2672
+ getCoinGeckoPriceQueryOptions("SOL")
2673
+ );
2674
+ const price = CONFIG.queryClient.getQueryData(
2675
+ getCoinGeckoPriceQueryOptions("SOL").queryKey
2676
+ ) ?? 0;
2677
+ return {
2678
+ name: "SOL",
2679
+ title: "Solana",
2680
+ price,
2681
+ accountBalance
2682
+ };
2683
+ }
2684
+ });
2685
+ }
2686
+ function getTonAssetBalanceQueryOptions(address) {
2687
+ return queryOptions({
2688
+ queryKey: ["assets", "ton", "balance", address],
2689
+ queryFn: async () => {
2690
+ const baseUrl = `${CONFIG.privateApiHost}/private-api/balance/ton/${encodeURIComponent(
2691
+ address
2692
+ )}`;
2693
+ try {
2694
+ const response = await fetch(baseUrl);
2695
+ if (!response.ok) {
2696
+ throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
2697
+ }
2698
+ return +parsePrivateApiBalance2(await response.json(), "ton").balanceString;
2699
+ } catch (error) {
2700
+ console.error(error);
2701
+ const response = await fetch(`${baseUrl}?provider=chainz`);
2702
+ return +parsePrivateApiBalance2(await response.json(), "ton").balanceString;
2703
+ }
2704
+ }
2705
+ });
2706
+ }
2707
+
2708
+ // src/modules/assets/external/ton/get-ton-asset-general-info-query-options.ts
2709
+ function getTonAssetGeneralInfoQueryOptions(username) {
2710
+ return queryOptions({
2711
+ queryKey: ["assets", "ton", "general-info", username],
2712
+ staleTime: 6e4,
2713
+ refetchInterval: 9e4,
2714
+ queryFn: async () => {
2715
+ const address = await getAddressFromAccount(username, "TON");
2716
+ await CONFIG.queryClient.fetchQuery(
2717
+ getTonAssetBalanceQueryOptions(address)
2718
+ );
2719
+ const accountBalance = (CONFIG.queryClient.getQueryData(
2720
+ getTonAssetBalanceQueryOptions(address).queryKey
2721
+ ) ?? 0) / 1e9;
2722
+ await CONFIG.queryClient.prefetchQuery(
2723
+ getCoinGeckoPriceQueryOptions("TON")
2724
+ );
2725
+ const price = CONFIG.queryClient.getQueryData(
2726
+ getCoinGeckoPriceQueryOptions("TON").queryKey
2727
+ ) ?? 0;
2728
+ return {
2729
+ name: "TON",
2730
+ title: "The open network",
2731
+ price,
2732
+ accountBalance
2733
+ };
2734
+ }
2735
+ });
2736
+ }
2737
+ function getTronAssetBalanceQueryOptions(address) {
2738
+ return queryOptions({
2739
+ queryKey: ["assets", "tron", "balance", address],
2740
+ queryFn: async () => {
2741
+ const baseUrl = `${CONFIG.privateApiHost}/private-api/balance/tron/${encodeURIComponent(
2742
+ address
2743
+ )}`;
2744
+ try {
2745
+ const response = await fetch(baseUrl);
2746
+ if (!response.ok) {
2747
+ throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
2748
+ }
2749
+ return +parsePrivateApiBalance2(await response.json(), "tron").balanceString;
2750
+ } catch (error) {
2751
+ console.error(error);
2752
+ const response = await fetch(`${baseUrl}?provider=chainz`);
2753
+ return +parsePrivateApiBalance2(await response.json(), "tron").balanceString;
2754
+ }
2755
+ }
2756
+ });
2757
+ }
2758
+
2759
+ // src/modules/assets/external/tron/get-tron-asset-general-info-query-options.ts
2760
+ function getTronAssetGeneralInfoQueryOptions(username) {
2761
+ return queryOptions({
2762
+ queryKey: ["assets", "tron", "general-info", username],
2763
+ staleTime: 6e4,
2764
+ refetchInterval: 9e4,
2765
+ queryFn: async () => {
2766
+ const address = await getAddressFromAccount(username, "TRX");
2767
+ await CONFIG.queryClient.fetchQuery(
2768
+ getTronAssetBalanceQueryOptions(address)
2769
+ );
2770
+ const accountBalance = (CONFIG.queryClient.getQueryData(
2771
+ getTronAssetBalanceQueryOptions(address).queryKey
2772
+ ) ?? 0) / 1e6;
2773
+ await CONFIG.queryClient.prefetchQuery(
2774
+ getCoinGeckoPriceQueryOptions("TRX")
2775
+ );
2776
+ const price = CONFIG.queryClient.getQueryData(
2777
+ getCoinGeckoPriceQueryOptions("TRX").queryKey
2778
+ ) ?? 0;
2779
+ return {
2780
+ name: "TRX",
2781
+ title: "Tron",
2782
+ price,
2783
+ accountBalance
2784
+ };
2785
+ }
2786
+ });
2787
+ }
2788
+
2789
+ // src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts
2790
+ function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { refetch: false }) {
2791
+ const fetchQuery = async (queryOptions39) => {
2792
+ if (options2.refetch) {
2793
+ await getQueryClient().fetchQuery(queryOptions39);
2794
+ } else {
2795
+ await getQueryClient().prefetchQuery(queryOptions39);
2796
+ }
2797
+ return getQueryClient().getQueryData(
2798
+ queryOptions39.queryKey
2799
+ );
2800
+ };
2801
+ return queryOptions({
2802
+ queryKey: ["ecency-wallets", "asset-info", username, asset],
2803
+ queryFn: async () => {
2804
+ if (asset === "HIVE") {
2805
+ return fetchQuery(getHiveAssetGeneralInfoQueryOptions(username));
2806
+ } else if (asset === "HP") {
2807
+ return fetchQuery(getHivePowerAssetGeneralInfoQueryOptions(username));
2808
+ } else if (asset === "HBD") {
2809
+ return fetchQuery(getHbdAssetGeneralInfoQueryOptions(username));
2810
+ } else if (asset === "SPK") {
2811
+ return fetchQuery(getSpkAssetGeneralInfoQueryOptions(username));
2812
+ } else if (asset === "LARYNX") {
2813
+ return fetchQuery(getLarynxAssetGeneralInfoQueryOptions(username));
2814
+ } else if (asset === "LP") {
2815
+ return fetchQuery(getLarynxPowerAssetGeneralInfoQueryOptions(username));
2816
+ } else if (asset === "POINTS") {
2817
+ return fetchQuery(getPointsAssetGeneralInfoQueryOptions(username));
2818
+ } else if (asset === "APT") {
2819
+ return fetchQuery(getAptAssetGeneralInfoQueryOptions(username));
2820
+ } else if (asset === "BNB") {
2821
+ return fetchQuery(getBnbAssetGeneralInfoQueryOptions(username));
2822
+ } else if (asset === "BTC") {
2823
+ return fetchQuery(getBtcAssetGeneralInfoQueryOptions(username));
2824
+ } else if (asset === "ETH") {
2825
+ return fetchQuery(getEthAssetGeneralInfoQueryOptions(username));
2826
+ } else if (asset === "SOL") {
2827
+ return fetchQuery(getSolAssetGeneralInfoQueryOptions(username));
2828
+ } else if (asset === "TON") {
2829
+ return fetchQuery(getTonAssetGeneralInfoQueryOptions(username));
2830
+ } else if (asset === "TRX") {
2831
+ return fetchQuery(getTronAssetGeneralInfoQueryOptions(username));
2832
+ } else if (HiveEngineTokens.includes(asset)) {
2833
+ return await fetchQuery(
2834
+ getHiveEngineTokenGeneralInfoQueryOptions(username, asset)
2835
+ );
2836
+ } else {
2837
+ throw new Error(
2838
+ "[SDK][Wallets] \u2013 has requested unrecognized asset info"
2839
+ );
2840
+ }
2841
+ }
2842
+ });
2843
+ }
2844
+ function getTokenOperationsQueryOptions(token, username, isForOwner = false) {
2845
+ return queryOptions({
2846
+ queryKey: ["wallets", "token-operations", token, username, isForOwner],
2847
+ queryFn: async () => {
2848
+ switch (token) {
2849
+ case "HIVE" /* Hive */:
2850
+ return [
2851
+ "transfer" /* Transfer */,
2852
+ ...isForOwner ? [
2853
+ "transfer-saving" /* TransferToSavings */,
2854
+ "power-up" /* PowerUp */,
2855
+ "swap" /* Swap */
2856
+ ] : []
2857
+ ];
2858
+ case "HP" /* HivePower */:
2859
+ return [
2860
+ "delegate" /* Delegate */,
2861
+ ...isForOwner ? ["power-down" /* PowerDown */, "withdraw-saving" /* WithdrawRoutes */] : ["power-up" /* PowerUp */]
2862
+ ];
2863
+ case "HBD" /* HiveDollar */:
2864
+ return [
2865
+ "transfer" /* Transfer */,
2866
+ ...isForOwner ? ["transfer-saving" /* TransferToSavings */, "swap" /* Swap */] : []
2867
+ ];
2868
+ case "POINTS" /* Points */:
2869
+ return [
2870
+ "gift" /* Gift */,
2871
+ ...isForOwner ? [
2872
+ "promote" /* Promote */,
2873
+ "claim" /* Claim */,
2874
+ "buy" /* Buy */
2875
+ ] : []
2876
+ ];
2877
+ case "SPK" /* Spk */:
2878
+ return ["transfer" /* Transfer */];
2879
+ case "LARYNX":
2880
+ return [
2881
+ "transfer" /* Transfer */,
2882
+ ...isForOwner ? ["power-up" /* PowerUp */, "lock" /* LockLiquidity */] : []
2883
+ ];
2884
+ case "LP":
2885
+ return [
2886
+ "delegate" /* Delegate */,
2887
+ ...isForOwner ? ["power-down" /* PowerDown */] : []
2888
+ ];
2889
+ case "APT":
2890
+ case "BNB":
2891
+ case "BTC":
2892
+ case "ETH":
2893
+ case "SOL":
2894
+ case "TON":
2895
+ case "TRX":
2896
+ return [];
2897
+ }
2898
+ const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
2899
+ await getQueryClient().prefetchQuery(balancesListQuery);
2900
+ const balances = getQueryClient().getQueryData(
2901
+ balancesListQuery.queryKey
2902
+ );
2903
+ const tokensQuery = getHiveEngineTokensMetadataQueryOptions(
2904
+ balances?.map((b) => b.symbol) ?? []
2905
+ );
2906
+ await getQueryClient().prefetchQuery(tokensQuery);
2907
+ const tokens = getQueryClient().getQueryData(tokensQuery.queryKey);
2908
+ const balanceInfo = balances?.find((m) => m.symbol === token);
2909
+ const tokenInfo = tokens?.find((t) => t.symbol === token);
2910
+ const canDelegate = isForOwner && tokenInfo?.delegationEnabled && balanceInfo && parseFloat(balanceInfo.delegationsOut) !== parseFloat(balanceInfo.balance);
2911
+ const canUndelegate = isForOwner && parseFloat(balanceInfo?.delegationsOut ?? "0") > 0;
2912
+ const canStake = isForOwner && tokenInfo?.stakingEnabled;
2913
+ const canUnstake = isForOwner && parseFloat(balanceInfo?.stake ?? "0") > 0;
2914
+ return [
2915
+ "transfer" /* Transfer */,
2916
+ ...canDelegate ? ["delegate" /* Delegate */] : [],
2917
+ ...canUndelegate ? ["undelegate" /* Undelegate */] : [],
2918
+ ...canStake ? ["stake" /* Stake */] : [],
2919
+ ...canUnstake ? ["unstake" /* Unstake */] : []
2920
+ ];
2921
+ }
2922
+ });
2923
+ }
2924
+ var PATHS = {
2925
+ ["BTC" /* BTC */]: "m/44'/0'/0'/0/0",
2926
+ // Bitcoin (BIP44)
2927
+ ["ETH" /* ETH */]: "m/44'/60'/0'/0/0",
2928
+ // Ethereum (BIP44)
2929
+ ["BNB" /* BNB */]: "m/44'/60'/0'/0/0",
2930
+ // BNB Smart Chain (BIP44)
2931
+ ["SOL" /* SOL */]: "m/44'/501'/0'/0'",
2932
+ // Solana (BIP44)
2933
+ ["TON" /* TON */]: "m/44'/607'/0'",
2934
+ // TON (BIP44)
2935
+ ["TRX" /* TRON */]: "m/44'/195'/0'/0/0",
2936
+ // Tron (BIP44)
2937
+ ["APT" /* APT */]: "m/44'/637'/0'/0'/0'"
2938
+ // Aptos (BIP44)
2939
+ };
2940
+ function useWalletCreate(username, currency) {
2941
+ const { data: mnemonic } = useSeedPhrase(username);
2942
+ const queryClient = useQueryClient();
2943
+ const createWallet = useMutation({
2944
+ mutationKey: ["ecency-wallets", "create-wallet", username, currency],
2945
+ mutationFn: async () => {
2946
+ if (!mnemonic) {
2947
+ throw new Error("[Ecency][Wallets] - No seed to create a wallet");
2948
+ }
2949
+ const wallet = getWallet(currency);
2950
+ const privateKey = await wallet?.getDerivedPrivateKey({
2951
+ mnemonic,
2952
+ hdPath: PATHS[currency]
2953
+ });
2954
+ await delay(1e3);
2955
+ const address = await wallet?.getNewAddress({
2956
+ privateKey
2957
+ });
2958
+ return {
2959
+ privateKey,
2960
+ address: address.address,
2961
+ publicKey: address.publicKey,
2962
+ username,
2963
+ currency
2964
+ };
2965
+ },
2966
+ onSuccess: (info) => {
2967
+ queryClient.setQueryData(
2968
+ ["ecency-wallets", "wallets", info.username],
2969
+ (data) => new Map(data ? Array.from(data.entries()) : []).set(
2970
+ info.currency,
2971
+ info
2972
+ )
2973
+ );
2974
+ }
2975
+ });
2976
+ const importWallet = useCallback(() => {
2977
+ }, []);
2978
+ return {
2979
+ createWallet,
2980
+ importWallet
2981
+ };
2982
+ }
2983
+
2984
+ // src/modules/wallets/mutations/private-api/index.ts
2985
+ var private_api_exports = {};
2986
+ __export(private_api_exports, {
2987
+ useCheckWalletExistence: () => useCheckWalletExistence,
2988
+ useCreateAccountWithWallets: () => useCreateAccountWithWallets
2989
+ });
2990
+ function useCreateAccountWithWallets(username) {
2991
+ const { data } = useQuery({
2992
+ queryKey: ["ecency-wallets", "wallets", username]
2993
+ });
2994
+ const { data: hiveKeys } = useHiveKeysQuery(username);
2995
+ return useMutation({
2996
+ mutationKey: ["ecency-wallets", "create-account-with-wallets", username],
2997
+ mutationFn: ({ currency, address }) => fetch(CONFIG.privateApiHost + "/private-api/wallets-add", {
2998
+ method: "POST",
2999
+ headers: {
3000
+ "Content-Type": "application/json"
3001
+ },
3002
+ body: JSON.stringify({
3003
+ username,
3004
+ token: currency,
3005
+ address,
3006
+ meta: {
3007
+ ownerPublicKey: hiveKeys?.ownerPubkey,
3008
+ activePublicKey: hiveKeys?.activePubkey,
3009
+ postingPublicKey: hiveKeys?.postingPubkey,
3010
+ memoPublicKey: hiveKeys?.memoPubkey,
3011
+ ...Array.from(data?.entries() ?? []).reduce(
3012
+ (acc, [curr, info]) => ({
3013
+ ...acc,
3014
+ [curr]: info.address
3015
+ }),
3016
+ {}
3017
+ )
3018
+ }
3019
+ })
3020
+ })
3021
+ });
3022
+ }
3023
+ function useCheckWalletExistence() {
3024
+ return useMutation({
3025
+ mutationKey: ["ecency-wallets", "check-wallet-existence"],
3026
+ mutationFn: async ({ address, currency }) => {
3027
+ const response = await fetch(
3028
+ CONFIG.privateApiHost + "/private-api/wallets-exist",
3029
+ {
3030
+ method: "POST",
3031
+ headers: {
3032
+ "Content-Type": "application/json"
3033
+ },
3034
+ body: JSON.stringify({
3035
+ address,
3036
+ token: currency
3037
+ })
3038
+ }
3039
+ );
3040
+ const data = await response.json();
3041
+ return data.length === 0;
3042
+ }
3043
+ });
3044
+ }
3045
+
3046
+ // src/modules/wallets/functions/get-keys-from-seed.ts
3047
+ var HD_PATHS = {
3048
+ ["BTC" /* BTC */]: ["m/84'/0'/0'/0/0"],
3049
+ ["ETH" /* ETH */]: ["m/84'/60'/0'/0/0"],
3050
+ // its not working for Trust, Exodus, todo: check others below
3051
+ ["BNB" /* BNB */]: ["m/84'/60'/0'/0/0"],
3052
+ ["SOL" /* SOL */]: ["m/84'/501'/0'/0/0"],
3053
+ ["TRX" /* TRON */]: ["m/44'/195'/0'/0'/0'"],
3054
+ ["APT" /* APT */]: ["m/84'/637'/0'/0/0"],
3055
+ ["TON" /* TON */]: ["m/44'/607'/0'"]
3056
+ };
3057
+ async function getKeysFromSeed(mnemonic, wallet, currency) {
3058
+ for (const hdPath of HD_PATHS[currency] || []) {
3059
+ try {
3060
+ const derivedPrivateKey = await wallet.getDerivedPrivateKey({
3061
+ mnemonic,
3062
+ hdPath
3063
+ });
3064
+ const derivedPublicKey = await wallet.getNewAddress({
3065
+ privateKey: derivedPrivateKey,
3066
+ addressType: currency === "BTC" /* BTC */ ? "segwit_native" : void 0
3067
+ });
3068
+ return [derivedPrivateKey.toString(), derivedPublicKey.address];
3069
+ } catch (error) {
3070
+ return [];
3071
+ }
3072
+ }
3073
+ return [];
3074
+ }
3075
+ function useImportWallet(username, currency) {
3076
+ const queryClient = useQueryClient();
3077
+ const { mutateAsync: checkWalletExistence } = private_api_exports.useCheckWalletExistence();
3078
+ return useMutation({
3079
+ mutationKey: ["ecency-wallets", "import-wallet", username, currency],
3080
+ mutationFn: async ({ privateKeyOrSeed }) => {
3081
+ const wallet = getWallet(currency);
3082
+ if (!wallet) {
3083
+ throw new Error("Cannot find token for this currency");
3084
+ }
3085
+ const isSeed = privateKeyOrSeed.split(" ").length === 12;
3086
+ let address;
3087
+ let privateKey = privateKeyOrSeed;
3088
+ if (isSeed) {
3089
+ [privateKey, address] = await getKeysFromSeed(
3090
+ privateKeyOrSeed,
3091
+ wallet,
3092
+ currency
3093
+ );
3094
+ } else {
3095
+ address = (await wallet.getNewAddress({
3096
+ privateKey: privateKeyOrSeed
3097
+ })).address;
3098
+ }
3099
+ if (!address || !privateKeyOrSeed) {
3100
+ throw new Error(
3101
+ "Private key/seed phrase isn't matching with public key or token"
3102
+ );
3103
+ }
3104
+ const hasChecked = await checkWalletExistence({
3105
+ address,
3106
+ currency
3107
+ });
3108
+ if (!hasChecked) {
3109
+ throw new Error(
3110
+ "This wallet has already in use by Hive account. Please, try another one"
3111
+ );
3112
+ }
3113
+ return {
3114
+ privateKey,
3115
+ address,
3116
+ publicKey: ""
3117
+ };
3118
+ },
3119
+ onSuccess: ({ privateKey, publicKey, address }) => {
3120
+ queryClient.setQueryData(
3121
+ ["ecency-wallets", "wallets", username],
3122
+ (data) => new Map(data ? Array.from(data.entries()) : []).set(currency, {
3123
+ privateKey,
3124
+ publicKey,
3125
+ address,
3126
+ username,
3127
+ currency,
3128
+ type: "CHAIN",
3129
+ custom: true
3130
+ })
3131
+ );
3132
+ }
3133
+ });
3134
+ }
3135
+ function getGroupedChainTokens(tokens, show = false) {
3136
+ if (!tokens) {
3137
+ return {};
3138
+ }
3139
+ return R.pipe(
3140
+ tokens,
3141
+ R.filter(
3142
+ ({ type, symbol }) => type === "CHAIN" || Object.values(EcencyWalletCurrency).includes(symbol)
3143
+ ),
3144
+ R.map((item) => {
3145
+ item.meta.show = show;
3146
+ return item;
3147
+ }),
3148
+ // Chain tokens are unique by symbol, so indexing by symbol
3149
+ // gives a direct lookup map instead of an array-based grouping.
3150
+ R.indexBy(
3151
+ (item) => item.symbol
3152
+ )
3153
+ );
3154
+ }
3155
+ function useSaveWalletInformationToMetadata(username, options2) {
3156
+ const queryClient = useQueryClient();
3157
+ const { data: accountData } = useQuery(getAccountFullQueryOptions(username));
3158
+ const { mutateAsync: updateProfile } = useAccountUpdate(username);
3159
+ return useMutation({
3160
+ mutationKey: [
3161
+ "ecency-wallets",
3162
+ "save-wallet-to-metadata",
3163
+ accountData?.name
3164
+ ],
3165
+ mutationFn: async (tokens) => {
3166
+ if (!accountData) {
3167
+ throw new Error("[SDK][Wallets] \u2013 no account data to save wallets");
3168
+ }
3169
+ const profileChainTokens = getGroupedChainTokens(
3170
+ accountData.profile?.tokens
3171
+ );
3172
+ console.log("profile tokens are ", profileChainTokens);
3173
+ const payloadTokens = tokens.map(({ currency, type, privateKey, username: username2, ...meta }) => ({
3174
+ symbol: currency,
3175
+ type: type ?? Object.values(EcencyWalletCurrency).includes(currency) ? "CHAIN" : void 0,
3176
+ meta
3177
+ })) ?? [];
3178
+ const payloadChainTokens = getGroupedChainTokens(payloadTokens, true);
3179
+ const payloadNonChainTokens = payloadTokens.filter(
3180
+ ({ type, symbol }) => type !== "CHAIN" && !Object.values(EcencyWalletCurrency).includes(symbol)
3181
+ );
3182
+ console.log("payload tokens are ", payloadChainTokens);
3183
+ console.log("payload non-chain tokens are ", payloadNonChainTokens);
3184
+ const mergedChainTokens = R.pipe(
3185
+ profileChainTokens,
3186
+ R.mergeDeep(payloadChainTokens),
3187
+ R.values()
3188
+ );
3189
+ return updateProfile({
3190
+ tokens: [
3191
+ ...payloadNonChainTokens,
3192
+ ...mergedChainTokens
3193
+ ]
3194
+ });
3195
+ },
3196
+ onError: options2?.onError,
3197
+ onSuccess: (response, vars, context) => {
3198
+ options2?.onSuccess?.(response, vars, context);
3199
+ queryClient.invalidateQueries({
3200
+ queryKey: getAccountWalletListQueryOptions(username).queryKey
3201
+ });
3202
+ }
3203
+ });
3204
+ }
3205
+ var operationToFunctionMap = {
3206
+ HIVE: {
3207
+ ["transfer" /* Transfer */]: transferHive,
3208
+ ["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
3209
+ ["power-up" /* PowerUp */]: powerUpHive
3210
+ },
3211
+ HBD: {
3212
+ ["transfer" /* Transfer */]: transferHive,
3213
+ ["transfer-saving" /* TransferToSavings */]: transferToSavingsHive
3214
+ },
3215
+ HP: {
3216
+ ["power-down" /* PowerDown */]: powerDownHive,
3217
+ ["delegate" /* Delegate */]: delegateHive,
3218
+ ["withdraw-saving" /* WithdrawRoutes */]: withdrawVestingRouteHive
3219
+ },
3220
+ POINTS: {
3221
+ ["gift" /* Gift */]: transferPoint
3222
+ },
3223
+ SPK: {
3224
+ ["transfer" /* Transfer */]: transferSpk
3225
+ },
3226
+ LARYNX: {
3227
+ ["lock" /* LockLiquidity */]: lockLarynx,
3228
+ ["power-up" /* PowerUp */]: powerUpLarynx
3229
+ }
3230
+ };
3231
+ var engineOperationToFunctionMap = {
3232
+ ["transfer" /* Transfer */]: transferEngineToken,
3233
+ ["stake" /* Stake */]: stakeEngineToken,
3234
+ ["unstake" /* Unstake */]: unstakeEngineToken,
3235
+ ["delegate" /* Delegate */]: delegateEngineToken,
3236
+ ["undelegate" /* Undelegate */]: undelegateEngineToken
3237
+ };
3238
+ function useWalletOperation(username, asset, operation) {
3239
+ const { mutateAsync: recordActivity } = EcencyAnalytics.useRecordActivity(
3240
+ username,
3241
+ operation
3242
+ );
3243
+ return useMutation({
3244
+ mutationKey: ["ecency-wallets", asset, operation],
3245
+ mutationFn: async (payload) => {
3246
+ const operationFn = operationToFunctionMap[asset][operation];
3247
+ if (operationFn) {
3248
+ return operationFn(payload);
3249
+ }
3250
+ const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
3251
+ await getQueryClient().prefetchQuery(balancesListQuery);
3252
+ const balances = getQueryClient().getQueryData(
3253
+ balancesListQuery.queryKey
3254
+ );
3255
+ if (balances?.some((b) => b.symbol === asset)) {
3256
+ const operationFn2 = engineOperationToFunctionMap[operation];
3257
+ if (operationFn2) {
3258
+ return operationFn2({ ...payload, asset });
3259
+ }
3260
+ }
3261
+ throw new Error("[SDK][Wallets] \u2013 no operation for given asset");
3262
+ },
3263
+ onSuccess: () => {
3264
+ recordActivity();
3265
+ const query = getAccountWalletAssetInfoQueryOptions(username, asset, {
3266
+ refetch: true
3267
+ });
3268
+ setTimeout(
3269
+ () => getQueryClient().invalidateQueries({
3270
+ queryKey: query.queryKey
3271
+ }),
3272
+ 5e3
3273
+ );
3274
+ }
3275
+ });
3276
+ }
3277
+
3278
+ // src/index.ts
3279
+ rememberScryptBsvVersion();
3280
+
3281
+ export { AssetOperation, EcencyWalletBasicTokens, EcencyWalletCurrency, private_api_exports as EcencyWalletsPrivateApi, NaiMap, PointTransactionType, Symbol2 as Symbol, buildAptTx, buildEthTx, buildExternalTx, buildPsbt, buildSolTx, buildTonTx, buildTronTx, decryptMemoWithAccounts, decryptMemoWithKeys, delay, delegateEngineToken, delegateHive, deriveHiveKey, deriveHiveKeys, deriveHiveMasterPasswordKey, deriveHiveMasterPasswordKeys, detectHiveKeyDerivation, encryptMemoWithAccounts, encryptMemoWithKeys, getAccountWalletAssetInfoQueryOptions, getAccountWalletListQueryOptions, getAllTokensListQueryOptions, getCoinGeckoPriceQueryOptions, getHbdAssetGeneralInfoQueryOptions, getHbdAssetTransactionsQueryOptions, getHiveAssetGeneralInfoQueryOptions, getHiveAssetMetricQueryOptions, getHiveAssetTransactionsQueryOptions, getHiveAssetWithdrawalRoutesQueryOptions, getHiveEngineTokenGeneralInfoQueryOptions, getHiveEngineTokenTransactionsQueryOptions, getHiveEngineTokensBalancesQueryOptions, getHiveEngineTokensMarketQueryOptions, getHiveEngineTokensMetadataQueryOptions, getHiveEngineTokensMetricsQueryOptions, getHivePowerAssetGeneralInfoQueryOptions, getHivePowerAssetTransactionsQueryOptions, getHivePowerDelegatesInfiniteQueryOptions, getHivePowerDelegatingsQueryOptions, getLarynxAssetGeneralInfoQueryOptions, getLarynxPowerAssetGeneralInfoQueryOptions, getPointsAssetGeneralInfoQueryOptions, getPointsAssetTransactionsQueryOptions, getPointsQueryOptions, getSpkAssetGeneralInfoQueryOptions, getSpkMarketsQueryOptions, getTokenOperationsQueryOptions, getWallet, isEmptyDate, lockLarynx, mnemonicToSeedBip39, parseAsset, powerDownHive, powerUpHive, powerUpLarynx, rewardSpk, signDigest, signExternalTx, signExternalTxAndBroadcast, signTx, signTxAndBroadcast, stakeEngineToken, transferEngineToken, transferHive, transferPoint, transferSpk, transferToSavingsHive, undelegateEngineToken, unstakeEngineToken, useClaimPoints, useClaimRewards, useGetExternalWalletBalanceQuery, useHiveKeysQuery, useImportWallet, useSaveWalletInformationToMetadata, useSeedPhrase, useWalletCreate, useWalletOperation, vestsToHp, withdrawVestingRouteHive };
3282
+ //# sourceMappingURL=index.mjs.map
3283
+ //# sourceMappingURL=index.mjs.map