@ecency/wallets 1.2.24 → 1.3.1

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 (89) hide show
  1. package/dist/ecency-sdk.es.js +1885 -257
  2. package/dist/modules/assets/hive/consts/hive-account-operation-groups.d.ts +2 -0
  3. package/dist/modules/assets/hive/consts/index.d.ts +1 -0
  4. package/dist/modules/assets/hive/index.d.ts +2 -0
  5. package/dist/modules/assets/hive/mutations/delegate.d.ts +13 -0
  6. package/dist/modules/assets/hive/mutations/index.d.ts +6 -0
  7. package/dist/modules/assets/hive/mutations/power-down.d.ts +11 -0
  8. package/dist/modules/assets/hive/mutations/power-up.d.ts +13 -0
  9. package/dist/modules/assets/hive/mutations/transfer-to-savings.d.ts +13 -0
  10. package/dist/modules/assets/hive/mutations/transfer.d.ts +12 -0
  11. package/dist/modules/assets/hive/mutations/withdraw-route.d.ts +13 -0
  12. package/dist/modules/assets/hive/queries/get-hbd-asset-general-info-query-options.d.ts +76 -0
  13. package/dist/modules/assets/hive/queries/get-hbd-asset-transactions-query-options.d.ts +9 -0
  14. package/dist/modules/assets/hive/queries/get-hive-asset-general-info-query-options.d.ts +28 -0
  15. package/dist/modules/assets/hive/queries/get-hive-asset-metric-query-options.d.ts +43 -0
  16. package/dist/modules/assets/hive/queries/get-hive-asset-transactions-query-options.d.ts +9 -0
  17. package/dist/modules/assets/hive/queries/get-hive-asset-withdrawal-routes-query-options.d.ts +9 -0
  18. package/dist/modules/assets/hive/queries/get-hive-power-asset-general-info-query-options.d.ts +76 -0
  19. package/dist/modules/assets/hive/queries/get-hive-power-asset-transactions-query-options.d.ts +9 -0
  20. package/dist/modules/assets/hive/queries/index.d.ts +8 -0
  21. package/dist/modules/assets/hive/types/hive-market-metric.d.ts +19 -0
  22. package/dist/modules/assets/hive/types/hive-operation-group.d.ts +1 -0
  23. package/dist/modules/assets/hive/types/hive-transaction.d.ts +198 -0
  24. package/dist/modules/assets/hive/types/hive-withdraw-route.d.ts +7 -0
  25. package/dist/modules/assets/hive/types/index.d.ts +4 -0
  26. package/dist/modules/assets/hive-engine/index.d.ts +3 -0
  27. package/dist/modules/assets/hive-engine/mutations/delegate.d.ts +12 -0
  28. package/dist/modules/assets/hive-engine/mutations/index.d.ts +5 -0
  29. package/dist/modules/assets/hive-engine/mutations/stake.d.ts +12 -0
  30. package/dist/modules/assets/hive-engine/mutations/transfer.d.ts +13 -0
  31. package/dist/modules/assets/hive-engine/mutations/undelegate.d.ts +12 -0
  32. package/dist/modules/assets/hive-engine/mutations/unstake.d.ts +12 -0
  33. package/dist/modules/assets/hive-engine/queries/get-hive-engine-token-general-info-query-options.d.ts +32 -0
  34. package/dist/modules/assets/hive-engine/queries/get-hive-engine-token-metrics-query-options.d.ts +9 -0
  35. package/dist/modules/assets/hive-engine/queries/get-hive-engine-token-transactions-query-options.d.ts +9 -0
  36. package/dist/modules/assets/hive-engine/queries/get-hive-engine-tokens-balances-query-options.d.ts +9 -0
  37. package/dist/modules/assets/hive-engine/queries/get-hive-engine-tokens-market-query-options.d.ts +9 -0
  38. package/dist/modules/assets/hive-engine/queries/get-hive-engine-tokens-metadata-query-options.d.ts +9 -0
  39. package/dist/modules/assets/hive-engine/queries/index.d.ts +6 -0
  40. package/dist/modules/assets/hive-engine/types/hive-engine-list-response.d.ts +13 -0
  41. package/dist/modules/assets/hive-engine/types/hive-engine-metric.d.ts +9 -0
  42. package/dist/modules/assets/hive-engine/types/hive-engine-token-balance.d.ts +10 -0
  43. package/dist/modules/assets/hive-engine/types/hive-engine-token-metadata-response.d.ts +16 -0
  44. package/dist/modules/assets/hive-engine/types/hive-engine-transaction.d.ts +14 -0
  45. package/dist/modules/assets/hive-engine/types/index.d.ts +6 -0
  46. package/dist/modules/assets/index.d.ts +5 -0
  47. package/dist/modules/assets/points/mutations/gift.d.ts +14 -0
  48. package/dist/modules/assets/points/mutations/index.d.ts +1 -0
  49. package/dist/modules/assets/points/queries/get-points-asset-general-info-query-options.d.ts +28 -0
  50. package/dist/modules/assets/points/queries/get-points-asset-transactions-query-options.d.ts +41 -0
  51. package/dist/modules/assets/points/queries/index.d.ts +2 -0
  52. package/dist/modules/assets/points/types/index.d.ts +2 -0
  53. package/dist/modules/assets/points/types/point-transaction-type.d.ts +15 -0
  54. package/dist/modules/assets/points/types/point-transaction.d.ts +10 -0
  55. package/dist/modules/assets/spk/index.d.ts +2 -0
  56. package/dist/modules/assets/spk/mutations/index.d.ts +4 -0
  57. package/dist/modules/assets/spk/mutations/lock.d.ts +12 -0
  58. package/dist/modules/assets/spk/mutations/power-up.d.ts +12 -0
  59. package/dist/modules/assets/spk/mutations/transfer.d.ts +14 -0
  60. package/dist/modules/assets/spk/queries/get-larynx-asset-general-info-query-options.d.ts +56 -0
  61. package/dist/modules/assets/spk/queries/get-larynx-power-asset-general-info-query-options.d.ts +76 -0
  62. package/dist/modules/assets/spk/queries/get-spk-asset-general-info-query-options.d.ts +28 -0
  63. package/dist/modules/assets/spk/queries/get-spk-markets-query-options.d.ts +33 -0
  64. package/dist/modules/assets/spk/queries/get-spk-wallet-query-options.d.ts +9 -0
  65. package/dist/modules/assets/spk/queries/index.d.ts +4 -0
  66. package/dist/modules/assets/types/asset-operation.d.ts +17 -0
  67. package/dist/modules/assets/types/general-asset-info.d.ts +12 -0
  68. package/dist/modules/assets/types/general-asset-transaction.d.ts +13 -0
  69. package/dist/modules/assets/types/hive-based-asset-sign-type.d.ts +1 -0
  70. package/dist/modules/assets/types/index.d.ts +5 -0
  71. package/dist/modules/assets/types/spk-wallet.d.ts +60 -0
  72. package/dist/modules/assets/utils/index.d.ts +4 -0
  73. package/dist/modules/assets/utils/is-empty-date.d.ts +1 -0
  74. package/dist/modules/assets/utils/parse-asset.d.ts +17 -0
  75. package/dist/modules/assets/utils/reward-spk.d.ts +2 -0
  76. package/dist/modules/assets/utils/vests-to-hp.d.ts +1 -0
  77. package/dist/modules/wallets/consts/hive-engine-tokens.d.ts +1 -0
  78. package/dist/modules/wallets/consts/index.d.ts +1 -0
  79. package/dist/modules/wallets/mutations/change-assets-list.d.ts +1 -0
  80. package/dist/modules/wallets/mutations/index.d.ts +2 -0
  81. package/dist/modules/wallets/mutations/wallet-operation.d.ts +2 -0
  82. package/dist/modules/wallets/queries/get-account-wallet-asset-info-query-options.d.ts +13 -0
  83. package/dist/modules/wallets/queries/get-all-tokens-list-query-options.d.ts +26 -0
  84. package/dist/modules/wallets/queries/get-tokens-operations-query-options.d.ts +9 -0
  85. package/dist/modules/wallets/queries/index.d.ts +4 -2
  86. package/dist/modules/wallets/queries/use-get-account-wallet-list-query.d.ts +3 -4
  87. package/package.json +3 -2
  88. package/dist/modules/wallets/queries/get-account-points-query-options.d.ts +0 -9
  89. package/dist/modules/wallets/queries/use-get-all-tokens-list-query.d.ts +0 -6
@@ -1,55 +1,57 @@
1
- import { useMemo as S, useCallback as R } from "react";
2
- import { useQuery as m, queryOptions as h, useQueryClient as T, useMutation as y } from "@tanstack/react-query";
3
- import { BtcWallet as k } from "@okxweb3/coin-bitcoin";
4
- import { EthWallet as C } from "@okxweb3/coin-ethereum";
5
- import { TrxWallet as H } from "@okxweb3/coin-tron";
6
- import { TonWallet as K } from "@okxweb3/coin-ton";
7
- import { SolWallet as N } from "@okxweb3/coin-solana";
8
- import { AtomWallet as D } from "@okxweb3/coin-cosmos";
9
- import { AptosWallet as j } from "@okxweb3/coin-aptos";
10
- import L from "bip39";
11
- import { CONFIG as l, getHiveEngineTokensListQueryOptions as F, useAccountUpdate as x, EcencyAnalytics as q, getAccessToken as E } from "@ecency/sdk";
12
- import { LRUCache as M } from "lru-cache";
13
- import { PrivateKey as d } from "@hiveio/dhive";
14
- var n = /* @__PURE__ */ ((e) => (e.BTC = "BTC", e.ETH = "ETH", e.APT = "APT", e.ATOM = "ATOM", e.TON = "TON", e.TRON = "TRX", e.SOL = "SOL", e))(n || {}), u = /* @__PURE__ */ ((e) => (e.Points = "POINTS", e.HivePower = "HP", e.Hive = "HIVE", e.HiveDollar = "HBD", e.Spk = "SPK", e))(u || {});
15
- function _(e) {
1
+ import { useCallback as se } from "react";
2
+ import { useQuery as E, queryOptions as h, infiniteQueryOptions as R, useMutation as O, useQueryClient as G } from "@tanstack/react-query";
3
+ import { BtcWallet as ae } from "@okxweb3/coin-bitcoin";
4
+ import { EthWallet as oe } from "@okxweb3/coin-ethereum";
5
+ import { TrxWallet as ie } from "@okxweb3/coin-tron";
6
+ import { TonWallet as ce } from "@okxweb3/coin-ton";
7
+ import { SolWallet as ue } from "@okxweb3/coin-solana";
8
+ import { AtomWallet as le } from "@okxweb3/coin-cosmos";
9
+ import { AptosWallet as fe } from "@okxweb3/coin-aptos";
10
+ import me from "bip39";
11
+ import { CONFIG as l, getQueryClient as i, getDynamicPropsQueryOptions as N, getAccountFullQueryOptions as T, Keychain as b, EcencyAnalytics as W, getAccessToken as ye, useAccountUpdate as pe } from "@ecency/sdk";
12
+ import { LRUCache as he } from "lru-cache";
13
+ import { PrivateKey as C, utils as A } from "@hiveio/dhive";
14
+ import Q from "dayjs";
15
+ import d from "hivesigner";
16
+ var m = /* @__PURE__ */ ((e) => (e.BTC = "BTC", e.ETH = "ETH", e.APT = "APT", e.ATOM = "ATOM", e.TON = "TON", e.TRON = "TRX", e.SOL = "SOL", e))(m || {}), w = /* @__PURE__ */ ((e) => (e.Points = "POINTS", e.HivePower = "HP", e.Hive = "HIVE", e.HiveDollar = "HBD", e.Spk = "SPK", e))(w || {});
17
+ function ge(e) {
16
18
  return new Promise((t) => setTimeout(t, e));
17
19
  }
18
- function P(e) {
20
+ function Y(e) {
19
21
  switch (e) {
20
- case n.BTC:
21
- return new k();
22
- case n.ETH:
23
- return new C();
24
- case n.TRON:
25
- return new H();
26
- case n.TON:
27
- return new K();
28
- case n.SOL:
29
- return new N();
30
- case n.ATOM:
31
- return new D();
32
- case n.APT:
33
- return new j();
22
+ case m.BTC:
23
+ return new ae();
24
+ case m.ETH:
25
+ return new oe();
26
+ case m.TRON:
27
+ return new ie();
28
+ case m.TON:
29
+ return new ce();
30
+ case m.SOL:
31
+ return new ue();
32
+ case m.ATOM:
33
+ return new le();
34
+ case m.APT:
35
+ return new fe();
34
36
  default:
35
37
  return;
36
38
  }
37
39
  }
38
- function we(e, t) {
39
- return m({
40
+ function gt(e, t) {
41
+ return E({
40
42
  queryKey: ["ecency-wallets", "external-wallet-balance", e, t],
41
43
  queryFn: async () => {
42
44
  switch (e) {
43
- case n.BTC:
44
- const s = await (await fetch(
45
+ case m.BTC:
46
+ const r = await (await fetch(
45
47
  `https://mempool.space/api/address/${t}`
46
48
  )).json();
47
- return (s.chain_stats.funded_txo_sum - s.chain_stats.spent_txo_sum) / 1e8;
48
- case n.ETH:
49
+ return (r.chain_stats.funded_txo_sum - r.chain_stats.spent_txo_sum) / 1e8;
50
+ case m.ETH:
49
51
  return +(await (await fetch(
50
52
  `https://api.ethplorer.io/getAddressInfo/${t}?apiKey=freekey`
51
53
  )).json()).ETH.balance;
52
- case n.SOL:
54
+ case m.SOL:
53
55
  return (await (await fetch(
54
56
  `https://rpc.helius.xyz/?api-key=${l.heliusApiKey}`,
55
57
  {
@@ -65,22 +67,22 @@ function we(e, t) {
65
67
  }
66
68
  }
67
69
  )).json()).result.value / 1e9;
68
- case n.TRON:
70
+ case m.TRON:
69
71
  return (await (await fetch(
70
72
  `https://api.trongrid.io/v1/accounts/${t}`
71
73
  )).json()).data[0].balance / 1e6;
72
- case n.TON:
74
+ case m.TON:
73
75
  return (await (await fetch(
74
76
  `https://tonapi.io/v1/blockchain/getAccount?account=${t}`
75
77
  )).json()).balance / 1e9;
76
- case n.APT:
77
- const f = (await (await fetch(
78
+ case m.APT:
79
+ const P = (await (await fetch(
78
80
  `https://fullnode.mainnet.aptoslabs.com/v1/accounts/${t}/resources`
79
81
  )).json()).find(
80
- (A) => A.type.includes("coin::CoinStore")
82
+ (re) => re.type.includes("coin::CoinStore")
81
83
  );
82
- return f ? parseInt(f.data.coin.value) / 1e8 : 0;
83
- case n.ATOM:
84
+ return P ? parseInt(P.data.coin.value) / 1e8 : 0;
85
+ case m.ATOM:
84
86
  return +(await (await fetch(
85
87
  `https://rest.cosmos.directory/cosmoshub/auth/accounts/${t}`
86
88
  )).json()).result.value.coins[0].amount / 1e6;
@@ -88,13 +90,13 @@ function we(e, t) {
88
90
  }
89
91
  });
90
92
  }
91
- function b(e) {
92
- return m({
93
+ function X(e) {
94
+ return E({
93
95
  queryKey: ["ecency-wallets", "seed", e],
94
- queryFn: async () => L.generateMnemonic(128)
96
+ queryFn: async () => me.generateMnemonic(128)
95
97
  });
96
98
  }
97
- const Q = {
99
+ const we = {
98
100
  max: 500,
99
101
  // how long to live in ms
100
102
  ttl: 1e3 * 60 * 5,
@@ -102,36 +104,36 @@ const Q = {
102
104
  allowStale: !1,
103
105
  updateAgeOnGet: !1,
104
106
  updateAgeOnHas: !1
105
- }, g = new M(Q), w = Symbol("undefined"), W = (e, t) => g.set(e, t === void 0 ? w : t), I = (e) => {
106
- const t = g.get(e);
107
- return t === w ? void 0 : t;
107
+ }, z = new he(we), J = Symbol("undefined"), de = (e, t) => z.set(e, t === void 0 ? J : t), _e = (e) => {
108
+ const t = z.get(e);
109
+ return t === J ? void 0 : t;
108
110
  };
109
- function fe(e) {
110
- return m({
111
+ function wt(e) {
112
+ return E({
111
113
  queryKey: ["ecency-wallets", "coingecko-price", e],
112
114
  queryFn: async () => {
113
115
  let t = e;
114
116
  switch (e) {
115
- case n.BTC:
117
+ case m.BTC:
116
118
  t = "binance-wrapped-btc";
117
119
  break;
118
- case n.ETH:
120
+ case m.ETH:
119
121
  t = "ethereum";
120
122
  break;
121
- case n.SOL:
123
+ case m.SOL:
122
124
  t = "solana";
123
125
  break;
124
- case n.TON:
126
+ case m.TON:
125
127
  t = "trx";
126
128
  break;
127
129
  default:
128
130
  t = e;
129
131
  }
130
- let o = I("gecko"), s;
131
- if (o)
132
- s = o;
132
+ let n = _e("gecko"), r;
133
+ if (n)
134
+ r = n;
133
135
  else {
134
- const i = await (await fetch(
136
+ const o = await (await fetch(
135
137
  "https://api.coingecko.com/api/v3/simple/price",
136
138
  {
137
139
  method: "POST",
@@ -143,152 +145,1708 @@ function fe(e) {
143
145
  })
144
146
  }
145
147
  )).json();
146
- W("gecko", i === void 0 ? w : i), s = i;
148
+ de("gecko", o === void 0 ? J : o), r = o;
147
149
  }
148
- return 1 / +s[Object.keys(s)[0]].usd;
150
+ return 1 / +r[Object.keys(r)[0]].usd;
149
151
  },
150
152
  enabled: !!e
151
153
  });
152
154
  }
153
- function B(e) {
154
- const { data: t } = b(e);
155
- return m({
155
+ function ve(e) {
156
+ const { data: t } = X(e);
157
+ return E({
156
158
  queryKey: ["ecencу-wallets", "hive-keys", e, t],
157
159
  staleTime: 1 / 0,
158
160
  queryFn: async () => {
159
161
  if (!t)
160
162
  throw new Error("[Ecency][Wallets] - no seed to create Hive account");
161
- const o = d.fromLogin(e, t, "owner"), s = d.fromLogin(e, t, "active"), a = d.fromLogin(e, t, "posting"), c = d.fromLogin(e, t, "memo");
163
+ const n = C.fromLogin(e, t, "owner"), r = C.fromLogin(e, t, "active"), s = C.fromLogin(e, t, "posting"), a = C.fromLogin(e, t, "memo");
162
164
  return {
163
165
  username: e,
164
- owner: o.toString(),
165
- active: s.toString(),
166
- posting: a.toString(),
167
- memo: c.toString(),
168
- ownerPubkey: o.createPublic().toString(),
169
- activePubkey: s.createPublic().toString(),
170
- postingPubkey: a.createPublic().toString(),
171
- memoPubkey: c.createPublic().toString()
166
+ owner: n.toString(),
167
+ active: r.toString(),
168
+ posting: s.toString(),
169
+ memo: a.toString(),
170
+ ownerPubkey: n.createPublic().toString(),
171
+ activePubkey: r.createPublic().toString(),
172
+ postingPubkey: s.createPublic().toString(),
173
+ memoPubkey: a.createPublic().toString()
174
+ };
175
+ }
176
+ });
177
+ }
178
+ var Z = /* @__PURE__ */ ((e) => (e.HIVE = "HIVE", e.HBD = "HBD", e.VESTS = "VESTS", e.SPK = "SPK", e))(Z || {}), ee = /* @__PURE__ */ ((e) => (e["@@000000021"] = "HIVE", e["@@000000013"] = "HBD", e["@@000000037"] = "VESTS", e))(ee || {});
179
+ function p(e) {
180
+ if (typeof e == "string") {
181
+ const t = e.split(" ");
182
+ return {
183
+ amount: parseFloat(t[0]),
184
+ // @ts-ignore
185
+ symbol: Z[t[1]]
186
+ };
187
+ } else
188
+ return {
189
+ amount: parseFloat(e.amount.toString()) / Math.pow(10, e.precision),
190
+ // @ts-ignore
191
+ symbol: ee[e.nai]
192
+ };
193
+ }
194
+ function dt(e) {
195
+ return e === void 0 ? !0 : parseInt(e.split("-")[0], 10) < 1980;
196
+ }
197
+ function B(e, t) {
198
+ return e / 1e6 * t;
199
+ }
200
+ function ke(e, t) {
201
+ let n = 0, r = 0, s = 0, a = 0, o = e.head_block - e.spk_block;
202
+ if (e.spk_block) {
203
+ if (o < 28800)
204
+ return 0;
205
+ {
206
+ a = o / 28800, n = e.gov ? c(e.gov, a, t.spk_rate_lgov) : 0, r = e.pow ? c(e.pow, a, t.spk_rate_lpow) : 0, s = c(
207
+ (e.granted.t > 0 ? e.granted.t : 0) + (e.granting.t && e.granting.t > 0 ? e.granting.t : 0),
208
+ a,
209
+ t.spk_rate_ldel
210
+ );
211
+ const f = n + r + s;
212
+ return f || 0;
213
+ }
214
+ } else return 0;
215
+ function c(f, g, _) {
216
+ return (f * (1 + _ / 365) - f) * g;
217
+ }
218
+ }
219
+ function q(e) {
220
+ return h({
221
+ queryKey: ["assets", "hive", "general-info", e],
222
+ staleTime: 6e4,
223
+ refetchInterval: 9e4,
224
+ queryFn: async () => {
225
+ await i().prefetchQuery(N()), await i().prefetchQuery(
226
+ T(e)
227
+ );
228
+ const t = i().getQueryData(
229
+ N().queryKey
230
+ ), n = i().getQueryData(
231
+ T(e).queryKey
232
+ );
233
+ return {
234
+ name: "HIVE",
235
+ title: "Hive",
236
+ price: t ? t.base / t.quote : 0,
237
+ accountBalance: n ? p(n.balance).amount : 0
238
+ };
239
+ }
240
+ });
241
+ }
242
+ function be(e) {
243
+ let f = 9.5 - (e.headBlock - 7e6) / 25e4 * 0.01;
244
+ f < 0.95 && (f = 0.95);
245
+ const g = e.vestingRewardPercent / 1e4, _ = e.virtualSupply, v = e.totalVestingFund;
246
+ return (_ * f * g / v).toFixed(3);
247
+ }
248
+ function Pe(e) {
249
+ return h({
250
+ queryKey: ["assets", "hive-power", "general-info", e],
251
+ staleTime: 6e4,
252
+ refetchInterval: 9e4,
253
+ queryFn: async () => {
254
+ await i().prefetchQuery(N()), await i().prefetchQuery(
255
+ T(e)
256
+ );
257
+ const t = i().getQueryData(
258
+ N().queryKey
259
+ ), n = i().getQueryData(
260
+ T(e).queryKey
261
+ );
262
+ return !t || !n ? {
263
+ name: "HP",
264
+ title: "Hive Power",
265
+ price: 0,
266
+ accountBalance: 0
267
+ } : {
268
+ name: "HP",
269
+ title: "Hive Power",
270
+ price: t ? t.base / t.quote : 0,
271
+ accountBalance: +B(
272
+ p(n.vesting_shares).amount,
273
+ // parseAsset(accountData.delegated_vesting_shares).amount +
274
+ // parseAsset(accountData.received_vesting_shares).amount -
275
+ // nextVestingSharesWithdrawal,
276
+ t.hivePerMVests
277
+ ).toFixed(3),
278
+ apr: be(t),
279
+ parts: [
280
+ {
281
+ name: "delegating",
282
+ balance: +B(
283
+ p(n.delegated_vesting_shares).amount,
284
+ t.hivePerMVests
285
+ ).toFixed(3)
286
+ },
287
+ {
288
+ name: "received",
289
+ balance: +B(
290
+ p(n.received_vesting_shares).amount,
291
+ t.hivePerMVests
292
+ ).toFixed(3)
293
+ }
294
+ ]
172
295
  };
173
296
  }
174
297
  });
175
298
  }
176
- function he(e, t) {
299
+ function qe(e) {
177
300
  return h({
178
- queryKey: ["ecency-wallets", "points", e, t],
179
- queryFn: async () => await (await fetch(
180
- `${l.privateApiHost}/private-api/points`,
301
+ queryKey: ["assets", "hbd", "general-info", e],
302
+ staleTime: 6e4,
303
+ refetchInterval: 9e4,
304
+ queryFn: async () => {
305
+ await i().prefetchQuery(N()), await i().prefetchQuery(
306
+ T(e)
307
+ );
308
+ const t = i().getQueryData(
309
+ T(e).queryKey
310
+ ), n = i().getQueryData(
311
+ N().queryKey
312
+ );
313
+ return t ? {
314
+ name: "HBD",
315
+ title: "Hive-based dollar",
316
+ price: 1,
317
+ accountBalance: p(t.hbd_balance).amount + p(t == null ? void 0 : t.savings_hbd_balance).amount,
318
+ apr: (((n == null ? void 0 : n.hbdInterestRate) ?? 0) / 100).toFixed(3),
319
+ parts: [
320
+ {
321
+ name: "account",
322
+ balance: p(t.hbd_balance).amount
323
+ },
324
+ {
325
+ name: "savings",
326
+ balance: p(t.savings_hbd_balance).amount
327
+ }
328
+ ]
329
+ } : {
330
+ name: "HBD",
331
+ title: "Hive-based dollar",
332
+ price: 1,
333
+ accountBalance: 0
334
+ };
335
+ }
336
+ });
337
+ }
338
+ const y = A.operationOrders, D = {
339
+ transfers: [
340
+ y.transfer,
341
+ y.transfer_to_savings,
342
+ y.transfer_from_savings,
343
+ y.cancel_transfer_from_savings,
344
+ y.recurrent_transfer,
345
+ y.fill_recurrent_transfer,
346
+ y.escrow_transfer,
347
+ y.fill_recurrent_transfer
348
+ ],
349
+ "market-orders": [
350
+ y.fill_convert_request,
351
+ y.fill_order,
352
+ y.fill_collateralized_convert_request,
353
+ y.limit_order_create2,
354
+ y.limit_order_create,
355
+ y.limit_order_cancel
356
+ ],
357
+ interests: [y.interest],
358
+ "stake-operations": [
359
+ y.return_vesting_delegation,
360
+ y.withdraw_vesting,
361
+ y.transfer_to_vesting,
362
+ y.set_withdraw_vesting_route,
363
+ y.update_proposal_votes,
364
+ y.fill_vesting_withdraw,
365
+ y.account_witness_proxy,
366
+ y.delegate_vesting_shares
367
+ ],
368
+ rewards: [
369
+ y.author_reward,
370
+ y.curation_reward,
371
+ y.producer_reward,
372
+ y.claim_reward_balance,
373
+ y.comment_benefactor_reward,
374
+ y.liquidity_reward,
375
+ y.proposal_pay
376
+ ]
377
+ };
378
+ function te(e, t = 20, n) {
379
+ return R({
380
+ queryKey: ["assets", "hive", "transactions", e, t, n],
381
+ initialData: { pages: [], pageParams: [] },
382
+ initialPageParam: -1,
383
+ getNextPageParam: (r, s) => {
384
+ var a;
385
+ return r ? +(((a = r[r.length - 1]) == null ? void 0 : a.num) ?? 0) - 1 : -1;
386
+ },
387
+ queryFn: async ({ pageParam: r }) => {
388
+ let s = [];
389
+ switch (n) {
390
+ case "transfers":
391
+ s = A.makeBitMaskFilter(
392
+ D.transfers
393
+ );
394
+ break;
395
+ case "market-orders":
396
+ s = A.makeBitMaskFilter(
397
+ D["market-orders"]
398
+ );
399
+ break;
400
+ case "interests":
401
+ s = A.makeBitMaskFilter(
402
+ D.interests
403
+ );
404
+ break;
405
+ case "stake-operations":
406
+ s = A.makeBitMaskFilter(
407
+ D["stake-operations"]
408
+ );
409
+ break;
410
+ case "rewards":
411
+ s = A.makeBitMaskFilter(
412
+ D.rewards
413
+ );
414
+ break;
415
+ default:
416
+ s = A.makeBitMaskFilter([]);
417
+ }
418
+ return (await l.hiveClient.call(
419
+ "condenser_api",
420
+ "get_account_history",
421
+ [e, r, t, ...s]
422
+ )).map(
423
+ (o) => ({
424
+ num: o[0],
425
+ type: o[1].op[0],
426
+ timestamp: o[1].timestamp,
427
+ trx_id: o[1].trx_id,
428
+ ...o[1].op[1]
429
+ })
430
+ );
431
+ },
432
+ select: ({ pages: r, pageParams: s }) => ({
433
+ pageParams: s,
434
+ pages: r.map(
435
+ (a) => a.filter((o) => {
436
+ switch (o.type) {
437
+ case "author_reward":
438
+ case "comment_benefactor_reward":
439
+ return p(o.hive_payout).amount > 0;
440
+ case "transfer":
441
+ case "transfer_to_savings":
442
+ case "transfer_to_vesting":
443
+ case "recurrent_transfer":
444
+ return ["HIVE"].includes(o.amount);
445
+ case "fill_recurrent_transfer":
446
+ const f = p(o.amount);
447
+ return ["HIVE"].includes(f.symbol);
448
+ case "claim_reward_balance":
449
+ return p(
450
+ o.reward_hive
451
+ ).amount > 0;
452
+ case "cancel_transfer_from_savings":
453
+ case "fill_order":
454
+ case "limit_order_create":
455
+ case "limit_order_cancel":
456
+ case "interest":
457
+ case "fill_convert_request":
458
+ case "fill_collateralized_convert_request":
459
+ case "proposal_pay":
460
+ case "update_proposal_votes":
461
+ case "comment_payout_update":
462
+ case "collateralized_convert":
463
+ case "account_witness_proxy":
464
+ return !0;
465
+ default:
466
+ return !1;
467
+ }
468
+ })
469
+ )
470
+ })
471
+ });
472
+ }
473
+ function _t(e, t = 20, n) {
474
+ return R({
475
+ ...te(e, t, n),
476
+ queryKey: ["assets", "hive-power", "transactions", e, t, n],
477
+ select: ({ pages: r, pageParams: s }) => ({
478
+ pageParams: s,
479
+ pages: r.map(
480
+ (a) => a.filter((o) => {
481
+ switch (o.type) {
482
+ case "author_reward":
483
+ case "comment_benefactor_reward":
484
+ return p(
485
+ o.vesting_payout
486
+ ).amount > 0;
487
+ case "claim_reward_balance":
488
+ return p(
489
+ o.reward_vests
490
+ ).amount > 0;
491
+ case "transfer":
492
+ case "transfer_to_savings":
493
+ case "transfer_to_vesting":
494
+ case "recurrent_transfer":
495
+ return ["VESTS", "HP"].includes(o.amount);
496
+ case "fill_recurrent_transfer":
497
+ const g = p(o.amount);
498
+ return ["VESTS", "HP"].includes(g.symbol);
499
+ case "curation_reward":
500
+ case "withdraw_vesting":
501
+ case "delegate_vesting_shares":
502
+ case "fill_vesting_withdraw":
503
+ case "return_vesting_delegation":
504
+ case "producer_reward":
505
+ case "set_withdraw_vesting_route":
506
+ return !0;
507
+ default:
508
+ return !1;
509
+ }
510
+ })
511
+ )
512
+ })
513
+ });
514
+ }
515
+ function vt(e, t = 20, n) {
516
+ return R({
517
+ ...te(e, t, n),
518
+ queryKey: ["assets", "hbd", "transactions", e, t, n],
519
+ select: ({ pages: r, pageParams: s }) => ({
520
+ pageParams: s,
521
+ pages: r.map(
522
+ (a) => a.filter((o) => {
523
+ switch (o.type) {
524
+ case "author_reward":
525
+ case "comment_benefactor_reward":
526
+ return p(o.hbd_payout).amount > 0;
527
+ case "claim_reward_balance":
528
+ return p(
529
+ o.reward_hbd
530
+ ).amount > 0;
531
+ case "transfer":
532
+ case "transfer_to_savings":
533
+ case "transfer_to_vesting":
534
+ case "recurrent_transfer":
535
+ return ["HBD"].includes(o.amount);
536
+ case "fill_recurrent_transfer":
537
+ const g = p(o.amount);
538
+ return ["HBD"].includes(g.symbol);
539
+ case "comment_reward":
540
+ case "effective_comment_vote":
541
+ return !0;
542
+ default:
543
+ return !1;
544
+ }
545
+ })
546
+ )
547
+ })
548
+ });
549
+ }
550
+ function kt(e = 86400) {
551
+ return R({
552
+ queryKey: ["assets", "hive", "metrics", e],
553
+ queryFn: async ({ pageParam: [t, n] }) => (await l.hiveClient.call(
554
+ "condenser_api",
555
+ "get_market_history",
556
+ [
557
+ e,
558
+ Q(t).format("YYYY-MM-DDTHH:mm:ss"),
559
+ Q(n).format("YYYY-MM-DDTHH:mm:ss")
560
+ ]
561
+ )).map(({ hive: s, non_hive: a, open: o }) => ({
562
+ close: a.close / s.close,
563
+ open: a.open / s.open,
564
+ low: a.low / s.low,
565
+ high: a.high / s.high,
566
+ volume: s.volume,
567
+ time: new Date(o)
568
+ })),
569
+ initialPageParam: [
570
+ // Fetch at least 8 hours or given interval
571
+ Q().subtract(Math.max(100 * e, 28800), "second").toDate(),
572
+ /* @__PURE__ */ new Date()
573
+ ],
574
+ getNextPageParam: (t, n, [r]) => [
575
+ Q(r.getTime()).subtract(Math.max(100 * e, 28800), "second").toDate(),
576
+ Q(r.getTime()).subtract(e, "second").toDate()
577
+ ]
578
+ });
579
+ }
580
+ function bt(e) {
581
+ return h({
582
+ queryKey: ["assets", "hive", "withdrawal-routes", e],
583
+ queryFn: () => l.hiveClient.database.call("get_withdraw_routes", [
584
+ e,
585
+ "outgoing"
586
+ ])
587
+ });
588
+ }
589
+ async function x(e) {
590
+ const n = p(e.amount).symbol;
591
+ if (e.type === "key" && "key" in e) {
592
+ const { key: r, type: s, ...a } = e;
593
+ return l.hiveClient.broadcast.transfer(
594
+ {
595
+ from: a.from,
596
+ to: a.to,
597
+ amount: a.amount,
598
+ memo: a.memo
599
+ },
600
+ r
601
+ );
602
+ } else return e.type === "keychain" ? new Promise(
603
+ (r, s) => {
604
+ var a;
605
+ return (a = window.hive_keychain) == null ? void 0 : a.requestTransfer(
606
+ e.from,
607
+ e.to,
608
+ e.amount,
609
+ e.memo,
610
+ n,
611
+ (o) => {
612
+ o.success || s({ message: "Operation cancelled" }), r(o);
613
+ },
614
+ !0,
615
+ null
616
+ );
617
+ }
618
+ ) : d.sendOperation(
619
+ [
620
+ "transfer",
621
+ {
622
+ from: e.from,
623
+ to: e.to,
624
+ amount: e.amount,
625
+ memo: e.memo
626
+ }
627
+ ],
628
+ { callback: `https://ecency.com/@${e.from}/wallet` },
629
+ () => {
630
+ }
631
+ );
632
+ }
633
+ async function U(e) {
634
+ if (e.type === "key" && "key" in e) {
635
+ const { key: t, type: n, ...r } = e;
636
+ return l.hiveClient.broadcast.sendOperations(
637
+ [["transfer_to_savings", r]],
638
+ t
639
+ );
640
+ } else return e.type === "keychain" ? b.broadcast(
641
+ e.from,
642
+ [["transfer_to_savings", e]],
643
+ "Active"
644
+ ) : d.sendOperation(
645
+ ["transfer_to_savings", e],
646
+ { callback: `https://ecency.com/@${e.from}/wallet` },
647
+ () => {
648
+ }
649
+ );
650
+ }
651
+ async function Oe(e) {
652
+ if (e.type === "key" && "key" in e) {
653
+ const { key: t, type: n, ...r } = e;
654
+ return l.hiveClient.broadcast.sendOperations(
655
+ [["transfer_to_vesting", r]],
656
+ t
657
+ );
658
+ } else return e.type === "keychain" ? b.broadcast(
659
+ e.from,
660
+ [["transfer_to_vesting", e]],
661
+ "Active"
662
+ ) : d.sendOperation(
663
+ ["transfer_to_vesting", e],
664
+ { callback: `https://ecency.com/@${e.from}/wallet` },
665
+ () => {
666
+ }
667
+ );
668
+ }
669
+ async function Se(e) {
670
+ if (e.type === "key" && "key" in e) {
671
+ const { key: t, type: n, ...r } = e;
672
+ return l.hiveClient.broadcast.sendOperations(
673
+ [["delegate_vesting_shares", r]],
674
+ t
675
+ );
676
+ } else return e.type === "keychain" ? b.broadcast(
677
+ e.from,
678
+ [["delegate_vesting_shares", e]],
679
+ "Active"
680
+ ) : d.sendOperation(
681
+ ["delegate_vesting_shares", e],
682
+ { callback: `https://ecency.com/@${e.from}/wallet` },
683
+ () => {
684
+ }
685
+ );
686
+ }
687
+ async function Ae(e) {
688
+ if (e.type === "key" && "key" in e) {
689
+ const { key: t, type: n, ...r } = e;
690
+ return l.hiveClient.broadcast.sendOperations(
691
+ [["withdraw_vesting", r]],
692
+ t
693
+ );
694
+ } else return e.type === "keychain" ? b.broadcast(
695
+ e.from,
696
+ [["withdraw_vesting", e]],
697
+ "Active"
698
+ ) : d.sendOperation(
699
+ ["withdraw_vesting", e],
700
+ { callback: `https://ecency.com/@${e.from}/wallet` },
701
+ () => {
702
+ }
703
+ );
704
+ }
705
+ async function Ne(e) {
706
+ if (e.type === "key" && "key" in e) {
707
+ const { key: r, type: s, ...a } = e;
708
+ return l.hiveClient.broadcast.sendOperations(
709
+ [["set_withdraw_vesting_route", a]],
710
+ r
711
+ );
712
+ }
713
+ if (e.type === "keychain") {
714
+ const { type: r, ...s } = e;
715
+ return b.broadcast(
716
+ s.from_account,
717
+ [["set_withdraw_vesting_route", s]],
718
+ "Active"
719
+ );
720
+ }
721
+ const { type: t, ...n } = e;
722
+ return d.sendOperation(
723
+ ["set_withdraw_vesting_route", n],
724
+ { callback: `https://ecency.com/@${n.from_account}/wallet` },
725
+ () => {
726
+ }
727
+ );
728
+ }
729
+ var u = /* @__PURE__ */ ((e) => (e.Transfer = "transfer", e.TransferToSavings = "transfer-saving", e.Delegate = "delegate", e.PowerUp = "power-up", e.PowerDown = "power-down", e.WithdrawRoutes = "withdraw-saving", e.Swap = "swap", e.Gift = "gift", e.Promote = "promote", e.Claim = "claim", e.Buy = "buy", e.LockLiquidity = "lock", e.Stake = "stake", e.Unstake = "unstake", e.Undelegate = "undelegate", e))(u || {});
730
+ async function Te(e) {
731
+ const t = JSON.stringify({
732
+ to: e.to,
733
+ amount: +e.amount * 1e3,
734
+ ...typeof e.memo == "string" ? { memo: e.memo } : {}
735
+ }), n = {
736
+ id: e.id,
737
+ json: t,
738
+ required_auths: [e.from],
739
+ required_posting_auths: []
740
+ };
741
+ if (e.type === "key" && "key" in e) {
742
+ const { key: r } = e;
743
+ return l.hiveClient.broadcast.json(n, r);
744
+ } else {
745
+ if (e.type === "keychain")
746
+ return b.customJson(
747
+ e.from,
748
+ e.id,
749
+ "Active",
750
+ t,
751
+ e.to
752
+ );
753
+ {
754
+ const { amount: r } = p(e.amount);
755
+ return d.sign(
756
+ "custom_json",
757
+ {
758
+ authority: "active",
759
+ required_auths: `["${e.from}"]`,
760
+ required_posting_auths: "[]",
761
+ id: e.id,
762
+ json: JSON.stringify({
763
+ to: e.to,
764
+ amount: +r * 1e3,
765
+ ...typeof e.memo == "string" ? { memo: e.memo } : {}
766
+ })
767
+ },
768
+ `https://ecency.com/@${e.from}/wallet`
769
+ );
770
+ }
771
+ }
772
+ }
773
+ const He = async (e) => {
774
+ const t = JSON.stringify({ amount: +e.amount * 1e3 }), n = {
775
+ id: e.mode === "lock" ? "spkcc_gov_up" : "spkcc_gov_down",
776
+ json: t,
777
+ required_auths: [e.from],
778
+ required_posting_auths: []
779
+ };
780
+ if (e.type === "key" && "key" in e) {
781
+ const { key: r } = e;
782
+ return l.hiveClient.broadcast.json(n, r);
783
+ } else {
784
+ if (e.type === "keychain")
785
+ return b.customJson(
786
+ e.from,
787
+ n.id,
788
+ "Active",
789
+ t,
790
+ e.from
791
+ );
792
+ {
793
+ const { amount: r } = p(e.amount);
794
+ return d.sign(
795
+ "custom_json",
796
+ {
797
+ authority: "active",
798
+ required_auths: `["${e.from}"]`,
799
+ required_posting_auths: "[]",
800
+ id: n.id,
801
+ json: JSON.stringify({ amount: +r * 1e3 })
802
+ },
803
+ `https://ecency.com/@${e.from}/wallet`
804
+ );
805
+ }
806
+ }
807
+ };
808
+ async function Ke(e) {
809
+ const t = JSON.stringify({ amount: +e.amount * 1e3 }), n = {
810
+ id: `spkcc_power_${e.mode}`,
811
+ json: t,
812
+ required_auths: [e.from],
813
+ required_posting_auths: []
814
+ };
815
+ if (e.type === "key" && "key" in e) {
816
+ const { key: r } = e;
817
+ return l.hiveClient.broadcast.json(n, r);
818
+ } else {
819
+ if (e.type === "keychain")
820
+ return b.customJson(
821
+ e.from,
822
+ `spkcc_power_${e.mode}`,
823
+ "Active",
824
+ t,
825
+ ""
826
+ );
827
+ {
828
+ const { amount: r } = p(e.amount);
829
+ return d.sign(
830
+ "custom_json",
831
+ {
832
+ authority: "active",
833
+ required_auths: `["${e.from}"]`,
834
+ required_posting_auths: "[]",
835
+ id: `spkcc_power_${e.mode}`,
836
+ json: JSON.stringify({ amount: +r * 1e3 })
837
+ },
838
+ `https://ecency.com/@${e.from}/wallet`
839
+ );
840
+ }
841
+ }
842
+ }
843
+ function H() {
844
+ return h({
845
+ queryKey: ["assets", "spk", "markets"],
846
+ staleTime: 6e4,
847
+ refetchInterval: 9e4,
848
+ queryFn: async () => {
849
+ const t = await (await fetch(`${l.spkNode}/markets`)).json();
850
+ return {
851
+ list: Object.entries(t.markets.node).map(([n, r]) => ({
852
+ name: n,
853
+ status: r.lastGood >= t.head_block - 1200 ? "🟩" : r.lastGood > t.head_block - 28800 ? "🟨" : "🟥"
854
+ })),
855
+ raw: t
856
+ };
857
+ }
858
+ });
859
+ }
860
+ function K(e) {
861
+ return h({
862
+ queryKey: ["assets", "spk", "wallet", e],
863
+ queryFn: async () => (await fetch(l.spkNode + `/@${e}`)).json(),
864
+ enabled: !!e,
865
+ staleTime: 6e4,
866
+ refetchInterval: 9e4
867
+ });
868
+ }
869
+ function V(e) {
870
+ return e.toFixed(3);
871
+ }
872
+ function Qe(e) {
873
+ return h({
874
+ queryKey: ["assets", "larynx", "general-info", e],
875
+ staleTime: 6e4,
876
+ refetchInterval: 9e4,
877
+ queryFn: async () => {
878
+ await i().prefetchQuery(K(e)), await i().prefetchQuery(H()), await i().prefetchQuery(
879
+ q(e)
880
+ );
881
+ const t = i().getQueryData(
882
+ K(e).queryKey
883
+ ), n = i().getQueryData(
884
+ H().queryKey
885
+ ), r = i().getQueryData(
886
+ q(e).queryKey
887
+ );
888
+ if (!t || !n)
889
+ return {
890
+ name: "LARYNX",
891
+ title: "SPK Network / LARYNX",
892
+ price: 1,
893
+ accountBalance: 0
894
+ };
895
+ const s = +V(
896
+ t.balance / 1e3 * +t.tick * ((r == null ? void 0 : r.price) ?? 0)
897
+ ), a = +V(t.balance / 1e3);
898
+ return {
899
+ name: "LARYNX",
900
+ layer: "SPK",
901
+ title: "LARYNX",
902
+ price: s / a,
903
+ accountBalance: a
904
+ };
905
+ }
906
+ });
907
+ }
908
+ function I(e) {
909
+ return e.toFixed(3);
910
+ }
911
+ function De(e) {
912
+ return h({
913
+ queryKey: ["assets", "spk", "general-info", e],
914
+ staleTime: 6e4,
915
+ refetchInterval: 9e4,
916
+ queryFn: async () => {
917
+ await i().prefetchQuery(K(e)), await i().prefetchQuery(H()), await i().prefetchQuery(
918
+ q(e)
919
+ );
920
+ const t = i().getQueryData(
921
+ K(e).queryKey
922
+ ), n = i().getQueryData(
923
+ H().queryKey
924
+ ), r = i().getQueryData(
925
+ q(e).queryKey
926
+ );
927
+ if (!t || !n)
928
+ return {
929
+ name: "SPK",
930
+ title: "SPK Network",
931
+ price: 1,
932
+ accountBalance: 0
933
+ };
934
+ const s = +I(
935
+ (t.gov + t.spk) / 1e3 * +t.tick * ((r == null ? void 0 : r.price) ?? 0)
936
+ ), a = +I(
937
+ (t.spk + ke(
938
+ t,
939
+ n.raw.stats || {
940
+ spk_rate_lgov: "0.001",
941
+ spk_rate_lpow: I(
942
+ parseFloat(n.raw.stats.spk_rate_lpow) * 100
943
+ ),
944
+ spk_rate_ldel: I(
945
+ parseFloat(n.raw.stats.spk_rate_ldel) * 100
946
+ )
947
+ }
948
+ )) / 1e3
949
+ );
950
+ return {
951
+ name: "SPK",
952
+ title: "SPK Network",
953
+ price: s / a,
954
+ accountBalance: a
955
+ };
956
+ }
957
+ });
958
+ }
959
+ function j(e) {
960
+ return e.toFixed(3);
961
+ }
962
+ function Ee(e) {
963
+ return h({
964
+ queryKey: ["assets", "larynx-power", "general-info", e],
965
+ staleTime: 6e4,
966
+ refetchInterval: 9e4,
967
+ queryFn: async () => {
968
+ var o, c;
969
+ await i().prefetchQuery(K(e)), await i().prefetchQuery(H()), await i().prefetchQuery(
970
+ q(e)
971
+ );
972
+ const t = i().getQueryData(
973
+ K(e).queryKey
974
+ ), n = i().getQueryData(
975
+ H().queryKey
976
+ ), r = i().getQueryData(
977
+ q(e).queryKey
978
+ );
979
+ if (!t || !n)
980
+ return {
981
+ name: "LP",
982
+ title: "SPK Network / LARYNX Power",
983
+ price: 1,
984
+ accountBalance: 0
985
+ };
986
+ const s = +j(
987
+ t.poweredUp / 1e3 * +t.tick * ((r == null ? void 0 : r.price) ?? 0)
988
+ ), a = +j(t.poweredUp / 1e3);
989
+ return {
990
+ name: "LP",
991
+ title: "LARYNX Power",
992
+ layer: "SPK",
993
+ price: s / a,
994
+ accountBalance: a,
995
+ parts: [
996
+ {
997
+ name: "delegating",
998
+ balance: (o = t.granting) != null && o.t ? +j(t.granting.t / 1e3) : 0
999
+ },
1000
+ {
1001
+ name: "recieved",
1002
+ balance: (c = t.granted) != null && c.t ? +j(t.granted.t / 1e3) : 0
1003
+ }
1004
+ ]
1005
+ };
1006
+ }
1007
+ });
1008
+ }
1009
+ function F(e) {
1010
+ return h({
1011
+ queryKey: ["assets", "hive-engine", "metadata-list", e],
1012
+ staleTime: 6e4,
1013
+ refetchInterval: 9e4,
1014
+ queryFn: async () => (await (await fetch(
1015
+ `${l.privateApiHost}/private-api/engine-api`,
181
1016
  {
182
1017
  method: "POST",
183
1018
  body: JSON.stringify({
184
- username: e.replace("@", "")
1019
+ jsonrpc: "2.0",
1020
+ method: "find",
1021
+ params: {
1022
+ contract: "tokens",
1023
+ table: "tokens",
1024
+ query: {
1025
+ symbol: { $in: e }
1026
+ }
1027
+ },
1028
+ id: 2
1029
+ }),
1030
+ headers: { "Content-type": "application/json" }
1031
+ }
1032
+ )).json()).result
1033
+ });
1034
+ }
1035
+ const L = [
1036
+ "LEO",
1037
+ "ARCHON",
1038
+ "WAIV",
1039
+ "CHOISM",
1040
+ "CCC",
1041
+ "POB",
1042
+ "PHOTO",
1043
+ "LUV",
1044
+ "ALIVE",
1045
+ "LOLZ",
1046
+ "CENT",
1047
+ "FUN",
1048
+ "VYB",
1049
+ "VKBT",
1050
+ "BUIDL",
1051
+ "NEOXAG",
1052
+ "BEE",
1053
+ "PIMP",
1054
+ "PEPE",
1055
+ "PAY",
1056
+ "SPT",
1057
+ "ONEUP",
1058
+ "SPORTS",
1059
+ "CURE"
1060
+ ];
1061
+ function $(e) {
1062
+ return h({
1063
+ queryKey: ["assets", "hive-engine", "balances", e],
1064
+ staleTime: 6e4,
1065
+ refetchInterval: 9e4,
1066
+ queryFn: async () => (await (await fetch(
1067
+ `${l.privateApiHost}/private-api/engine-api`,
1068
+ {
1069
+ method: "POST",
1070
+ body: JSON.stringify({
1071
+ jsonrpc: "2.0",
1072
+ method: "find",
1073
+ params: {
1074
+ contract: "tokens",
1075
+ table: "balances",
1076
+ query: {
1077
+ account: e
1078
+ }
1079
+ },
1080
+ id: 1
1081
+ }),
1082
+ headers: { "Content-type": "application/json" }
1083
+ }
1084
+ )).json()).result
1085
+ });
1086
+ }
1087
+ function Re() {
1088
+ return h({
1089
+ queryKey: ["assets", "hive-engine", "markets"],
1090
+ staleTime: 6e4,
1091
+ refetchInterval: 9e4,
1092
+ queryFn: async () => (await (await fetch(
1093
+ `${l.privateApiHost}/private-api/engine-api`,
1094
+ {
1095
+ method: "POST",
1096
+ body: JSON.stringify({
1097
+ jsonrpc: "2.0",
1098
+ method: "find",
1099
+ params: {
1100
+ contract: "market",
1101
+ table: "metrics",
1102
+ query: {}
1103
+ },
1104
+ id: 1
1105
+ }),
1106
+ headers: { "Content-type": "application/json" }
1107
+ }
1108
+ )).json()).result
1109
+ });
1110
+ }
1111
+ function Ce(e, t) {
1112
+ return h({
1113
+ queryKey: ["assets", "hive-engine", t, "general-info", e],
1114
+ enabled: !!t && !!e,
1115
+ staleTime: 6e4,
1116
+ refetchInterval: 9e4,
1117
+ queryFn: async () => {
1118
+ if (!t || !e)
1119
+ throw new Error(
1120
+ "[SDK][Wallets] – hive engine token or username missed"
1121
+ );
1122
+ const n = q(e);
1123
+ await i().prefetchQuery(n);
1124
+ const r = i().getQueryData(
1125
+ n.queryKey
1126
+ ), s = F(L);
1127
+ await i().prefetchQuery(s);
1128
+ const a = i().getQueryData(s.queryKey), o = $(e);
1129
+ await i().prefetchQuery(o);
1130
+ const c = i().getQueryData(o.queryKey), f = Re();
1131
+ await i().prefetchQuery(f);
1132
+ const g = i().getQueryData(f.queryKey), _ = a == null ? void 0 : a.find((P) => P.symbol === t), v = c == null ? void 0 : c.find((P) => P.symbol === t), S = g == null ? void 0 : g.find((P) => P.symbol === t), k = +((S == null ? void 0 : S.lastPrice) ?? "0");
1133
+ return {
1134
+ name: t,
1135
+ title: (_ == null ? void 0 : _.name) ?? "",
1136
+ price: k === 0 ? 0 : Number(k * ((r == null ? void 0 : r.price) ?? 0)),
1137
+ accountBalance: parseFloat((v == null ? void 0 : v.balance) ?? "0"),
1138
+ layer: "ENGINE"
1139
+ };
1140
+ }
1141
+ });
1142
+ }
1143
+ function Pt(e, t, n = 20) {
1144
+ return R({
1145
+ queryKey: ["assets", "hive-engine", t, "transactions", e],
1146
+ enabled: !!t && !!e,
1147
+ initialPageParam: 0,
1148
+ getNextPageParam: (r) => ((r == null ? void 0 : r.length) ?? 0) + n,
1149
+ queryFn: async ({ pageParam: r }) => {
1150
+ if (!t || !e)
1151
+ throw new Error(
1152
+ "[SDK][Wallets] – hive engine token or username missed"
1153
+ );
1154
+ const s = new URL(
1155
+ `${l.privateApiHost}/private-api/engine-account-history`
1156
+ );
1157
+ return s.searchParams.set("account", e), s.searchParams.set("symbol", t), s.searchParams.set("limit", n.toString()), s.searchParams.set("offset", r.toString()), await (await fetch(s, {
1158
+ method: "GET",
1159
+ headers: { "Content-type": "application/json" }
1160
+ })).json();
1161
+ }
1162
+ });
1163
+ }
1164
+ function qt(e, t = "daily") {
1165
+ return h({
1166
+ queryKey: ["assets", "hive-engine", e],
1167
+ staleTime: 6e4,
1168
+ refetchInterval: 9e4,
1169
+ queryFn: async () => {
1170
+ const n = new URL(
1171
+ `${l.privateApiHost}/private-api/engine-chart-api`
1172
+ );
1173
+ return n.searchParams.set("symbol", e), n.searchParams.set("interval", t), await (await fetch(n, {
1174
+ headers: { "Content-type": "application/json" }
1175
+ })).json();
1176
+ }
1177
+ });
1178
+ }
1179
+ async function Ie(e) {
1180
+ const n = p(e.amount).amount.toString();
1181
+ if (e.type === "key" && "key" in e) {
1182
+ const { key: r, type: s, ...a } = e, o = {
1183
+ id: "ssc-mainnet-hive",
1184
+ json: JSON.stringify({
1185
+ contractName: "tokens",
1186
+ contractAction: "delegate",
1187
+ contractPayload: {
1188
+ symbol: a.asset,
1189
+ to: a.to,
1190
+ quantity: n
1191
+ }
1192
+ }),
1193
+ required_auths: [a.from],
1194
+ required_posting_auths: []
1195
+ };
1196
+ return l.hiveClient.broadcast.json(o, r);
1197
+ } else return e.type === "keychain" ? new Promise(
1198
+ (r, s) => {
1199
+ var a;
1200
+ return (a = window.hive_keychain) == null ? void 0 : a.requestCustomJson(
1201
+ e.from,
1202
+ "ssc-mainnet-hive",
1203
+ "Active",
1204
+ JSON.stringify({
1205
+ contractName: "tokens",
1206
+ contractAction: "delegate",
1207
+ contractPayload: {
1208
+ symbol: e.asset,
1209
+ to: e.to,
1210
+ quantity: n
1211
+ }
1212
+ }),
1213
+ "Token Delegation",
1214
+ (o) => {
1215
+ o.success || s({ message: "Operation cancelled" }), r(o);
1216
+ }
1217
+ );
1218
+ }
1219
+ ) : d.sendOperation(
1220
+ [
1221
+ "custom_json",
1222
+ {
1223
+ id: "ssc-mainnet-hive",
1224
+ required_auths: [e.from],
1225
+ required_posting_auths: [],
1226
+ json: JSON.stringify({
1227
+ contractName: "tokens",
1228
+ contractAction: "delegate",
1229
+ contractPayload: {
1230
+ symbol: e.asset,
1231
+ to: e.to,
1232
+ quantity: n
1233
+ }
185
1234
  })
186
1235
  }
187
- )).json(),
188
- staleTime: 3e4,
1236
+ ],
1237
+ { callback: `https://ecency.com/@${e.from}/wallet` },
1238
+ () => {
1239
+ }
1240
+ );
1241
+ }
1242
+ async function je(e) {
1243
+ const n = p(e.amount).amount.toString();
1244
+ if (e.type === "key" && "key" in e) {
1245
+ const { key: r, type: s, ...a } = e, o = {
1246
+ id: "ssc-mainnet-hive",
1247
+ json: JSON.stringify({
1248
+ contractName: "tokens",
1249
+ contractAction: "undelegate",
1250
+ contractPayload: {
1251
+ symbol: a.asset,
1252
+ from: a.to,
1253
+ quantity: n
1254
+ }
1255
+ }),
1256
+ required_auths: [a.from],
1257
+ required_posting_auths: []
1258
+ };
1259
+ return l.hiveClient.broadcast.json(o, r);
1260
+ } else return e.type === "keychain" ? new Promise(
1261
+ (r, s) => {
1262
+ var a;
1263
+ return (a = window.hive_keychain) == null ? void 0 : a.requestCustomJson(
1264
+ e.from,
1265
+ "ssc-mainnet-hive",
1266
+ "Active",
1267
+ JSON.stringify({
1268
+ contractName: "tokens",
1269
+ contractAction: "undelegate",
1270
+ contractPayload: {
1271
+ symbol: e.asset,
1272
+ from: e.to,
1273
+ quantity: n
1274
+ }
1275
+ }),
1276
+ "Token Undelegation",
1277
+ (o) => {
1278
+ o.success || s({ message: "Operation cancelled" }), r(o);
1279
+ }
1280
+ );
1281
+ }
1282
+ ) : d.sendOperation(
1283
+ [
1284
+ "custom_json",
1285
+ {
1286
+ id: "ssc-mainnet-hive",
1287
+ required_auths: [e.from],
1288
+ required_posting_auths: [],
1289
+ json: JSON.stringify({
1290
+ contractName: "tokens",
1291
+ contractAction: "undelegate",
1292
+ contractPayload: {
1293
+ symbol: e.asset,
1294
+ from: e.to,
1295
+ quantity: n
1296
+ }
1297
+ })
1298
+ }
1299
+ ],
1300
+ { callback: `https://ecency.com/@${e.from}/wallet` },
1301
+ () => {
1302
+ }
1303
+ );
1304
+ }
1305
+ async function Fe(e) {
1306
+ const n = p(e.amount).amount.toString();
1307
+ if (e.type === "key" && "key" in e) {
1308
+ const { key: r, type: s, ...a } = e, o = {
1309
+ id: "ssc-mainnet-hive",
1310
+ json: JSON.stringify({
1311
+ contractName: "tokens",
1312
+ contractAction: "stake",
1313
+ contractPayload: {
1314
+ symbol: a.asset,
1315
+ to: a.to,
1316
+ quantity: n
1317
+ }
1318
+ }),
1319
+ required_auths: [a.from],
1320
+ required_posting_auths: []
1321
+ };
1322
+ return l.hiveClient.broadcast.json(o, r);
1323
+ } else return e.type === "keychain" ? new Promise(
1324
+ (r, s) => {
1325
+ var a;
1326
+ return (a = window.hive_keychain) == null ? void 0 : a.requestCustomJson(
1327
+ e.from,
1328
+ "ssc-mainnet-hive",
1329
+ "Active",
1330
+ JSON.stringify({
1331
+ contractName: "tokens",
1332
+ contractAction: "stake",
1333
+ contractPayload: {
1334
+ symbol: e.asset,
1335
+ to: e.to,
1336
+ quantity: n
1337
+ }
1338
+ }),
1339
+ "Token Staking",
1340
+ (o) => {
1341
+ o.success || s({ message: "Operation cancelled" }), r(o);
1342
+ }
1343
+ );
1344
+ }
1345
+ ) : d.sendOperation(
1346
+ [
1347
+ "custom_json",
1348
+ {
1349
+ id: "ssc-mainnet-hive",
1350
+ required_auths: [e.from],
1351
+ required_posting_auths: [],
1352
+ json: JSON.stringify({
1353
+ contractName: "tokens",
1354
+ contractAction: "stake",
1355
+ contractPayload: {
1356
+ symbol: e.asset,
1357
+ to: e.to,
1358
+ quantity: n
1359
+ }
1360
+ })
1361
+ }
1362
+ ],
1363
+ { callback: `https://ecency.com/@${e.from}/wallet` },
1364
+ () => {
1365
+ }
1366
+ );
1367
+ }
1368
+ async function Le(e) {
1369
+ const n = p(e.amount).amount.toString();
1370
+ if (e.type === "key" && "key" in e) {
1371
+ const { key: r, type: s, ...a } = e, o = {
1372
+ id: "ssc-mainnet-hive",
1373
+ json: JSON.stringify({
1374
+ contractName: "tokens",
1375
+ contractAction: "unstake",
1376
+ contractPayload: {
1377
+ symbol: a.asset,
1378
+ to: a.to,
1379
+ quantity: n
1380
+ }
1381
+ }),
1382
+ required_auths: [a.from],
1383
+ required_posting_auths: []
1384
+ };
1385
+ return l.hiveClient.broadcast.json(o, r);
1386
+ } else return e.type === "keychain" ? new Promise(
1387
+ (r, s) => {
1388
+ var a;
1389
+ return (a = window.hive_keychain) == null ? void 0 : a.requestCustomJson(
1390
+ e.from,
1391
+ "ssc-mainnet-hive",
1392
+ "Active",
1393
+ JSON.stringify({
1394
+ contractName: "tokens",
1395
+ contractAction: "unstake",
1396
+ contractPayload: {
1397
+ symbol: e.asset,
1398
+ to: e.to,
1399
+ quantity: n
1400
+ }
1401
+ }),
1402
+ "Token Unstaking",
1403
+ (o) => {
1404
+ o.success || s({ message: "Operation cancelled" }), r(o);
1405
+ }
1406
+ );
1407
+ }
1408
+ ) : d.sendOperation(
1409
+ [
1410
+ "custom_json",
1411
+ {
1412
+ id: "ssc-mainnet-hive",
1413
+ required_auths: [e.from],
1414
+ required_posting_auths: [],
1415
+ json: JSON.stringify({
1416
+ contractName: "tokens",
1417
+ contractAction: "unstake",
1418
+ contractPayload: {
1419
+ symbol: e.asset,
1420
+ to: e.to,
1421
+ quantity: n
1422
+ }
1423
+ })
1424
+ }
1425
+ ],
1426
+ { callback: `https://ecency.com/@${e.from}/wallet` },
1427
+ () => {
1428
+ }
1429
+ );
1430
+ }
1431
+ async function Be(e) {
1432
+ const n = p(e.amount).amount.toString();
1433
+ if (e.type === "key" && "key" in e) {
1434
+ const { key: r, type: s, ...a } = e, o = {
1435
+ id: "ssc-mainnet-hive",
1436
+ json: JSON.stringify({
1437
+ contractName: "tokens",
1438
+ contractAction: "transfer",
1439
+ contractPayload: {
1440
+ symbol: a.asset,
1441
+ to: a.to,
1442
+ quantity: n,
1443
+ memo: a.memo
1444
+ }
1445
+ }),
1446
+ required_auths: [a.from],
1447
+ required_posting_auths: []
1448
+ };
1449
+ return l.hiveClient.broadcast.json(o, r);
1450
+ } else return e.type === "keychain" ? new Promise(
1451
+ (r, s) => {
1452
+ var a;
1453
+ return (a = window.hive_keychain) == null ? void 0 : a.requestCustomJson(
1454
+ e.from,
1455
+ "ssc-mainnet-hive",
1456
+ "Active",
1457
+ JSON.stringify({
1458
+ contractName: "tokens",
1459
+ contractAction: "transfer",
1460
+ contractPayload: {
1461
+ symbol: e.asset,
1462
+ to: e.to,
1463
+ quantity: n,
1464
+ memo: e.memo
1465
+ }
1466
+ }),
1467
+ "Token Transfer",
1468
+ (o) => {
1469
+ o.success || s({ message: "Operation cancelled" }), r(o);
1470
+ }
1471
+ );
1472
+ }
1473
+ ) : d.sendOperation(
1474
+ [
1475
+ "custom_json",
1476
+ {
1477
+ id: "ssc-mainnet-hive",
1478
+ required_auths: [e.from],
1479
+ required_posting_auths: [],
1480
+ json: JSON.stringify({
1481
+ contractName: "tokens",
1482
+ contractAction: "transfer",
1483
+ contractPayload: {
1484
+ symbol: e.asset,
1485
+ to: e.to,
1486
+ quantity: n,
1487
+ memo: e.memo
1488
+ }
1489
+ })
1490
+ }
1491
+ ],
1492
+ { callback: `https://ecency.com/@${e.from}/wallet` },
1493
+ () => {
1494
+ }
1495
+ );
1496
+ }
1497
+ function M(e) {
1498
+ return h({
1499
+ queryKey: ["assets", "points", e],
1500
+ queryFn: async () => {
1501
+ if (!e)
1502
+ throw new Error(
1503
+ "[SDK][Wallets][Assets][Points][Query] – username wasn`t provided"
1504
+ );
1505
+ const n = await (await fetch(
1506
+ l.privateApiHost + "/private-api/points",
1507
+ {
1508
+ method: "POST",
1509
+ headers: {
1510
+ "Content-Type": "application/json"
1511
+ },
1512
+ body: JSON.stringify({ username: e })
1513
+ }
1514
+ )).json();
1515
+ return {
1516
+ points: n.points,
1517
+ uPoints: n.unclaimed_points
1518
+ };
1519
+ },
1520
+ staleTime: 6e4,
1521
+ refetchInterval: 9e4,
189
1522
  refetchOnMount: !0,
190
1523
  enabled: !!e
191
1524
  });
192
1525
  }
193
- function Te(e) {
194
- const { data: t } = m(F());
195
- return S(
1526
+ function Me(e) {
1527
+ return h({
1528
+ queryKey: ["assets", "points", "general-info", e],
1529
+ staleTime: 6e4,
1530
+ refetchInterval: 9e4,
1531
+ queryFn: async () => {
1532
+ await i().prefetchQuery(M(e));
1533
+ const t = i().getQueryData(
1534
+ M(e).queryKey
1535
+ );
1536
+ return {
1537
+ name: "POINTS",
1538
+ title: "Ecency Points",
1539
+ price: 2e-3,
1540
+ accountBalance: +(t == null ? void 0 : t.points)
1541
+ };
1542
+ }
1543
+ });
1544
+ }
1545
+ function Ot(e, t) {
1546
+ return h({
1547
+ queryKey: ["assets", "points", "transactions", e],
1548
+ queryFn: async () => (await (await fetch(
1549
+ `${l.privateApiHost}/private-api/point-list`,
1550
+ {
1551
+ method: "POST",
1552
+ body: JSON.stringify({
1553
+ username: e,
1554
+ type: t ?? 0
1555
+ })
1556
+ }
1557
+ )).json()).map(({ created: s, type: a, amount: o, id: c }) => ({
1558
+ created: new Date(s),
1559
+ type: a,
1560
+ results: [
1561
+ {
1562
+ amount: parseInt(o),
1563
+ asset: "POINTS"
1564
+ }
1565
+ ],
1566
+ id: c
1567
+ }))
1568
+ });
1569
+ }
1570
+ function St(e, t, n) {
1571
+ const { mutateAsync: r } = W.useRecordActivity(
1572
+ e,
1573
+ "points-claimed"
1574
+ );
1575
+ return O({
1576
+ mutationFn: async () => {
1577
+ if (!e)
1578
+ throw new Error(
1579
+ "[SDK][Wallets][Assets][Points][Claim] – username wasn`t provided"
1580
+ );
1581
+ return fetch(l.privateApiHost + "/private-api/points-claim", {
1582
+ method: "POST",
1583
+ headers: {
1584
+ "Content-Type": "application/json"
1585
+ },
1586
+ body: JSON.stringify({ code: ye(e) })
1587
+ });
1588
+ },
1589
+ onError: n,
1590
+ onSuccess: () => {
1591
+ r(), l.queryClient.setQueryData(
1592
+ M(e).queryKey,
1593
+ (s) => s && {
1594
+ points: (parseFloat(s.points) + parseFloat(s.uPoints)).toFixed(3),
1595
+ uPoints: "0"
1596
+ }
1597
+ ), t == null || t();
1598
+ }
1599
+ });
1600
+ }
1601
+ async function Je({
1602
+ from: e,
1603
+ to: t,
1604
+ amount: n,
1605
+ memo: r,
1606
+ type: s,
1607
+ ...a
1608
+ }) {
1609
+ const o = [
1610
+ "custom_json",
1611
+ {
1612
+ id: "ecency_point_transfer",
1613
+ json: JSON.stringify({
1614
+ sender: e,
1615
+ receiver: t,
1616
+ amount: n.replace("POINTS", "POINT"),
1617
+ memo: r
1618
+ }),
1619
+ required_auths: [e],
1620
+ required_posting_auths: []
1621
+ }
1622
+ ];
1623
+ if (s === "key" && "key" in a) {
1624
+ const { key: c } = a;
1625
+ return l.hiveClient.broadcast.sendOperations([o], c);
1626
+ }
1627
+ return s === "keychain" ? b.broadcast(e, [o], "Active") : d.sendOperation(
1628
+ o,
1629
+ { callback: `https://ecency.com/@${e}/wallet` },
196
1630
  () => {
197
- var o;
1631
+ }
1632
+ );
1633
+ }
1634
+ var $e = /* @__PURE__ */ ((e) => (e[e.CHECKIN = 10] = "CHECKIN", e[e.LOGIN = 20] = "LOGIN", e[e.CHECKIN_EXTRA = 30] = "CHECKIN_EXTRA", e[e.POST = 100] = "POST", e[e.COMMENT = 110] = "COMMENT", e[e.VOTE = 120] = "VOTE", e[e.REBLOG = 130] = "REBLOG", e[e.DELEGATION = 150] = "DELEGATION", e[e.REFERRAL = 160] = "REFERRAL", e[e.COMMUNITY = 170] = "COMMUNITY", e[e.TRANSFER_SENT = 998] = "TRANSFER_SENT", e[e.TRANSFER_INCOMING = 999] = "TRANSFER_INCOMING", e[e.MINTED = 991] = "MINTED", e))($e || {});
1635
+ function At(e) {
1636
+ return h({
1637
+ queryKey: ["ecency-wallets", "all-tokens-list", e],
1638
+ queryFn: async () => {
1639
+ await i().prefetchQuery(
1640
+ F(L)
1641
+ );
1642
+ const t = i().getQueryData(F(L).queryKey);
198
1643
  return {
199
1644
  basic: [
200
- u.Points,
201
- u.Hive,
202
- u.HivePower,
203
- u.HiveDollar,
204
- u.Spk
205
- ].filter((s) => s.toLowerCase().includes(e.toLowerCase())),
206
- external: Object.values(n).filter(
207
- (s) => s.toLowerCase().includes(e.toLowerCase())
1645
+ w.Points,
1646
+ w.Hive,
1647
+ w.HivePower,
1648
+ w.HiveDollar,
1649
+ w.Spk,
1650
+ "LARYNX",
1651
+ "LP"
1652
+ ].filter((n) => n.toLowerCase().includes(e.toLowerCase())),
1653
+ external: Object.values(m).filter(
1654
+ (n) => n.toLowerCase().includes(e.toLowerCase())
208
1655
  ),
209
- layer2: ((o = t == null ? void 0 : t.map(({ symbol: s }) => s)) == null ? void 0 : o.filter(
210
- (s) => s.toLowerCase().includes(e.toLowerCase())
211
- )) ?? []
1656
+ layer2: t
212
1657
  };
213
- },
214
- [t, e]
215
- );
1658
+ }
1659
+ });
1660
+ }
1661
+ function xe(e) {
1662
+ return h({
1663
+ queryKey: ["ecency-wallets", "list", e],
1664
+ enabled: !!e,
1665
+ queryFn: async () => {
1666
+ const t = l.storage.getItem(
1667
+ l.storagePrefix + "_wallet_assets_list"
1668
+ );
1669
+ return t ? JSON.parse(t) : [
1670
+ w.Points,
1671
+ w.Hive,
1672
+ w.HivePower,
1673
+ w.HiveDollar,
1674
+ w.Spk
1675
+ ];
1676
+ }
1677
+ });
1678
+ }
1679
+ function Ue(e, t, n = { refetch: !1 }) {
1680
+ const r = async (s) => (n.refetch ? await i().fetchQuery(s) : await i().prefetchQuery(s), i().getQueryData(
1681
+ s.queryKey
1682
+ ));
1683
+ return h({
1684
+ queryKey: ["ecency-wallets", "asset-info", e, t],
1685
+ queryFn: async () => {
1686
+ if (t === "HIVE")
1687
+ return r(q(e));
1688
+ if (t === "HP")
1689
+ return r(Pe(e));
1690
+ if (t === "HBD")
1691
+ return r(qe(e));
1692
+ if (t === "SPK")
1693
+ return r(De(e));
1694
+ if (t === "LARYNX")
1695
+ return r(Qe(e));
1696
+ if (t === "LP")
1697
+ return r(Ee(e));
1698
+ if (t === "POINTS")
1699
+ return r(Me(e));
1700
+ if (L.includes(t))
1701
+ return await r(
1702
+ Ce(e, t)
1703
+ );
1704
+ throw new Error(
1705
+ "[SDK][Wallets] – has requested unrecognized asset info"
1706
+ );
1707
+ }
1708
+ });
216
1709
  }
217
- const $ = {
218
- [n.BTC]: "m/44'/0'/0'/0/0",
1710
+ function Nt(e, t, n = !1) {
1711
+ return h({
1712
+ queryKey: ["wallets", "token-operations", e, t, n],
1713
+ queryFn: async () => {
1714
+ switch (e) {
1715
+ case w.Hive:
1716
+ return [
1717
+ u.Transfer,
1718
+ ...n ? [
1719
+ u.TransferToSavings,
1720
+ u.PowerUp,
1721
+ u.Swap
1722
+ ] : []
1723
+ ];
1724
+ case w.HivePower:
1725
+ return [
1726
+ u.Delegate,
1727
+ ...n ? [u.PowerDown, u.WithdrawRoutes] : [u.PowerUp]
1728
+ ];
1729
+ case w.HiveDollar:
1730
+ return [
1731
+ u.Transfer,
1732
+ ...n ? [u.TransferToSavings, u.Swap] : []
1733
+ ];
1734
+ case w.Points:
1735
+ return [
1736
+ u.Gift,
1737
+ ...n ? [
1738
+ u.Promote,
1739
+ u.Claim,
1740
+ u.Buy
1741
+ ] : []
1742
+ ];
1743
+ case w.Spk:
1744
+ return [u.Transfer];
1745
+ case "LARYNX":
1746
+ return [
1747
+ u.Transfer,
1748
+ ...n ? [u.PowerUp, u.LockLiquidity] : []
1749
+ ];
1750
+ case "LP":
1751
+ return [
1752
+ u.Delegate,
1753
+ ...n ? [u.PowerDown] : []
1754
+ ];
1755
+ }
1756
+ const r = $(t);
1757
+ await i().prefetchQuery(r);
1758
+ const s = i().getQueryData(
1759
+ r.queryKey
1760
+ ), a = F(
1761
+ (s == null ? void 0 : s.map((k) => k.symbol)) ?? []
1762
+ );
1763
+ await i().prefetchQuery(a);
1764
+ const o = i().getQueryData(a.queryKey), c = s == null ? void 0 : s.find((k) => k.symbol === e), f = o == null ? void 0 : o.find((k) => k.symbol === e), g = n && (f == null ? void 0 : f.delegationEnabled) && c && parseFloat(c.delegationsOut) !== parseFloat(c.balance), _ = n && parseFloat((c == null ? void 0 : c.delegationsOut) ?? "0") > 0, v = n && (f == null ? void 0 : f.stakingEnabled), S = n && parseFloat((c == null ? void 0 : c.stake) ?? "0") > 0;
1765
+ return [
1766
+ u.Transfer,
1767
+ ...g ? [u.Delegate] : [],
1768
+ ..._ ? [u.Undelegate] : [],
1769
+ ...v ? [u.Stake] : [],
1770
+ ...S ? [u.Unstake] : []
1771
+ ];
1772
+ }
1773
+ });
1774
+ }
1775
+ const Ve = {
1776
+ [m.BTC]: "m/44'/0'/0'/0/0",
219
1777
  // Bitcoin (BIP44)
220
- [n.ETH]: "m/44'/60'/0'/0/0",
1778
+ [m.ETH]: "m/44'/60'/0'/0/0",
221
1779
  // Ethereum (BIP44)
222
- [n.SOL]: "m/44'/501'/0'/0'",
1780
+ [m.SOL]: "m/44'/501'/0'/0'",
223
1781
  // Solana (BIP44)
224
- [n.TON]: "m/44'/607'/0'",
1782
+ [m.TON]: "m/44'/607'/0'",
225
1783
  // TON (BIP44)
226
- [n.TRON]: "m/44'/195'/0'/0/0",
1784
+ [m.TRON]: "m/44'/195'/0'/0/0",
227
1785
  // Tron (BIP44)
228
- [n.APT]: "m/44'/637'/0'/0'/0'",
1786
+ [m.APT]: "m/44'/637'/0'/0'/0'",
229
1787
  // Aptos (BIP44)
230
- [n.ATOM]: "m/44'/118'/0'/0/0"
1788
+ [m.ATOM]: "m/44'/118'/0'/0/0"
231
1789
  // Cosmos (BIP44)
232
1790
  };
233
- function Pe(e, t) {
234
- const { data: o } = b(e), s = T(), a = y({
1791
+ function Tt(e, t) {
1792
+ const { data: n } = X(e), r = G(), s = O({
235
1793
  mutationKey: ["ecency-wallets", "create-wallet", e, t],
236
1794
  mutationFn: async () => {
237
- if (!o)
1795
+ if (!n)
238
1796
  throw new Error("[Ecency][Wallets] - No seed to create a wallet");
239
- const i = P(t), r = await (i == null ? void 0 : i.getDerivedPrivateKey({
240
- mnemonic: o,
241
- hdPath: $[t]
1797
+ const o = Y(t), c = await (o == null ? void 0 : o.getDerivedPrivateKey({
1798
+ mnemonic: n,
1799
+ hdPath: Ve[t]
242
1800
  }));
243
- await _(1e3);
244
- const p = await (i == null ? void 0 : i.getNewAddress({
245
- privateKey: r
1801
+ await ge(1e3);
1802
+ const f = await (o == null ? void 0 : o.getNewAddress({
1803
+ privateKey: c
246
1804
  }));
247
1805
  return {
248
- privateKey: r,
249
- address: p.address,
250
- publicKey: p.publicKey,
1806
+ privateKey: c,
1807
+ address: f.address,
1808
+ publicKey: f.publicKey,
251
1809
  username: e,
252
1810
  currency: t
253
1811
  };
254
1812
  },
255
- onSuccess: (i) => {
256
- s.setQueryData(
257
- ["ecency-wallets", "wallets", i.username],
258
- (r) => new Map(r ? Array.from(r.entries()) : []).set(i.currency, i)
1813
+ onSuccess: (o) => {
1814
+ r.setQueryData(
1815
+ ["ecency-wallets", "wallets", o.username],
1816
+ (c) => new Map(c ? Array.from(c.entries()) : []).set(o.currency, o)
259
1817
  );
260
1818
  }
261
- }), c = R(() => {
1819
+ }), a = se(() => {
262
1820
  }, []);
263
1821
  return {
264
- createWallet: a,
265
- importWallet: c
1822
+ createWallet: s,
1823
+ importWallet: a
266
1824
  };
267
1825
  }
268
- function J(e) {
269
- const { data: t } = m({
1826
+ function Ge(e) {
1827
+ const { data: t } = E({
270
1828
  queryKey: ["ecency-wallets", "wallets", e]
271
- }), { data: o } = B(e);
272
- return y({
1829
+ }), { data: n } = ve(e);
1830
+ return O({
273
1831
  mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
274
- mutationFn: ({ currency: s, address: a }) => fetch(l.privateApiHost + "/private-api/wallets-add", {
1832
+ mutationFn: ({ currency: r, address: s }) => fetch(l.privateApiHost + "/private-api/wallets-add", {
275
1833
  method: "POST",
276
1834
  headers: {
277
1835
  "Content-Type": "application/json"
278
1836
  },
279
1837
  body: JSON.stringify({
280
1838
  username: e,
281
- token: s,
282
- address: a,
1839
+ token: r,
1840
+ address: s,
283
1841
  meta: {
284
- ownerPublicKey: o == null ? void 0 : o.ownerPubkey,
285
- activePublicKey: o == null ? void 0 : o.activePubkey,
286
- postingPublicKey: o == null ? void 0 : o.postingPubkey,
287
- memoPublicKey: o == null ? void 0 : o.memoPubkey,
1842
+ ownerPublicKey: n == null ? void 0 : n.ownerPubkey,
1843
+ activePublicKey: n == null ? void 0 : n.activePubkey,
1844
+ postingPublicKey: n == null ? void 0 : n.postingPubkey,
1845
+ memoPublicKey: n == null ? void 0 : n.memoPubkey,
288
1846
  ...Array.from((t == null ? void 0 : t.entries()) ?? []).reduce(
289
- (c, [i, r]) => ({
290
- ...c,
291
- [i]: r.address
1847
+ (a, [o, c]) => ({
1848
+ ...a,
1849
+ [o]: c.address
292
1850
  }),
293
1851
  {}
294
1852
  )
@@ -297,8 +1855,8 @@ function J(e) {
297
1855
  })
298
1856
  });
299
1857
  }
300
- function v() {
301
- return y({
1858
+ function ne() {
1859
+ return O({
302
1860
  mutationKey: ["ecency-wallets", "check-wallet-existence"],
303
1861
  mutationFn: async ({ address: e, currency: t }) => (await (await fetch(
304
1862
  l.privateApiHost + "/private-api/wallets-exist",
@@ -315,77 +1873,77 @@ function v() {
315
1873
  )).json()).length === 0
316
1874
  });
317
1875
  }
318
- const be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1876
+ const Ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
319
1877
  __proto__: null,
320
- useCheckWalletExistence: v,
321
- useCreateAccountWithWallets: J
322
- }, Symbol.toStringTag, { value: "Module" })), G = {
323
- [n.BTC]: ["m/84'/0'/0'/0/0"],
324
- [n.ETH]: ["m/84'/60'/0'/0/0"],
1878
+ useCheckWalletExistence: ne,
1879
+ useCreateAccountWithWallets: Ge
1880
+ }, Symbol.toStringTag, { value: "Module" })), We = {
1881
+ [m.BTC]: ["m/84'/0'/0'/0/0"],
1882
+ [m.ETH]: ["m/84'/60'/0'/0/0"],
325
1883
  // its not working for Trust, Exodus, todo: check others below
326
- [n.SOL]: ["m/84'/501'/0'/0/0"],
327
- [n.TRON]: ["m/44'/195'/0'/0'/0'"],
328
- [n.APT]: ["m/84'/637'/0'/0/0"],
329
- [n.TON]: [],
1884
+ [m.SOL]: ["m/84'/501'/0'/0/0"],
1885
+ [m.TRON]: ["m/44'/195'/0'/0'/0'"],
1886
+ [m.APT]: ["m/84'/637'/0'/0/0"],
1887
+ [m.TON]: [],
330
1888
  // Disabled
331
- [n.ATOM]: ["m/84'/118'/0'/0'/0"]
1889
+ [m.ATOM]: ["m/84'/118'/0'/0'/0"]
332
1890
  };
333
- async function V(e, t, o) {
334
- for (const s of G[o] || [])
1891
+ async function Ye(e, t, n) {
1892
+ for (const r of We[n] || [])
335
1893
  try {
336
- const a = await t.getDerivedPrivateKey({
1894
+ const s = await t.getDerivedPrivateKey({
337
1895
  mnemonic: e,
338
- hdPath: s
339
- }), c = await t.getNewAddress({
340
- privateKey: a,
341
- addressType: o === n.BTC ? "segwit_native" : void 0
1896
+ hdPath: r
1897
+ }), a = await t.getNewAddress({
1898
+ privateKey: s,
1899
+ addressType: n === m.BTC ? "segwit_native" : void 0
342
1900
  });
343
- return [a.toString(), c.address];
1901
+ return [s.toString(), a.address];
344
1902
  } catch {
345
1903
  return [];
346
1904
  }
347
1905
  return [];
348
1906
  }
349
- function ge(e, t) {
350
- const o = T(), { mutateAsync: s } = v();
351
- return y({
1907
+ function Kt(e, t) {
1908
+ const n = G(), { mutateAsync: r } = ne();
1909
+ return O({
352
1910
  mutationKey: ["ecency-wallets", "import-wallet", e, t],
353
- mutationFn: async ({ privateKeyOrSeed: a }) => {
354
- const c = P(t);
355
- if (!c)
1911
+ mutationFn: async ({ privateKeyOrSeed: s }) => {
1912
+ const a = Y(t);
1913
+ if (!a)
356
1914
  throw new Error("Cannot find token for this currency");
357
- const i = a.split(" ").length === 12;
358
- let r, p = a;
359
- if (i ? [p, r] = await V(
1915
+ const o = s.split(" ").length === 12;
1916
+ let c, f = s;
1917
+ if (o ? [f, c] = await Ye(
1918
+ s,
360
1919
  a,
361
- c,
362
1920
  t
363
- ) : r = (await c.getNewAddress({
364
- privateKey: a
365
- })).address, !r || !a)
1921
+ ) : c = (await a.getNewAddress({
1922
+ privateKey: s
1923
+ })).address, !c || !s)
366
1924
  throw new Error(
367
1925
  "Private key/seed phrase isn't matching with public key or token"
368
1926
  );
369
- if (!await s({
370
- address: r,
1927
+ if (!await r({
1928
+ address: c,
371
1929
  currency: t
372
1930
  }))
373
1931
  throw new Error(
374
1932
  "This wallet has already in use by Hive account. Please, try another one"
375
1933
  );
376
1934
  return {
377
- privateKey: p,
378
- address: r,
1935
+ privateKey: f,
1936
+ address: c,
379
1937
  publicKey: ""
380
1938
  };
381
1939
  },
382
- onSuccess: ({ privateKey: a, publicKey: c, address: i }) => {
383
- o.setQueryData(
1940
+ onSuccess: ({ privateKey: s, publicKey: a, address: o }) => {
1941
+ n.setQueryData(
384
1942
  ["ecency-wallets", "wallets", e],
385
- (r) => new Map(r ? Array.from(r.entries()) : []).set(t, {
386
- privateKey: a,
387
- publicKey: c,
388
- address: i,
1943
+ (c) => new Map(c ? Array.from(c.entries()) : []).set(t, {
1944
+ privateKey: s,
1945
+ publicKey: a,
1946
+ address: o,
389
1947
  username: e,
390
1948
  currency: t,
391
1949
  custom: !0
@@ -394,97 +1952,167 @@ function ge(e, t) {
394
1952
  }
395
1953
  });
396
1954
  }
397
- function ve(e) {
398
- const { mutateAsync: t } = x(e);
399
- return y({
1955
+ function Qt(e) {
1956
+ const { mutateAsync: t } = pe(e);
1957
+ return O({
400
1958
  mutationKey: ["ecency-wallets", "save-wallet-to-metadata", e],
401
1959
  mutationFn: ({
402
- wallets: o
1960
+ wallets: n
403
1961
  }) => t({
404
1962
  profile: {},
405
- tokens: Array.from(o.entries() ?? []).map(([s, a]) => ({
406
- symbol: s,
1963
+ tokens: Array.from(n.entries() ?? []).map(([r, s]) => ({
1964
+ symbol: r,
407
1965
  type: "CHAIN",
408
1966
  meta: {
409
- address: a.address
1967
+ address: s.address
410
1968
  }
411
1969
  }))
412
1970
  })
413
1971
  });
414
1972
  }
415
- function z(e) {
416
- return h({
417
- queryKey: ["assets", "points", e],
418
- queryFn: async () => {
419
- if (!e)
420
- throw new Error(
421
- "[SDK][Wallets][Assets][Points][Query] – username wasn`t provided"
422
- );
423
- const o = await (await fetch(
424
- l.privateApiHost + "/private-api/points",
425
- {
426
- method: "POST",
427
- headers: {
428
- "Content-Type": "application/json"
429
- },
430
- body: JSON.stringify({ username: e })
431
- }
432
- )).json();
433
- return {
434
- points: o.points,
435
- uPoints: o.unclaimed_points
436
- };
437
- },
438
- staleTime: 6e4,
439
- refetchInterval: 9e4,
440
- refetchOnMount: !0,
441
- enabled: !!e
1973
+ function Dt(e) {
1974
+ return O({
1975
+ mutationKey: ["wallets", "assets-list", e],
1976
+ mutationFn: async (t) => (l.storage.setItem(
1977
+ l.storagePrefix + "_wallet_assets_list",
1978
+ JSON.stringify(t)
1979
+ ), t),
1980
+ onSuccess() {
1981
+ i().invalidateQueries({
1982
+ queryKey: xe(e).queryKey
1983
+ });
1984
+ }
442
1985
  });
443
1986
  }
444
- function Oe(e, t, o) {
445
- const { mutateAsync: s } = q.useRecordActivity(
1987
+ const Xe = {
1988
+ HIVE: {
1989
+ [u.Transfer]: x,
1990
+ [u.TransferToSavings]: U,
1991
+ [u.PowerUp]: Oe
1992
+ },
1993
+ HBD: {
1994
+ [u.Transfer]: x,
1995
+ [u.TransferToSavings]: U
1996
+ },
1997
+ HP: {
1998
+ [u.PowerDown]: Ae,
1999
+ [u.Delegate]: Se,
2000
+ [u.WithdrawRoutes]: Ne
2001
+ },
2002
+ POINTS: {
2003
+ [u.Gift]: Je
2004
+ },
2005
+ SPK: {
2006
+ [u.Transfer]: Te
2007
+ },
2008
+ LARYNX: {
2009
+ [u.LockLiquidity]: He,
2010
+ [u.PowerUp]: Ke
2011
+ }
2012
+ }, ze = {
2013
+ [u.Transfer]: Be,
2014
+ [u.Stake]: Fe,
2015
+ [u.Unstake]: Le,
2016
+ [u.Delegate]: Ie,
2017
+ [u.Undelegate]: je
2018
+ };
2019
+ function Et(e, t, n) {
2020
+ const { mutateAsync: r } = W.useRecordActivity(
446
2021
  e,
447
- "points-claimed"
2022
+ n
448
2023
  );
449
- return y({
450
- mutationFn: async () => {
451
- if (!e)
452
- throw new Error(
453
- "[SDK][Wallets][Assets][Points][Claim] – username wasn`t provided"
454
- );
455
- return fetch(l.privateApiHost + "/private-api/points-claim", {
456
- method: "POST",
457
- headers: {
458
- "Content-Type": "application/json"
459
- },
460
- body: JSON.stringify({ code: E(e) })
461
- });
2024
+ return O({
2025
+ mutationKey: ["ecency-wallets", t, n],
2026
+ mutationFn: async (s) => {
2027
+ const a = Xe[t][n];
2028
+ if (a)
2029
+ return a(s);
2030
+ const o = $(e);
2031
+ await i().prefetchQuery(o);
2032
+ const c = i().getQueryData(
2033
+ o.queryKey
2034
+ );
2035
+ if (c != null && c.some((f) => f.symbol === t)) {
2036
+ const f = ze[n];
2037
+ if (f)
2038
+ return f({ ...s, asset: t });
2039
+ }
2040
+ throw new Error("[SDK][Wallets] – no operation for given asset");
462
2041
  },
463
- onError: o,
464
2042
  onSuccess: () => {
465
- s(), l.queryClient.setQueryData(
466
- z(e).queryKey,
467
- (a) => a && {
468
- points: (parseFloat(a.points) + parseFloat(a.uPoints)).toFixed(3),
469
- uPoints: "0"
470
- }
471
- ), t == null || t();
2043
+ r();
2044
+ const s = Ue(e, t, {
2045
+ refetch: !0
2046
+ });
2047
+ setTimeout(
2048
+ () => i().invalidateQueries({
2049
+ queryKey: s.queryKey
2050
+ }),
2051
+ 5e3
2052
+ );
472
2053
  }
473
2054
  });
474
2055
  }
475
2056
  export {
476
- u as EcencyWalletBasicTokens,
477
- n as EcencyWalletCurrency,
478
- be as EcencyWalletsPrivateApi,
479
- he as getAccountPointsQueryOptions,
480
- z as getPointsQueryOptions,
481
- Oe as useClaimPoints,
482
- fe as useCoinGeckoPriceQuery,
483
- Te as useGetAllTokensListQuery,
484
- we as useGetExternalWalletBalanceQuery,
485
- B as useHiveKeysQuery,
486
- ge as useImportWallet,
487
- ve as useSaveWalletInformationToMetadata,
488
- b as useSeedPhrase,
489
- Pe as useWalletCreate
2057
+ u as AssetOperation,
2058
+ w as EcencyWalletBasicTokens,
2059
+ m as EcencyWalletCurrency,
2060
+ Ht as EcencyWalletsPrivateApi,
2061
+ ee as NaiMap,
2062
+ $e as PointTransactionType,
2063
+ Z as Symbol,
2064
+ Ie as delegateEngineToken,
2065
+ Se as delegateHive,
2066
+ Ue as getAccountWalletAssetInfoQueryOptions,
2067
+ xe as getAccountWalletListQueryOptions,
2068
+ At as getAllTokensListQueryOptions,
2069
+ qe as getHbdAssetGeneralInfoQueryOptions,
2070
+ vt as getHbdAssetTransactionsQueryOptions,
2071
+ q as getHiveAssetGeneralInfoQueryOptions,
2072
+ kt as getHiveAssetMetricQueryOptions,
2073
+ te as getHiveAssetTransactionsQueryOptions,
2074
+ bt as getHiveAssetWithdrawalRoutesQueryOptions,
2075
+ Ce as getHiveEngineTokenGeneralInfoQueryOptions,
2076
+ Pt as getHiveEngineTokenTransactionsQueryOptions,
2077
+ $ as getHiveEngineTokensBalancesQueryOptions,
2078
+ Re as getHiveEngineTokensMarketQueryOptions,
2079
+ F as getHiveEngineTokensMetadataQueryOptions,
2080
+ qt as getHiveEngineTokensMetricsQueryOptions,
2081
+ Pe as getHivePowerAssetGeneralInfoQueryOptions,
2082
+ _t as getHivePowerAssetTransactionsQueryOptions,
2083
+ Qe as getLarynxAssetGeneralInfoQueryOptions,
2084
+ Ee as getLarynxPowerAssetGeneralInfoQueryOptions,
2085
+ Me as getPointsAssetGeneralInfoQueryOptions,
2086
+ Ot as getPointsAssetTransactionsQueryOptions,
2087
+ M as getPointsQueryOptions,
2088
+ De as getSpkAssetGeneralInfoQueryOptions,
2089
+ H as getSpkMarketsQueryOptions,
2090
+ Nt as getTokenOperationsQueryOptions,
2091
+ dt as isEmptyDate,
2092
+ He as lockLarynx,
2093
+ p as parseAsset,
2094
+ Ae as powerDownHive,
2095
+ Oe as powerUpHive,
2096
+ Ke as powerUpLarynx,
2097
+ ke as rewardSpk,
2098
+ Fe as stakeEngineToken,
2099
+ Be as transferEngineToken,
2100
+ x as transferHive,
2101
+ Je as transferPoint,
2102
+ Te as transferSpk,
2103
+ U as transferToSavingsHive,
2104
+ je as undelegateEngineToken,
2105
+ Le as unstakeEngineToken,
2106
+ Dt as useChangeAssetsList,
2107
+ St as useClaimPoints,
2108
+ wt as useCoinGeckoPriceQuery,
2109
+ gt as useGetExternalWalletBalanceQuery,
2110
+ ve as useHiveKeysQuery,
2111
+ Kt as useImportWallet,
2112
+ Qt as useSaveWalletInformationToMetadata,
2113
+ X as useSeedPhrase,
2114
+ Tt as useWalletCreate,
2115
+ Et as useWalletOperation,
2116
+ B as vestsToHp,
2117
+ Ne as withdrawVestingRouteHive
490
2118
  };