@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.
package/dist/ecency-sdk.es.js
CHANGED
@@ -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
|
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
|
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
|
55
|
+
var C;
|
56
56
|
((e) => {
|
57
57
|
function t(n) {
|
58
58
|
s.queryClient = n;
|
59
59
|
}
|
60
60
|
e.setQueryClient = t;
|
61
|
-
})(
|
62
|
-
function
|
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
|
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 (
|
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
|
87
|
-
if (
|
88
|
-
const i = h.fromString(
|
86
|
+
const o = q(t);
|
87
|
+
if (o) {
|
88
|
+
const i = h.fromString(o);
|
89
89
|
return s.hiveClient.broadcast.sendOperations(
|
90
|
-
n(
|
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(
|
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
|
111
|
-
if (
|
112
|
-
const u = h.fromString(
|
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
|
124
|
-
if (
|
123
|
+
let o = l(e);
|
124
|
+
if (o)
|
125
125
|
return (await new d.Client({
|
126
|
-
accessToken:
|
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
|
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
|
156
|
+
async function r(a) {
|
157
157
|
return await c().prefetchQuery(a), t(a.queryKey);
|
158
158
|
}
|
159
|
-
e.prefetchQuery =
|
160
|
-
async function
|
159
|
+
e.prefetchQuery = r;
|
160
|
+
async function o(a) {
|
161
161
|
return await c().prefetchInfiniteQuery(a), n(a.queryKey);
|
162
162
|
}
|
163
|
-
e.prefetchInfiniteQuery =
|
163
|
+
e.prefetchInfiniteQuery = o;
|
164
164
|
function u(a) {
|
165
165
|
return {
|
166
|
-
prefetch: () =>
|
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: () =>
|
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
|
-
})(
|
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
|
216
|
+
let r;
|
217
217
|
try {
|
218
|
-
|
218
|
+
r = await s.hiveClient.database.call(
|
219
219
|
"get_follow_count",
|
220
220
|
[e]
|
221
221
|
);
|
222
222
|
} catch {
|
223
223
|
}
|
224
|
-
const
|
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:
|
232
|
-
reputation:
|
231
|
+
follow_stats: r,
|
232
|
+
reputation: o[0].reputation,
|
233
233
|
profile: {
|
234
234
|
...n,
|
235
|
-
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
|
-
(
|
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,
|
287
|
+
function te(e, t, n, r) {
|
288
288
|
return y({
|
289
289
|
mutationKey: [],
|
290
|
-
mutationFn: async (
|
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
|
-
...
|
306
|
-
...
|
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:
|
312
|
-
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:
|
316
|
-
onSuccess(
|
317
|
-
n(
|
315
|
+
onError: r,
|
316
|
+
onSuccess(o) {
|
317
|
+
n(o), c().setQueryData(
|
318
318
|
["accounts", "relations", e, t],
|
319
|
-
|
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
|
334
|
-
return n.split(" ").length === 12 ?
|
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
|
-
|
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,
|
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" }),
|
356
|
+
a.success || u({ message: "Operation cancelled" }), o(a);
|
357
357
|
},
|
358
|
-
|
358
|
+
r
|
359
359
|
);
|
360
|
-
}),
|
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
|
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(
|
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
|
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((
|
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
|
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
|
472
|
+
function pe(e, t) {
|
467
473
|
return y({
|
468
474
|
mutationKey: ["posts", "edit-fragment", e, t],
|
469
|
-
mutationFn: async ({ title: n, body:
|
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:
|
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
|
-
(
|
488
|
-
if (!
|
493
|
+
(r) => {
|
494
|
+
if (!r)
|
489
495
|
return [];
|
490
|
-
const
|
491
|
-
return
|
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
|
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:
|
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
|
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:
|
588
|
+
const { memoDecoded: r } = c().getQueryData(
|
583
589
|
n.queryKey
|
584
590
|
);
|
585
|
-
return
|
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" })),
|
622
|
+
}, Symbol.toStringTag, { value: "Module" })), fe = {
|
617
623
|
queries: U
|
618
624
|
};
|
619
|
-
function
|
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
|
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
|
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
|
660
|
-
const { mutateAsync:
|
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
|
-
|
691
|
+
r();
|
686
692
|
}
|
687
693
|
});
|
688
694
|
}
|
689
695
|
export {
|
690
696
|
s as CONFIG,
|
691
|
-
|
692
|
-
|
693
|
-
|
697
|
+
C as ConfigManager,
|
698
|
+
le as EcencyAnalytics,
|
699
|
+
O as EcencyQueriesManager,
|
694
700
|
x as HiveSignerIntegration,
|
695
|
-
|
696
|
-
|
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
|
-
|
707
|
+
de as getAccountRcQueryOptions,
|
708
|
+
se as getChainPropertiesQueryOptions,
|
702
709
|
v as getFragmentsQueryOptions,
|
703
|
-
|
704
|
-
|
710
|
+
ge as getGameStatusCheckQueryOptions,
|
711
|
+
ae as getHiveEngineTokensListQueryOptions,
|
705
712
|
q as getPostingKey,
|
706
713
|
c as getQueryClient,
|
707
|
-
|
714
|
+
he as getRcStatsQueryOptions,
|
708
715
|
L as getRefreshToken,
|
709
716
|
H as getRelationshipBetweenAccountsQueryOptions,
|
710
717
|
R as getSearchAccountsByUsernameQueryOptions,
|
711
|
-
|
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
|
-
|
723
|
+
ue as useAddFragment,
|
717
724
|
N as useBroadcastMutation,
|
718
|
-
|
719
|
-
|
720
|
-
|
725
|
+
pe as useEditFragment,
|
726
|
+
we as useGameClaim,
|
727
|
+
ye as useRemoveFragment,
|
721
728
|
ie as useSignOperationByHivesigner,
|
722
729
|
ne as useSignOperationByKey,
|
723
|
-
|
730
|
+
oe as useSignOperationByKeychain
|
724
731
|
};
|
@@ -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';
|