@ecency/wallets 1.2.24 → 1.3.0

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