@ecency/sdk 1.0.27 → 1.0.28
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 +67 -59
- package/dist/modules/core/config.d.ts +5 -0
- package/package.json +1 -1
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var g = (e, t, n) =>
|
4
|
-
import {
|
5
|
-
import { Client as
|
6
|
-
import
|
7
|
-
|
8
|
-
class I {
|
1
|
+
var K = Object.defineProperty;
|
2
|
+
var Q = (e, t, n) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
3
|
+
var g = (e, t, n) => Q(e, typeof t != "symbol" ? t + "" : t, n);
|
4
|
+
import { QueryClient as v, useMutation as l, useQuery as q, useInfiniteQuery as O, queryOptions as h } from "@tanstack/react-query";
|
5
|
+
import { Client as k, PrivateKey as p, cryptoUtils as S } from "@hiveio/dhive";
|
6
|
+
import C from "hivesigner";
|
7
|
+
class _ {
|
9
8
|
constructor() {
|
10
9
|
g(this, "length", 0);
|
11
10
|
}
|
@@ -27,9 +26,9 @@ class I {
|
|
27
26
|
}
|
28
27
|
const a = {
|
29
28
|
privateApiHost: "https://ecency.com",
|
30
|
-
storage: typeof window > "u" ? new
|
29
|
+
storage: typeof window > "u" ? new _() : window.localStorage,
|
31
30
|
storagePrefix: "ecency",
|
32
|
-
hiveClient: new
|
31
|
+
hiveClient: new k(
|
33
32
|
[
|
34
33
|
"https://api.hive.blog",
|
35
34
|
"https://api.deathwing.me",
|
@@ -49,43 +48,51 @@ const a = {
|
|
49
48
|
consoleOnFailover: !0
|
50
49
|
}
|
51
50
|
),
|
52
|
-
heliusApiKey: void 0
|
51
|
+
heliusApiKey: void 0,
|
52
|
+
queryClient: new v()
|
53
53
|
};
|
54
|
-
|
54
|
+
var d;
|
55
|
+
((e) => {
|
56
|
+
function t(n) {
|
57
|
+
a.queryClient = n;
|
58
|
+
}
|
59
|
+
e.setQueryClient = t;
|
60
|
+
})(d || (d = {}));
|
61
|
+
function b(e) {
|
55
62
|
let t = atob(e);
|
56
63
|
if (t[0] === "{")
|
57
64
|
return JSON.parse(t);
|
58
65
|
}
|
59
|
-
const
|
66
|
+
const y = (e) => {
|
60
67
|
try {
|
61
68
|
const t = a.storage.getItem(
|
62
69
|
a.storagePrefix + "_user_" + e
|
63
70
|
);
|
64
|
-
return
|
71
|
+
return b(JSON.parse(t));
|
65
72
|
} catch (t) {
|
66
73
|
console.error(t);
|
67
74
|
return;
|
68
75
|
}
|
69
|
-
},
|
70
|
-
function
|
71
|
-
return
|
76
|
+
}, I = (e) => y(e) && y(e).accessToken, A = (e) => y(e) && y(e).postingKey, N = (e) => y(e) && y(e).refreshToken;
|
77
|
+
function D(e = [], t, n) {
|
78
|
+
return l({
|
72
79
|
mutationKey: [...e, t],
|
73
80
|
mutationFn: async (i) => {
|
74
81
|
if (!t)
|
75
82
|
throw new Error(
|
76
83
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
77
84
|
);
|
78
|
-
const o =
|
85
|
+
const o = A(t);
|
79
86
|
if (o) {
|
80
|
-
const c =
|
87
|
+
const c = p.fromString(o);
|
81
88
|
return a.hiveClient.broadcast.sendOperations(
|
82
89
|
n(i),
|
83
90
|
c
|
84
91
|
);
|
85
92
|
}
|
86
|
-
let s =
|
93
|
+
let s = I(t);
|
87
94
|
if (s)
|
88
|
-
return (await new
|
95
|
+
return (await new C.Client({
|
89
96
|
accessToken: s
|
90
97
|
}).broadcast(n(i))).result;
|
91
98
|
throw new Error(
|
@@ -94,8 +101,8 @@ function T(e = [], t, n) {
|
|
94
101
|
}
|
95
102
|
});
|
96
103
|
}
|
97
|
-
function
|
98
|
-
return new
|
104
|
+
function H() {
|
105
|
+
return new v({
|
99
106
|
defaultOptions: {
|
100
107
|
queries: {
|
101
108
|
// With SSR, we usually want to set some default staleTime
|
@@ -107,7 +114,7 @@ function d() {
|
|
107
114
|
}
|
108
115
|
});
|
109
116
|
}
|
110
|
-
const u =
|
117
|
+
const u = () => a.queryClient;
|
111
118
|
var w;
|
112
119
|
((e) => {
|
113
120
|
function t(r) {
|
@@ -130,7 +137,7 @@ var w;
|
|
130
137
|
return {
|
131
138
|
prefetch: () => i(r),
|
132
139
|
getData: () => t(r.queryKey),
|
133
|
-
useClientQuery: () =>
|
140
|
+
useClientQuery: () => q(r),
|
134
141
|
fetchAndGet: () => u().fetchQuery(r)
|
135
142
|
};
|
136
143
|
}
|
@@ -139,14 +146,14 @@ var w;
|
|
139
146
|
return {
|
140
147
|
prefetch: () => o(r),
|
141
148
|
getData: () => n(r.queryKey),
|
142
|
-
useClientQuery: () =>
|
149
|
+
useClientQuery: () => O(r),
|
143
150
|
fetchAndGet: () => u().fetchInfiniteQuery(r)
|
144
151
|
};
|
145
152
|
}
|
146
153
|
e.generateClientServerInfiniteQuery = c;
|
147
154
|
})(w || (w = {}));
|
148
|
-
function
|
149
|
-
return
|
155
|
+
function J(e) {
|
156
|
+
return D(
|
150
157
|
["accounts", "update"],
|
151
158
|
e,
|
152
159
|
({
|
@@ -168,8 +175,8 @@ function E(e) {
|
|
168
175
|
]
|
169
176
|
);
|
170
177
|
}
|
171
|
-
function
|
172
|
-
return
|
178
|
+
function x(e) {
|
179
|
+
return h({
|
173
180
|
queryKey: ["get-account-full", e],
|
174
181
|
queryFn: async () => {
|
175
182
|
if (!e)
|
@@ -205,8 +212,8 @@ function U(e) {
|
|
205
212
|
staleTime: 6e4
|
206
213
|
});
|
207
214
|
}
|
208
|
-
function
|
209
|
-
return
|
215
|
+
function E(e, t = 5, n = []) {
|
216
|
+
return h({
|
210
217
|
queryKey: ["accounts", "search", e, n],
|
211
218
|
enabled: !!e,
|
212
219
|
queryFn: async () => (await a.hiveClient.database.call(
|
@@ -217,8 +224,8 @@ function G(e, t = 5, n = []) {
|
|
217
224
|
)
|
218
225
|
});
|
219
226
|
}
|
220
|
-
function
|
221
|
-
return
|
227
|
+
function U(e) {
|
228
|
+
return l({
|
222
229
|
mutationKey: ["operations", "sign", e],
|
223
230
|
mutationFn: ({
|
224
231
|
operation: t,
|
@@ -227,14 +234,14 @@ function M(e) {
|
|
227
234
|
if (!e)
|
228
235
|
throw new Error("[Operations][Sign] – cannot sign op with anon user");
|
229
236
|
let i;
|
230
|
-
return n.split(" ").length === 12 ? i =
|
237
|
+
return n.split(" ").length === 12 ? i = p.fromLogin(e, n, "active") : S.isWif(n) ? i = p.fromString(n) : i = p.from(n), a.hiveClient.broadcast.sendOperations(
|
231
238
|
[t],
|
232
239
|
i
|
233
240
|
);
|
234
241
|
}
|
235
242
|
});
|
236
243
|
}
|
237
|
-
function
|
244
|
+
function F() {
|
238
245
|
return new Promise((e) => {
|
239
246
|
var t;
|
240
247
|
(t = window.hive_keychain) == null || t.requestHandshake(() => {
|
@@ -253,13 +260,13 @@ const m = (e, t, n, i = null) => new Promise((o, s) => {
|
|
253
260
|
},
|
254
261
|
i
|
255
262
|
);
|
256
|
-
}),
|
263
|
+
}), G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
257
264
|
__proto__: null,
|
258
265
|
broadcast: m,
|
259
|
-
handshake:
|
266
|
+
handshake: F
|
260
267
|
}, Symbol.toStringTag, { value: "Module" }));
|
261
|
-
function
|
262
|
-
return
|
268
|
+
function M(e, t = "Active") {
|
269
|
+
return l({
|
263
270
|
mutationKey: ["operations", "sign-keychain", e],
|
264
271
|
mutationFn: ({ operation: n }) => {
|
265
272
|
if (!e)
|
@@ -270,15 +277,15 @@ function z(e, t = "Active") {
|
|
270
277
|
}
|
271
278
|
});
|
272
279
|
}
|
273
|
-
function
|
274
|
-
return
|
280
|
+
function W(e = "/") {
|
281
|
+
return l({
|
275
282
|
mutationKey: ["operations", "sign-hivesigner", e],
|
276
|
-
mutationFn: async ({ operation: t }) =>
|
283
|
+
mutationFn: async ({ operation: t }) => C.sendOperation(t, { callback: e }, () => {
|
277
284
|
})
|
278
285
|
});
|
279
286
|
}
|
280
|
-
function
|
281
|
-
return
|
287
|
+
function z(e, t) {
|
288
|
+
return h({
|
282
289
|
queryKey: ["hive-engine", "tokens-list", e, t],
|
283
290
|
queryFn: async () => (await (await fetch(
|
284
291
|
`${a.privateApiHost}/private-api/engine-api`,
|
@@ -304,20 +311,21 @@ function $(e, t) {
|
|
304
311
|
}
|
305
312
|
export {
|
306
313
|
a as CONFIG,
|
314
|
+
d as ConfigManager,
|
307
315
|
w as EcencyQueriesManager,
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
316
|
+
G as Keychain,
|
317
|
+
I as getAccessToken,
|
318
|
+
x as getAccountFullQueryOptions,
|
319
|
+
z as getHiveEngineTokensListQueryOptions,
|
320
|
+
A as getPostingKey,
|
313
321
|
u as getQueryClient,
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
322
|
+
N as getRefreshToken,
|
323
|
+
E as getSearchAccountsByUsernameQueryOptions,
|
324
|
+
y as getUser,
|
325
|
+
H as makeQueryClient,
|
326
|
+
J as useAccountUpdate,
|
327
|
+
D as useBroadcastMutation,
|
328
|
+
W as useSignOperationByHivesigner,
|
329
|
+
U as useSignOperationByKey,
|
330
|
+
M as useSignOperationByKeychain
|
323
331
|
};
|
@@ -1,8 +1,13 @@
|
|
1
1
|
import { Client } from '@hiveio/dhive';
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
2
3
|
export declare const CONFIG: {
|
3
4
|
privateApiHost: string;
|
4
5
|
storage: Storage;
|
5
6
|
storagePrefix: string;
|
6
7
|
hiveClient: Client;
|
7
8
|
heliusApiKey: any;
|
9
|
+
queryClient: QueryClient;
|
8
10
|
};
|
11
|
+
export declare namespace ConfigManager {
|
12
|
+
function setQueryClient(client: QueryClient): void;
|
13
|
+
}
|