@ecency/sdk 1.0.43 → 1.0.45

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,10 +1,10 @@
1
1
  var Q = Object.defineProperty;
2
2
  var _ = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var m = (e, t, n) => _(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as S, useMutation as y, useQuery as k, useInfiniteQuery as T, queryOptions as p, infiniteQueryOptions as j } from "@tanstack/react-query";
4
+ import { QueryClient as S, useMutation as y, useQuery as T, useInfiniteQuery as j, queryOptions as p, infiniteQueryOptions as k } from "@tanstack/react-query";
5
5
  import { Client as A, PrivateKey as h, cryptoUtils as F, RCAPI as D } from "@hiveio/dhive";
6
6
  import d from "hivesigner";
7
- class I {
7
+ class P {
8
8
  constructor() {
9
9
  m(this, "length", 0);
10
10
  }
@@ -26,7 +26,7 @@ class I {
26
26
  }
27
27
  const s = {
28
28
  privateApiHost: "https://ecency.com",
29
- storage: typeof window > "u" ? new I() : window.localStorage,
29
+ storage: typeof window > "u" ? new P() : window.localStorage,
30
30
  storagePrefix: "ecency",
31
31
  hiveClient: new A(
32
32
  [
@@ -52,14 +52,14 @@ const s = {
52
52
  queryClient: new S(),
53
53
  plausibleHost: "https://pl.ecency.com"
54
54
  };
55
- var O;
55
+ var C;
56
56
  ((e) => {
57
57
  function t(n) {
58
58
  s.queryClient = n;
59
59
  }
60
60
  e.setQueryClient = t;
61
- })(O || (O = {}));
62
- function P(e) {
61
+ })(C || (C = {}));
62
+ function I(e) {
63
63
  let t = atob(e);
64
64
  if (t[0] === "{")
65
65
  return JSON.parse(t);
@@ -69,25 +69,25 @@ const f = (e) => {
69
69
  const t = s.storage.getItem(
70
70
  s.storagePrefix + "_user_" + e
71
71
  );
72
- return P(JSON.parse(t));
72
+ return I(JSON.parse(t));
73
73
  } catch (t) {
74
74
  console.error(t);
75
75
  return;
76
76
  }
77
- }, l = (e) => f(e) && f(e).accessToken, q = (e) => f(e) && f(e).postingKey, L = (e) => f(e) && f(e).refreshToken;
77
+ }, l = (e) => f(e) && f(e).accessToken, q = (e) => f(e) && f(e).postingKey, V = (e) => f(e) && f(e).refreshToken;
78
78
  function N(e = [], t, n) {
79
79
  return y({
80
80
  mutationKey: [...e, t],
81
- mutationFn: async (o) => {
81
+ mutationFn: async (r) => {
82
82
  if (!t)
83
83
  throw new Error(
84
84
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
85
85
  );
86
- const r = q(t);
87
- if (r) {
88
- const i = h.fromString(r);
86
+ const o = q(t);
87
+ if (o) {
88
+ const i = h.fromString(o);
89
89
  return s.hiveClient.broadcast.sendOperations(
90
- n(o),
90
+ n(r),
91
91
  i
92
92
  );
93
93
  }
@@ -95,7 +95,7 @@ function N(e = [], t, n) {
95
95
  if (u)
96
96
  return (await new d.Client({
97
97
  accessToken: u
98
- }).broadcast(n(o))).result;
98
+ }).broadcast(n(r))).result;
99
99
  throw new Error(
100
100
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
101
101
  );
@@ -107,9 +107,9 @@ async function J(e, t, n) {
107
107
  throw new Error(
108
108
  "[Core][Broadcast] Attempted to call broadcast API with anon user"
109
109
  );
110
- const o = q(e);
111
- if (o) {
112
- const u = h.fromString(o);
110
+ const r = q(e);
111
+ if (r) {
112
+ const u = h.fromString(r);
113
113
  return s.hiveClient.broadcast.json(
114
114
  {
115
115
  id: t,
@@ -120,10 +120,10 @@ async function J(e, t, n) {
120
120
  u
121
121
  );
122
122
  }
123
- let r = l(e);
124
- if (r)
123
+ let o = l(e);
124
+ if (o)
125
125
  return (await new d.Client({
126
- accessToken: r
126
+ accessToken: o
127
127
  }).customJson([], [e], t, JSON.stringify(n))).result;
128
128
  throw new Error(
129
129
  "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
@@ -143,7 +143,7 @@ function X() {
143
143
  });
144
144
  }
145
145
  const c = () => s.queryClient;
146
- var C;
146
+ var O;
147
147
  ((e) => {
148
148
  function t(a) {
149
149
  return c().getQueryData(a);
@@ -153,33 +153,33 @@ var C;
153
153
  return c().getQueryData(a);
154
154
  }
155
155
  e.getInfiniteQueryData = n;
156
- async function o(a) {
156
+ async function r(a) {
157
157
  return await c().prefetchQuery(a), t(a.queryKey);
158
158
  }
159
- e.prefetchQuery = o;
160
- async function r(a) {
159
+ e.prefetchQuery = r;
160
+ async function o(a) {
161
161
  return await c().prefetchInfiniteQuery(a), n(a.queryKey);
162
162
  }
163
- e.prefetchInfiniteQuery = r;
163
+ e.prefetchInfiniteQuery = o;
164
164
  function u(a) {
165
165
  return {
166
- prefetch: () => o(a),
166
+ prefetch: () => r(a),
167
167
  getData: () => t(a.queryKey),
168
- useClientQuery: () => k(a),
168
+ useClientQuery: () => T(a),
169
169
  fetchAndGet: () => c().fetchQuery(a)
170
170
  };
171
171
  }
172
172
  e.generateClientServerQuery = u;
173
173
  function i(a) {
174
174
  return {
175
- prefetch: () => r(a),
175
+ prefetch: () => o(a),
176
176
  getData: () => n(a.queryKey),
177
- useClientQuery: () => T(a),
177
+ useClientQuery: () => j(a),
178
178
  fetchAndGet: () => c().fetchInfiniteQuery(a)
179
179
  };
180
180
  }
181
181
  e.generateClientServerInfiniteQuery = i;
182
- })(C || (C = {}));
182
+ })(O || (O = {}));
183
183
  function Y(e) {
184
184
  return N(
185
185
  ["accounts", "update"],
@@ -213,26 +213,26 @@ function Z(e) {
213
213
  if (!t[0])
214
214
  throw new Error("[SDK] No account with given username");
215
215
  const n = JSON.parse(t[0].posting_json_metadata).profile;
216
- let o;
216
+ let r;
217
217
  try {
218
- o = await s.hiveClient.database.call(
218
+ r = await s.hiveClient.database.call(
219
219
  "get_follow_count",
220
220
  [e]
221
221
  );
222
222
  } catch {
223
223
  }
224
- const r = await s.hiveClient.call(
224
+ const o = await s.hiveClient.call(
225
225
  "condenser_api",
226
226
  "get_account_reputations",
227
227
  [e, 1]
228
228
  );
229
229
  return {
230
230
  ...t,
231
- follow_stats: o,
232
- reputation: r[0].reputation,
231
+ follow_stats: r,
232
+ reputation: o[0].reputation,
233
233
  profile: {
234
234
  ...n,
235
- reputation: r[0].reputation
235
+ reputation: o[0].reputation
236
236
  }
237
237
  };
238
238
  },
@@ -248,7 +248,7 @@ function R(e, t = 5, n = []) {
248
248
  "lookup_accounts",
249
249
  [e, t]
250
250
  )).filter(
251
- (r) => n.length > 0 ? !n.includes(r) : !0
251
+ (o) => n.length > 0 ? !n.includes(o) : !0
252
252
  )
253
253
  });
254
254
  }
@@ -284,10 +284,10 @@ function H(e, t) {
284
284
  )
285
285
  });
286
286
  }
287
- function te(e, t, n, o) {
287
+ function te(e, t, n, r) {
288
288
  return y({
289
289
  mutationKey: [],
290
- mutationFn: async (r) => {
290
+ mutationFn: async (o) => {
291
291
  const u = H(
292
292
  e,
293
293
  t
@@ -302,21 +302,21 @@ function te(e, t, n, o) {
302
302
  follower: e,
303
303
  following: t,
304
304
  what: [
305
- ...r === "toggle-ignore" && !(i != null && i.ignores) ? ["ignore"] : [],
306
- ...r === "toggle-follow" && !(i != null && i.follows) ? ["blog"] : []
305
+ ...o === "toggle-ignore" && !(i != null && i.ignores) ? ["ignore"] : [],
306
+ ...o === "toggle-follow" && !(i != null && i.follows) ? ["blog"] : []
307
307
  ]
308
308
  }
309
309
  ]), {
310
310
  ...i,
311
- ignores: r === "toggle-ignore" ? !(i != null && i.ignores) : i == null ? void 0 : i.ignores,
312
- follows: r === "toggle-follow" ? !(i != null && i.follows) : i == null ? void 0 : i.follows
311
+ ignores: o === "toggle-ignore" ? !(i != null && i.ignores) : i == null ? void 0 : i.ignores,
312
+ follows: o === "toggle-follow" ? !(i != null && i.follows) : i == null ? void 0 : i.follows
313
313
  };
314
314
  },
315
- onError: o,
316
- onSuccess(r) {
317
- n(r), c().setQueryData(
315
+ onError: r,
316
+ onSuccess(o) {
317
+ n(o), c().setQueryData(
318
318
  ["accounts", "relations", e, t],
319
- r
319
+ o
320
320
  );
321
321
  }
322
322
  });
@@ -330,15 +330,15 @@ function ne(e) {
330
330
  }) => {
331
331
  if (!e)
332
332
  throw new Error("[Operations][Sign] – cannot sign op with anon user");
333
- let o;
334
- return n.split(" ").length === 12 ? o = h.fromLogin(e, n, "active") : F.isWif(n) ? o = h.fromString(n) : o = h.from(n), s.hiveClient.broadcast.sendOperations(
333
+ let r;
334
+ return n.split(" ").length === 12 ? r = h.fromLogin(e, n, "active") : F.isWif(n) ? r = h.fromString(n) : r = h.from(n), s.hiveClient.broadcast.sendOperations(
335
335
  [t],
336
- o
336
+ r
337
337
  );
338
338
  }
339
339
  });
340
340
  }
341
- function B() {
341
+ function E() {
342
342
  return new Promise((e) => {
343
343
  var t;
344
344
  (t = window.hive_keychain) == null || t.requestHandshake(() => {
@@ -346,23 +346,23 @@ function B() {
346
346
  });
347
347
  });
348
348
  }
349
- const b = (e, t, n, o = null) => new Promise((r, u) => {
349
+ const K = (e, t, n, r = null) => new Promise((o, u) => {
350
350
  var i;
351
351
  (i = window.hive_keychain) == null || i.requestBroadcast(
352
352
  e,
353
353
  t,
354
354
  n,
355
355
  (a) => {
356
- a.success || u({ message: "Operation cancelled" }), r(a);
356
+ a.success || u({ message: "Operation cancelled" }), o(a);
357
357
  },
358
- o
358
+ r
359
359
  );
360
- }), oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
360
+ }), re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
361
361
  __proto__: null,
362
- broadcast: b,
363
- handshake: B
362
+ broadcast: K,
363
+ handshake: E
364
364
  }, Symbol.toStringTag, { value: "Module" }));
365
- function re(e, t = "Active") {
365
+ function oe(e, t = "Active") {
366
366
  return y({
367
367
  mutationKey: ["operations", "sign-keychain", e],
368
368
  mutationFn: ({ operation: n }) => {
@@ -370,7 +370,7 @@ function re(e, t = "Active") {
370
370
  throw new Error(
371
371
  "[SDK][Keychain] – cannot sign operation with anon user"
372
372
  );
373
- return b(e, [n], t);
373
+ return K(e, [n], t);
374
374
  }
375
375
  });
376
376
  }
@@ -381,7 +381,13 @@ function ie(e = "/") {
381
381
  })
382
382
  });
383
383
  }
384
- function se(e, t) {
384
+ function se() {
385
+ return p({
386
+ queryKey: ["operations", "chain-properties"],
387
+ queryFn: async () => await s.hiveClient.database.getChainProperties()
388
+ });
389
+ }
390
+ function ae(e, t) {
385
391
  return p({
386
392
  queryKey: ["hive-engine", "tokens-list", e, t],
387
393
  queryFn: async () => (await (await fetch(
@@ -406,11 +412,11 @@ function se(e, t) {
406
412
  )).json()).result
407
413
  });
408
414
  }
409
- function ae(e = 20) {
410
- return j({
415
+ function ce(e = 20) {
416
+ return k({
411
417
  queryKey: ["posts", "trending-tags"],
412
418
  queryFn: async ({ pageParam: { afterTag: t } }) => s.hiveClient.database.call("get_trending_tags", [t, e]).then(
413
- (n) => n.filter((o) => o.name !== "").filter((o) => !o.name.startsWith("hive-")).map((o) => o.name)
419
+ (n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
414
420
  ),
415
421
  initialPageParam: { afterTag: "" },
416
422
  getNextPageParam: (t) => ({
@@ -438,7 +444,23 @@ function v(e) {
438
444
  enabled: !!e
439
445
  });
440
446
  }
441
- function ce(e) {
447
+ function ue(e = "feed") {
448
+ return p({
449
+ queryKey: ["posts", "promoted", e],
450
+ queryFn: async () => {
451
+ const t = new URL(
452
+ s.privateApiHost + "/private-api/promoted-entries"
453
+ );
454
+ return e === "waves" && t.searchParams.append("short_content", "1"), await (await fetch(t.toString(), {
455
+ method: "GET",
456
+ headers: {
457
+ "Content-Type": "application/json"
458
+ }
459
+ })).json();
460
+ }
461
+ });
462
+ }
463
+ function pe(e) {
442
464
  return y({
443
465
  mutationKey: ["posts", "add-fragment", e],
444
466
  mutationFn: async ({ title: t, body: n }) => (await fetch(
@@ -463,10 +485,10 @@ function ce(e) {
463
485
  }
464
486
  });
465
487
  }
466
- function ue(e, t) {
488
+ function ye(e, t) {
467
489
  return y({
468
490
  mutationKey: ["posts", "edit-fragment", e, t],
469
- mutationFn: async ({ title: n, body: o }) => (await fetch(
491
+ mutationFn: async ({ title: n, body: r }) => (await fetch(
470
492
  s.privateApiHost + "/private-api/fragments-update",
471
493
  {
472
494
  method: "POST",
@@ -474,7 +496,7 @@ function ue(e, t) {
474
496
  code: l(e),
475
497
  id: t,
476
498
  title: n,
477
- body: o
499
+ body: r
478
500
  }),
479
501
  headers: {
480
502
  "Content-Type": "application/json"
@@ -484,17 +506,17 @@ function ue(e, t) {
484
506
  onSuccess(n) {
485
507
  c().setQueryData(
486
508
  v(e).queryKey,
487
- (o) => {
488
- if (!o)
509
+ (r) => {
510
+ if (!r)
489
511
  return [];
490
- const r = o.findIndex(({ id: u }) => u === t);
491
- return r >= 0 && (o[r] = n), [...o];
512
+ const o = r.findIndex(({ id: u }) => u === t);
513
+ return o >= 0 && (r[o] = n), [...r];
492
514
  }
493
515
  );
494
516
  }
495
517
  });
496
518
  }
497
- function pe(e, t) {
519
+ function le(e, t) {
498
520
  return y({
499
521
  mutationKey: ["posts", "remove-fragment", e],
500
522
  mutationFn: async () => fetch(s.privateApiHost + "/private-api/fragments-delete", {
@@ -510,12 +532,12 @@ function pe(e, t) {
510
532
  onSuccess() {
511
533
  c().setQueryData(
512
534
  v(e).queryKey,
513
- (n) => [...n ?? []].filter(({ id: o }) => o !== t)
535
+ (n) => [...n ?? []].filter(({ id: r }) => r !== t)
514
536
  );
515
537
  }
516
538
  });
517
539
  }
518
- function K(e, t) {
540
+ function b(e, t) {
519
541
  return y({
520
542
  mutationKey: ["analytics", t],
521
543
  mutationFn: async () => {
@@ -538,11 +560,11 @@ function K(e, t) {
538
560
  }
539
561
  });
540
562
  }
541
- const ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
563
+ const fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
542
564
  __proto__: null,
543
- useRecordActivity: K
565
+ useRecordActivity: b
544
566
  }, Symbol.toStringTag, { value: "Module" }));
545
- function E(e, t) {
567
+ function B(e, t) {
546
568
  return p({
547
569
  queryKey: ["integrations", "hivesigner", "decode-memo", e],
548
570
  queryFn: async () => {
@@ -556,7 +578,7 @@ function E(e, t) {
556
578
  }
557
579
  const M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
558
580
  __proto__: null,
559
- getDecodeMemoQueryOptions: E
581
+ getDecodeMemoQueryOptions: B
560
582
  }, Symbol.toStringTag, { value: "Module" })), x = {
561
583
  queries: M
562
584
  };
@@ -579,10 +601,10 @@ function w(e) {
579
601
  (await t.json()).memo
580
602
  );
581
603
  await c().prefetchQuery(n);
582
- const { memoDecoded: o } = c().getQueryData(
604
+ const { memoDecoded: r } = c().getQueryData(
583
605
  n.queryKey
584
606
  );
585
- return o.replace("#", "");
607
+ return r.replace("#", "");
586
608
  }
587
609
  });
588
610
  }
@@ -613,10 +635,10 @@ const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
613
635
  __proto__: null,
614
636
  getAccountTokenQueryOptions: w,
615
637
  getAccountVideosQueryOptions: G
616
- }, Symbol.toStringTag, { value: "Module" })), le = {
638
+ }, Symbol.toStringTag, { value: "Module" })), he = {
617
639
  queries: U
618
640
  };
619
- function fe() {
641
+ function de() {
620
642
  return p({
621
643
  queryKey: ["resource-credits", "stats"],
622
644
  queryFn: async () => (await s.hiveClient.call(
@@ -626,14 +648,14 @@ function fe() {
626
648
  )).rc_stats
627
649
  });
628
650
  }
629
- function he(e) {
651
+ function ge(e) {
630
652
  return p({
631
653
  queryKey: ["resource-credits", "account", e],
632
654
  queryFn: async () => new D(s.hiveClient).findRCAccounts([e]),
633
655
  enabled: !!e
634
656
  });
635
657
  }
636
- function de(e, t) {
658
+ function we(e, t) {
637
659
  return p({
638
660
  queryKey: ["games", "status-check", t, e],
639
661
  enabled: !!e,
@@ -656,8 +678,8 @@ function de(e, t) {
656
678
  }
657
679
  });
658
680
  }
659
- function ge(e, t, n) {
660
- const { mutateAsync: o } = K(
681
+ function ve(e, t, n) {
682
+ const { mutateAsync: r } = b(
661
683
  e,
662
684
  "spin-rolled"
663
685
  );
@@ -682,43 +704,45 @@ function ge(e, t, n) {
682
704
  )).json();
683
705
  },
684
706
  onSuccess() {
685
- o();
707
+ r();
686
708
  }
687
709
  });
688
710
  }
689
711
  export {
690
712
  s as CONFIG,
691
- O as ConfigManager,
692
- ye as EcencyAnalytics,
693
- C as EcencyQueriesManager,
713
+ C as ConfigManager,
714
+ fe as EcencyAnalytics,
715
+ O as EcencyQueriesManager,
694
716
  x as HiveSignerIntegration,
695
- oe as Keychain,
696
- le as ThreeSpeakIntegration,
717
+ re as Keychain,
718
+ he as ThreeSpeakIntegration,
697
719
  J as broadcastJson,
698
720
  ee as checkUsernameWalletsPendingQueryOptions,
699
721
  l as getAccessToken,
700
722
  Z as getAccountFullQueryOptions,
701
- he as getAccountRcQueryOptions,
723
+ ge as getAccountRcQueryOptions,
724
+ se as getChainPropertiesQueryOptions,
702
725
  v as getFragmentsQueryOptions,
703
- de as getGameStatusCheckQueryOptions,
704
- se as getHiveEngineTokensListQueryOptions,
726
+ we as getGameStatusCheckQueryOptions,
727
+ ae as getHiveEngineTokensListQueryOptions,
705
728
  q as getPostingKey,
729
+ ue as getPromotedPostsQuery,
706
730
  c as getQueryClient,
707
- fe as getRcStatsQueryOptions,
708
- L as getRefreshToken,
731
+ de as getRcStatsQueryOptions,
732
+ V as getRefreshToken,
709
733
  H as getRelationshipBetweenAccountsQueryOptions,
710
734
  R as getSearchAccountsByUsernameQueryOptions,
711
- ae as getTrendingTagsQueryOptions,
735
+ ce as getTrendingTagsQueryOptions,
712
736
  f as getUser,
713
737
  X as makeQueryClient,
714
738
  te as useAccountRelationsUpdate,
715
739
  Y as useAccountUpdate,
716
- ce as useAddFragment,
740
+ pe as useAddFragment,
717
741
  N as useBroadcastMutation,
718
- ue as useEditFragment,
719
- ge as useGameClaim,
720
- pe as useRemoveFragment,
742
+ ye as useEditFragment,
743
+ ve as useGameClaim,
744
+ le as useRemoveFragment,
721
745
  ie as useSignOperationByHivesigner,
722
746
  ne as useSignOperationByKey,
723
- re as useSignOperationByKeychain
747
+ oe as useSignOperationByKeychain
724
748
  };
@@ -1 +1,2 @@
1
1
  export * from './mutations';
2
+ export * from './queries';
@@ -0,0 +1,8 @@
1
+ export declare function getChainPropertiesQueryOptions(): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<import('@hiveio/dhive').ChainProperties, Error, import('@hiveio/dhive').ChainProperties, string[]>, "queryFn"> & {
2
+ queryFn?: import('@tanstack/query-core').QueryFunction<import('@hiveio/dhive').ChainProperties, string[], never> | undefined;
3
+ } & {
4
+ queryKey: string[] & {
5
+ [dataTagSymbol]: import('@hiveio/dhive').ChainProperties;
6
+ [dataTagErrorSymbol]: Error;
7
+ };
8
+ };
@@ -0,0 +1 @@
1
+ export * from './get-chain-properties-query-options';
@@ -0,0 +1,8 @@
1
+ export declare function getPromotedPostsQuery<T extends any>(type?: "feed" | "waves"): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<T[], Error, T[], string[]>, "queryFn"> & {
2
+ queryFn?: import('@tanstack/query-core').QueryFunction<T[], string[], never> | undefined;
3
+ } & {
4
+ queryKey: string[] & {
5
+ [dataTagSymbol]: T[];
6
+ [dataTagErrorSymbol]: Error;
7
+ };
8
+ };
@@ -1,2 +1,3 @@
1
1
  export * from './get-trending-tags-query-options';
2
2
  export * from './get-fragments-query-options';
3
+ export * from './get-promoted-posts-query-options';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.43",
4
+ "version": "1.0.45",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",