@ecency/sdk 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,48 +1,45 @@
1
- import { useMemo as K, useCallback as R } from "react";
2
- import { useQuery as h, queryOptions as g, useQueryClient as v, useMutation as u } from "@tanstack/react-query";
3
- import { BtcWallet as C } from "@okxweb3/coin-bitcoin";
1
+ import { useMemo as K, useCallback as C } from "react";
2
+ import { useQuery as w, queryOptions as f, useQueryClient as v, useMutation as l } from "@tanstack/react-query";
3
+ import { BtcWallet as R } from "@okxweb3/coin-bitcoin";
4
4
  import { EthWallet as H } from "@okxweb3/coin-ethereum";
5
5
  import { TrxWallet as N } from "@okxweb3/coin-tron";
6
- import { TonWallet as j } from "@okxweb3/coin-ton";
7
- import { SolWallet as D } from "@okxweb3/coin-solana";
8
- import { AtomWallet as x } from "@okxweb3/coin-cosmos";
9
- import { AptosWallet as L } from "@okxweb3/coin-aptos";
10
- import _, { mnemonicToSeedSync as F } from "bip39";
11
- import { Client as B, PrivateKey as l, cryptoUtils as E } from "@hiveio/dhive";
6
+ import { TonWallet as _ } from "@okxweb3/coin-ton";
7
+ import { SolWallet as j } from "@okxweb3/coin-solana";
8
+ import { AtomWallet as D } from "@okxweb3/coin-cosmos";
9
+ import { AptosWallet as F } from "@okxweb3/coin-aptos";
10
+ import L from "bip39";
11
+ import { Client as x, PrivateKey as u, cryptoUtils as E } from "@hiveio/dhive";
12
12
  import { LRUCache as q } from "lru-cache";
13
13
  import b from "hivesigner";
14
- var a = /* @__PURE__ */ ((e) => (e.BTC = "BTC", e.ETH = "ETH", e.APT = "APT", e.ATOM = "ATOM", e.TON = "TON", e.TRON = "TRX", e.SOL = "SOL", e))(a || {}), m = /* @__PURE__ */ ((e) => (e.Points = "POINTS", e.HivePower = "HP", e.Hive = "HIVE", e.HiveDollar = "HBD", e.Spk = "SPK", e))(m || {});
15
- function M(e) {
16
- return new Promise((t) => setTimeout(t, e));
14
+ var a = /* @__PURE__ */ ((t) => (t.BTC = "BTC", t.ETH = "ETH", t.APT = "APT", t.ATOM = "ATOM", t.TON = "TON", t.TRON = "TRX", t.SOL = "SOL", t))(a || {}), d = /* @__PURE__ */ ((t) => (t.Points = "POINTS", t.HivePower = "HP", t.Hive = "HIVE", t.HiveDollar = "HBD", t.Spk = "SPK", t))(d || {});
15
+ function B(t) {
16
+ return new Promise((e) => setTimeout(e, t));
17
17
  }
18
- function T(e) {
19
- switch (e) {
18
+ function T(t) {
19
+ switch (t) {
20
20
  case a.BTC:
21
- return new C();
21
+ return new R();
22
22
  case a.ETH:
23
23
  return new H();
24
24
  case a.TRON:
25
25
  return new N();
26
26
  case a.TON:
27
- return new j();
27
+ return new _();
28
28
  case a.SOL:
29
- return new D();
29
+ return new j();
30
30
  case a.ATOM:
31
- return new x();
31
+ return new D();
32
32
  case a.APT:
33
- return new L();
33
+ return new F();
34
34
  default:
35
35
  return;
36
36
  }
37
37
  }
38
- function Pe(e) {
39
- return F(e).toString("hex");
40
- }
41
38
  const p = {
42
39
  privateApiHost: "https://ecency.com",
43
40
  storage: localStorage,
44
41
  storagePrefix: "ecency",
45
- hiveClient: new B(
42
+ hiveClient: new x(
46
43
  [
47
44
  "https://api.hive.blog",
48
45
  "https://api.deathwing.me",
@@ -64,19 +61,19 @@ const p = {
64
61
  ),
65
62
  heliusApiKey: "fb1e2935-f911-4b1d-8e1c-3863f6879d42"
66
63
  };
67
- function Se(e, t) {
68
- return h({
69
- queryKey: ["ecency-wallets", "external-wallet-balance", e, t],
64
+ function Tt(t, e) {
65
+ return w({
66
+ queryKey: ["ecency-wallets", "external-wallet-balance", t, e],
70
67
  queryFn: async () => {
71
- switch (e) {
68
+ switch (t) {
72
69
  case a.BTC:
73
70
  const o = await (await fetch(
74
- `https://mempool.space/api/address/${t}`
71
+ `https://mempool.space/api/address/${e}`
75
72
  )).json();
76
73
  return (o.chain_stats.funded_txo_sum - o.chain_stats.spent_txo_sum) / 1e8;
77
74
  case a.ETH:
78
75
  return +(await (await fetch(
79
- `https://api.ethplorer.io/getAddressInfo/${t}?apiKey=freekey`
76
+ `https://api.ethplorer.io/getAddressInfo/${e}?apiKey=freekey`
80
77
  )).json()).ETH.balance;
81
78
  case a.SOL:
82
79
  return (await (await fetch(
@@ -87,7 +84,7 @@ function Se(e, t) {
87
84
  jsonrpc: "2.0",
88
85
  id: "1",
89
86
  method: "getBalance",
90
- params: [t]
87
+ params: [e]
91
88
  }),
92
89
  headers: {
93
90
  "Content-Type": "application/json"
@@ -96,34 +93,34 @@ function Se(e, t) {
96
93
  )).json()).result.value / 1e9;
97
94
  case a.TRON:
98
95
  return (await (await fetch(
99
- `https://api.trongrid.io/v1/accounts/${t}`
96
+ `https://api.trongrid.io/v1/accounts/${e}`
100
97
  )).json()).data[0].balance / 1e6;
101
98
  case a.TON:
102
99
  return (await (await fetch(
103
- `https://tonapi.io/v1/blockchain/getAccount?account=${t}`
100
+ `https://tonapi.io/v1/blockchain/getAccount?account=${e}`
104
101
  )).json()).balance / 1e9;
105
102
  case a.APT:
106
- const f = (await (await fetch(
107
- `https://fullnode.mainnet.aptoslabs.com/v1/accounts/${t}/resources`
103
+ const g = (await (await fetch(
104
+ `https://fullnode.mainnet.aptoslabs.com/v1/accounts/${e}/resources`
108
105
  )).json()).find(
109
106
  (k) => k.type.includes("coin::CoinStore")
110
107
  );
111
- return f ? parseInt(f.data.coin.value) / 1e8 : 0;
108
+ return g ? parseInt(g.data.coin.value) / 1e8 : 0;
112
109
  case a.ATOM:
113
110
  return +(await (await fetch(
114
- `https://rest.cosmos.directory/cosmoshub/auth/accounts/${t}`
111
+ `https://rest.cosmos.directory/cosmoshub/auth/accounts/${e}`
115
112
  )).json()).result.value.coins[0].amount / 1e6;
116
113
  }
117
114
  }
118
115
  });
119
116
  }
120
- function P(e) {
121
- return h({
122
- queryKey: ["ecency-wallets", "seed", e],
123
- queryFn: async () => _.generateMnemonic(128)
117
+ function P(t) {
118
+ return w({
119
+ queryKey: ["ecency-wallets", "seed", t],
120
+ queryFn: async () => L.generateMnemonic(128)
124
121
  });
125
122
  }
126
- const W = {
123
+ const M = {
127
124
  max: 500,
128
125
  // how long to live in ms
129
126
  ttl: 1e3 * 60 * 5,
@@ -131,32 +128,32 @@ const W = {
131
128
  allowStale: !1,
132
129
  updateAgeOnGet: !1,
133
130
  updateAgeOnHas: !1
134
- }, S = new q(W), w = Symbol("undefined"), I = (e, t) => S.set(e, t === void 0 ? w : t), Q = (e) => {
135
- const t = S.get(e);
136
- return t === w ? void 0 : t;
131
+ }, O = new q(M), m = Symbol("undefined"), Q = (t, e) => O.set(t, e === void 0 ? m : e), W = (t) => {
132
+ const e = O.get(t);
133
+ return e === m ? void 0 : e;
137
134
  };
138
- function Oe(e) {
139
- return h({
140
- queryKey: ["ecency-wallets", "coingecko-price", e],
135
+ function Pt(t) {
136
+ return w({
137
+ queryKey: ["ecency-wallets", "coingecko-price", t],
141
138
  queryFn: async () => {
142
- let t = e;
143
- switch (e) {
139
+ let e = t;
140
+ switch (t) {
144
141
  case a.BTC:
145
- t = "binance-wrapped-btc";
142
+ e = "binance-wrapped-btc";
146
143
  break;
147
144
  case a.ETH:
148
- t = "ethereum";
145
+ e = "ethereum";
149
146
  break;
150
147
  case a.SOL:
151
- t = "solana";
148
+ e = "solana";
152
149
  break;
153
150
  case a.TON:
154
- t = "trx";
151
+ e = "trx";
155
152
  break;
156
153
  default:
157
- t = e;
154
+ e = t;
158
155
  }
159
- let n = Q("gecko"), o;
156
+ let n = W("gecko"), o;
160
157
  if (n)
161
158
  o = n;
162
159
  else {
@@ -166,29 +163,29 @@ function Oe(e) {
166
163
  method: "POST",
167
164
  body: JSON.stringify({
168
165
  params: {
169
- ids: [t],
166
+ ids: [e],
170
167
  vs_currencies: "usd"
171
168
  }
172
169
  })
173
170
  }
174
171
  )).json();
175
- I("gecko", i === void 0 ? w : i), o = i;
172
+ Q("gecko", i === void 0 ? m : i), o = i;
176
173
  }
177
174
  return 1 / +o[Object.keys(o)[0]].usd;
178
175
  },
179
- enabled: !!e
176
+ enabled: !!t
180
177
  });
181
178
  }
182
- function J(e) {
183
- const { data: t } = P(e);
184
- return h({
185
- queryKey: ["ecencу-wallets", "hive-keys", e, t],
179
+ function I(t) {
180
+ const { data: e } = P(t);
181
+ return w({
182
+ queryKey: ["ecencу-wallets", "hive-keys", t, e],
186
183
  queryFn: async () => {
187
- if (!t)
184
+ if (!e)
188
185
  throw new Error("[Ecency][Wallets] - no seed to create Hive account");
189
- const n = l.fromLogin(e, t, "owner"), o = l.fromLogin(e, t, "active"), s = l.fromLogin(e, t, "posting"), r = l.fromLogin(e, t, "memo");
186
+ const n = u.fromLogin(t, e, "owner"), o = u.fromLogin(t, e, "active"), s = u.fromLogin(t, e, "posting"), r = u.fromLogin(t, e, "memo");
190
187
  return {
191
- username: e,
188
+ username: t,
192
189
  owner: n.toString(),
193
190
  active: o.toString(),
194
191
  posting: s.toString(),
@@ -201,26 +198,26 @@ function J(e) {
201
198
  }
202
199
  });
203
200
  }
204
- function Ae(e, t) {
205
- return g({
206
- queryKey: ["ecency-wallets", "points", e, t],
201
+ function Ot(t, e) {
202
+ return f({
203
+ queryKey: ["ecency-wallets", "points", t, e],
207
204
  queryFn: async () => await (await fetch(
208
205
  `${p.privateApiHost}/private-api/points`,
209
206
  {
210
207
  method: "POST",
211
208
  body: JSON.stringify({
212
- username: e.replace("@", "")
209
+ username: t.replace("@", "")
213
210
  })
214
211
  }
215
212
  )).json(),
216
213
  staleTime: 3e4,
217
214
  refetchOnMount: !0,
218
- enabled: !!e
215
+ enabled: !!t
219
216
  });
220
217
  }
221
- function $(e, t) {
222
- return g({
223
- queryKey: ["hive-engine", "tokens-list", e, t],
218
+ function J(t, e) {
219
+ return f({
220
+ queryKey: ["hive-engine", "tokens-list", t, e],
224
221
  queryFn: async () => (await (await fetch(
225
222
  `${p.privateApiHost}/private-api/engine-api`,
226
223
  {
@@ -232,8 +229,8 @@ function $(e, t) {
232
229
  contract: "market",
233
230
  table: "metrics",
234
231
  query: {
235
- symbol: t,
236
- account: e
232
+ symbol: e,
233
+ account: t
237
234
  }
238
235
  },
239
236
  id: 1
@@ -243,31 +240,31 @@ function $(e, t) {
243
240
  )).json()).result
244
241
  });
245
242
  }
246
- function ke(e) {
247
- const { data: t } = h($());
243
+ function St(t) {
244
+ const { data: e } = w(J());
248
245
  return K(
249
246
  () => {
250
247
  var n;
251
248
  return {
252
249
  basic: [
253
- m.Points,
254
- m.Hive,
255
- m.HivePower,
256
- m.HiveDollar,
257
- m.Spk
258
- ].filter((o) => o.toLowerCase().includes(e.toLowerCase())),
250
+ d.Points,
251
+ d.Hive,
252
+ d.HivePower,
253
+ d.HiveDollar,
254
+ d.Spk
255
+ ].filter((o) => o.toLowerCase().includes(t.toLowerCase())),
259
256
  external: Object.values(a).filter(
260
- (o) => o.toLowerCase().includes(e.toLowerCase())
257
+ (o) => o.toLowerCase().includes(t.toLowerCase())
261
258
  ),
262
- layer2: ((n = t == null ? void 0 : t.map(({ symbol: o }) => o)) == null ? void 0 : n.filter(
263
- (o) => o.toLowerCase().includes(e.toLowerCase())
259
+ layer2: ((n = e == null ? void 0 : e.map(({ symbol: o }) => o)) == null ? void 0 : n.filter(
260
+ (o) => o.toLowerCase().includes(t.toLowerCase())
264
261
  )) ?? []
265
262
  };
266
263
  },
267
- [t, e]
264
+ [e, t]
268
265
  );
269
266
  }
270
- const G = {
267
+ const $ = {
271
268
  [a.BTC]: "m/44'/0'/0'/0/0",
272
269
  // Bitcoin (BIP44)
273
270
  [a.ETH]: "m/44'/60'/0'/0/0",
@@ -283,26 +280,26 @@ const G = {
283
280
  [a.ATOM]: "m/44'/118'/0'/0/0"
284
281
  // Cosmos (BIP44)
285
282
  };
286
- function Ke(e, t) {
287
- const { data: n } = P(e), o = v(), s = u({
288
- mutationKey: ["ecency-wallets", "create-wallet", e, t],
283
+ function At(t, e) {
284
+ const { data: n } = P(t), o = v(), s = l({
285
+ mutationKey: ["ecency-wallets", "create-wallet", t, e],
289
286
  mutationFn: async () => {
290
287
  if (!n)
291
288
  throw new Error("[Ecency][Wallets] - No seed to create a wallet");
292
- const i = T(t), c = await (i == null ? void 0 : i.getDerivedPrivateKey({
289
+ const i = T(e), c = await (i == null ? void 0 : i.getDerivedPrivateKey({
293
290
  mnemonic: n,
294
- hdPath: G[t]
291
+ hdPath: $[e]
295
292
  }));
296
- await M(1e3);
297
- const d = await (i == null ? void 0 : i.getNewAddress({
293
+ await B(1e3);
294
+ const h = await (i == null ? void 0 : i.getNewAddress({
298
295
  privateKey: c
299
296
  }));
300
297
  return {
301
298
  privateKey: c,
302
- address: d.address,
303
- publicKey: d.publicKey,
304
- username: e,
305
- currency: t
299
+ address: h.address,
300
+ publicKey: h.publicKey,
301
+ username: t,
302
+ currency: e
306
303
  };
307
304
  },
308
305
  onSuccess: (i) => {
@@ -311,26 +308,26 @@ function Ke(e, t) {
311
308
  (c) => new Map(c ? Array.from(c.entries()) : []).set(i.currency, i)
312
309
  );
313
310
  }
314
- }), r = R(() => {
311
+ }), r = C(() => {
315
312
  }, []);
316
313
  return {
317
314
  createWallet: s,
318
315
  importWallet: r
319
316
  };
320
317
  }
321
- function V(e) {
322
- const { data: t } = h({
323
- queryKey: ["ecency-wallets", "wallets", e]
324
- }), { data: n } = J(e);
325
- return u({
326
- mutationKey: ["ecency-wallets", "create-account-with-wallets", e],
318
+ function G(t) {
319
+ const { data: e } = w({
320
+ queryKey: ["ecency-wallets", "wallets", t]
321
+ }), { data: n } = I(t);
322
+ return l({
323
+ mutationKey: ["ecency-wallets", "create-account-with-wallets", t],
327
324
  mutationFn: ({ currency: o, address: s }) => fetch(p.privateApiHost + "/private-api/wallets-add", {
328
325
  method: "POST",
329
326
  headers: {
330
327
  "Content-Type": "application/json"
331
328
  },
332
329
  body: JSON.stringify({
333
- username: e,
330
+ username: t,
334
331
  token: o,
335
332
  address: s,
336
333
  meta: {
@@ -338,7 +335,7 @@ function V(e) {
338
335
  activePublicKey: n == null ? void 0 : n.activePubkey,
339
336
  postingPublicKey: n == null ? void 0 : n.postingPubkey,
340
337
  memoPublicKey: n == null ? void 0 : n.memoPubkey,
341
- ...Array.from((t == null ? void 0 : t.entries()) ?? []).reduce(
338
+ ...Array.from((e == null ? void 0 : e.entries()) ?? []).reduce(
342
339
  (r, [i, c]) => ({
343
340
  ...r,
344
341
  [i]: c.address
@@ -350,10 +347,10 @@ function V(e) {
350
347
  })
351
348
  });
352
349
  }
353
- function O() {
354
- return u({
350
+ function S() {
351
+ return l({
355
352
  mutationKey: ["ecency-wallets", "check-wallet-existence"],
356
- mutationFn: async ({ address: e, currency: t }) => (await (await fetch(
353
+ mutationFn: async ({ address: t, currency: e }) => (await (await fetch(
357
354
  p.privateApiHost + "/private-api/wallets-exist",
358
355
  {
359
356
  method: "POST",
@@ -361,17 +358,17 @@ function O() {
361
358
  "Content-Type": "application/json"
362
359
  },
363
360
  body: JSON.stringify({
364
- address: e,
365
- token: t
361
+ address: t,
362
+ token: e
366
363
  })
367
364
  }
368
365
  )).json()).length === 0
369
366
  });
370
367
  }
371
- const Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
368
+ const kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
372
369
  __proto__: null,
373
- useCheckWalletExistence: O,
374
- useCreateAccountWithWallets: V
370
+ useCheckWalletExistence: S,
371
+ useCreateAccountWithWallets: G
375
372
  }, Symbol.toStringTag, { value: "Module" })), U = {
376
373
  [a.BTC]: ["m/84'/0'/0'/0/0"],
377
374
  [a.ETH]: ["m/84'/60'/0'/0/0"],
@@ -383,13 +380,13 @@ const Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
383
380
  // Disabled
384
381
  [a.ATOM]: ["m/84'/118'/0'/0'/0"]
385
382
  };
386
- async function z(e, t, n) {
383
+ async function V(t, e, n) {
387
384
  for (const o of U[n] || [])
388
385
  try {
389
- const s = await t.getDerivedPrivateKey({
390
- mnemonic: e,
386
+ const s = await e.getDerivedPrivateKey({
387
+ mnemonic: t,
391
388
  hdPath: o
392
- }), r = await t.getNewAddress({
389
+ }), r = await e.getNewAddress({
393
390
  privateKey: s,
394
391
  addressType: n === a.BTC ? "segwit_native" : void 0
395
392
  });
@@ -399,20 +396,20 @@ async function z(e, t, n) {
399
396
  }
400
397
  return [];
401
398
  }
402
- function Ce(e, t) {
403
- const n = v(), { mutateAsync: o } = O();
404
- return u({
405
- mutationKey: ["ecency-wallets", "import-wallet", e, t],
399
+ function Kt(t, e) {
400
+ const n = v(), { mutateAsync: o } = S();
401
+ return l({
402
+ mutationKey: ["ecency-wallets", "import-wallet", t, e],
406
403
  mutationFn: async ({ privateKeyOrSeed: s }) => {
407
- const r = T(t);
404
+ const r = T(e);
408
405
  if (!r)
409
406
  throw new Error("Cannot find token for this currency");
410
407
  const i = s.split(" ").length === 12;
411
- let c, d = s;
412
- if (i ? [d, c] = await z(
408
+ let c, h = s;
409
+ if (i ? [h, c] = await V(
413
410
  s,
414
411
  r,
415
- t
412
+ e
416
413
  ) : c = (await r.getNewAddress({
417
414
  privateKey: s
418
415
  })).address, !c || !s)
@@ -421,65 +418,65 @@ function Ce(e, t) {
421
418
  );
422
419
  if (!await o({
423
420
  address: c,
424
- currency: t
421
+ currency: e
425
422
  }))
426
423
  throw new Error(
427
424
  "This wallet has already in use by Hive account. Please, try another one"
428
425
  );
429
426
  return {
430
- privateKey: d,
427
+ privateKey: h,
431
428
  address: c,
432
429
  publicKey: ""
433
430
  };
434
431
  },
435
432
  onSuccess: ({ privateKey: s, publicKey: r, address: i }) => {
436
433
  n.setQueryData(
437
- ["ecency-wallets", "wallets", e],
438
- (c) => new Map(c ? Array.from(c.entries()) : []).set(t, {
434
+ ["ecency-wallets", "wallets", t],
435
+ (c) => new Map(c ? Array.from(c.entries()) : []).set(e, {
439
436
  privateKey: s,
440
437
  publicKey: r,
441
438
  address: i,
442
- username: e,
443
- currency: t,
439
+ username: t,
440
+ currency: e,
444
441
  custom: !0
445
442
  })
446
443
  );
447
444
  }
448
445
  });
449
446
  }
450
- function X(e) {
451
- let t = atob(e);
452
- if (t[0] === "{")
453
- return JSON.parse(t);
447
+ function z(t) {
448
+ let e = atob(t);
449
+ if (e[0] === "{")
450
+ return JSON.parse(e);
454
451
  }
455
- const y = (e) => {
452
+ const y = (t) => {
456
453
  try {
457
- const t = p.storage.getItem(
458
- p.storagePrefix + "_user_" + e
454
+ const e = p.storage.getItem(
455
+ p.storagePrefix + "_user_" + t
459
456
  );
460
- return X(JSON.parse(t));
461
- } catch (t) {
462
- console.error(t);
457
+ return z(JSON.parse(e));
458
+ } catch (e) {
459
+ console.error(e);
463
460
  return;
464
461
  }
465
- }, Y = (e) => y(e) && y(e).accessToken, Z = (e) => y(e) && y(e).postingKey;
466
- function ee(e = [], t, n) {
467
- return u({
468
- mutationKey: [...e, t],
462
+ }, X = (t) => y(t) && y(t).accessToken, Y = (t) => y(t) && y(t).postingKey;
463
+ function Z(t = [], e, n) {
464
+ return l({
465
+ mutationKey: [...t, e],
469
466
  mutationFn: async (o) => {
470
- if (!t)
467
+ if (!e)
471
468
  throw new Error(
472
469
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
473
470
  );
474
- const s = Z(t);
471
+ const s = Y(e);
475
472
  if (s) {
476
- const i = l.fromString(s);
473
+ const i = u.fromString(s);
477
474
  return p.hiveClient.broadcast.sendOperations(
478
475
  n(o),
479
476
  i
480
477
  );
481
478
  }
482
- let r = Y(t);
479
+ let r = X(e);
483
480
  if (r)
484
481
  return (await new b.Client({
485
482
  accessToken: r
@@ -490,21 +487,21 @@ function ee(e = [], t, n) {
490
487
  }
491
488
  });
492
489
  }
493
- function te(e) {
494
- return ee(
490
+ function tt(t) {
491
+ return Z(
495
492
  ["accounts", "update"],
496
- e,
493
+ t,
497
494
  ({
498
- profile: t,
495
+ profile: e,
499
496
  tokens: n
500
497
  }) => [
501
498
  [
502
499
  "account_update2",
503
500
  {
504
- account: e,
501
+ account: t,
505
502
  json_metadata: "",
506
503
  posting_json_metadata: JSON.stringify({
507
- profile: { ...t, version: 2 },
504
+ profile: { ...e, version: 2 },
508
505
  tokens: n
509
506
  }),
510
507
  extensions: []
@@ -513,13 +510,62 @@ function te(e) {
513
510
  ]
514
511
  );
515
512
  }
516
- function He(e) {
517
- const { mutateAsync: t } = te(e);
518
- return u({
519
- mutationKey: ["ecency-wallets", "save-wallet-to-metadata", e],
513
+ function Ct(t) {
514
+ return f({
515
+ queryKey: ["get-account-full", t],
516
+ queryFn: async () => {
517
+ if (!t)
518
+ throw new Error("[SDK] Username is empty");
519
+ const e = await p.hiveClient.database.getAccounts([t]);
520
+ if (!e[0])
521
+ throw new Error("[SDK] No account with given username");
522
+ const n = JSON.parse(e[0].posting_json_metadata).profile;
523
+ let o;
524
+ try {
525
+ o = await p.hiveClient.database.call(
526
+ "get_follow_count",
527
+ [t]
528
+ );
529
+ } catch {
530
+ }
531
+ const s = await p.hiveClient.call(
532
+ "condenser_api",
533
+ "get_account_reputations",
534
+ [t, 1]
535
+ );
536
+ return {
537
+ ...e,
538
+ follow_stats: o,
539
+ reputation: s[0].reputation,
540
+ profile: {
541
+ ...n,
542
+ reputation: s[0].reputation
543
+ }
544
+ };
545
+ },
546
+ enabled: !!t,
547
+ staleTime: 6e4
548
+ });
549
+ }
550
+ function Rt(t, e = 5, n = []) {
551
+ return f({
552
+ queryKey: ["accounts", "search", t, n],
553
+ enabled: !!t,
554
+ queryFn: async () => (await p.hiveClient.database.call(
555
+ "lookup_accounts",
556
+ [t, e]
557
+ )).filter(
558
+ (s) => n.length > 0 ? !n.includes(s) : !0
559
+ )
560
+ });
561
+ }
562
+ function Ht(t) {
563
+ const { mutateAsync: e } = tt(t);
564
+ return l({
565
+ mutationKey: ["ecency-wallets", "save-wallet-to-metadata", t],
520
566
  mutationFn: ({
521
567
  wallets: n
522
- }) => t({
568
+ }) => e({
523
569
  profile: {},
524
570
  tokens: Array.from(n.entries() ?? []).map(([o, s]) => ({
525
571
  symbol: o,
@@ -531,28 +577,28 @@ function He(e) {
531
577
  })
532
578
  });
533
579
  }
534
- function Ne(e) {
535
- return u({
536
- mutationKey: ["operations", "sign", e],
580
+ function Nt(t) {
581
+ return l({
582
+ mutationKey: ["operations", "sign", t],
537
583
  mutationFn: ({
538
- operation: t,
584
+ operation: e,
539
585
  keyOrSeed: n
540
586
  }) => {
541
- if (!e)
587
+ if (!t)
542
588
  throw new Error("[Operations][Sign] – cannot sign op with anon user");
543
589
  let o;
544
- return n.split(" ").length === 12 ? o = l.fromLogin(e, n, "active") : E.isWif(n) ? o = l.fromString(n) : o = l.from(n), p.hiveClient.broadcast.sendOperations(
545
- [t],
590
+ return n.split(" ").length === 12 ? o = u.fromLogin(t, n, "active") : E.isWif(n) ? o = u.fromString(n) : o = u.from(n), p.hiveClient.broadcast.sendOperations(
591
+ [e],
546
592
  o
547
593
  );
548
594
  }
549
595
  });
550
596
  }
551
- const ne = (e, t, n, o = null) => new Promise((s, r) => {
597
+ const et = (t, e, n, o = null) => new Promise((s, r) => {
552
598
  var i;
553
599
  (i = window.hive_keychain) == null || i.requestBroadcast(
554
- e,
555
600
  t,
601
+ e,
556
602
  n,
557
603
  (c) => {
558
604
  c.success || r({ message: "Operation cancelled" }), s(c);
@@ -560,43 +606,42 @@ const ne = (e, t, n, o = null) => new Promise((s, r) => {
560
606
  o
561
607
  );
562
608
  });
563
- function je(e, t = "Active") {
564
- return u({
565
- mutationKey: ["operations", "sign-keychain", e],
609
+ function _t(t, e = "Active") {
610
+ return l({
611
+ mutationKey: ["operations", "sign-keychain", t],
566
612
  mutationFn: ({ operation: n }) => {
567
- if (!e)
613
+ if (!t)
568
614
  throw new Error(
569
615
  "[SDK][Keychain] – cannot sign operation with anon user"
570
616
  );
571
- return ne(e, [n], t);
617
+ return et(t, [n], e);
572
618
  }
573
619
  });
574
620
  }
575
- function De(e = "/") {
576
- return u({
577
- mutationKey: ["operations", "sign-hivesigner", e],
578
- mutationFn: async ({ operation: t }) => b.sendOperation(t, { callback: e }, () => {
621
+ function jt(t = "/") {
622
+ return l({
623
+ mutationKey: ["operations", "sign-hivesigner", t],
624
+ mutationFn: async ({ operation: e }) => b.sendOperation(e, { callback: t }, () => {
579
625
  })
580
626
  });
581
627
  }
582
628
  export {
583
- m as EcencyWalletBasicTokens,
629
+ d as EcencyWalletBasicTokens,
584
630
  a as EcencyWalletCurrency,
585
- Re as EcencyWalletsPrivateApi,
586
- M as delay,
587
- Ae as getAccountPointsQueryOptions,
588
- T as getWallet,
589
- Pe as mnemonicToSeedBip39,
590
- te as useAccountUpdate,
591
- Oe as useCoinGeckoPriceQuery,
592
- ke as useGetAllTokensListQuery,
593
- Se as useGetExternalWalletBalanceQuery,
594
- J as useHiveKeysQuery,
595
- Ce as useImportWallet,
596
- He as useSaveWalletInformationToMetadata,
631
+ kt as EcencyWalletsPrivateApi,
632
+ Ct as getAccountFullQueryOptions,
633
+ Ot as getAccountPointsQueryOptions,
634
+ Rt as getSearchAccountsByUsernameQueryOptions,
635
+ tt as useAccountUpdate,
636
+ Pt as useCoinGeckoPriceQuery,
637
+ St as useGetAllTokensListQuery,
638
+ Tt as useGetExternalWalletBalanceQuery,
639
+ I as useHiveKeysQuery,
640
+ Kt as useImportWallet,
641
+ Ht as useSaveWalletInformationToMetadata,
597
642
  P as useSeedPhrase,
598
- De as useSignOperationByHivesigner,
599
- Ne as useSignOperationByKey,
600
- je as useSignOperationByKeychain,
601
- Ke as useWalletCreate
643
+ jt as useSignOperationByHivesigner,
644
+ Nt as useSignOperationByKey,
645
+ _t as useSignOperationByKeychain,
646
+ At as useWalletCreate
602
647
  };
@@ -1 +1,2 @@
1
1
  export * from './mutations';
2
+ export * from './queries';
@@ -1 +1,2 @@
1
1
  export * from './get-account-full-query-options';
2
+ export * from './search-accounts-by-username-query-options';
@@ -1,5 +1,4 @@
1
1
  export * from './enums';
2
2
  export * from './mutations';
3
- export * from './utils';
4
3
  export * from './queries';
5
4
  export * from './types';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.23",
4
+ "version": "1.0.24",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",