@ecency/sdk 1.0.43 → 1.0.44

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.
@@ -4,7 +4,7 @@ var m = (e, t, n) => _(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { QueryClient as S, useMutation as y, useQuery as k, useInfiniteQuery as T, queryOptions as p, infiniteQueryOptions as j } 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,7 +69,7 @@ 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;
@@ -78,16 +78,16 @@ const f = (e) => {
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,17 +153,17 @@ 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
168
  useClientQuery: () => k(a),
169
169
  fetchAndGet: () => c().fetchQuery(a)
@@ -172,14 +172,14 @@ var C;
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
177
  useClientQuery: () => T(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,10 +330,10 @@ 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
  });
@@ -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 b = (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
362
  broadcast: b,
363
363
  handshake: B
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 }) => {
@@ -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) {
415
+ function ce(e = 20) {
410
416
  return j({
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,7 @@ function v(e) {
438
444
  enabled: !!e
439
445
  });
440
446
  }
441
- function ce(e) {
447
+ function ue(e) {
442
448
  return y({
443
449
  mutationKey: ["posts", "add-fragment", e],
444
450
  mutationFn: async ({ title: t, body: n }) => (await fetch(
@@ -463,10 +469,10 @@ function ce(e) {
463
469
  }
464
470
  });
465
471
  }
466
- function ue(e, t) {
472
+ function pe(e, t) {
467
473
  return y({
468
474
  mutationKey: ["posts", "edit-fragment", e, t],
469
- mutationFn: async ({ title: n, body: o }) => (await fetch(
475
+ mutationFn: async ({ title: n, body: r }) => (await fetch(
470
476
  s.privateApiHost + "/private-api/fragments-update",
471
477
  {
472
478
  method: "POST",
@@ -474,7 +480,7 @@ function ue(e, t) {
474
480
  code: l(e),
475
481
  id: t,
476
482
  title: n,
477
- body: o
483
+ body: r
478
484
  }),
479
485
  headers: {
480
486
  "Content-Type": "application/json"
@@ -484,17 +490,17 @@ function ue(e, t) {
484
490
  onSuccess(n) {
485
491
  c().setQueryData(
486
492
  v(e).queryKey,
487
- (o) => {
488
- if (!o)
493
+ (r) => {
494
+ if (!r)
489
495
  return [];
490
- const r = o.findIndex(({ id: u }) => u === t);
491
- return r >= 0 && (o[r] = n), [...o];
496
+ const o = r.findIndex(({ id: u }) => u === t);
497
+ return o >= 0 && (r[o] = n), [...r];
492
498
  }
493
499
  );
494
500
  }
495
501
  });
496
502
  }
497
- function pe(e, t) {
503
+ function ye(e, t) {
498
504
  return y({
499
505
  mutationKey: ["posts", "remove-fragment", e],
500
506
  mutationFn: async () => fetch(s.privateApiHost + "/private-api/fragments-delete", {
@@ -510,7 +516,7 @@ function pe(e, t) {
510
516
  onSuccess() {
511
517
  c().setQueryData(
512
518
  v(e).queryKey,
513
- (n) => [...n ?? []].filter(({ id: o }) => o !== t)
519
+ (n) => [...n ?? []].filter(({ id: r }) => r !== t)
514
520
  );
515
521
  }
516
522
  });
@@ -538,7 +544,7 @@ function K(e, t) {
538
544
  }
539
545
  });
540
546
  }
541
- const ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
547
+ const le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
542
548
  __proto__: null,
543
549
  useRecordActivity: K
544
550
  }, Symbol.toStringTag, { value: "Module" }));
@@ -579,10 +585,10 @@ function w(e) {
579
585
  (await t.json()).memo
580
586
  );
581
587
  await c().prefetchQuery(n);
582
- const { memoDecoded: o } = c().getQueryData(
588
+ const { memoDecoded: r } = c().getQueryData(
583
589
  n.queryKey
584
590
  );
585
- return o.replace("#", "");
591
+ return r.replace("#", "");
586
592
  }
587
593
  });
588
594
  }
@@ -613,10 +619,10 @@ const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
613
619
  __proto__: null,
614
620
  getAccountTokenQueryOptions: w,
615
621
  getAccountVideosQueryOptions: G
616
- }, Symbol.toStringTag, { value: "Module" })), le = {
622
+ }, Symbol.toStringTag, { value: "Module" })), fe = {
617
623
  queries: U
618
624
  };
619
- function fe() {
625
+ function he() {
620
626
  return p({
621
627
  queryKey: ["resource-credits", "stats"],
622
628
  queryFn: async () => (await s.hiveClient.call(
@@ -626,14 +632,14 @@ function fe() {
626
632
  )).rc_stats
627
633
  });
628
634
  }
629
- function he(e) {
635
+ function de(e) {
630
636
  return p({
631
637
  queryKey: ["resource-credits", "account", e],
632
638
  queryFn: async () => new D(s.hiveClient).findRCAccounts([e]),
633
639
  enabled: !!e
634
640
  });
635
641
  }
636
- function de(e, t) {
642
+ function ge(e, t) {
637
643
  return p({
638
644
  queryKey: ["games", "status-check", t, e],
639
645
  enabled: !!e,
@@ -656,8 +662,8 @@ function de(e, t) {
656
662
  }
657
663
  });
658
664
  }
659
- function ge(e, t, n) {
660
- const { mutateAsync: o } = K(
665
+ function we(e, t, n) {
666
+ const { mutateAsync: r } = K(
661
667
  e,
662
668
  "spin-rolled"
663
669
  );
@@ -682,43 +688,44 @@ function ge(e, t, n) {
682
688
  )).json();
683
689
  },
684
690
  onSuccess() {
685
- o();
691
+ r();
686
692
  }
687
693
  });
688
694
  }
689
695
  export {
690
696
  s as CONFIG,
691
- O as ConfigManager,
692
- ye as EcencyAnalytics,
693
- C as EcencyQueriesManager,
697
+ C as ConfigManager,
698
+ le as EcencyAnalytics,
699
+ O as EcencyQueriesManager,
694
700
  x as HiveSignerIntegration,
695
- oe as Keychain,
696
- le as ThreeSpeakIntegration,
701
+ re as Keychain,
702
+ fe as ThreeSpeakIntegration,
697
703
  J as broadcastJson,
698
704
  ee as checkUsernameWalletsPendingQueryOptions,
699
705
  l as getAccessToken,
700
706
  Z as getAccountFullQueryOptions,
701
- he as getAccountRcQueryOptions,
707
+ de as getAccountRcQueryOptions,
708
+ se as getChainPropertiesQueryOptions,
702
709
  v as getFragmentsQueryOptions,
703
- de as getGameStatusCheckQueryOptions,
704
- se as getHiveEngineTokensListQueryOptions,
710
+ ge as getGameStatusCheckQueryOptions,
711
+ ae as getHiveEngineTokensListQueryOptions,
705
712
  q as getPostingKey,
706
713
  c as getQueryClient,
707
- fe as getRcStatsQueryOptions,
714
+ he as getRcStatsQueryOptions,
708
715
  L as getRefreshToken,
709
716
  H as getRelationshipBetweenAccountsQueryOptions,
710
717
  R as getSearchAccountsByUsernameQueryOptions,
711
- ae as getTrendingTagsQueryOptions,
718
+ ce as getTrendingTagsQueryOptions,
712
719
  f as getUser,
713
720
  X as makeQueryClient,
714
721
  te as useAccountRelationsUpdate,
715
722
  Y as useAccountUpdate,
716
- ce as useAddFragment,
723
+ ue as useAddFragment,
717
724
  N as useBroadcastMutation,
718
- ue as useEditFragment,
719
- ge as useGameClaim,
720
- pe as useRemoveFragment,
725
+ pe as useEditFragment,
726
+ we as useGameClaim,
727
+ ye as useRemoveFragment,
721
728
  ie as useSignOperationByHivesigner,
722
729
  ne as useSignOperationByKey,
723
- re as useSignOperationByKeychain
730
+ oe as useSignOperationByKeychain
724
731
  };
@@ -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';
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.44",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",