@ecency/wallets 1.2.13 → 1.2.15

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.
@@ -1,57 +1,57 @@
1
- import { useMemo as S, useCallback as A } from "react";
2
- import { useQuery as p, queryOptions as R, useQueryClient as h, useMutation as m } from "@tanstack/react-query";
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
3
  import { BtcWallet as k } from "@okxweb3/coin-bitcoin";
4
- import { EthWallet as H } from "@okxweb3/coin-ethereum";
5
- import { TrxWallet as C } from "@okxweb3/coin-tron";
4
+ import { EthWallet as C } from "@okxweb3/coin-ethereum";
5
+ import { TrxWallet as H } from "@okxweb3/coin-tron";
6
6
  import { TonWallet as K } from "@okxweb3/coin-ton";
7
7
  import { SolWallet as N } from "@okxweb3/coin-solana";
8
8
  import { AtomWallet as D } from "@okxweb3/coin-cosmos";
9
- import { AptosWallet as L } from "@okxweb3/coin-aptos";
10
- import j from "bip39";
11
- import { CONFIG as d, getHiveEngineTokensListQueryOptions as x, useAccountUpdate as M } from "@ecency/sdk";
12
- import { LRUCache as _ } from "lru-cache";
13
- import { PrivateKey as w } from "@hiveio/dhive";
14
- var o = /* @__PURE__ */ ((e) => (e.BTC = "BTC", e.ETH = "ETH", e.APT = "APT", e.ATOM = "ATOM", e.TON = "TON", e.TRON = "TRX", e.SOL = "SOL", e))(o || {}), u = /* @__PURE__ */ ((e) => (e.Points = "POINTS", e.HivePower = "HP", e.Hive = "HIVE", e.HiveDollar = "HBD", e.Spk = "SPK", e))(u || {});
15
- function E(e) {
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) {
16
16
  return new Promise((t) => setTimeout(t, e));
17
17
  }
18
- function T(e) {
18
+ function P(e) {
19
19
  switch (e) {
20
- case o.BTC:
20
+ case n.BTC:
21
21
  return new k();
22
- case o.ETH:
23
- return new H();
24
- case o.TRON:
22
+ case n.ETH:
25
23
  return new C();
26
- case o.TON:
24
+ case n.TRON:
25
+ return new H();
26
+ case n.TON:
27
27
  return new K();
28
- case o.SOL:
28
+ case n.SOL:
29
29
  return new N();
30
- case o.ATOM:
30
+ case n.ATOM:
31
31
  return new D();
32
- case o.APT:
33
- return new L();
32
+ case n.APT:
33
+ return new j();
34
34
  default:
35
35
  return;
36
36
  }
37
37
  }
38
- function me(e, t) {
39
- return p({
38
+ function we(e, t) {
39
+ return m({
40
40
  queryKey: ["ecency-wallets", "external-wallet-balance", e, t],
41
41
  queryFn: async () => {
42
42
  switch (e) {
43
- case o.BTC:
44
- const a = await (await fetch(
43
+ case n.BTC:
44
+ const s = await (await fetch(
45
45
  `https://mempool.space/api/address/${t}`
46
46
  )).json();
47
- return (a.chain_stats.funded_txo_sum - a.chain_stats.spent_txo_sum) / 1e8;
48
- case o.ETH:
47
+ return (s.chain_stats.funded_txo_sum - s.chain_stats.spent_txo_sum) / 1e8;
48
+ case n.ETH:
49
49
  return +(await (await fetch(
50
50
  `https://api.ethplorer.io/getAddressInfo/${t}?apiKey=freekey`
51
51
  )).json()).ETH.balance;
52
- case o.SOL:
52
+ case n.SOL:
53
53
  return (await (await fetch(
54
- `https://rpc.helius.xyz/?api-key=${d.heliusApiKey}`,
54
+ `https://rpc.helius.xyz/?api-key=${l.heliusApiKey}`,
55
55
  {
56
56
  method: "POST",
57
57
  body: JSON.stringify({
@@ -65,22 +65,22 @@ function me(e, t) {
65
65
  }
66
66
  }
67
67
  )).json()).result.value / 1e9;
68
- case o.TRON:
68
+ case n.TRON:
69
69
  return (await (await fetch(
70
70
  `https://api.trongrid.io/v1/accounts/${t}`
71
71
  )).json()).data[0].balance / 1e6;
72
- case o.TON:
72
+ case n.TON:
73
73
  return (await (await fetch(
74
74
  `https://tonapi.io/v1/blockchain/getAccount?account=${t}`
75
75
  )).json()).balance / 1e9;
76
- case o.APT:
76
+ case n.APT:
77
77
  const f = (await (await fetch(
78
78
  `https://fullnode.mainnet.aptoslabs.com/v1/accounts/${t}/resources`
79
79
  )).json()).find(
80
- (O) => O.type.includes("coin::CoinStore")
80
+ (A) => A.type.includes("coin::CoinStore")
81
81
  );
82
82
  return f ? parseInt(f.data.coin.value) / 1e8 : 0;
83
- case o.ATOM:
83
+ case n.ATOM:
84
84
  return +(await (await fetch(
85
85
  `https://rest.cosmos.directory/cosmoshub/auth/accounts/${t}`
86
86
  )).json()).result.value.coins[0].amount / 1e6;
@@ -89,12 +89,12 @@ function me(e, t) {
89
89
  });
90
90
  }
91
91
  function b(e) {
92
- return p({
92
+ return m({
93
93
  queryKey: ["ecency-wallets", "seed", e],
94
- queryFn: async () => j.generateMnemonic(128)
94
+ queryFn: async () => L.generateMnemonic(128)
95
95
  });
96
96
  }
97
- const F = {
97
+ const Q = {
98
98
  max: 500,
99
99
  // how long to live in ms
100
100
  ttl: 1e3 * 60 * 5,
@@ -102,36 +102,36 @@ const F = {
102
102
  allowStale: !1,
103
103
  updateAgeOnGet: !1,
104
104
  updateAgeOnHas: !1
105
- }, g = new _(F), y = Symbol("undefined"), q = (e, t) => g.set(e, t === void 0 ? y : t), W = (e) => {
105
+ }, g = new M(Q), w = Symbol("undefined"), W = (e, t) => g.set(e, t === void 0 ? w : t), I = (e) => {
106
106
  const t = g.get(e);
107
- return t === y ? void 0 : t;
107
+ return t === w ? void 0 : t;
108
108
  };
109
- function we(e) {
110
- return p({
109
+ function fe(e) {
110
+ return m({
111
111
  queryKey: ["ecency-wallets", "coingecko-price", e],
112
112
  queryFn: async () => {
113
113
  let t = e;
114
114
  switch (e) {
115
- case o.BTC:
115
+ case n.BTC:
116
116
  t = "binance-wrapped-btc";
117
117
  break;
118
- case o.ETH:
118
+ case n.ETH:
119
119
  t = "ethereum";
120
120
  break;
121
- case o.SOL:
121
+ case n.SOL:
122
122
  t = "solana";
123
123
  break;
124
- case o.TON:
124
+ case n.TON:
125
125
  t = "trx";
126
126
  break;
127
127
  default:
128
128
  t = e;
129
129
  }
130
- let n = W("gecko"), a;
131
- if (n)
132
- a = n;
130
+ let o = I("gecko"), s;
131
+ if (o)
132
+ s = o;
133
133
  else {
134
- const r = await (await fetch(
134
+ const i = await (await fetch(
135
135
  "https://api.coingecko.com/api/v3/simple/price",
136
136
  {
137
137
  method: "POST",
@@ -143,41 +143,41 @@ function we(e) {
143
143
  })
144
144
  }
145
145
  )).json();
146
- q("gecko", r === void 0 ? y : r), a = r;
146
+ W("gecko", i === void 0 ? w : i), s = i;
147
147
  }
148
- return 1 / +a[Object.keys(a)[0]].usd;
148
+ return 1 / +s[Object.keys(s)[0]].usd;
149
149
  },
150
150
  enabled: !!e
151
151
  });
152
152
  }
153
- function Q(e) {
153
+ function B(e) {
154
154
  const { data: t } = b(e);
155
- return p({
155
+ return m({
156
156
  queryKey: ["ecencу-wallets", "hive-keys", e, t],
157
157
  staleTime: 1 / 0,
158
158
  queryFn: async () => {
159
159
  if (!t)
160
160
  throw new Error("[Ecency][Wallets] - no seed to create Hive account");
161
- const n = w.fromLogin(e, t, "owner"), a = w.fromLogin(e, t, "active"), s = w.fromLogin(e, t, "posting"), c = w.fromLogin(e, t, "memo");
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");
162
162
  return {
163
163
  username: e,
164
- owner: n.toString(),
165
- active: a.toString(),
166
- posting: s.toString(),
164
+ owner: o.toString(),
165
+ active: s.toString(),
166
+ posting: a.toString(),
167
167
  memo: c.toString(),
168
- ownerPubkey: n.createPublic().toString(),
169
- activePubkey: a.createPublic().toString(),
170
- postingPubkey: s.createPublic().toString(),
168
+ ownerPubkey: o.createPublic().toString(),
169
+ activePubkey: s.createPublic().toString(),
170
+ postingPubkey: a.createPublic().toString(),
171
171
  memoPubkey: c.createPublic().toString()
172
172
  };
173
173
  }
174
174
  });
175
175
  }
176
- function de(e, t) {
177
- return R({
176
+ function he(e, t) {
177
+ return h({
178
178
  queryKey: ["ecency-wallets", "points", e, t],
179
179
  queryFn: async () => await (await fetch(
180
- `${d.privateApiHost}/private-api/points`,
180
+ `${l.privateApiHost}/private-api/points`,
181
181
  {
182
182
  method: "POST",
183
183
  body: JSON.stringify({
@@ -190,11 +190,11 @@ function de(e, t) {
190
190
  enabled: !!e
191
191
  });
192
192
  }
193
- function ye(e) {
194
- const { data: t } = p(x());
193
+ function Te(e) {
194
+ const { data: t } = m(F());
195
195
  return S(
196
196
  () => {
197
- var n;
197
+ var o;
198
198
  return {
199
199
  basic: [
200
200
  u.Points,
@@ -202,93 +202,93 @@ function ye(e) {
202
202
  u.HivePower,
203
203
  u.HiveDollar,
204
204
  u.Spk
205
- ].filter((a) => a.toLowerCase().includes(e.toLowerCase())),
206
- external: Object.values(o).filter(
207
- (a) => a.toLowerCase().includes(e.toLowerCase())
205
+ ].filter((s) => s.toLowerCase().includes(e.toLowerCase())),
206
+ external: Object.values(n).filter(
207
+ (s) => s.toLowerCase().includes(e.toLowerCase())
208
208
  ),
209
- layer2: ((n = t == null ? void 0 : t.map(({ symbol: a }) => a)) == null ? void 0 : n.filter(
210
- (a) => a.toLowerCase().includes(e.toLowerCase())
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
211
  )) ?? []
212
212
  };
213
213
  },
214
214
  [t, e]
215
215
  );
216
216
  }
217
- const I = {
218
- [o.BTC]: "m/44'/0'/0'/0/0",
217
+ const $ = {
218
+ [n.BTC]: "m/44'/0'/0'/0/0",
219
219
  // Bitcoin (BIP44)
220
- [o.ETH]: "m/44'/60'/0'/0/0",
220
+ [n.ETH]: "m/44'/60'/0'/0/0",
221
221
  // Ethereum (BIP44)
222
- [o.SOL]: "m/44'/501'/0'/0'",
222
+ [n.SOL]: "m/44'/501'/0'/0'",
223
223
  // Solana (BIP44)
224
- [o.TON]: "m/44'/607'/0'",
224
+ [n.TON]: "m/44'/607'/0'",
225
225
  // TON (BIP44)
226
- [o.TRON]: "m/44'/195'/0'/0/0",
226
+ [n.TRON]: "m/44'/195'/0'/0/0",
227
227
  // Tron (BIP44)
228
- [o.APT]: "m/44'/637'/0'/0'/0'",
228
+ [n.APT]: "m/44'/637'/0'/0'/0'",
229
229
  // Aptos (BIP44)
230
- [o.ATOM]: "m/44'/118'/0'/0/0"
230
+ [n.ATOM]: "m/44'/118'/0'/0/0"
231
231
  // Cosmos (BIP44)
232
232
  };
233
- function fe(e, t) {
234
- const { data: n } = b(e), a = h(), s = m({
233
+ function Pe(e, t) {
234
+ const { data: o } = b(e), s = T(), a = y({
235
235
  mutationKey: ["ecency-wallets", "create-wallet", e, t],
236
236
  mutationFn: async () => {
237
- if (!n)
237
+ if (!o)
238
238
  throw new Error("[Ecency][Wallets] - No seed to create a wallet");
239
- const r = T(t), i = await (r == null ? void 0 : r.getDerivedPrivateKey({
240
- mnemonic: n,
241
- hdPath: I[t]
239
+ const i = P(t), r = await (i == null ? void 0 : i.getDerivedPrivateKey({
240
+ mnemonic: o,
241
+ hdPath: $[t]
242
242
  }));
243
- await E(1e3);
244
- const l = await (r == null ? void 0 : r.getNewAddress({
245
- privateKey: i
243
+ await _(1e3);
244
+ const p = await (i == null ? void 0 : i.getNewAddress({
245
+ privateKey: r
246
246
  }));
247
247
  return {
248
- privateKey: i,
249
- address: l.address,
250
- publicKey: l.publicKey,
248
+ privateKey: r,
249
+ address: p.address,
250
+ publicKey: p.publicKey,
251
251
  username: e,
252
252
  currency: t
253
253
  };
254
254
  },
255
- onSuccess: (r) => {
256
- a.setQueryData(
257
- ["ecency-wallets", "wallets", r.username],
258
- (i) => new Map(i ? Array.from(i.entries()) : []).set(r.currency, r)
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)
259
259
  );
260
260
  }
261
- }), c = A(() => {
261
+ }), c = R(() => {
262
262
  }, []);
263
263
  return {
264
- createWallet: s,
264
+ createWallet: a,
265
265
  importWallet: c
266
266
  };
267
267
  }
268
- function B(e) {
269
- const { data: t } = p({
268
+ function J(e) {
269
+ const { data: t } = m({
270
270
  queryKey: ["ecency-wallets", "wallets", e]
271
- }), { data: n } = Q(e);
272
- return m({
271
+ }), { data: o } = B(e);
272
+ return y({
273
273
  mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
274
- mutationFn: ({ currency: a, address: s }) => fetch(d.privateApiHost + "/private-api/wallets-add", {
274
+ mutationFn: ({ currency: s, address: a }) => fetch(l.privateApiHost + "/private-api/wallets-add", {
275
275
  method: "POST",
276
276
  headers: {
277
277
  "Content-Type": "application/json"
278
278
  },
279
279
  body: JSON.stringify({
280
280
  username: e,
281
- token: a,
282
- address: s,
281
+ token: s,
282
+ address: a,
283
283
  meta: {
284
- ownerPublicKey: n == null ? void 0 : n.ownerPubkey,
285
- activePublicKey: n == null ? void 0 : n.activePubkey,
286
- postingPublicKey: n == null ? void 0 : n.postingPubkey,
287
- memoPublicKey: n == null ? void 0 : n.memoPubkey,
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,
288
288
  ...Array.from((t == null ? void 0 : t.entries()) ?? []).reduce(
289
- (c, [r, i]) => ({
289
+ (c, [i, r]) => ({
290
290
  ...c,
291
- [r]: i.address
291
+ [i]: r.address
292
292
  }),
293
293
  {}
294
294
  )
@@ -297,11 +297,11 @@ function B(e) {
297
297
  })
298
298
  });
299
299
  }
300
- function P() {
301
- return m({
300
+ function v() {
301
+ return y({
302
302
  mutationKey: ["ecency-wallets", "check-wallet-existence"],
303
303
  mutationFn: async ({ address: e, currency: t }) => (await (await fetch(
304
- d.privateApiHost + "/private-api/wallets-exist",
304
+ l.privateApiHost + "/private-api/wallets-exist",
305
305
  {
306
306
  method: "POST",
307
307
  headers: {
@@ -315,77 +315,77 @@ function P() {
315
315
  )).json()).length === 0
316
316
  });
317
317
  }
318
- const he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
318
+ const be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
319
319
  __proto__: null,
320
- useCheckWalletExistence: P,
321
- useCreateAccountWithWallets: B
322
- }, Symbol.toStringTag, { value: "Module" })), $ = {
323
- [o.BTC]: ["m/84'/0'/0'/0/0"],
324
- [o.ETH]: ["m/84'/60'/0'/0/0"],
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"],
325
325
  // its not working for Trust, Exodus, todo: check others below
326
- [o.SOL]: ["m/84'/501'/0'/0/0"],
327
- [o.TRON]: ["m/44'/195'/0'/0'/0'"],
328
- [o.APT]: ["m/84'/637'/0'/0/0"],
329
- [o.TON]: [],
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]: [],
330
330
  // Disabled
331
- [o.ATOM]: ["m/84'/118'/0'/0'/0"]
331
+ [n.ATOM]: ["m/84'/118'/0'/0'/0"]
332
332
  };
333
- async function G(e, t, n) {
334
- for (const a of $[n] || [])
333
+ async function V(e, t, o) {
334
+ for (const s of G[o] || [])
335
335
  try {
336
- const s = await t.getDerivedPrivateKey({
336
+ const a = await t.getDerivedPrivateKey({
337
337
  mnemonic: e,
338
- hdPath: a
338
+ hdPath: s
339
339
  }), c = await t.getNewAddress({
340
- privateKey: s,
341
- addressType: n === o.BTC ? "segwit_native" : void 0
340
+ privateKey: a,
341
+ addressType: o === n.BTC ? "segwit_native" : void 0
342
342
  });
343
- return [s.toString(), c.address];
343
+ return [a.toString(), c.address];
344
344
  } catch {
345
345
  return [];
346
346
  }
347
347
  return [];
348
348
  }
349
- function Te(e, t) {
350
- const n = h(), { mutateAsync: a } = P();
351
- return m({
349
+ function ge(e, t) {
350
+ const o = T(), { mutateAsync: s } = v();
351
+ return y({
352
352
  mutationKey: ["ecency-wallets", "import-wallet", e, t],
353
- mutationFn: async ({ privateKeyOrSeed: s }) => {
354
- const c = T(t);
353
+ mutationFn: async ({ privateKeyOrSeed: a }) => {
354
+ const c = P(t);
355
355
  if (!c)
356
356
  throw new Error("Cannot find token for this currency");
357
- const r = s.split(" ").length === 12;
358
- let i, l = s;
359
- if (r ? [l, i] = await G(
360
- s,
357
+ const i = a.split(" ").length === 12;
358
+ let r, p = a;
359
+ if (i ? [p, r] = await V(
360
+ a,
361
361
  c,
362
362
  t
363
- ) : i = (await c.getNewAddress({
364
- privateKey: s
365
- })).address, !i || !s)
363
+ ) : r = (await c.getNewAddress({
364
+ privateKey: a
365
+ })).address, !r || !a)
366
366
  throw new Error(
367
367
  "Private key/seed phrase isn't matching with public key or token"
368
368
  );
369
- if (!await a({
370
- address: i,
369
+ if (!await s({
370
+ address: r,
371
371
  currency: t
372
372
  }))
373
373
  throw new Error(
374
374
  "This wallet has already in use by Hive account. Please, try another one"
375
375
  );
376
376
  return {
377
- privateKey: l,
378
- address: i,
377
+ privateKey: p,
378
+ address: r,
379
379
  publicKey: ""
380
380
  };
381
381
  },
382
- onSuccess: ({ privateKey: s, publicKey: c, address: r }) => {
383
- n.setQueryData(
382
+ onSuccess: ({ privateKey: a, publicKey: c, address: i }) => {
383
+ o.setQueryData(
384
384
  ["ecency-wallets", "wallets", e],
385
- (i) => new Map(i ? Array.from(i.entries()) : []).set(t, {
386
- privateKey: s,
385
+ (r) => new Map(r ? Array.from(r.entries()) : []).set(t, {
386
+ privateKey: a,
387
387
  publicKey: c,
388
- address: r,
388
+ address: i,
389
389
  username: e,
390
390
  currency: t,
391
391
  custom: !0
@@ -394,35 +394,97 @@ function Te(e, t) {
394
394
  }
395
395
  });
396
396
  }
397
- function be(e) {
398
- const { mutateAsync: t } = M(e);
399
- return m({
397
+ function ve(e) {
398
+ const { mutateAsync: t } = x(e);
399
+ return y({
400
400
  mutationKey: ["ecency-wallets", "save-wallet-to-metadata", e],
401
401
  mutationFn: ({
402
- wallets: n
402
+ wallets: o
403
403
  }) => t({
404
404
  profile: {},
405
- tokens: Array.from(n.entries() ?? []).map(([a, s]) => ({
406
- symbol: a,
405
+ tokens: Array.from(o.entries() ?? []).map(([s, a]) => ({
406
+ symbol: s,
407
407
  type: "CHAIN",
408
408
  meta: {
409
- address: s.address
409
+ address: a.address
410
410
  }
411
411
  }))
412
412
  })
413
413
  });
414
414
  }
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
442
+ });
443
+ }
444
+ function Oe(e, t, o) {
445
+ const { mutateAsync: s } = q.useRecordActivity(
446
+ e,
447
+ "points-claimed"
448
+ );
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
+ });
462
+ },
463
+ onError: o,
464
+ 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();
472
+ }
473
+ });
474
+ }
415
475
  export {
416
476
  u as EcencyWalletBasicTokens,
417
- o as EcencyWalletCurrency,
418
- he as EcencyWalletsPrivateApi,
419
- de as getAccountPointsQueryOptions,
420
- we as useCoinGeckoPriceQuery,
421
- ye as useGetAllTokensListQuery,
422
- me as useGetExternalWalletBalanceQuery,
423
- Q as useHiveKeysQuery,
424
- Te as useImportWallet,
425
- be as useSaveWalletInformationToMetadata,
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,
426
488
  b as useSeedPhrase,
427
- fe as useWalletCreate
489
+ Pe as useWalletCreate
428
490
  };
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './modules/wallets';
2
+ export * from './modules/assets';
@@ -0,0 +1 @@
1
+ export * from './points';
@@ -0,0 +1,3 @@
1
+ export * from './mutations';
2
+ export * from './queries';
3
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ import { useMutation } from '@tanstack/react-query';
2
+ export declare function useClaimPoints(username: string | undefined, onSuccess?: () => void, onError?: Parameters<typeof useMutation>["0"]["onError"]): import('@tanstack/react-query').UseMutationResult<Response, unknown, unknown, unknown>;
@@ -0,0 +1 @@
1
+ export * from './claim-points';
@@ -0,0 +1,20 @@
1
+ export declare function getPointsQueryOptions(username?: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<{
2
+ readonly points: any;
3
+ readonly uPoints: any;
4
+ }, Error, {
5
+ readonly points: any;
6
+ readonly uPoints: any;
7
+ }, (string | undefined)[]>, "queryFn"> & {
8
+ queryFn?: import('@tanstack/query-core').QueryFunction<{
9
+ readonly points: any;
10
+ readonly uPoints: any;
11
+ }, (string | undefined)[], never> | undefined;
12
+ } & {
13
+ queryKey: (string | undefined)[] & {
14
+ [dataTagSymbol]: {
15
+ readonly points: any;
16
+ readonly uPoints: any;
17
+ };
18
+ [dataTagErrorSymbol]: Error;
19
+ };
20
+ };
@@ -0,0 +1 @@
1
+ export * from './get-points-query-options';
@@ -0,0 +1,2 @@
1
+ export * from './points-response';
2
+ export * from './points';
@@ -0,0 +1,4 @@
1
+ export interface PointsResponse {
2
+ points: string;
3
+ unclaimed_points: string;
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface Points {
2
+ points: string;
3
+ uPoints: string;
4
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/wallets",
3
3
  "private": false,
4
- "version": "1.2.13",
4
+ "version": "1.2.15",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",
@@ -17,7 +17,7 @@
17
17
  "preview": "vite preview"
18
18
  },
19
19
  "devDependencies": {
20
- "@ecency/sdk": "1.0.28",
20
+ "@ecency/sdk": "^1.0.40",
21
21
  "@hiveio/dhive": "^1.3.2",
22
22
  "@tanstack/react-query": "^5.74.4",
23
23
  "@types/node": "^22.13.8",