@ecency/sdk 1.0.50 → 1.0.52

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,12 @@
1
- var T = Object.defineProperty;
2
- var j = (e, t, n) => t in e ? T(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var b = (e, t, n) => j(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as K, useMutation as l, useQuery as A, useInfiniteQuery as k, queryOptions as u, infiniteQueryOptions as D } from "@tanstack/react-query";
5
- import { Client as F, PrivateKey as d, cryptoUtils as P, RCAPI as M } from "@hiveio/dhive";
1
+ var A = Object.defineProperty;
2
+ var Q = (e, t, n) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var C = (e, t, n) => Q(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { QueryClient as K, useMutation as l, useQuery as j, useInfiniteQuery as _, queryOptions as p, infiniteQueryOptions as F } from "@tanstack/react-query";
5
+ import { Client as D, PrivateKey as h, cryptoUtils as P, RCAPI as N } from "@hiveio/dhive";
6
6
  import g from "hivesigner";
7
- class I {
7
+ class M {
8
8
  constructor() {
9
- b(this, "length", 0);
9
+ C(this, "length", 0);
10
10
  }
11
11
  clear() {
12
12
  throw new Error("Method not implemented.");
@@ -24,11 +24,11 @@ class I {
24
24
  this[t] = n;
25
25
  }
26
26
  }
27
- const a = {
27
+ const i = {
28
28
  privateApiHost: "https://ecency.com",
29
- storage: typeof window > "u" ? new I() : window.localStorage,
29
+ storage: typeof window > "u" ? new M() : window.localStorage,
30
30
  storagePrefix: "ecency",
31
- hiveClient: new F(
31
+ hiveClient: new D(
32
32
  [
33
33
  "https://api.hive.blog",
34
34
  "https://api.deathwing.me",
@@ -55,27 +55,27 @@ const a = {
55
55
  var O;
56
56
  ((e) => {
57
57
  function t(n) {
58
- a.queryClient = n;
58
+ i.queryClient = n;
59
59
  }
60
60
  e.setQueryClient = t;
61
61
  })(O || (O = {}));
62
- function N(e) {
62
+ function E(e) {
63
63
  let t = atob(e);
64
64
  if (t[0] === "{")
65
65
  return JSON.parse(t);
66
66
  }
67
- const h = (e) => {
67
+ const f = (e) => {
68
68
  try {
69
- const t = a.storage.getItem(
70
- a.storagePrefix + "_user_" + e
69
+ const t = i.storage.getItem(
70
+ i.storagePrefix + "_user_" + e
71
71
  );
72
- return N(JSON.parse(t));
72
+ return E(JSON.parse(t));
73
73
  } catch (t) {
74
74
  console.error(t);
75
75
  return;
76
76
  }
77
- }, f = (e) => h(e) && h(e).accessToken, S = (e) => h(e) && h(e).postingKey, Q = (e) => h(e) && h(e).loginType, Z = (e) => h(e) && h(e).refreshToken;
78
- function E() {
77
+ }, y = (e) => f(e) && f(e).accessToken, q = (e) => f(e) && f(e).postingKey, k = (e) => f(e) && f(e).loginType, Z = (e) => f(e) && f(e).refreshToken;
78
+ function J() {
79
79
  return new Promise((e) => {
80
80
  var t;
81
81
  (t = window.hive_keychain) == null || t.requestHandshake(() => {
@@ -83,77 +83,77 @@ function E() {
83
83
  });
84
84
  });
85
85
  }
86
- const w = (e, t, n, r = null) => new Promise((o, c) => {
87
- var s;
88
- (s = window.hive_keychain) == null || s.requestBroadcast(
86
+ const w = (e, t, n, o = null) => new Promise((r, c) => {
87
+ var a;
88
+ (a = window.hive_keychain) == null || a.requestBroadcast(
89
89
  e,
90
90
  t,
91
91
  n,
92
- (i) => {
93
- i.success || c({ message: "Operation cancelled" }), o(i);
92
+ (s) => {
93
+ s.success || c({ message: "Operation cancelled" }), r(s);
94
94
  },
95
- r
95
+ o
96
96
  );
97
97
  }), L = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
98
98
  __proto__: null,
99
99
  broadcast: w,
100
- handshake: E
100
+ handshake: J
101
101
  }, Symbol.toStringTag, { value: "Module" }));
102
- function J(e = [], t, n) {
102
+ function I(e = [], t, n) {
103
103
  return l({
104
104
  mutationKey: [...e, t],
105
- mutationFn: async (r) => {
105
+ mutationFn: async (o) => {
106
106
  if (!t)
107
107
  throw new Error(
108
108
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
109
109
  );
110
- const o = S(t);
111
- if (o) {
112
- const i = d.fromString(o);
113
- return a.hiveClient.broadcast.sendOperations(
114
- n(r),
115
- i
110
+ const r = q(t);
111
+ if (r) {
112
+ const s = h.fromString(r);
113
+ return i.hiveClient.broadcast.sendOperations(
114
+ n(o),
115
+ s
116
116
  );
117
117
  }
118
- const c = Q(t);
118
+ const c = k(t);
119
119
  if (c && c == "keychain")
120
- return w(t, n(r), "Posting").then((i) => i.result);
121
- let s = f(t);
122
- if (s)
120
+ return w(t, n(o), "Posting").then((s) => s.result);
121
+ let a = y(t);
122
+ if (a)
123
123
  return (await new g.Client({
124
- accessToken: s
125
- }).broadcast(n(r))).result;
124
+ accessToken: a
125
+ }).broadcast(n(o))).result;
126
126
  throw new Error(
127
127
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
128
128
  );
129
129
  }
130
130
  });
131
131
  }
132
- async function H(e, t, n) {
132
+ async function B(e, t, n) {
133
133
  if (!e)
134
134
  throw new Error(
135
135
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
136
136
  );
137
- const r = {
137
+ const o = {
138
138
  id: t,
139
139
  required_auths: [],
140
140
  required_posting_auths: [e],
141
141
  json: JSON.stringify(n)
142
- }, o = S(e);
143
- if (o) {
144
- const i = d.fromString(o);
145
- return a.hiveClient.broadcast.json(
146
- r,
147
- i
142
+ }, r = q(e);
143
+ if (r) {
144
+ const s = h.fromString(r);
145
+ return i.hiveClient.broadcast.json(
146
+ o,
147
+ s
148
148
  );
149
149
  }
150
- const c = Q(e);
150
+ const c = k(e);
151
151
  if (c && c == "keychain")
152
- return w(e, [["custom_json", r]], "Posting").then((i) => i.result);
153
- let s = f(e);
154
- if (s)
152
+ return w(e, [["custom_json", o]], "Posting").then((s) => s.result);
153
+ let a = y(e);
154
+ if (a)
155
155
  return (await new g.Client({
156
- accessToken: s
156
+ accessToken: a
157
157
  }).customJson([], [e], t, JSON.stringify(n))).result;
158
158
  throw new Error(
159
159
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
@@ -172,46 +172,46 @@ function R() {
172
172
  }
173
173
  });
174
174
  }
175
- const p = () => a.queryClient;
176
- var q;
175
+ const u = () => i.queryClient;
176
+ var S;
177
177
  ((e) => {
178
- function t(i) {
179
- return p().getQueryData(i);
178
+ function t(s) {
179
+ return u().getQueryData(s);
180
180
  }
181
181
  e.getQueryData = t;
182
- function n(i) {
183
- return p().getQueryData(i);
182
+ function n(s) {
183
+ return u().getQueryData(s);
184
184
  }
185
185
  e.getInfiniteQueryData = n;
186
- async function r(i) {
187
- return await p().prefetchQuery(i), t(i.queryKey);
186
+ async function o(s) {
187
+ return await u().prefetchQuery(s), t(s.queryKey);
188
188
  }
189
- e.prefetchQuery = r;
190
- async function o(i) {
191
- return await p().prefetchInfiniteQuery(i), n(i.queryKey);
189
+ e.prefetchQuery = o;
190
+ async function r(s) {
191
+ return await u().prefetchInfiniteQuery(s), n(s.queryKey);
192
192
  }
193
- e.prefetchInfiniteQuery = o;
194
- function c(i) {
193
+ e.prefetchInfiniteQuery = r;
194
+ function c(s) {
195
195
  return {
196
- prefetch: () => r(i),
197
- getData: () => t(i.queryKey),
198
- useClientQuery: () => A(i),
199
- fetchAndGet: () => p().fetchQuery(i)
196
+ prefetch: () => o(s),
197
+ getData: () => t(s.queryKey),
198
+ useClientQuery: () => j(s),
199
+ fetchAndGet: () => u().fetchQuery(s)
200
200
  };
201
201
  }
202
202
  e.generateClientServerQuery = c;
203
- function s(i) {
203
+ function a(s) {
204
204
  return {
205
- prefetch: () => o(i),
206
- getData: () => n(i.queryKey),
207
- useClientQuery: () => k(i),
208
- fetchAndGet: () => p().fetchInfiniteQuery(i)
205
+ prefetch: () => r(s),
206
+ getData: () => n(s.queryKey),
207
+ useClientQuery: () => _(s),
208
+ fetchAndGet: () => u().fetchInfiniteQuery(s)
209
209
  };
210
210
  }
211
- e.generateClientServerInfiniteQuery = s;
212
- })(q || (q = {}));
211
+ e.generateClientServerInfiniteQuery = a;
212
+ })(S || (S = {}));
213
213
  function ee(e) {
214
- return J(
214
+ return I(
215
215
  ["accounts", "update"],
216
216
  e,
217
217
  ({
@@ -234,35 +234,35 @@ function ee(e) {
234
234
  );
235
235
  }
236
236
  function te(e) {
237
- return u({
237
+ return p({
238
238
  queryKey: ["get-account-full", e],
239
239
  queryFn: async () => {
240
240
  if (!e)
241
241
  throw new Error("[SDK] Username is empty");
242
- const t = await a.hiveClient.database.getAccounts([e]);
242
+ const t = await i.hiveClient.database.getAccounts([e]);
243
243
  if (!t[0])
244
244
  throw new Error("[SDK] No account with given username");
245
245
  const n = JSON.parse(t[0].posting_json_metadata).profile;
246
- let r;
246
+ let o;
247
247
  try {
248
- r = await a.hiveClient.database.call(
248
+ o = await i.hiveClient.database.call(
249
249
  "get_follow_count",
250
250
  [e]
251
251
  );
252
252
  } catch {
253
253
  }
254
- const o = await a.hiveClient.call(
254
+ const r = await i.hiveClient.call(
255
255
  "condenser_api",
256
256
  "get_account_reputations",
257
257
  [e, 1]
258
258
  );
259
259
  return {
260
260
  ...t,
261
- follow_stats: r,
262
- reputation: o[0].reputation,
261
+ follow_stats: o,
262
+ reputation: r[0].reputation,
263
263
  profile: {
264
264
  ...n,
265
- reputation: o[0].reputation
265
+ reputation: r[0].reputation
266
266
  }
267
267
  };
268
268
  },
@@ -271,22 +271,22 @@ function te(e) {
271
271
  });
272
272
  }
273
273
  function ne(e, t = 5, n = []) {
274
- return u({
274
+ return p({
275
275
  queryKey: ["accounts", "search", e, n],
276
276
  enabled: !!e,
277
- queryFn: async () => (await a.hiveClient.database.call(
277
+ queryFn: async () => (await i.hiveClient.database.call(
278
278
  "lookup_accounts",
279
279
  [e, t]
280
280
  )).filter(
281
- (o) => n.length > 0 ? !n.includes(o) : !0
281
+ (r) => n.length > 0 ? !n.includes(r) : !0
282
282
  )
283
283
  });
284
284
  }
285
- function re(e) {
286
- return u({
285
+ function oe(e) {
286
+ return p({
287
287
  queryKey: ["accounts", "check-wallet-pending", e],
288
288
  queryFn: async () => await (await fetch(
289
- a.privateApiHost + "/private-api/wallets-chkuser",
289
+ i.privateApiHost + "/private-api/wallets-chkuser",
290
290
  {
291
291
  method: "POST",
292
292
  headers: {
@@ -301,24 +301,24 @@ function re(e) {
301
301
  refetchOnMount: !0
302
302
  });
303
303
  }
304
- function B(e, t) {
305
- return u({
304
+ function H(e, t) {
305
+ return p({
306
306
  queryKey: ["accounts", "relations", e, t],
307
307
  enabled: !!e && !!t,
308
308
  refetchOnMount: !1,
309
309
  refetchInterval: 36e5,
310
- queryFn: async () => await a.hiveClient.call(
310
+ queryFn: async () => await i.hiveClient.call(
311
311
  "bridge",
312
312
  "get_relationship_between_accounts",
313
313
  [e, t]
314
314
  )
315
315
  });
316
316
  }
317
- function oe(e) {
318
- return u({
317
+ function re(e) {
318
+ return p({
319
319
  queryKey: ["accounts", "subscriptions", e],
320
320
  enabled: !!e,
321
- queryFn: async () => await a.hiveClient.call(
321
+ queryFn: async () => await i.hiveClient.call(
322
322
  "bridge",
323
323
  "list_all_subscriptions",
324
324
  {
@@ -327,44 +327,197 @@ function oe(e) {
327
327
  ) ?? []
328
328
  });
329
329
  }
330
- function ie(e, t, n, r) {
330
+ function ie(e) {
331
+ return p({
332
+ queryKey: ["accounts", "bookmarks", e],
333
+ enabled: !!e,
334
+ queryFn: async () => {
335
+ if (!e)
336
+ throw new Error("[SDK][Accounts][Bookmarks] – no active user");
337
+ return await (await fetch(
338
+ i.privateApiHost + "/private-api/bookmarks",
339
+ {
340
+ method: "POST",
341
+ headers: {
342
+ "Content-Type": "application/json"
343
+ },
344
+ body: JSON.stringify({ code: y(e) })
345
+ }
346
+ )).json();
347
+ }
348
+ });
349
+ }
350
+ function se(e) {
351
+ return p({
352
+ queryKey: ["accounts", "favourites", e],
353
+ enabled: !!e,
354
+ queryFn: async () => {
355
+ if (!e)
356
+ throw new Error("[SDK][Accounts][Favourites] – no active user");
357
+ return await (await fetch(
358
+ i.privateApiHost + "/private-api/favorites",
359
+ {
360
+ method: "POST",
361
+ headers: {
362
+ "Content-Type": "application/json"
363
+ },
364
+ body: JSON.stringify({ code: y(e) })
365
+ }
366
+ )).json();
367
+ }
368
+ });
369
+ }
370
+ function ae(e, t, n, o) {
331
371
  return l({
332
372
  mutationKey: [],
333
- mutationFn: async (o) => {
334
- const c = B(
373
+ mutationFn: async (r) => {
374
+ const c = H(
335
375
  e,
336
376
  t
337
377
  );
338
- await p().prefetchQuery(c);
339
- const s = p().getQueryData(
378
+ await u().prefetchQuery(c);
379
+ const a = u().getQueryData(
340
380
  c.queryKey
341
381
  );
342
- return await H(e, "follow", [
382
+ return await B(e, "follow", [
343
383
  "follow",
344
384
  {
345
385
  follower: e,
346
386
  following: t,
347
387
  what: [
348
- ...o === "toggle-ignore" && !(s != null && s.ignores) ? ["ignore"] : [],
349
- ...o === "toggle-follow" && !(s != null && s.follows) ? ["blog"] : []
388
+ ...r === "toggle-ignore" && !(a != null && a.ignores) ? ["ignore"] : [],
389
+ ...r === "toggle-follow" && !(a != null && a.follows) ? ["blog"] : []
350
390
  ]
351
391
  }
352
392
  ]), {
353
- ...s,
354
- ignores: o === "toggle-ignore" ? !(s != null && s.ignores) : s == null ? void 0 : s.ignores,
355
- follows: o === "toggle-follow" ? !(s != null && s.follows) : s == null ? void 0 : s.follows
393
+ ...a,
394
+ ignores: r === "toggle-ignore" ? !(a != null && a.ignores) : a == null ? void 0 : a.ignores,
395
+ follows: r === "toggle-follow" ? !(a != null && a.follows) : a == null ? void 0 : a.follows
356
396
  };
357
397
  },
358
- onError: r,
359
- onSuccess(o) {
360
- n(o), p().setQueryData(
398
+ onError: o,
399
+ onSuccess(r) {
400
+ n(r), u().setQueryData(
361
401
  ["accounts", "relations", e, t],
362
- o
402
+ r
363
403
  );
364
404
  }
365
405
  });
366
406
  }
367
- function se(e) {
407
+ function ce(e, t, n) {
408
+ return l({
409
+ mutationKey: ["accounts", "bookmarks", "add", e],
410
+ mutationFn: async ({ author: o, permlink: r }) => {
411
+ if (!e)
412
+ throw new Error("[SDK][Account][Bookmarks] – no active user");
413
+ return (await fetch(
414
+ i.privateApiHost + "/private-api/bookmarks-add",
415
+ {
416
+ method: "POST",
417
+ headers: {
418
+ "Content-Type": "application/json"
419
+ },
420
+ body: JSON.stringify({
421
+ author: o,
422
+ permlink: r,
423
+ code: y(e)
424
+ })
425
+ }
426
+ )).json();
427
+ },
428
+ onSuccess: () => {
429
+ t(), u().invalidateQueries({
430
+ queryKey: ["accounts", "bookmarks", e]
431
+ });
432
+ },
433
+ onError: n
434
+ });
435
+ }
436
+ function ue(e, t, n) {
437
+ return l({
438
+ mutationKey: ["accounts", "bookmarks", "delete", e],
439
+ mutationFn: async (o) => {
440
+ if (!e)
441
+ throw new Error("[SDK][Account][Bookmarks] – no active user");
442
+ return (await fetch(
443
+ i.privateApiHost + "/private-api/bookmarks-delete",
444
+ {
445
+ method: "POST",
446
+ headers: {
447
+ "Content-Type": "application/json"
448
+ },
449
+ body: JSON.stringify({
450
+ id: o,
451
+ code: y(e)
452
+ })
453
+ }
454
+ )).json();
455
+ },
456
+ onSuccess: () => {
457
+ t(), u().invalidateQueries({
458
+ queryKey: ["accounts", "bookmarks", e]
459
+ });
460
+ },
461
+ onError: n
462
+ });
463
+ }
464
+ function pe(e, t, n) {
465
+ return l({
466
+ mutationKey: ["accounts", "favourites", "add", e],
467
+ mutationFn: async (o) => {
468
+ if (!e)
469
+ throw new Error("[SDK][Account][Bookmarks] – no active user");
470
+ return (await fetch(
471
+ i.privateApiHost + "/private-api/favorites-add",
472
+ {
473
+ method: "POST",
474
+ headers: {
475
+ "Content-Type": "application/json"
476
+ },
477
+ body: JSON.stringify({
478
+ account: o,
479
+ code: y(e)
480
+ })
481
+ }
482
+ )).json();
483
+ },
484
+ onSuccess: () => {
485
+ t(), u().invalidateQueries({
486
+ queryKey: ["accounts", "favourites", e]
487
+ });
488
+ },
489
+ onError: n
490
+ });
491
+ }
492
+ function ye(e, t, n) {
493
+ return l({
494
+ mutationKey: ["accounts", "favourites", "add", e],
495
+ mutationFn: async (o) => {
496
+ if (!e)
497
+ throw new Error("[SDK][Account][Bookmarks] – no active user");
498
+ return (await fetch(
499
+ i.privateApiHost + "/private-api/favorites-delete",
500
+ {
501
+ method: "POST",
502
+ headers: {
503
+ "Content-Type": "application/json"
504
+ },
505
+ body: JSON.stringify({
506
+ account: o,
507
+ code: y(e)
508
+ })
509
+ }
510
+ )).json();
511
+ },
512
+ onSuccess: () => {
513
+ t(), u().invalidateQueries({
514
+ queryKey: ["accounts", "favourites", e]
515
+ });
516
+ },
517
+ onError: n
518
+ });
519
+ }
520
+ function le(e) {
368
521
  return l({
369
522
  mutationKey: ["operations", "sign", e],
370
523
  mutationFn: ({
@@ -373,15 +526,15 @@ function se(e) {
373
526
  }) => {
374
527
  if (!e)
375
528
  throw new Error("[Operations][Sign] – cannot sign op with anon user");
376
- let r;
377
- return n.split(" ").length === 12 ? r = d.fromLogin(e, n, "active") : P.isWif(n) ? r = d.fromString(n) : r = d.from(n), a.hiveClient.broadcast.sendOperations(
529
+ let o;
530
+ return n.split(" ").length === 12 ? o = h.fromLogin(e, n, "active") : P.isWif(n) ? o = h.fromString(n) : o = h.from(n), i.hiveClient.broadcast.sendOperations(
378
531
  [t],
379
- r
532
+ o
380
533
  );
381
534
  }
382
535
  });
383
536
  }
384
- function ae(e, t = "Active") {
537
+ function de(e, t = "Active") {
385
538
  return l({
386
539
  mutationKey: ["operations", "sign-keychain", e],
387
540
  mutationFn: ({ operation: n }) => {
@@ -393,24 +546,24 @@ function ae(e, t = "Active") {
393
546
  }
394
547
  });
395
548
  }
396
- function ce(e = "/") {
549
+ function fe(e = "/") {
397
550
  return l({
398
551
  mutationKey: ["operations", "sign-hivesigner", e],
399
552
  mutationFn: async ({ operation: t }) => g.sendOperation(t, { callback: e }, () => {
400
553
  })
401
554
  });
402
555
  }
403
- function ue() {
404
- return u({
556
+ function he() {
557
+ return p({
405
558
  queryKey: ["operations", "chain-properties"],
406
- queryFn: async () => await a.hiveClient.database.getChainProperties()
559
+ queryFn: async () => await i.hiveClient.database.getChainProperties()
407
560
  });
408
561
  }
409
- function pe(e, t) {
410
- return u({
562
+ function ge(e, t) {
563
+ return p({
411
564
  queryKey: ["hive-engine", "tokens-list", e, t],
412
565
  queryFn: async () => (await (await fetch(
413
- `${a.privateApiHost}/private-api/engine-api`,
566
+ `${i.privateApiHost}/private-api/engine-api`,
414
567
  {
415
568
  method: "POST",
416
569
  body: JSON.stringify({
@@ -431,11 +584,11 @@ function pe(e, t) {
431
584
  )).json()).result
432
585
  });
433
586
  }
434
- function ye(e = 20) {
435
- return D({
587
+ function we(e = 20) {
588
+ return F({
436
589
  queryKey: ["posts", "trending-tags"],
437
- queryFn: async ({ pageParam: { afterTag: t } }) => a.hiveClient.database.call("get_trending_tags", [t, e]).then(
438
- (n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
590
+ queryFn: async ({ pageParam: { afterTag: t } }) => i.hiveClient.database.call("get_trending_tags", [t, e]).then(
591
+ (n) => n.filter((o) => o.name !== "").filter((o) => !o.name.startsWith("hive-")).map((o) => o.name)
439
592
  ),
440
593
  initialPageParam: { afterTag: "" },
441
594
  getNextPageParam: (t) => ({
@@ -445,15 +598,15 @@ function ye(e = 20) {
445
598
  refetchOnMount: !0
446
599
  });
447
600
  }
448
- function C(e) {
449
- return u({
601
+ function b(e) {
602
+ return p({
450
603
  queryKey: ["posts", "fragments", e],
451
604
  queryFn: async () => (await fetch(
452
- a.privateApiHost + "/private-api/fragments",
605
+ i.privateApiHost + "/private-api/fragments",
453
606
  {
454
607
  method: "POST",
455
608
  body: JSON.stringify({
456
- code: f(e)
609
+ code: y(e)
457
610
  }),
458
611
  headers: {
459
612
  "Content-Type": "application/json"
@@ -463,12 +616,12 @@ function C(e) {
463
616
  enabled: !!e
464
617
  });
465
618
  }
466
- function le(e = "feed") {
467
- return u({
619
+ function ve(e = "feed") {
620
+ return p({
468
621
  queryKey: ["posts", "promoted", e],
469
622
  queryFn: async () => {
470
623
  const t = new URL(
471
- a.privateApiHost + "/private-api/promoted-entries"
624
+ i.privateApiHost + "/private-api/promoted-entries"
472
625
  );
473
626
  return e === "waves" && t.searchParams.append("short_content", "1"), await (await fetch(t.toString(), {
474
627
  method: "GET",
@@ -479,15 +632,15 @@ function le(e = "feed") {
479
632
  }
480
633
  });
481
634
  }
482
- function fe(e) {
635
+ function me(e) {
483
636
  return l({
484
637
  mutationKey: ["posts", "add-fragment", e],
485
638
  mutationFn: async ({ title: t, body: n }) => (await fetch(
486
- a.privateApiHost + "/private-api/fragments-add",
639
+ i.privateApiHost + "/private-api/fragments-add",
487
640
  {
488
641
  method: "POST",
489
642
  body: JSON.stringify({
490
- code: f(e),
643
+ code: y(e),
491
644
  title: t,
492
645
  body: n
493
646
  }),
@@ -497,25 +650,25 @@ function fe(e) {
497
650
  }
498
651
  )).json(),
499
652
  onSuccess(t) {
500
- p().setQueryData(
501
- C(e).queryKey,
653
+ u().setQueryData(
654
+ b(e).queryKey,
502
655
  (n) => [t, ...n ?? []]
503
656
  );
504
657
  }
505
658
  });
506
659
  }
507
- function he(e, t) {
660
+ function be(e, t) {
508
661
  return l({
509
662
  mutationKey: ["posts", "edit-fragment", e, t],
510
- mutationFn: async ({ title: n, body: r }) => (await fetch(
511
- a.privateApiHost + "/private-api/fragments-update",
663
+ mutationFn: async ({ title: n, body: o }) => (await fetch(
664
+ i.privateApiHost + "/private-api/fragments-update",
512
665
  {
513
666
  method: "POST",
514
667
  body: JSON.stringify({
515
- code: f(e),
668
+ code: y(e),
516
669
  id: t,
517
670
  title: n,
518
- body: r
671
+ body: o
519
672
  }),
520
673
  headers: {
521
674
  "Content-Type": "application/json"
@@ -523,25 +676,25 @@ function he(e, t) {
523
676
  }
524
677
  )).json(),
525
678
  onSuccess(n) {
526
- p().setQueryData(
527
- C(e).queryKey,
528
- (r) => {
529
- if (!r)
679
+ u().setQueryData(
680
+ b(e).queryKey,
681
+ (o) => {
682
+ if (!o)
530
683
  return [];
531
- const o = r.findIndex(({ id: c }) => c === t);
532
- return o >= 0 && (r[o] = n), [...r];
684
+ const r = o.findIndex(({ id: c }) => c === t);
685
+ return r >= 0 && (o[r] = n), [...o];
533
686
  }
534
687
  );
535
688
  }
536
689
  });
537
690
  }
538
- function de(e, t) {
691
+ function Ce(e, t) {
539
692
  return l({
540
693
  mutationKey: ["posts", "remove-fragment", e],
541
- mutationFn: async () => fetch(a.privateApiHost + "/private-api/fragments-delete", {
694
+ mutationFn: async () => fetch(i.privateApiHost + "/private-api/fragments-delete", {
542
695
  method: "POST",
543
696
  body: JSON.stringify({
544
- code: f(e),
697
+ code: y(e),
545
698
  id: t
546
699
  }),
547
700
  headers: {
@@ -549,20 +702,20 @@ function de(e, t) {
549
702
  }
550
703
  }),
551
704
  onSuccess() {
552
- p().setQueryData(
553
- C(e).queryKey,
554
- (n) => [...n ?? []].filter(({ id: r }) => r !== t)
705
+ u().setQueryData(
706
+ b(e).queryKey,
707
+ (n) => [...n ?? []].filter(({ id: o }) => o !== t)
555
708
  );
556
709
  }
557
710
  });
558
711
  }
559
- function _(e, t) {
712
+ function T(e, t) {
560
713
  return l({
561
714
  mutationKey: ["analytics", t],
562
715
  mutationFn: async () => {
563
716
  if (!t)
564
717
  throw new Error("[SDK][Analytics] – no activity type provided");
565
- await fetch(a.plausibleHost + "/api/event", {
718
+ await fetch(i.plausibleHost + "/api/event", {
566
719
  method: "POST",
567
720
  headers: {
568
721
  "Content-Type": "application/json"
@@ -579,15 +732,15 @@ function _(e, t) {
579
732
  }
580
733
  });
581
734
  }
582
- const ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
735
+ const Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
583
736
  __proto__: null,
584
- useRecordActivity: _
737
+ useRecordActivity: T
585
738
  }, Symbol.toStringTag, { value: "Module" }));
586
- function U(e, t) {
587
- return u({
739
+ function x(e, t) {
740
+ return p({
588
741
  queryKey: ["integrations", "hivesigner", "decode-memo", e],
589
742
  queryFn: async () => {
590
- const n = f(e);
743
+ const n = y(e);
591
744
  if (n)
592
745
  return new g.Client({
593
746
  accessToken: n
@@ -595,14 +748,14 @@ function U(e, t) {
595
748
  }
596
749
  });
597
750
  }
598
- const x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
751
+ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
599
752
  __proto__: null,
600
- getDecodeMemoQueryOptions: U
601
- }, Symbol.toStringTag, { value: "Module" })), G = {
602
- queries: x
753
+ getDecodeMemoQueryOptions: x
754
+ }, Symbol.toStringTag, { value: "Module" })), W = {
755
+ queries: G
603
756
  };
604
- function v(e) {
605
- return u({
757
+ function m(e) {
758
+ return p({
606
759
  queryKey: ["integrations", "3speak", "authenticate", e],
607
760
  enabled: !!e,
608
761
  queryFn: async () => {
@@ -615,28 +768,28 @@ function v(e) {
615
768
  "Content-Type": "application/json"
616
769
  }
617
770
  }
618
- ), n = G.queries.getDecodeMemoQueryOptions(
771
+ ), n = W.queries.getDecodeMemoQueryOptions(
619
772
  e,
620
773
  (await t.json()).memo
621
774
  );
622
- await p().prefetchQuery(n);
623
- const { memoDecoded: r } = p().getQueryData(
775
+ await u().prefetchQuery(n);
776
+ const { memoDecoded: o } = u().getQueryData(
624
777
  n.queryKey
625
778
  );
626
- return r.replace("#", "");
779
+ return o.replace("#", "");
627
780
  }
628
781
  });
629
782
  }
630
- function W(e) {
631
- return u({
783
+ function U(e) {
784
+ return p({
632
785
  queryKey: ["integrations", "3speak", "videos", e],
633
786
  enabled: !!e,
634
787
  queryFn: async () => {
635
- await p().prefetchQuery(
636
- v(e)
788
+ await u().prefetchQuery(
789
+ m(e)
637
790
  );
638
- const t = p().getQueryData(
639
- v(e).queryKey
791
+ const t = u().getQueryData(
792
+ m(e).queryKey
640
793
  );
641
794
  return await (await fetch(
642
795
  "https://studio.3speak.tv/mobile/api/my-videos",
@@ -652,42 +805,42 @@ function W(e) {
652
805
  }
653
806
  const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
654
807
  __proto__: null,
655
- getAccountTokenQueryOptions: v,
656
- getAccountVideosQueryOptions: W
657
- }, Symbol.toStringTag, { value: "Module" })), we = {
808
+ getAccountTokenQueryOptions: m,
809
+ getAccountVideosQueryOptions: U
810
+ }, Symbol.toStringTag, { value: "Module" })), Se = {
658
811
  queries: z
659
812
  };
660
- function me() {
661
- return u({
813
+ function Ke() {
814
+ return p({
662
815
  queryKey: ["resource-credits", "stats"],
663
- queryFn: async () => (await a.hiveClient.call(
816
+ queryFn: async () => (await i.hiveClient.call(
664
817
  "rc_api",
665
818
  "get_rc_stats",
666
819
  {}
667
820
  )).rc_stats
668
821
  });
669
822
  }
670
- function ve(e) {
671
- return u({
823
+ function qe(e) {
824
+ return p({
672
825
  queryKey: ["resource-credits", "account", e],
673
- queryFn: async () => new M(a.hiveClient).findRCAccounts([e]),
826
+ queryFn: async () => new N(i.hiveClient).findRCAccounts([e]),
674
827
  enabled: !!e
675
828
  });
676
829
  }
677
- function Ce(e, t) {
678
- return u({
830
+ function ke(e, t) {
831
+ return p({
679
832
  queryKey: ["games", "status-check", t, e],
680
833
  enabled: !!e,
681
834
  queryFn: async () => {
682
835
  if (!e)
683
836
  throw new Error("[SDK][Games] – anon user in status check");
684
837
  return await (await fetch(
685
- a.privateApiHost + "/private-api/get-game",
838
+ i.privateApiHost + "/private-api/get-game",
686
839
  {
687
840
  method: "POST",
688
841
  body: JSON.stringify({
689
842
  game_type: t,
690
- code: f(e)
843
+ code: y(e)
691
844
  }),
692
845
  headers: {
693
846
  "Content-Type": "application/json"
@@ -697,8 +850,8 @@ function Ce(e, t) {
697
850
  }
698
851
  });
699
852
  }
700
- function be(e, t, n) {
701
- const { mutateAsync: r } = _(
853
+ function Te(e, t, n) {
854
+ const { mutateAsync: o } = T(
702
855
  e,
703
856
  "spin-rolled"
704
857
  );
@@ -708,12 +861,12 @@ function be(e, t, n) {
708
861
  if (!e)
709
862
  throw new Error("[SDK][Games] – anon user in game post");
710
863
  return await (await fetch(
711
- a.privateApiHost + "/private-api/post-game",
864
+ i.privateApiHost + "/private-api/post-game",
712
865
  {
713
866
  method: "POST",
714
867
  body: JSON.stringify({
715
868
  game_type: t,
716
- code: f(e),
869
+ code: y(e),
717
870
  key: n
718
871
  }),
719
872
  headers: {
@@ -723,16 +876,16 @@ function be(e, t, n) {
723
876
  )).json();
724
877
  },
725
878
  onSuccess() {
726
- r();
879
+ o();
727
880
  }
728
881
  });
729
882
  }
730
- function Oe(e, t, n = 100, r = void 0, o = !0) {
731
- return u({
883
+ function Ae(e, t, n = 100, o = void 0, r = !0) {
884
+ return p({
732
885
  queryKey: ["communities", "list", e, t, n],
733
- enabled: o,
886
+ enabled: r,
734
887
  queryFn: async () => {
735
- const c = await a.hiveClient.call(
888
+ const c = await i.hiveClient.call(
736
889
  "bridge",
737
890
  "list_communities",
738
891
  {
@@ -740,19 +893,19 @@ function Oe(e, t, n = 100, r = void 0, o = !0) {
740
893
  limit: n,
741
894
  sort: e === "hot" ? "rank" : e,
742
895
  query: t || null,
743
- observer: r
896
+ observer: o
744
897
  }
745
898
  );
746
899
  return c ? e === "hot" ? c.sort(() => Math.random() - 0.5) : c : [];
747
900
  }
748
901
  });
749
902
  }
750
- function qe(e, t) {
751
- return u({
903
+ function Qe(e, t) {
904
+ return p({
752
905
  queryKey: ["community", "context", e, t],
753
906
  enabled: !!e && !!t,
754
907
  queryFn: async () => {
755
- const n = await a.hiveClient.call("bridge", "get_community_context", {
908
+ const n = await i.hiveClient.call("bridge", "get_community_context", {
756
909
  account: e,
757
910
  name: t
758
911
  });
@@ -763,8 +916,8 @@ function qe(e, t) {
763
916
  }
764
917
  });
765
918
  }
766
- var y = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(y || {});
767
- const Ke = {
919
+ var d = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(d || {});
920
+ const je = {
768
921
  owner: [
769
922
  "admin",
770
923
  "mod",
@@ -787,74 +940,80 @@ const Ke = {
787
940
  /* MUTED */
788
941
  ]
789
942
  };
790
- function Se(e, t) {
943
+ function _e(e, t) {
791
944
  return e.startsWith("hive-3") || t === 3 ? "Council" : e.startsWith("hive-2") || t === 2 ? "Journal" : "Topic";
792
945
  }
793
- function Qe({
946
+ function Fe({
794
947
  communityType: e,
795
948
  userRole: t,
796
949
  subscribed: n
797
950
  }) {
798
- const r = t === y.MUTED ? !1 : e === "Topic" ? !0 : [y.OWNER, y.ADMIN, y.MOD, y.MEMBER].includes(t), o = (() => {
799
- if (t === y.MUTED) return !1;
951
+ const o = t === d.MUTED ? !1 : e === "Topic" ? !0 : [d.OWNER, d.ADMIN, d.MOD, d.MEMBER].includes(t), r = (() => {
952
+ if (t === d.MUTED) return !1;
800
953
  switch (e) {
801
954
  case "Topic":
802
955
  return !0;
803
956
  case "Journal":
804
- return t !== y.GUEST || n;
957
+ return t !== d.GUEST || n;
805
958
  case "Council":
806
- return r;
959
+ return o;
807
960
  }
808
- })(), c = [y.OWNER, y.ADMIN, y.MOD].includes(t);
961
+ })(), c = [d.OWNER, d.ADMIN, d.MOD].includes(t);
809
962
  return {
810
- canPost: r,
811
- canComment: o,
963
+ canPost: o,
964
+ canComment: r,
812
965
  isModerator: c
813
966
  };
814
967
  }
815
968
  export {
816
- a as CONFIG,
969
+ i as CONFIG,
817
970
  O as ConfigManager,
818
- ge as EcencyAnalytics,
819
- q as EcencyQueriesManager,
820
- G as HiveSignerIntegration,
971
+ Oe as EcencyAnalytics,
972
+ S as EcencyQueriesManager,
973
+ W as HiveSignerIntegration,
821
974
  L as Keychain,
822
- y as ROLES,
823
- we as ThreeSpeakIntegration,
824
- H as broadcastJson,
825
- re as checkUsernameWalletsPendingQueryOptions,
826
- f as getAccessToken,
975
+ d as ROLES,
976
+ Se as ThreeSpeakIntegration,
977
+ B as broadcastJson,
978
+ oe as checkUsernameWalletsPendingQueryOptions,
979
+ y as getAccessToken,
827
980
  te as getAccountFullQueryOptions,
828
- ve as getAccountRcQueryOptions,
829
- oe as getAccountSubscriptionsQueryOptions,
830
- ue as getChainPropertiesQueryOptions,
831
- Oe as getCommunitiesQueryOptions,
832
- qe as getCommunityContextQueryOptions,
833
- Qe as getCommunityPermissions,
834
- Se as getCommunityType,
835
- C as getFragmentsQueryOptions,
836
- Ce as getGameStatusCheckQueryOptions,
837
- pe as getHiveEngineTokensListQueryOptions,
838
- Q as getLoginType,
839
- S as getPostingKey,
840
- le as getPromotedPostsQuery,
841
- p as getQueryClient,
842
- me as getRcStatsQueryOptions,
981
+ qe as getAccountRcQueryOptions,
982
+ re as getAccountSubscriptionsQueryOptions,
983
+ ie as getActiveAccountBookmarksQueryOptions,
984
+ se as getActiveAccountFavouritesQueryOptions,
985
+ he as getChainPropertiesQueryOptions,
986
+ Ae as getCommunitiesQueryOptions,
987
+ Qe as getCommunityContextQueryOptions,
988
+ Fe as getCommunityPermissions,
989
+ _e as getCommunityType,
990
+ b as getFragmentsQueryOptions,
991
+ ke as getGameStatusCheckQueryOptions,
992
+ ge as getHiveEngineTokensListQueryOptions,
993
+ k as getLoginType,
994
+ q as getPostingKey,
995
+ ve as getPromotedPostsQuery,
996
+ u as getQueryClient,
997
+ Ke as getRcStatsQueryOptions,
843
998
  Z as getRefreshToken,
844
- B as getRelationshipBetweenAccountsQueryOptions,
999
+ H as getRelationshipBetweenAccountsQueryOptions,
845
1000
  ne as getSearchAccountsByUsernameQueryOptions,
846
- ye as getTrendingTagsQueryOptions,
847
- h as getUser,
1001
+ we as getTrendingTagsQueryOptions,
1002
+ f as getUser,
848
1003
  R as makeQueryClient,
849
- Ke as roleMap,
850
- ie as useAccountRelationsUpdate,
1004
+ je as roleMap,
1005
+ pe as useAccountFavouriteAdd,
1006
+ ye as useAccountFavouriteDelete,
1007
+ ae as useAccountRelationsUpdate,
851
1008
  ee as useAccountUpdate,
852
- fe as useAddFragment,
853
- J as useBroadcastMutation,
854
- he as useEditFragment,
855
- be as useGameClaim,
856
- de as useRemoveFragment,
857
- ce as useSignOperationByHivesigner,
858
- se as useSignOperationByKey,
859
- ae as useSignOperationByKeychain
1009
+ me as useAddFragment,
1010
+ ce as useBookmarkAdd,
1011
+ ue as useBookmarkDelete,
1012
+ I as useBroadcastMutation,
1013
+ be as useEditFragment,
1014
+ Te as useGameClaim,
1015
+ Ce as useRemoveFragment,
1016
+ fe as useSignOperationByHivesigner,
1017
+ le as useSignOperationByKey,
1018
+ de as useSignOperationByKeychain
860
1019
  };
@@ -0,0 +1,2 @@
1
+ export * from './use-account-bookmark-add';
2
+ export * from './use-account-bookmark-delete';
@@ -0,0 +1,6 @@
1
+ interface Payload {
2
+ author: string;
3
+ permlink: string;
4
+ }
5
+ export declare function useBookmarkAdd(username: string | undefined, onSuccess: () => void, onError: (e: Error) => void): import('@tanstack/react-query').UseMutationResult<any, Error, Payload, unknown>;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare function useBookmarkDelete(username: string | undefined, onSuccess: () => void, onError: (e: Error) => void): import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
@@ -0,0 +1,2 @@
1
+ export * from './use-account-favourite-add';
2
+ export * from './use-account-favourite-delete';
@@ -0,0 +1 @@
1
+ export declare function useAccountFavouriteAdd(username: string | undefined, onSuccess: () => void, onError: (e: Error) => void): import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
@@ -0,0 +1 @@
1
+ export declare function useAccountFavouriteDelete(username: string | undefined, onSuccess: () => void, onError: (e: Error) => void): import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
@@ -1,2 +1,4 @@
1
1
  export * from './use-account-update';
2
2
  export * from './use-account-relations-update';
3
+ export * from './bookmarks';
4
+ export * from './favourites';
@@ -0,0 +1,9 @@
1
+ import { AccountBookmark } from '../types';
2
+ export declare function getActiveAccountBookmarksQueryOptions(activeUsername: string | undefined): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<AccountBookmark[], Error, AccountBookmark[], (string | undefined)[]>, "queryFn"> & {
3
+ queryFn?: import('@tanstack/query-core').QueryFunction<AccountBookmark[], (string | undefined)[], never> | undefined;
4
+ } & {
5
+ queryKey: (string | undefined)[] & {
6
+ [dataTagSymbol]: AccountBookmark[];
7
+ [dataTagErrorSymbol]: Error;
8
+ };
9
+ };
@@ -0,0 +1,9 @@
1
+ import { AccountFavorite } from '../types';
2
+ export declare function getActiveAccountFavouritesQueryOptions(activeUsername: string | undefined): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<AccountFavorite[], Error, AccountFavorite[], (string | undefined)[]>, "queryFn"> & {
3
+ queryFn?: import('@tanstack/query-core').QueryFunction<AccountFavorite[], (string | undefined)[], never> | undefined;
4
+ } & {
5
+ queryKey: (string | undefined)[] & {
6
+ [dataTagSymbol]: AccountFavorite[];
7
+ [dataTagErrorSymbol]: Error;
8
+ };
9
+ };
@@ -3,3 +3,5 @@ export * from './search-accounts-by-username-query-options';
3
3
  export * from './check-username-wallets-pending-query-options';
4
4
  export * from './get-relationship-between-accounts-query-options';
5
5
  export * from './get-account-subscriptions-query-options';
6
+ export * from './get-active-account-bookmarks-query-options';
7
+ export * from './get-active-account-favourites-query-options';
@@ -0,0 +1,7 @@
1
+ export interface AccountBookmark {
2
+ _id: string;
3
+ author: string;
4
+ permlink: string;
5
+ timestamp: number;
6
+ created: string;
7
+ }
@@ -0,0 +1,5 @@
1
+ export interface AccountFavorite {
2
+ _id: string;
3
+ account: string;
4
+ timestamp: number;
5
+ }
@@ -1,3 +1,5 @@
1
1
  export * from './account-follow-stats';
2
2
  export * from './account-reputation';
3
3
  export * from './account-relationship';
4
+ export * from './account-bookmark';
5
+ export * from './account-favourite';
@@ -1,13 +1,7 @@
1
1
  import { ROLES } from '../types';
2
2
  export type CommunityRole = (typeof ROLES)[keyof typeof ROLES];
3
3
  export type CommunityType = "Topic" | "Journal" | "Council";
4
- /**
5
- * Determine community type based on its `name` or `type_id`
6
- */
7
4
  export declare function getCommunityType(name: string, type_id: number): CommunityType;
8
- /**
9
- * Compute permissions for a given user role in a community
10
- */
11
5
  export declare function getCommunityPermissions({ communityType, userRole, subscribed, }: {
12
6
  communityType: CommunityType;
13
7
  userRole: CommunityRole;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.50",
4
+ "version": "1.0.52",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",