@ecency/sdk 1.1.1 → 1.1.3

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,12 +1,13 @@
1
- var N = Object.defineProperty;
2
- var x = (e, t, n) => t in e ? N(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var O = (e, t, n) => x(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as q, useMutation as d, useQuery as T, useInfiniteQuery as G, queryOptions as p, infiniteQueryOptions as V } from "@tanstack/react-query";
5
- import { Client as W, PrivateKey as v, cryptoUtils as z, RCAPI as U } from "@hiveio/dhive";
1
+ var V = Object.defineProperty;
2
+ var W = (e, t, n) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var k = (e, t, n) => W(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { QueryClient as A, useMutation as d, useQuery as j, useInfiniteQuery as z, queryOptions as p, useQueryClient as U, infiniteQueryOptions as $ } from "@tanstack/react-query";
5
+ import { Client as R, PrivateKey as v, cryptoUtils as X, RCAPI as Y } from "@hiveio/dhive";
6
6
  import m from "hivesigner";
7
- class $ {
7
+ import * as C from "remeda";
8
+ class Z {
8
9
  constructor() {
9
- O(this, "length", 0);
10
+ k(this, "length", 0);
10
11
  }
11
12
  clear() {
12
13
  throw new Error("Method not implemented.");
@@ -26,9 +27,9 @@ class $ {
26
27
  }
27
28
  const i = {
28
29
  privateApiHost: "https://ecency.com",
29
- storage: typeof window > "u" ? new $() : window.localStorage,
30
+ storage: typeof window > "u" ? new Z() : window.localStorage,
30
31
  storagePrefix: "ecency",
31
- hiveClient: new W(
32
+ hiveClient: new R(
32
33
  [
33
34
  "https://api.hive.blog",
34
35
  "https://api.deathwing.me",
@@ -49,36 +50,36 @@ const i = {
49
50
  }
50
51
  ),
51
52
  heliusApiKey: void 0,
52
- queryClient: new q(),
53
+ queryClient: new A(),
53
54
  plausibleHost: "https://pl.ecency.com",
54
55
  spkNode: "https://spk.good-karma.xyz"
55
56
  };
56
- var k;
57
+ var K;
57
58
  ((e) => {
58
59
  function t(n) {
59
60
  i.queryClient = n;
60
61
  }
61
62
  e.setQueryClient = t;
62
- })(k || (k = {}));
63
- function R(e) {
63
+ })(K || (K = {}));
64
+ function L(e) {
64
65
  let t = atob(e);
65
66
  if (t[0] === "{")
66
67
  return JSON.parse(t);
67
68
  }
68
- var Q = /* @__PURE__ */ ((e) => (e.HIVE = "HIVE", e.HBD = "HBD", e.VESTS = "VESTS", e.SPK = "SPK", e))(Q || {}), A = /* @__PURE__ */ ((e) => (e["@@000000021"] = "HIVE", e["@@000000013"] = "HBD", e["@@000000037"] = "VESTS", e))(A || {});
69
+ var D = /* @__PURE__ */ ((e) => (e.HIVE = "HIVE", e.HBD = "HBD", e.VESTS = "VESTS", e.SPK = "SPK", e))(D || {}), F = /* @__PURE__ */ ((e) => (e["@@000000021"] = "HIVE", e["@@000000013"] = "HBD", e["@@000000037"] = "VESTS", e))(F || {});
69
70
  function g(e) {
70
71
  if (typeof e == "string") {
71
72
  const t = e.split(" ");
72
73
  return {
73
74
  amount: parseFloat(t[0]),
74
75
  // @ts-ignore
75
- symbol: Q[t[1]]
76
+ symbol: D[t[1]]
76
77
  };
77
78
  } else
78
79
  return {
79
80
  amount: parseFloat(e.amount.toString()) / Math.pow(10, e.precision),
80
81
  // @ts-ignore
81
- symbol: A[e.nai]
82
+ symbol: F[e.nai]
82
83
  };
83
84
  }
84
85
  const _ = (e) => {
@@ -86,13 +87,13 @@ const _ = (e) => {
86
87
  const t = i.storage.getItem(
87
88
  i.storagePrefix + "_user_" + e
88
89
  );
89
- return R(JSON.parse(t));
90
+ return L(JSON.parse(t));
90
91
  } catch (t) {
91
92
  console.error(t);
92
93
  return;
93
94
  }
94
- }, y = (e) => _(e) && _(e).accessToken, j = (e) => _(e) && _(e).postingKey, F = (e) => _(e) && _(e).loginType, ye = (e) => _(e) && _(e).refreshToken;
95
- function X() {
95
+ }, y = (e) => _(e) && _(e).accessToken, P = (e) => _(e) && _(e).postingKey, E = (e) => _(e) && _(e).loginType, he = (e) => _(e) && _(e).refreshToken;
96
+ function ee() {
96
97
  return new Promise((e) => {
97
98
  var t;
98
99
  (t = window.hive_keychain) == null || t.requestHandshake(() => {
@@ -101,66 +102,72 @@ function X() {
101
102
  });
102
103
  }
103
104
  const b = (e, t, n, o = null) => new Promise((r, c) => {
104
- var a;
105
- (a = window.hive_keychain) == null || a.requestBroadcast(
105
+ var s;
106
+ (s = window.hive_keychain) == null || s.requestBroadcast(
106
107
  e,
107
108
  t,
108
109
  n,
109
- (s) => {
110
- s.success || c({ message: "Operation cancelled" }), r(s);
110
+ (a) => {
111
+ a.success || c({ message: "Operation cancelled" }), r(a);
111
112
  },
112
113
  o
113
114
  );
114
- }), Y = (e, t, n, o, r, c = null) => new Promise((a, s) => {
115
- var f;
116
- (f = window.hive_keychain) == null || f.requestCustomJson(
115
+ }), te = (e, t, n, o, r, c = null) => new Promise((s, a) => {
116
+ var l;
117
+ (l = window.hive_keychain) == null || l.requestCustomJson(
117
118
  e,
118
119
  t,
119
120
  n,
120
121
  o,
121
122
  r,
122
123
  (w) => {
123
- w.success || s({ message: "Operation cancelled" }), a(w);
124
+ w.success || a({ message: "Operation cancelled" }), s(w);
124
125
  },
125
126
  c
126
127
  );
127
- }), de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
128
+ }), fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
128
129
  __proto__: null,
129
130
  broadcast: b,
130
- customJson: Y,
131
- handshake: X
131
+ customJson: te,
132
+ handshake: ee
132
133
  }, Symbol.toStringTag, { value: "Module" }));
133
- function Z(e = [], t, n) {
134
+ function ne(e = [], t, n, o = () => {
135
+ }) {
134
136
  return d({
137
+ onSuccess: o,
135
138
  mutationKey: [...e, t],
136
- mutationFn: async (o) => {
139
+ mutationFn: async (r) => {
137
140
  if (!t)
138
141
  throw new Error(
139
142
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
140
143
  );
141
- const r = j(t);
142
- if (r) {
143
- const s = v.fromString(r);
144
+ const c = P(t);
145
+ if (c) {
146
+ const l = v.fromString(c);
144
147
  return i.hiveClient.broadcast.sendOperations(
145
- n(o),
146
- s
148
+ n(r),
149
+ l
147
150
  );
148
151
  }
149
- const c = F(t);
150
- if (c && c == "keychain")
151
- return b(t, n(o), "Posting").then((s) => s.result);
152
+ const s = E(t);
153
+ if (s && s == "keychain")
154
+ return b(
155
+ t,
156
+ n(r),
157
+ "Posting"
158
+ ).then((l) => l.result);
152
159
  let a = y(t);
153
160
  if (a)
154
161
  return (await new m.Client({
155
162
  accessToken: a
156
- }).broadcast(n(o))).result;
163
+ }).broadcast(n(r))).result;
157
164
  throw new Error(
158
165
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
159
166
  );
160
167
  }
161
168
  });
162
169
  }
163
- async function L(e, t, n) {
170
+ async function oe(e, t, n) {
164
171
  if (!e)
165
172
  throw new Error(
166
173
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
@@ -170,28 +177,28 @@ async function L(e, t, n) {
170
177
  required_auths: [],
171
178
  required_posting_auths: [e],
172
179
  json: JSON.stringify(n)
173
- }, r = j(e);
180
+ }, r = P(e);
174
181
  if (r) {
175
- const s = v.fromString(r);
182
+ const a = v.fromString(r);
176
183
  return i.hiveClient.broadcast.json(
177
184
  o,
178
- s
185
+ a
179
186
  );
180
187
  }
181
- const c = F(e);
188
+ const c = E(e);
182
189
  if (c && c == "keychain")
183
- return b(e, [["custom_json", o]], "Posting").then((s) => s.result);
184
- let a = y(e);
185
- if (a)
190
+ return b(e, [["custom_json", o]], "Posting").then((a) => a.result);
191
+ let s = y(e);
192
+ if (s)
186
193
  return (await new m.Client({
187
- accessToken: a
194
+ accessToken: s
188
195
  }).customJson([], [e], t, JSON.stringify(n))).result;
189
196
  throw new Error(
190
197
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
191
198
  );
192
199
  }
193
- function le() {
194
- return new q({
200
+ function ge() {
201
+ return new A({
195
202
  defaultOptions: {
196
203
  queries: {
197
204
  // With SSR, we usually want to set some default staleTime
@@ -204,87 +211,87 @@ function le() {
204
211
  });
205
212
  }
206
213
  const u = () => i.queryClient;
207
- var K;
214
+ var q;
208
215
  ((e) => {
209
- function t(s) {
210
- return u().getQueryData(s);
216
+ function t(a) {
217
+ return u().getQueryData(a);
211
218
  }
212
219
  e.getQueryData = t;
213
- function n(s) {
214
- return u().getQueryData(s);
220
+ function n(a) {
221
+ return u().getQueryData(a);
215
222
  }
216
223
  e.getInfiniteQueryData = n;
217
- async function o(s) {
218
- return await u().prefetchQuery(s), t(s.queryKey);
224
+ async function o(a) {
225
+ return await u().prefetchQuery(a), t(a.queryKey);
219
226
  }
220
227
  e.prefetchQuery = o;
221
- async function r(s) {
222
- return await u().prefetchInfiniteQuery(s), n(s.queryKey);
228
+ async function r(a) {
229
+ return await u().prefetchInfiniteQuery(a), n(a.queryKey);
223
230
  }
224
231
  e.prefetchInfiniteQuery = r;
225
- function c(s) {
232
+ function c(a) {
226
233
  return {
227
- prefetch: () => o(s),
228
- getData: () => t(s.queryKey),
229
- useClientQuery: () => T(s),
230
- fetchAndGet: () => u().fetchQuery(s)
234
+ prefetch: () => o(a),
235
+ getData: () => t(a.queryKey),
236
+ useClientQuery: () => j(a),
237
+ fetchAndGet: () => u().fetchQuery(a)
231
238
  };
232
239
  }
233
240
  e.generateClientServerQuery = c;
234
- function a(s) {
241
+ function s(a) {
235
242
  return {
236
- prefetch: () => r(s),
237
- getData: () => n(s.queryKey),
238
- useClientQuery: () => G(s),
239
- fetchAndGet: () => u().fetchInfiniteQuery(s)
243
+ prefetch: () => r(a),
244
+ getData: () => n(a.queryKey),
245
+ useClientQuery: () => z(a),
246
+ fetchAndGet: () => u().fetchInfiniteQuery(a)
240
247
  };
241
248
  }
242
- e.generateClientServerInfiniteQuery = a;
243
- })(K || (K = {}));
244
- function he() {
249
+ e.generateClientServerInfiniteQuery = s;
250
+ })(q || (q = {}));
251
+ function _e() {
245
252
  return p({
246
253
  queryKey: ["core", "dynamic-props"],
247
254
  refetchInterval: 6e4,
248
255
  staleTime: 6e4,
249
256
  refetchOnMount: !0,
250
257
  queryFn: async () => {
251
- const e = await i.hiveClient.database.getDynamicGlobalProperties().then((h) => ({
252
- total_vesting_fund_hive: h.total_vesting_fund_hive || h.total_vesting_fund_steem,
253
- total_vesting_shares: h.total_vesting_shares,
254
- hbd_print_rate: h.hbd_print_rate || h.sbd_print_rate,
255
- hbd_interest_rate: h.hbd_interest_rate,
256
- head_block_number: h.head_block_number,
257
- vesting_reward_percent: h.vesting_reward_percent,
258
- virtual_supply: h.virtual_supply
258
+ const e = await i.hiveClient.database.getDynamicGlobalProperties().then((f) => ({
259
+ total_vesting_fund_hive: f.total_vesting_fund_hive || f.total_vesting_fund_steem,
260
+ total_vesting_shares: f.total_vesting_shares,
261
+ hbd_print_rate: f.hbd_print_rate || f.sbd_print_rate,
262
+ hbd_interest_rate: f.hbd_interest_rate,
263
+ head_block_number: f.head_block_number,
264
+ vesting_reward_percent: f.vesting_reward_percent,
265
+ virtual_supply: f.virtual_supply
259
266
  })), t = await i.hiveClient.database.call("get_feed_history"), n = await i.hiveClient.database.call(
260
267
  "get_chain_properties"
261
268
  ), o = await i.hiveClient.database.call(
262
269
  "get_reward_fund",
263
270
  ["post"]
264
- ), r = g(e.total_vesting_fund_hive).amount / g(e.total_vesting_shares).amount * 1e6, c = g(t.current_median_history.base).amount, a = g(t.current_median_history.quote).amount, s = parseFloat(o.recent_claims), f = g(o.reward_balance).amount, w = e.hbd_print_rate, P = e.hbd_interest_rate, E = e.head_block_number, H = g(
271
+ ), r = g(e.total_vesting_fund_hive).amount / g(e.total_vesting_shares).amount * 1e6, c = g(t.current_median_history.base).amount, s = g(t.current_median_history.quote).amount, a = parseFloat(o.recent_claims), l = g(o.reward_balance).amount, w = e.hbd_print_rate, H = e.hbd_interest_rate, I = e.head_block_number, M = g(
265
272
  e.total_vesting_fund_hive
266
- ).amount, I = g(
273
+ ).amount, J = g(
267
274
  e.total_vesting_shares
268
- ).amount, M = g(e.virtual_supply).amount, B = e.vesting_reward_percent, J = n.account_creation_fee;
275
+ ).amount, N = g(e.virtual_supply).amount, x = e.vesting_reward_percent, G = n.account_creation_fee;
269
276
  return {
270
277
  hivePerMVests: r,
271
278
  base: c,
272
- quote: a,
273
- fundRecentClaims: s,
274
- fundRewardBalance: f,
279
+ quote: s,
280
+ fundRecentClaims: a,
281
+ fundRewardBalance: l,
275
282
  hbdPrintRate: w,
276
- hbdInterestRate: P,
277
- headBlock: E,
278
- totalVestingFund: H,
279
- totalVestingShares: I,
280
- virtualSupply: M,
281
- vestingRewardPercent: B,
282
- accountCreationFee: J
283
+ hbdInterestRate: H,
284
+ headBlock: I,
285
+ totalVestingFund: M,
286
+ totalVestingShares: J,
287
+ virtualSupply: N,
288
+ vestingRewardPercent: x,
289
+ accountCreationFee: G
283
290
  };
284
291
  }
285
292
  });
286
293
  }
287
- function ee(e) {
294
+ function T(e) {
288
295
  return p({
289
296
  queryKey: ["get-account-full", e],
290
297
  queryFn: async () => {
@@ -359,7 +366,7 @@ function ee(e) {
359
366
  staleTime: 6e4
360
367
  });
361
368
  }
362
- function fe(e, t = 5, n = []) {
369
+ function ve(e, t = 5, n = []) {
363
370
  return p({
364
371
  queryKey: ["accounts", "search", e, n],
365
372
  enabled: !!e,
@@ -371,7 +378,7 @@ function fe(e, t = 5, n = []) {
371
378
  )
372
379
  });
373
380
  }
374
- function ge(e) {
381
+ function we(e) {
375
382
  return p({
376
383
  queryKey: ["accounts", "check-wallet-pending", e],
377
384
  queryFn: async () => await (await fetch(
@@ -390,7 +397,7 @@ function ge(e) {
390
397
  refetchOnMount: !0
391
398
  });
392
399
  }
393
- function te(e, t) {
400
+ function re(e, t) {
394
401
  return p({
395
402
  queryKey: ["accounts", "relations", e, t],
396
403
  enabled: !!e && !!t,
@@ -403,7 +410,7 @@ function te(e, t) {
403
410
  )
404
411
  });
405
412
  }
406
- function _e(e) {
413
+ function me(e) {
407
414
  return p({
408
415
  queryKey: ["accounts", "subscriptions", e],
409
416
  enabled: !!e,
@@ -416,7 +423,7 @@ function _e(e) {
416
423
  ) ?? []
417
424
  });
418
425
  }
419
- function ve(e) {
426
+ function be(e) {
420
427
  return p({
421
428
  queryKey: ["accounts", "bookmarks", e],
422
429
  enabled: !!e,
@@ -436,7 +443,7 @@ function ve(e) {
436
443
  }
437
444
  });
438
445
  }
439
- function we(e) {
446
+ function Ce(e) {
440
447
  return p({
441
448
  queryKey: ["accounts", "favourites", e],
442
449
  enabled: !!e,
@@ -456,54 +463,76 @@ function we(e) {
456
463
  }
457
464
  });
458
465
  }
459
- function me(e) {
460
- const { data: t } = T(ee(e));
461
- return Z(
462
- ["accounts", "update", t],
466
+ function Q({
467
+ profile: e,
468
+ tokens: t,
469
+ data: n
470
+ }) {
471
+ const o = C.pipe(
472
+ JSON.parse((n == null ? void 0 : n.posting_json_metadata) || "{}"),
473
+ C.mergeDeep(e ?? {})
474
+ );
475
+ return t && t.length > 0 && (o.tokens = t), o;
476
+ }
477
+ function Se(e) {
478
+ const t = U(), { data: n } = j(T(e));
479
+ return ne(
480
+ ["accounts", "update", n == null ? void 0 : n.name],
463
481
  e,
464
- ({ profile: n, tokens: o }) => {
465
- const r = {
466
- ...JSON.parse((t == null ? void 0 : t.posting_json_metadata) || "{}"),
467
- profile: { ...t == null ? void 0 : t.profile, ...n, version: 2 }
468
- };
469
- return o && o.length > 0 && (r.tokens = o), [
482
+ (o) => {
483
+ if (!n)
484
+ throw new Error("[SDK][Accounts] cannot update not existing account");
485
+ return [
470
486
  [
471
487
  "account_update2",
472
488
  {
473
489
  account: e,
474
- posting_json_metadata: JSON.stringify(r)
490
+ json_metadata: "",
491
+ extensions: [],
492
+ posting_json_metadata: JSON.stringify({
493
+ profile: Q({ ...o, data: n })
494
+ })
475
495
  }
476
496
  ]
477
497
  ];
478
- }
498
+ },
499
+ (o, r) => t.setQueryData(
500
+ T(e).queryKey,
501
+ (c) => {
502
+ if (!c)
503
+ return c;
504
+ const s = C.clone(c);
505
+ return s.profile = Q({ ...r, data: c }), s;
506
+ }
507
+ )
479
508
  );
480
509
  }
481
- function be(e, t, n, o) {
510
+ function Oe(e, t, n, o) {
482
511
  return d({
483
512
  mutationKey: [],
484
513
  mutationFn: async (r) => {
485
- const c = te(
514
+ const c = re(
486
515
  e,
487
516
  t
488
517
  );
489
518
  await u().prefetchQuery(c);
490
- const a = u().getQueryData(
519
+ const s = u().getQueryData(
491
520
  c.queryKey
492
521
  );
493
- return await L(e, "follow", [
522
+ return await oe(e, "follow", [
494
523
  "follow",
495
524
  {
496
525
  follower: e,
497
526
  following: t,
498
527
  what: [
499
- ...r === "toggle-ignore" && !(a != null && a.ignores) ? ["ignore"] : [],
500
- ...r === "toggle-follow" && !(a != null && a.follows) ? ["blog"] : []
528
+ ...r === "toggle-ignore" && !(s != null && s.ignores) ? ["ignore"] : [],
529
+ ...r === "toggle-follow" && !(s != null && s.follows) ? ["blog"] : []
501
530
  ]
502
531
  }
503
532
  ]), {
504
- ...a,
505
- ignores: r === "toggle-ignore" ? !(a != null && a.ignores) : a == null ? void 0 : a.ignores,
506
- follows: r === "toggle-follow" ? !(a != null && a.follows) : a == null ? void 0 : a.follows
533
+ ...s,
534
+ ignores: r === "toggle-ignore" ? !(s != null && s.ignores) : s == null ? void 0 : s.ignores,
535
+ follows: r === "toggle-follow" ? !(s != null && s.follows) : s == null ? void 0 : s.follows
507
536
  };
508
537
  },
509
538
  onError: o,
@@ -515,7 +544,7 @@ function be(e, t, n, o) {
515
544
  }
516
545
  });
517
546
  }
518
- function Ce(e, t, n) {
547
+ function ke(e, t, n) {
519
548
  return d({
520
549
  mutationKey: ["accounts", "bookmarks", "add", e],
521
550
  mutationFn: async ({ author: o, permlink: r }) => {
@@ -544,7 +573,7 @@ function Ce(e, t, n) {
544
573
  onError: n
545
574
  });
546
575
  }
547
- function Se(e, t, n) {
576
+ function Ke(e, t, n) {
548
577
  return d({
549
578
  mutationKey: ["accounts", "bookmarks", "delete", e],
550
579
  mutationFn: async (o) => {
@@ -572,7 +601,7 @@ function Se(e, t, n) {
572
601
  onError: n
573
602
  });
574
603
  }
575
- function Oe(e, t, n) {
604
+ function qe(e, t, n) {
576
605
  return d({
577
606
  mutationKey: ["accounts", "favourites", "add", e],
578
607
  mutationFn: async (o) => {
@@ -600,7 +629,7 @@ function Oe(e, t, n) {
600
629
  onError: n
601
630
  });
602
631
  }
603
- function ke(e, t, n) {
632
+ function Te(e, t, n) {
604
633
  return d({
605
634
  mutationKey: ["accounts", "favourites", "add", e],
606
635
  mutationFn: async (o) => {
@@ -628,7 +657,7 @@ function ke(e, t, n) {
628
657
  onError: n
629
658
  });
630
659
  }
631
- function Ke(e) {
660
+ function Qe(e) {
632
661
  return d({
633
662
  mutationKey: ["operations", "sign", e],
634
663
  mutationFn: ({
@@ -638,14 +667,14 @@ function Ke(e) {
638
667
  if (!e)
639
668
  throw new Error("[Operations][Sign] – cannot sign op with anon user");
640
669
  let o;
641
- return n.split(" ").length === 12 ? o = v.fromLogin(e, n, "active") : z.isWif(n) ? o = v.fromString(n) : o = v.from(n), i.hiveClient.broadcast.sendOperations(
670
+ return n.split(" ").length === 12 ? o = v.fromLogin(e, n, "active") : X.isWif(n) ? o = v.fromString(n) : o = v.from(n), i.hiveClient.broadcast.sendOperations(
642
671
  [t],
643
672
  o
644
673
  );
645
674
  }
646
675
  });
647
676
  }
648
- function qe(e, t = "Active") {
677
+ function Ae(e, t = "Active") {
649
678
  return d({
650
679
  mutationKey: ["operations", "sign-keychain", e],
651
680
  mutationFn: ({ operation: n }) => {
@@ -657,21 +686,21 @@ function qe(e, t = "Active") {
657
686
  }
658
687
  });
659
688
  }
660
- function Te(e = "/") {
689
+ function je(e = "/") {
661
690
  return d({
662
691
  mutationKey: ["operations", "sign-hivesigner", e],
663
692
  mutationFn: async ({ operation: t }) => m.sendOperation(t, { callback: e }, () => {
664
693
  })
665
694
  });
666
695
  }
667
- function Qe() {
696
+ function De() {
668
697
  return p({
669
698
  queryKey: ["operations", "chain-properties"],
670
699
  queryFn: async () => await i.hiveClient.database.getChainProperties()
671
700
  });
672
701
  }
673
- function Ae(e = 20) {
674
- return V({
702
+ function Fe(e = 20) {
703
+ return $({
675
704
  queryKey: ["posts", "trending-tags"],
676
705
  queryFn: async ({ pageParam: { afterTag: t } }) => i.hiveClient.database.call("get_trending_tags", [t, e]).then(
677
706
  (n) => n.filter((o) => o.name !== "").filter((o) => !o.name.startsWith("hive-")).map((o) => o.name)
@@ -684,7 +713,7 @@ function Ae(e = 20) {
684
713
  refetchOnMount: !0
685
714
  });
686
715
  }
687
- function S(e) {
716
+ function O(e) {
688
717
  return p({
689
718
  queryKey: ["posts", "fragments", e],
690
719
  queryFn: async () => (await fetch(
@@ -702,7 +731,7 @@ function S(e) {
702
731
  enabled: !!e
703
732
  });
704
733
  }
705
- function je(e = "feed") {
734
+ function Pe(e = "feed") {
706
735
  return p({
707
736
  queryKey: ["posts", "promoted", e],
708
737
  queryFn: async () => {
@@ -718,7 +747,7 @@ function je(e = "feed") {
718
747
  }
719
748
  });
720
749
  }
721
- function Fe(e) {
750
+ function Ee(e) {
722
751
  return d({
723
752
  mutationKey: ["posts", "add-fragment", e],
724
753
  mutationFn: async ({ title: t, body: n }) => (await fetch(
@@ -737,13 +766,13 @@ function Fe(e) {
737
766
  )).json(),
738
767
  onSuccess(t) {
739
768
  u().setQueryData(
740
- S(e).queryKey,
769
+ O(e).queryKey,
741
770
  (n) => [t, ...n ?? []]
742
771
  );
743
772
  }
744
773
  });
745
774
  }
746
- function De(e, t) {
775
+ function Be(e, t) {
747
776
  return d({
748
777
  mutationKey: ["posts", "edit-fragment", e, t],
749
778
  mutationFn: async ({ title: n, body: o }) => (await fetch(
@@ -763,7 +792,7 @@ function De(e, t) {
763
792
  )).json(),
764
793
  onSuccess(n) {
765
794
  u().setQueryData(
766
- S(e).queryKey,
795
+ O(e).queryKey,
767
796
  (o) => {
768
797
  if (!o)
769
798
  return [];
@@ -774,7 +803,7 @@ function De(e, t) {
774
803
  }
775
804
  });
776
805
  }
777
- function Pe(e, t) {
806
+ function He(e, t) {
778
807
  return d({
779
808
  mutationKey: ["posts", "remove-fragment", e],
780
809
  mutationFn: async () => fetch(i.privateApiHost + "/private-api/fragments-delete", {
@@ -789,13 +818,13 @@ function Pe(e, t) {
789
818
  }),
790
819
  onSuccess() {
791
820
  u().setQueryData(
792
- S(e).queryKey,
821
+ O(e).queryKey,
793
822
  (n) => [...n ?? []].filter(({ id: o }) => o !== t)
794
823
  );
795
824
  }
796
825
  });
797
826
  }
798
- function D(e, t) {
827
+ function B(e, t) {
799
828
  return d({
800
829
  mutationKey: ["analytics", t],
801
830
  mutationFn: async () => {
@@ -818,11 +847,11 @@ function D(e, t) {
818
847
  }
819
848
  });
820
849
  }
821
- const Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
850
+ const Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
822
851
  __proto__: null,
823
- useRecordActivity: D
852
+ useRecordActivity: B
824
853
  }, Symbol.toStringTag, { value: "Module" }));
825
- function ne(e, t) {
854
+ function ie(e, t) {
826
855
  return p({
827
856
  queryKey: ["integrations", "hivesigner", "decode-memo", e],
828
857
  queryFn: async () => {
@@ -834,13 +863,13 @@ function ne(e, t) {
834
863
  }
835
864
  });
836
865
  }
837
- const oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
866
+ const se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
838
867
  __proto__: null,
839
- getDecodeMemoQueryOptions: ne
840
- }, Symbol.toStringTag, { value: "Module" })), re = {
841
- queries: oe
868
+ getDecodeMemoQueryOptions: ie
869
+ }, Symbol.toStringTag, { value: "Module" })), ae = {
870
+ queries: se
842
871
  };
843
- function C(e) {
872
+ function S(e) {
844
873
  return p({
845
874
  queryKey: ["integrations", "3speak", "authenticate", e],
846
875
  enabled: !!e,
@@ -854,7 +883,7 @@ function C(e) {
854
883
  "Content-Type": "application/json"
855
884
  }
856
885
  }
857
- ), n = re.queries.getDecodeMemoQueryOptions(
886
+ ), n = ae.queries.getDecodeMemoQueryOptions(
858
887
  e,
859
888
  (await t.json()).memo
860
889
  );
@@ -866,16 +895,16 @@ function C(e) {
866
895
  }
867
896
  });
868
897
  }
869
- function ie(e) {
898
+ function ce(e) {
870
899
  return p({
871
900
  queryKey: ["integrations", "3speak", "videos", e],
872
901
  enabled: !!e,
873
902
  queryFn: async () => {
874
903
  await u().prefetchQuery(
875
- C(e)
904
+ S(e)
876
905
  );
877
906
  const t = u().getQueryData(
878
- C(e).queryKey
907
+ S(e).queryKey
879
908
  );
880
909
  return await (await fetch(
881
910
  "https://studio.3speak.tv/mobile/api/my-videos",
@@ -889,14 +918,14 @@ function ie(e) {
889
918
  }
890
919
  });
891
920
  }
892
- const se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
921
+ const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
893
922
  __proto__: null,
894
- getAccountTokenQueryOptions: C,
895
- getAccountVideosQueryOptions: ie
896
- }, Symbol.toStringTag, { value: "Module" })), He = {
897
- queries: se
923
+ getAccountTokenQueryOptions: S,
924
+ getAccountVideosQueryOptions: ce
925
+ }, Symbol.toStringTag, { value: "Module" })), Me = {
926
+ queries: ue
898
927
  };
899
- function Ie(e) {
928
+ function Je(e) {
900
929
  return p({
901
930
  queryKey: ["integrations", "hiveposh", "links", e],
902
931
  queryFn: async () => {
@@ -921,7 +950,7 @@ function Ie(e) {
921
950
  }
922
951
  });
923
952
  }
924
- function Me() {
953
+ function Ne() {
925
954
  return p({
926
955
  queryKey: ["resource-credits", "stats"],
927
956
  queryFn: async () => (await i.hiveClient.call(
@@ -931,14 +960,14 @@ function Me() {
931
960
  )).rc_stats
932
961
  });
933
962
  }
934
- function Be(e) {
963
+ function xe(e) {
935
964
  return p({
936
965
  queryKey: ["resource-credits", "account", e],
937
- queryFn: async () => new U(i.hiveClient).findRCAccounts([e]),
966
+ queryFn: async () => new Y(i.hiveClient).findRCAccounts([e]),
938
967
  enabled: !!e
939
968
  });
940
969
  }
941
- function Je(e, t) {
970
+ function Ge(e, t) {
942
971
  return p({
943
972
  queryKey: ["games", "status-check", t, e],
944
973
  enabled: !!e,
@@ -961,8 +990,8 @@ function Je(e, t) {
961
990
  }
962
991
  });
963
992
  }
964
- function Ne(e, t, n) {
965
- const { mutateAsync: o } = D(
993
+ function Ve(e, t, n) {
994
+ const { mutateAsync: o } = B(
966
995
  e,
967
996
  "spin-rolled"
968
997
  );
@@ -991,7 +1020,7 @@ function Ne(e, t, n) {
991
1020
  }
992
1021
  });
993
1022
  }
994
- function xe(e, t, n = 100, o = void 0, r = !0) {
1023
+ function We(e, t, n = 100, o = void 0, r = !0) {
995
1024
  return p({
996
1025
  queryKey: ["communities", "list", e, t, n],
997
1026
  enabled: r,
@@ -1011,7 +1040,7 @@ function xe(e, t, n = 100, o = void 0, r = !0) {
1011
1040
  }
1012
1041
  });
1013
1042
  }
1014
- function Ge(e, t) {
1043
+ function ze(e, t) {
1015
1044
  return p({
1016
1045
  queryKey: ["community", "context", e, t],
1017
1046
  enabled: !!e && !!t,
@@ -1031,8 +1060,8 @@ function Ge(e, t) {
1031
1060
  }
1032
1061
  });
1033
1062
  }
1034
- var l = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(l || {});
1035
- const Ve = {
1063
+ var h = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(h || {});
1064
+ const Ue = {
1036
1065
  owner: [
1037
1066
  "admin",
1038
1067
  "mod",
@@ -1055,27 +1084,27 @@ const Ve = {
1055
1084
  /* MUTED */
1056
1085
  ]
1057
1086
  };
1058
- function We(e, t) {
1087
+ function $e(e, t) {
1059
1088
  return e.startsWith("hive-3") || t === 3 ? "Council" : e.startsWith("hive-2") || t === 2 ? "Journal" : "Topic";
1060
1089
  }
1061
- function ze({
1090
+ function Re({
1062
1091
  communityType: e,
1063
1092
  userRole: t,
1064
1093
  subscribed: n
1065
1094
  }) {
1066
- const o = t === l.MUTED ? !1 : e === "Topic" ? !0 : [l.OWNER, l.ADMIN, l.MOD, l.MEMBER].includes(
1095
+ const o = t === h.MUTED ? !1 : e === "Topic" ? !0 : [h.OWNER, h.ADMIN, h.MOD, h.MEMBER].includes(
1067
1096
  t
1068
1097
  ), r = (() => {
1069
- if (t === l.MUTED) return !1;
1098
+ if (t === h.MUTED) return !1;
1070
1099
  switch (e) {
1071
1100
  case "Topic":
1072
1101
  return !0;
1073
1102
  case "Journal":
1074
- return t !== l.GUEST || n;
1103
+ return t !== h.GUEST || n;
1075
1104
  case "Council":
1076
1105
  return o;
1077
1106
  }
1078
- })(), c = [l.OWNER, l.ADMIN, l.MOD].includes(t);
1107
+ })(), c = [h.OWNER, h.ADMIN, h.MOD].includes(t);
1079
1108
  return {
1080
1109
  canPost: o,
1081
1110
  canComment: r,
@@ -1084,54 +1113,54 @@ function ze({
1084
1113
  }
1085
1114
  export {
1086
1115
  i as CONFIG,
1087
- k as ConfigManager,
1088
- Ee as EcencyAnalytics,
1089
- K as EcencyQueriesManager,
1090
- re as HiveSignerIntegration,
1091
- de as Keychain,
1092
- l as ROLES,
1093
- He as ThreeSpeakIntegration,
1094
- L as broadcastJson,
1095
- ge as checkUsernameWalletsPendingQueryOptions,
1116
+ K as ConfigManager,
1117
+ Ie as EcencyAnalytics,
1118
+ q as EcencyQueriesManager,
1119
+ ae as HiveSignerIntegration,
1120
+ fe as Keychain,
1121
+ h as ROLES,
1122
+ Me as ThreeSpeakIntegration,
1123
+ oe as broadcastJson,
1124
+ we as checkUsernameWalletsPendingQueryOptions,
1096
1125
  y as getAccessToken,
1097
- ee as getAccountFullQueryOptions,
1098
- Be as getAccountRcQueryOptions,
1099
- _e as getAccountSubscriptionsQueryOptions,
1100
- ve as getActiveAccountBookmarksQueryOptions,
1101
- we as getActiveAccountFavouritesQueryOptions,
1102
- Qe as getChainPropertiesQueryOptions,
1103
- xe as getCommunitiesQueryOptions,
1104
- Ge as getCommunityContextQueryOptions,
1105
- ze as getCommunityPermissions,
1106
- We as getCommunityType,
1107
- he as getDynamicPropsQueryOptions,
1108
- S as getFragmentsQueryOptions,
1109
- Je as getGameStatusCheckQueryOptions,
1110
- Ie as getHivePoshLinksQueryOptions,
1111
- F as getLoginType,
1112
- j as getPostingKey,
1113
- je as getPromotedPostsQuery,
1126
+ T as getAccountFullQueryOptions,
1127
+ xe as getAccountRcQueryOptions,
1128
+ me as getAccountSubscriptionsQueryOptions,
1129
+ be as getActiveAccountBookmarksQueryOptions,
1130
+ Ce as getActiveAccountFavouritesQueryOptions,
1131
+ De as getChainPropertiesQueryOptions,
1132
+ We as getCommunitiesQueryOptions,
1133
+ ze as getCommunityContextQueryOptions,
1134
+ Re as getCommunityPermissions,
1135
+ $e as getCommunityType,
1136
+ _e as getDynamicPropsQueryOptions,
1137
+ O as getFragmentsQueryOptions,
1138
+ Ge as getGameStatusCheckQueryOptions,
1139
+ Je as getHivePoshLinksQueryOptions,
1140
+ E as getLoginType,
1141
+ P as getPostingKey,
1142
+ Pe as getPromotedPostsQuery,
1114
1143
  u as getQueryClient,
1115
- Me as getRcStatsQueryOptions,
1116
- ye as getRefreshToken,
1117
- te as getRelationshipBetweenAccountsQueryOptions,
1118
- fe as getSearchAccountsByUsernameQueryOptions,
1119
- Ae as getTrendingTagsQueryOptions,
1144
+ Ne as getRcStatsQueryOptions,
1145
+ he as getRefreshToken,
1146
+ re as getRelationshipBetweenAccountsQueryOptions,
1147
+ ve as getSearchAccountsByUsernameQueryOptions,
1148
+ Fe as getTrendingTagsQueryOptions,
1120
1149
  _ as getUser,
1121
- le as makeQueryClient,
1122
- Ve as roleMap,
1123
- Oe as useAccountFavouriteAdd,
1124
- ke as useAccountFavouriteDelete,
1125
- be as useAccountRelationsUpdate,
1126
- me as useAccountUpdate,
1127
- Fe as useAddFragment,
1128
- Ce as useBookmarkAdd,
1129
- Se as useBookmarkDelete,
1130
- Z as useBroadcastMutation,
1131
- De as useEditFragment,
1132
- Ne as useGameClaim,
1133
- Pe as useRemoveFragment,
1134
- Te as useSignOperationByHivesigner,
1135
- Ke as useSignOperationByKey,
1136
- qe as useSignOperationByKeychain
1150
+ ge as makeQueryClient,
1151
+ Ue as roleMap,
1152
+ qe as useAccountFavouriteAdd,
1153
+ Te as useAccountFavouriteDelete,
1154
+ Oe as useAccountRelationsUpdate,
1155
+ Se as useAccountUpdate,
1156
+ Ee as useAddFragment,
1157
+ ke as useBookmarkAdd,
1158
+ Ke as useBookmarkDelete,
1159
+ ne as useBroadcastMutation,
1160
+ Be as useEditFragment,
1161
+ Ve as useGameClaim,
1162
+ He as useRemoveFragment,
1163
+ je as useSignOperationByHivesigner,
1164
+ Qe as useSignOperationByKey,
1165
+ Ae as useSignOperationByKeychain
1137
1166
  };
@@ -1,2 +1,3 @@
1
1
  export * from './mutations';
2
2
  export * from './queries';
3
+ export * from './types';
@@ -1,12 +1,7 @@
1
1
  import { AccountProfile } from '../types';
2
2
  interface Payload {
3
3
  profile: Partial<AccountProfile>;
4
- tokens: {
5
- symbol: string;
6
- meta: {
7
- address: string;
8
- };
9
- }[];
4
+ tokens: AccountProfile["tokens"];
10
5
  }
11
- export declare function useAccountUpdate(username: string): import('@tanstack/react-query').UseMutationResult<any, Error, Partial<Payload>, unknown>;
6
+ export declare function useAccountUpdate(username: string): import('@tanstack/react-query').UseMutationResult<unknown, Error, Partial<Payload>, unknown>;
12
7
  export {};
@@ -52,6 +52,11 @@ export declare function getAccountFullQueryOptions(username: string): import('@t
52
52
  account: string;
53
53
  weight: number;
54
54
  };
55
+ tokens?: {
56
+ symbol: string;
57
+ type: string;
58
+ meta: Record<string, any>;
59
+ }[];
55
60
  };
56
61
  }, Error, {
57
62
  name: any;
@@ -106,6 +111,11 @@ export declare function getAccountFullQueryOptions(username: string): import('@t
106
111
  account: string;
107
112
  weight: number;
108
113
  };
114
+ tokens?: {
115
+ symbol: string;
116
+ type: string;
117
+ meta: Record<string, any>;
118
+ }[];
109
119
  };
110
120
  }, string[]>, "queryFn"> & {
111
121
  queryFn?: import('@tanstack/query-core').QueryFunction<{
@@ -161,6 +171,11 @@ export declare function getAccountFullQueryOptions(username: string): import('@t
161
171
  account: string;
162
172
  weight: number;
163
173
  };
174
+ tokens?: {
175
+ symbol: string;
176
+ type: string;
177
+ meta: Record<string, any>;
178
+ }[];
164
179
  };
165
180
  }, string[], never> | undefined;
166
181
  } & {
@@ -218,6 +233,11 @@ export declare function getAccountFullQueryOptions(username: string): import('@t
218
233
  account: string;
219
234
  weight: number;
220
235
  };
236
+ tokens?: {
237
+ symbol: string;
238
+ type: string;
239
+ meta: Record<string, any>;
240
+ }[];
221
241
  };
222
242
  };
223
243
  [dataTagErrorSymbol]: Error;
@@ -11,4 +11,9 @@ export interface AccountProfile {
11
11
  account: string;
12
12
  weight: number;
13
13
  };
14
+ tokens?: {
15
+ symbol: string;
16
+ type: string;
17
+ meta: Record<string, any>;
18
+ }[];
14
19
  }
@@ -1,3 +1,3 @@
1
1
  import { useMutation } from '@tanstack/react-query';
2
2
  import { Operation } from '@hiveio/dhive';
3
- export declare function useBroadcastMutation<T>(mutationKey: Parameters<typeof useMutation>[0]["mutationKey"], username: string | undefined, operations: (payload: T) => Operation[]): import('@tanstack/react-query').UseMutationResult<any, Error, T, unknown>;
3
+ export declare function useBroadcastMutation<T>(mutationKey: Parameters<typeof useMutation>[0]["mutationKey"], username: string | undefined, operations: (payload: T) => Operation[], onSuccess?: Parameters<typeof useMutation<unknown, unknown, T>>[0]["onSuccess"]): import('@tanstack/react-query').UseMutationResult<unknown, Error, T, unknown>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.1.1",
4
+ "version": "1.1.3",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",
@@ -17,20 +17,21 @@
17
17
  "preview": "vite preview"
18
18
  },
19
19
  "devDependencies": {
20
+ "@hiveio/dhive": "^1.3.2",
21
+ "@tanstack/react-query": "^5.74.4",
20
22
  "@types/node": "^22.13.8",
21
23
  "@types/react": "^19.0.10",
22
24
  "@vitejs/plugin-react": "^4.3.4",
25
+ "bip39": "^3.1.0",
23
26
  "eslint": "^9.21.0",
27
+ "hivesigner": "3.3.4",
28
+ "lru-cache": "^11.0.2",
24
29
  "prettier": "^3.5.2",
30
+ "react": "^19.0.0",
31
+ "remeda": "^2.30.0",
25
32
  "vite": "^6.2.0",
26
33
  "vite-plugin-dts": "4.5.3",
27
- "vite-plugin-node-polyfills": "^0.23.0",
28
- "lru-cache": "^11.0.2",
29
- "@hiveio/dhive": "^1.3.2",
30
- "@tanstack/react-query": "^5.74.4",
31
- "react": "^19.0.0",
32
- "bip39": "^3.1.0",
33
- "hivesigner": "3.3.4"
34
+ "vite-plugin-node-polyfills": "^0.23.0"
34
35
  },
35
36
  "dependencies": {}
36
37
  }