@ecency/sdk 1.0.36 → 1.0.37
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 +91 -72
- package/dist/index.d.ts +1 -0
- package/dist/modules/resource-credits/index.d.ts +2 -0
- package/dist/modules/resource-credits/queries/get-account-rc-query-options.d.ts +8 -0
- package/dist/modules/resource-credits/queries/get-rc-stats-query-options.d.ts +8 -0
- package/dist/modules/resource-credits/queries/index.d.ts +2 -0
- package/dist/modules/resource-credits/types/index.d.ts +1 -0
- package/dist/modules/resource-credits/types/stats.d.ts +67 -0
- package/package.json +1 -1
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var w = (e, t, n) =>
|
4
|
-
import { QueryClient as C, useMutation as l, useQuery as
|
5
|
-
import { Client as k, PrivateKey as h, cryptoUtils as T } from "@hiveio/dhive";
|
1
|
+
var Q = Object.defineProperty;
|
2
|
+
var b = (e, t, n) => t in e ? Q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
3
|
+
var w = (e, t, n) => b(e, typeof t != "symbol" ? t + "" : t, n);
|
4
|
+
import { QueryClient as C, useMutation as l, useQuery as _, useInfiniteQuery as K, queryOptions as c, infiniteQueryOptions as S } from "@tanstack/react-query";
|
5
|
+
import { Client as k, PrivateKey as h, cryptoUtils as T, RCAPI as j } from "@hiveio/dhive";
|
6
6
|
import g from "hivesigner";
|
7
|
-
class
|
7
|
+
class A {
|
8
8
|
constructor() {
|
9
9
|
w(this, "length", 0);
|
10
10
|
}
|
@@ -26,7 +26,7 @@ class j {
|
|
26
26
|
}
|
27
27
|
const o = {
|
28
28
|
privateApiHost: "https://ecency.com",
|
29
|
-
storage: typeof window > "u" ? new
|
29
|
+
storage: typeof window > "u" ? new A() : window.localStorage,
|
30
30
|
storagePrefix: "ecency",
|
31
31
|
hiveClient: new k(
|
32
32
|
[
|
@@ -59,7 +59,7 @@ var v;
|
|
59
59
|
}
|
60
60
|
e.setQueryClient = t;
|
61
61
|
})(v || (v = {}));
|
62
|
-
function
|
62
|
+
function I(e) {
|
63
63
|
let t = atob(e);
|
64
64
|
if (t[0] === "{")
|
65
65
|
return JSON.parse(t);
|
@@ -69,13 +69,13 @@ const p = (e) => {
|
|
69
69
|
const t = o.storage.getItem(
|
70
70
|
o.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;
|
76
76
|
}
|
77
77
|
}, O = (e) => p(e) && p(e).accessToken, D = (e) => p(e) && p(e).postingKey, W = (e) => p(e) && p(e).refreshToken;
|
78
|
-
function
|
78
|
+
function F(e = [], t, n) {
|
79
79
|
return l({
|
80
80
|
mutationKey: [...e, t],
|
81
81
|
mutationFn: async (r) => {
|
@@ -85,16 +85,16 @@ function I(e = [], t, n) {
|
|
85
85
|
);
|
86
86
|
const a = D(t);
|
87
87
|
if (a) {
|
88
|
-
const
|
88
|
+
const y = h.fromString(a);
|
89
89
|
return o.hiveClient.broadcast.sendOperations(
|
90
90
|
n(r),
|
91
|
-
|
91
|
+
y
|
92
92
|
);
|
93
93
|
}
|
94
|
-
let
|
95
|
-
if (
|
94
|
+
let u = O(t);
|
95
|
+
if (u)
|
96
96
|
return (await new g.Client({
|
97
|
-
accessToken:
|
97
|
+
accessToken: u
|
98
98
|
}).broadcast(n(r))).result;
|
99
99
|
throw new Error(
|
100
100
|
"[SDK][Broadcast] – cannot broadcast w/o posting key or token"
|
@@ -134,27 +134,27 @@ var m;
|
|
134
134
|
return await s().prefetchInfiniteQuery(i), n(i.queryKey);
|
135
135
|
}
|
136
136
|
e.prefetchInfiniteQuery = a;
|
137
|
-
function
|
137
|
+
function u(i) {
|
138
138
|
return {
|
139
139
|
prefetch: () => r(i),
|
140
140
|
getData: () => t(i.queryKey),
|
141
|
-
useClientQuery: () =>
|
141
|
+
useClientQuery: () => _(i),
|
142
142
|
fetchAndGet: () => s().fetchQuery(i)
|
143
143
|
};
|
144
144
|
}
|
145
|
-
e.generateClientServerQuery =
|
146
|
-
function
|
145
|
+
e.generateClientServerQuery = u;
|
146
|
+
function y(i) {
|
147
147
|
return {
|
148
148
|
prefetch: () => a(i),
|
149
149
|
getData: () => n(i.queryKey),
|
150
|
-
useClientQuery: () =>
|
150
|
+
useClientQuery: () => K(i),
|
151
151
|
fetchAndGet: () => s().fetchInfiniteQuery(i)
|
152
152
|
};
|
153
153
|
}
|
154
|
-
e.generateClientServerInfiniteQuery =
|
154
|
+
e.generateClientServerInfiniteQuery = y;
|
155
155
|
})(m || (m = {}));
|
156
156
|
function G(e) {
|
157
|
-
return
|
157
|
+
return F(
|
158
158
|
["accounts", "update"],
|
159
159
|
e,
|
160
160
|
({
|
@@ -176,8 +176,8 @@ function G(e) {
|
|
176
176
|
]
|
177
177
|
);
|
178
178
|
}
|
179
|
-
function
|
180
|
-
return
|
179
|
+
function V(e) {
|
180
|
+
return c({
|
181
181
|
queryKey: ["get-account-full", e],
|
182
182
|
queryFn: async () => {
|
183
183
|
if (!e)
|
@@ -213,8 +213,8 @@ function R(e) {
|
|
213
213
|
staleTime: 6e4
|
214
214
|
});
|
215
215
|
}
|
216
|
-
function
|
217
|
-
return
|
216
|
+
function L(e, t = 5, n = []) {
|
217
|
+
return c({
|
218
218
|
queryKey: ["accounts", "search", e, n],
|
219
219
|
enabled: !!e,
|
220
220
|
queryFn: async () => (await o.hiveClient.database.call(
|
@@ -225,8 +225,8 @@ function V(e, t = 5, n = []) {
|
|
225
225
|
)
|
226
226
|
});
|
227
227
|
}
|
228
|
-
function
|
229
|
-
return
|
228
|
+
function X(e) {
|
229
|
+
return c({
|
230
230
|
queryKey: ["accounts", "check-wallet-pending", e],
|
231
231
|
queryFn: async () => await (await fetch(
|
232
232
|
o.privateApiHost + "/private-api/wallets-chkuser",
|
@@ -244,7 +244,7 @@ function L(e) {
|
|
244
244
|
refetchOnMount: !0
|
245
245
|
});
|
246
246
|
}
|
247
|
-
function
|
247
|
+
function Y(e) {
|
248
248
|
return l({
|
249
249
|
mutationKey: ["operations", "sign", e],
|
250
250
|
mutationFn: ({
|
@@ -261,7 +261,7 @@ function X(e) {
|
|
261
261
|
}
|
262
262
|
});
|
263
263
|
}
|
264
|
-
function
|
264
|
+
function P() {
|
265
265
|
return new Promise((e) => {
|
266
266
|
var t;
|
267
267
|
(t = window.hive_keychain) == null || t.requestHandshake(() => {
|
@@ -269,23 +269,23 @@ function F() {
|
|
269
269
|
});
|
270
270
|
});
|
271
271
|
}
|
272
|
-
const q = (e, t, n, r = null) => new Promise((a,
|
273
|
-
var
|
274
|
-
(
|
272
|
+
const q = (e, t, n, r = null) => new Promise((a, u) => {
|
273
|
+
var y;
|
274
|
+
(y = window.hive_keychain) == null || y.requestBroadcast(
|
275
275
|
e,
|
276
276
|
t,
|
277
277
|
n,
|
278
278
|
(i) => {
|
279
|
-
i.success ||
|
279
|
+
i.success || u({ message: "Operation cancelled" }), a(i);
|
280
280
|
},
|
281
281
|
r
|
282
282
|
);
|
283
|
-
}),
|
283
|
+
}), Z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
284
284
|
__proto__: null,
|
285
285
|
broadcast: q,
|
286
|
-
handshake:
|
286
|
+
handshake: P
|
287
287
|
}, Symbol.toStringTag, { value: "Module" }));
|
288
|
-
function
|
288
|
+
function ee(e, t = "Active") {
|
289
289
|
return l({
|
290
290
|
mutationKey: ["operations", "sign-keychain", e],
|
291
291
|
mutationFn: ({ operation: n }) => {
|
@@ -297,15 +297,15 @@ function Z(e, t = "Active") {
|
|
297
297
|
}
|
298
298
|
});
|
299
299
|
}
|
300
|
-
function
|
300
|
+
function te(e = "/") {
|
301
301
|
return l({
|
302
302
|
mutationKey: ["operations", "sign-hivesigner", e],
|
303
303
|
mutationFn: async ({ operation: t }) => g.sendOperation(t, { callback: e }, () => {
|
304
304
|
})
|
305
305
|
});
|
306
306
|
}
|
307
|
-
function
|
308
|
-
return
|
307
|
+
function ne(e, t) {
|
308
|
+
return c({
|
309
309
|
queryKey: ["hive-engine", "tokens-list", e, t],
|
310
310
|
queryFn: async () => (await (await fetch(
|
311
311
|
`${o.privateApiHost}/private-api/engine-api`,
|
@@ -329,8 +329,8 @@ function te(e, t) {
|
|
329
329
|
)).json()).result
|
330
330
|
});
|
331
331
|
}
|
332
|
-
function
|
333
|
-
return
|
332
|
+
function re(e = 20) {
|
333
|
+
return S({
|
334
334
|
queryKey: ["posts", "trending-tags"],
|
335
335
|
queryFn: async ({ pageParam: { afterTag: t } }) => o.hiveClient.database.call("get_trending_tags", [t, e]).then(
|
336
336
|
(n) => n.filter((r) => r.name !== "").filter((r) => !r.name.startsWith("hive-")).map((r) => r.name)
|
@@ -343,7 +343,7 @@ function ne(e = 20) {
|
|
343
343
|
refetchOnMount: !0
|
344
344
|
});
|
345
345
|
}
|
346
|
-
function
|
346
|
+
function M(e, t) {
|
347
347
|
return l({
|
348
348
|
mutationKey: ["analytics", t],
|
349
349
|
mutationFn: async () => {
|
@@ -366,12 +366,12 @@ function P(e, t) {
|
|
366
366
|
}
|
367
367
|
});
|
368
368
|
}
|
369
|
-
const
|
369
|
+
const ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
370
370
|
__proto__: null,
|
371
|
-
useRecordActivity:
|
371
|
+
useRecordActivity: M
|
372
372
|
}, Symbol.toStringTag, { value: "Module" }));
|
373
|
-
function
|
374
|
-
return
|
373
|
+
function N(e, t) {
|
374
|
+
return c({
|
375
375
|
queryKey: ["integrations", "hivesigner", "decode-memo", e],
|
376
376
|
queryFn: async () => {
|
377
377
|
const n = O(e);
|
@@ -382,14 +382,14 @@ function M(e, t) {
|
|
382
382
|
}
|
383
383
|
});
|
384
384
|
}
|
385
|
-
const
|
385
|
+
const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
386
386
|
__proto__: null,
|
387
|
-
getDecodeMemoQueryOptions:
|
388
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
389
|
-
queries:
|
387
|
+
getDecodeMemoQueryOptions: N
|
388
|
+
}, Symbol.toStringTag, { value: "Module" })), H = {
|
389
|
+
queries: B
|
390
390
|
};
|
391
391
|
function d(e) {
|
392
|
-
return
|
392
|
+
return c({
|
393
393
|
queryKey: ["integrations", "3speak", "authenticate", e],
|
394
394
|
enabled: !!e,
|
395
395
|
queryFn: async () => {
|
@@ -402,7 +402,7 @@ function d(e) {
|
|
402
402
|
"Content-Type": "application/json"
|
403
403
|
}
|
404
404
|
}
|
405
|
-
), n =
|
405
|
+
), n = H.queries.getDecodeMemoQueryOptions(
|
406
406
|
e,
|
407
407
|
(await t.json()).memo
|
408
408
|
);
|
@@ -414,8 +414,8 @@ function d(e) {
|
|
414
414
|
}
|
415
415
|
});
|
416
416
|
}
|
417
|
-
function
|
418
|
-
return
|
417
|
+
function E(e) {
|
418
|
+
return c({
|
419
419
|
queryKey: ["integrations", "3speak", "videos", e],
|
420
420
|
enabled: !!e,
|
421
421
|
queryFn: async () => {
|
@@ -437,35 +437,54 @@ function H(e) {
|
|
437
437
|
}
|
438
438
|
});
|
439
439
|
}
|
440
|
-
const
|
440
|
+
const J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
441
441
|
__proto__: null,
|
442
442
|
getAccountTokenQueryOptions: d,
|
443
|
-
getAccountVideosQueryOptions:
|
444
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
445
|
-
queries:
|
443
|
+
getAccountVideosQueryOptions: E
|
444
|
+
}, Symbol.toStringTag, { value: "Module" })), oe = {
|
445
|
+
queries: J
|
446
446
|
};
|
447
|
+
function ae() {
|
448
|
+
return c({
|
449
|
+
queryKey: ["resource-credits", "stats"],
|
450
|
+
queryFn: async () => (await o.hiveClient.call(
|
451
|
+
"rc_api",
|
452
|
+
"get_rc_stats",
|
453
|
+
{}
|
454
|
+
)).rc_stats
|
455
|
+
});
|
456
|
+
}
|
457
|
+
function se(e) {
|
458
|
+
return c({
|
459
|
+
queryKey: ["resource-credits", "account", e],
|
460
|
+
queryFn: async () => new j(o.hiveClient).findRCAccounts([e]),
|
461
|
+
enabled: !!e
|
462
|
+
});
|
463
|
+
}
|
447
464
|
export {
|
448
465
|
o as CONFIG,
|
449
466
|
v as ConfigManager,
|
450
|
-
|
467
|
+
ie as EcencyAnalytics,
|
451
468
|
m as EcencyQueriesManager,
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
469
|
+
H as HiveSignerIntegration,
|
470
|
+
Z as Keychain,
|
471
|
+
oe as ThreeSpeakIntegration,
|
472
|
+
X as checkUsernameWalletsPendingQueryOptions,
|
456
473
|
O as getAccessToken,
|
457
|
-
|
458
|
-
|
474
|
+
V as getAccountFullQueryOptions,
|
475
|
+
se as getAccountRcQueryOptions,
|
476
|
+
ne as getHiveEngineTokensListQueryOptions,
|
459
477
|
D as getPostingKey,
|
460
478
|
s as getQueryClient,
|
479
|
+
ae as getRcStatsQueryOptions,
|
461
480
|
W as getRefreshToken,
|
462
|
-
|
463
|
-
|
481
|
+
L as getSearchAccountsByUsernameQueryOptions,
|
482
|
+
re as getTrendingTagsQueryOptions,
|
464
483
|
p as getUser,
|
465
484
|
$ as makeQueryClient,
|
466
485
|
G as useAccountUpdate,
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
486
|
+
F as useBroadcastMutation,
|
487
|
+
te as useSignOperationByHivesigner,
|
488
|
+
Y as useSignOperationByKey,
|
489
|
+
ee as useSignOperationByKeychain
|
471
490
|
};
|
package/dist/index.d.ts
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
export declare function getAccountRcQueryOptions(username: string): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<import('@hiveio/dhive/lib/chain/rc').RCAccount[], Error, import('@hiveio/dhive/lib/chain/rc').RCAccount[], string[]>, "queryFn"> & {
|
2
|
+
queryFn?: import('@tanstack/query-core').QueryFunction<import('@hiveio/dhive/lib/chain/rc').RCAccount[], string[], never> | undefined;
|
3
|
+
} & {
|
4
|
+
queryKey: string[] & {
|
5
|
+
[dataTagSymbol]: import('@hiveio/dhive/lib/chain/rc').RCAccount[];
|
6
|
+
[dataTagErrorSymbol]: Error;
|
7
|
+
};
|
8
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export declare function getRcStatsQueryOptions(): import('@tanstack/query-core').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<any, Error, any, string[]>, "queryFn"> & {
|
2
|
+
queryFn?: import('@tanstack/query-core').QueryFunction<any, string[], never> | undefined;
|
3
|
+
} & {
|
4
|
+
queryKey: string[] & {
|
5
|
+
[dataTagSymbol]: any;
|
6
|
+
[dataTagErrorSymbol]: Error;
|
7
|
+
};
|
8
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './stats';
|
@@ -0,0 +1,67 @@
|
|
1
|
+
export interface RcStats {
|
2
|
+
block: number;
|
3
|
+
budget: number[];
|
4
|
+
comment: number;
|
5
|
+
ops: Ops;
|
6
|
+
payers: Payer[];
|
7
|
+
pool: number[];
|
8
|
+
regen: number;
|
9
|
+
share: number[];
|
10
|
+
stamp: string;
|
11
|
+
transfer: number;
|
12
|
+
vote: number;
|
13
|
+
}
|
14
|
+
interface Ops {
|
15
|
+
account_create_operation: OperationCost;
|
16
|
+
account_update2_operation: OperationCost;
|
17
|
+
account_update_operation: OperationCost;
|
18
|
+
account_witness_proxy_operation: OperationCost;
|
19
|
+
account_witness_vote_operation: OperationCost;
|
20
|
+
cancel_transfer_from_savings_operation: OperationCost;
|
21
|
+
change_recovery_account_operation: OperationCost;
|
22
|
+
claim_account_operation: OperationCost;
|
23
|
+
claim_reward_balance_operation: OperationCost;
|
24
|
+
collateralized_convert_operation: OperationCost;
|
25
|
+
comment_operation: OperationCost;
|
26
|
+
comment_options_operation: OperationCost;
|
27
|
+
convert_operation: OperationCost;
|
28
|
+
create_claimed_account_operation: OperationCost;
|
29
|
+
custom_json_operation: OperationCost;
|
30
|
+
delegate_vesting_shares_operation: OperationCost;
|
31
|
+
delete_comment_operation: OperationCost;
|
32
|
+
feed_publish_operation: OperationCost;
|
33
|
+
limit_order_cancel_operation: OperationCost;
|
34
|
+
limit_order_create_operation: OperationCost;
|
35
|
+
multiop: OperationCost;
|
36
|
+
recover_account_operation: OperationCost;
|
37
|
+
recurrent_transfer_operation: OperationCost;
|
38
|
+
request_account_recovery_operation: OperationCost;
|
39
|
+
set_withdraw_vesting_route_operation: OperationCost;
|
40
|
+
transfer_from_savings_operation: OperationCost;
|
41
|
+
transfer_operation: OperationCost;
|
42
|
+
transfer_to_savings_operation: OperationCost;
|
43
|
+
transfer_to_vesting_operation: OperationCost;
|
44
|
+
update_proposal_votes_operation: OperationCost;
|
45
|
+
vote_operation: OperationCost;
|
46
|
+
withdraw_vesting_operation: OperationCost;
|
47
|
+
witness_set_properties_operation: OperationCost;
|
48
|
+
witness_update_operation: OperationCost;
|
49
|
+
}
|
50
|
+
interface OperationCost {
|
51
|
+
avg_cost: number;
|
52
|
+
count: number;
|
53
|
+
}
|
54
|
+
export interface Payer {
|
55
|
+
cant_afford?: CantAfford;
|
56
|
+
count: number;
|
57
|
+
lt10?: number;
|
58
|
+
lt20?: number;
|
59
|
+
lt5?: number;
|
60
|
+
rank: number;
|
61
|
+
}
|
62
|
+
export interface CantAfford {
|
63
|
+
comment: number;
|
64
|
+
transfer: number;
|
65
|
+
vote: number;
|
66
|
+
}
|
67
|
+
export {};
|