@ecency/sdk 1.0.26 → 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.
@@ -1,11 +1,10 @@
1
- var C = Object.defineProperty;
2
- var K = (e, t, n) => t in e ? C(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var g = (e, t, n) => K(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { useMutation as f, isServer as Q, QueryClient as O, useQuery as S, useInfiniteQuery as k, queryOptions as l } from "@tanstack/react-query";
5
- import { Client as q, PrivateKey as y, cryptoUtils as _ } from "@hiveio/dhive";
6
- import v from "hivesigner";
7
- import { cache as b } from "react";
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 I() : window.localStorage,
29
+ storage: typeof window > "u" ? new _() : window.localStorage,
31
30
  storagePrefix: "ecency",
32
- hiveClient: new q(
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
- function A(e) {
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 p = (e) => {
66
+ const y = (e) => {
60
67
  try {
61
68
  const t = a.storage.getItem(
62
69
  a.storagePrefix + "_user_" + e
63
70
  );
64
- return A(JSON.parse(t));
71
+ return b(JSON.parse(t));
65
72
  } catch (t) {
66
73
  console.error(t);
67
74
  return;
68
75
  }
69
- }, D = (e) => p(e) && p(e).accessToken, F = (e) => p(e) && p(e).postingKey, x = (e) => p(e) && p(e).refreshToken;
70
- function T(e = [], t, n) {
71
- return f({
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 = F(t);
85
+ const o = A(t);
79
86
  if (o) {
80
- const c = y.fromString(o);
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 = D(t);
93
+ let s = I(t);
87
94
  if (s)
88
- return (await new v.Client({
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 d() {
98
- return new O({
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 = Q ? b(() => d()) : () => d();
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: () => S(r),
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: () => k(r),
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 E(e) {
149
- return T(
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 U(e) {
172
- return l({
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 G(e, t = 5, n = []) {
209
- return l({
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 M(e) {
221
- return f({
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 = y.fromLogin(e, n, "active") : _.isWif(n) ? i = y.fromString(n) : i = y.from(n), a.hiveClient.broadcast.sendOperations(
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 j() {
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
- }), W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
263
+ }), G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
257
264
  __proto__: null,
258
265
  broadcast: m,
259
- handshake: j
266
+ handshake: F
260
267
  }, Symbol.toStringTag, { value: "Module" }));
261
- function z(e, t = "Active") {
262
- return f({
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 R(e = "/") {
274
- return f({
280
+ function W(e = "/") {
281
+ return l({
275
282
  mutationKey: ["operations", "sign-hivesigner", e],
276
- mutationFn: async ({ operation: t }) => v.sendOperation(t, { callback: e }, () => {
283
+ mutationFn: async ({ operation: t }) => C.sendOperation(t, { callback: e }, () => {
277
284
  })
278
285
  });
279
286
  }
280
- function $(e, t) {
281
- return l({
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
- W as Keychain,
309
- D as getAccessToken,
310
- U as getAccountFullQueryOptions,
311
- $ as getHiveEngineTokensListQueryOptions,
312
- F as getPostingKey,
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
- x as getRefreshToken,
315
- G as getSearchAccountsByUsernameQueryOptions,
316
- p as getUser,
317
- d as makeQueryClient,
318
- E as useAccountUpdate,
319
- T as useBroadcastMutation,
320
- R as useSignOperationByHivesigner,
321
- M as useSignOperationByKey,
322
- z as useSignOperationByKeychain
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
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ecency/sdk",
3
3
  "private": false,
4
- "version": "1.0.26",
4
+ "version": "1.0.28",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "main": "./dist/ecency-sdk.umd.js",