@ecency/sdk 1.1.1 → 1.1.3
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 +253 -224
- package/dist/modules/accounts/index.d.ts +1 -0
- package/dist/modules/accounts/mutations/use-account-update.d.ts +2 -7
- package/dist/modules/accounts/queries/get-account-full-query-options.d.ts +20 -0
- package/dist/modules/accounts/types/account-profile.d.ts +5 -0
- package/dist/modules/core/mutations/use-broadcast-mutation.d.ts +1 -1
- package/package.json +9 -8
package/dist/ecency-sdk.es.js
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
import { QueryClient as
|
5
|
-
import { Client as
|
1
|
+
var V = Object.defineProperty;
|
2
|
+
var W = (e, t, n) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
3
|
+
var k = (e, t, n) => W(e, typeof t != "symbol" ? t + "" : t, n);
|
4
|
+
import { QueryClient as A, useMutation as d, useQuery as j, useInfiniteQuery as z, queryOptions as p, useQueryClient as U, infiniteQueryOptions as $ } from "@tanstack/react-query";
|
5
|
+
import { Client as R, PrivateKey as v, cryptoUtils as X, RCAPI as Y } from "@hiveio/dhive";
|
6
6
|
import m from "hivesigner";
|
7
|
-
|
7
|
+
import * as C from "remeda";
|
8
|
+
class Z {
|
8
9
|
constructor() {
|
9
|
-
|
10
|
+
k(this, "length", 0);
|
10
11
|
}
|
11
12
|
clear() {
|
12
13
|
throw new Error("Method not implemented.");
|
@@ -26,9 +27,9 @@ class $ {
|
|
26
27
|
}
|
27
28
|
const i = {
|
28
29
|
privateApiHost: "https://ecency.com",
|
29
|
-
storage: typeof window > "u" ? new
|
30
|
+
storage: typeof window > "u" ? new Z() : window.localStorage,
|
30
31
|
storagePrefix: "ecency",
|
31
|
-
hiveClient: new
|
32
|
+
hiveClient: new R(
|
32
33
|
[
|
33
34
|
"https://api.hive.blog",
|
34
35
|
"https://api.deathwing.me",
|
@@ -49,36 +50,36 @@ const i = {
|
|
49
50
|
}
|
50
51
|
),
|
51
52
|
heliusApiKey: void 0,
|
52
|
-
queryClient: new
|
53
|
+
queryClient: new A(),
|
53
54
|
plausibleHost: "https://pl.ecency.com",
|
54
55
|
spkNode: "https://spk.good-karma.xyz"
|
55
56
|
};
|
56
|
-
var
|
57
|
+
var K;
|
57
58
|
((e) => {
|
58
59
|
function t(n) {
|
59
60
|
i.queryClient = n;
|
60
61
|
}
|
61
62
|
e.setQueryClient = t;
|
62
|
-
})(
|
63
|
-
function
|
63
|
+
})(K || (K = {}));
|
64
|
+
function L(e) {
|
64
65
|
let t = atob(e);
|
65
66
|
if (t[0] === "{")
|
66
67
|
return JSON.parse(t);
|
67
68
|
}
|
68
|
-
var
|
69
|
+
var D = /* @__PURE__ */ ((e) => (e.HIVE = "HIVE", e.HBD = "HBD", e.VESTS = "VESTS", e.SPK = "SPK", e))(D || {}), F = /* @__PURE__ */ ((e) => (e["@@000000021"] = "HIVE", e["@@000000013"] = "HBD", e["@@000000037"] = "VESTS", e))(F || {});
|
69
70
|
function g(e) {
|
70
71
|
if (typeof e == "string") {
|
71
72
|
const t = e.split(" ");
|
72
73
|
return {
|
73
74
|
amount: parseFloat(t[0]),
|
74
75
|
// @ts-ignore
|
75
|
-
symbol:
|
76
|
+
symbol: D[t[1]]
|
76
77
|
};
|
77
78
|
} else
|
78
79
|
return {
|
79
80
|
amount: parseFloat(e.amount.toString()) / Math.pow(10, e.precision),
|
80
81
|
// @ts-ignore
|
81
|
-
symbol:
|
82
|
+
symbol: F[e.nai]
|
82
83
|
};
|
83
84
|
}
|
84
85
|
const _ = (e) => {
|
@@ -86,13 +87,13 @@ const _ = (e) => {
|
|
86
87
|
const t = i.storage.getItem(
|
87
88
|
i.storagePrefix + "_user_" + e
|
88
89
|
);
|
89
|
-
return
|
90
|
+
return L(JSON.parse(t));
|
90
91
|
} catch (t) {
|
91
92
|
console.error(t);
|
92
93
|
return;
|
93
94
|
}
|
94
|
-
}, y = (e) => _(e) && _(e).accessToken,
|
95
|
-
function
|
95
|
+
}, y = (e) => _(e) && _(e).accessToken, P = (e) => _(e) && _(e).postingKey, E = (e) => _(e) && _(e).loginType, he = (e) => _(e) && _(e).refreshToken;
|
96
|
+
function ee() {
|
96
97
|
return new Promise((e) => {
|
97
98
|
var t;
|
98
99
|
(t = window.hive_keychain) == null || t.requestHandshake(() => {
|
@@ -101,66 +102,72 @@ function X() {
|
|
101
102
|
});
|
102
103
|
}
|
103
104
|
const b = (e, t, n, o = null) => new Promise((r, c) => {
|
104
|
-
var
|
105
|
-
(
|
105
|
+
var s;
|
106
|
+
(s = window.hive_keychain) == null || s.requestBroadcast(
|
106
107
|
e,
|
107
108
|
t,
|
108
109
|
n,
|
109
|
-
(
|
110
|
-
|
110
|
+
(a) => {
|
111
|
+
a.success || c({ message: "Operation cancelled" }), r(a);
|
111
112
|
},
|
112
113
|
o
|
113
114
|
);
|
114
|
-
}),
|
115
|
-
var
|
116
|
-
(
|
115
|
+
}), te = (e, t, n, o, r, c = null) => new Promise((s, a) => {
|
116
|
+
var l;
|
117
|
+
(l = window.hive_keychain) == null || l.requestCustomJson(
|
117
118
|
e,
|
118
119
|
t,
|
119
120
|
n,
|
120
121
|
o,
|
121
122
|
r,
|
122
123
|
(w) => {
|
123
|
-
w.success ||
|
124
|
+
w.success || a({ message: "Operation cancelled" }), s(w);
|
124
125
|
},
|
125
126
|
c
|
126
127
|
);
|
127
|
-
}),
|
128
|
+
}), fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
128
129
|
__proto__: null,
|
129
130
|
broadcast: b,
|
130
|
-
customJson:
|
131
|
-
handshake:
|
131
|
+
customJson: te,
|
132
|
+
handshake: ee
|
132
133
|
}, Symbol.toStringTag, { value: "Module" }));
|
133
|
-
function
|
134
|
+
function ne(e = [], t, n, o = () => {
|
135
|
+
}) {
|
134
136
|
return d({
|
137
|
+
onSuccess: o,
|
135
138
|
mutationKey: [...e, t],
|
136
|
-
mutationFn: async (
|
139
|
+
mutationFn: async (r) => {
|
137
140
|
if (!t)
|
138
141
|
throw new Error(
|
139
142
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
140
143
|
);
|
141
|
-
const
|
142
|
-
if (
|
143
|
-
const
|
144
|
+
const c = P(t);
|
145
|
+
if (c) {
|
146
|
+
const l = v.fromString(c);
|
144
147
|
return i.hiveClient.broadcast.sendOperations(
|
145
|
-
n(
|
146
|
-
|
148
|
+
n(r),
|
149
|
+
l
|
147
150
|
);
|
148
151
|
}
|
149
|
-
const
|
150
|
-
if (
|
151
|
-
return b(
|
152
|
+
const s = E(t);
|
153
|
+
if (s && s == "keychain")
|
154
|
+
return b(
|
155
|
+
t,
|
156
|
+
n(r),
|
157
|
+
"Posting"
|
158
|
+
).then((l) => l.result);
|
152
159
|
let a = y(t);
|
153
160
|
if (a)
|
154
161
|
return (await new m.Client({
|
155
162
|
accessToken: a
|
156
|
-
}).broadcast(n(
|
163
|
+
}).broadcast(n(r))).result;
|
157
164
|
throw new Error(
|
158
165
|
"[SDK][Broadcast] – cannot broadcast w/o posting key or token"
|
159
166
|
);
|
160
167
|
}
|
161
168
|
});
|
162
169
|
}
|
163
|
-
async function
|
170
|
+
async function oe(e, t, n) {
|
164
171
|
if (!e)
|
165
172
|
throw new Error(
|
166
173
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
@@ -170,28 +177,28 @@ async function L(e, t, n) {
|
|
170
177
|
required_auths: [],
|
171
178
|
required_posting_auths: [e],
|
172
179
|
json: JSON.stringify(n)
|
173
|
-
}, r =
|
180
|
+
}, r = P(e);
|
174
181
|
if (r) {
|
175
|
-
const
|
182
|
+
const a = v.fromString(r);
|
176
183
|
return i.hiveClient.broadcast.json(
|
177
184
|
o,
|
178
|
-
|
185
|
+
a
|
179
186
|
);
|
180
187
|
}
|
181
|
-
const c =
|
188
|
+
const c = E(e);
|
182
189
|
if (c && c == "keychain")
|
183
|
-
return b(e, [["custom_json", o]], "Posting").then((
|
184
|
-
let
|
185
|
-
if (
|
190
|
+
return b(e, [["custom_json", o]], "Posting").then((a) => a.result);
|
191
|
+
let s = y(e);
|
192
|
+
if (s)
|
186
193
|
return (await new m.Client({
|
187
|
-
accessToken:
|
194
|
+
accessToken: s
|
188
195
|
}).customJson([], [e], t, JSON.stringify(n))).result;
|
189
196
|
throw new Error(
|
190
197
|
"[SDK][Broadcast] – cannot broadcast w/o posting key or token"
|
191
198
|
);
|
192
199
|
}
|
193
|
-
function
|
194
|
-
return new
|
200
|
+
function ge() {
|
201
|
+
return new A({
|
195
202
|
defaultOptions: {
|
196
203
|
queries: {
|
197
204
|
// With SSR, we usually want to set some default staleTime
|
@@ -204,87 +211,87 @@ function le() {
|
|
204
211
|
});
|
205
212
|
}
|
206
213
|
const u = () => i.queryClient;
|
207
|
-
var
|
214
|
+
var q;
|
208
215
|
((e) => {
|
209
|
-
function t(
|
210
|
-
return u().getQueryData(
|
216
|
+
function t(a) {
|
217
|
+
return u().getQueryData(a);
|
211
218
|
}
|
212
219
|
e.getQueryData = t;
|
213
|
-
function n(
|
214
|
-
return u().getQueryData(
|
220
|
+
function n(a) {
|
221
|
+
return u().getQueryData(a);
|
215
222
|
}
|
216
223
|
e.getInfiniteQueryData = n;
|
217
|
-
async function o(
|
218
|
-
return await u().prefetchQuery(
|
224
|
+
async function o(a) {
|
225
|
+
return await u().prefetchQuery(a), t(a.queryKey);
|
219
226
|
}
|
220
227
|
e.prefetchQuery = o;
|
221
|
-
async function r(
|
222
|
-
return await u().prefetchInfiniteQuery(
|
228
|
+
async function r(a) {
|
229
|
+
return await u().prefetchInfiniteQuery(a), n(a.queryKey);
|
223
230
|
}
|
224
231
|
e.prefetchInfiniteQuery = r;
|
225
|
-
function c(
|
232
|
+
function c(a) {
|
226
233
|
return {
|
227
|
-
prefetch: () => o(
|
228
|
-
getData: () => t(
|
229
|
-
useClientQuery: () =>
|
230
|
-
fetchAndGet: () => u().fetchQuery(
|
234
|
+
prefetch: () => o(a),
|
235
|
+
getData: () => t(a.queryKey),
|
236
|
+
useClientQuery: () => j(a),
|
237
|
+
fetchAndGet: () => u().fetchQuery(a)
|
231
238
|
};
|
232
239
|
}
|
233
240
|
e.generateClientServerQuery = c;
|
234
|
-
function a
|
241
|
+
function s(a) {
|
235
242
|
return {
|
236
|
-
prefetch: () => r(
|
237
|
-
getData: () => n(
|
238
|
-
useClientQuery: () =>
|
239
|
-
fetchAndGet: () => u().fetchInfiniteQuery(
|
243
|
+
prefetch: () => r(a),
|
244
|
+
getData: () => n(a.queryKey),
|
245
|
+
useClientQuery: () => z(a),
|
246
|
+
fetchAndGet: () => u().fetchInfiniteQuery(a)
|
240
247
|
};
|
241
248
|
}
|
242
|
-
e.generateClientServerInfiniteQuery =
|
243
|
-
})(
|
244
|
-
function
|
249
|
+
e.generateClientServerInfiniteQuery = s;
|
250
|
+
})(q || (q = {}));
|
251
|
+
function _e() {
|
245
252
|
return p({
|
246
253
|
queryKey: ["core", "dynamic-props"],
|
247
254
|
refetchInterval: 6e4,
|
248
255
|
staleTime: 6e4,
|
249
256
|
refetchOnMount: !0,
|
250
257
|
queryFn: async () => {
|
251
|
-
const e = await i.hiveClient.database.getDynamicGlobalProperties().then((
|
252
|
-
total_vesting_fund_hive:
|
253
|
-
total_vesting_shares:
|
254
|
-
hbd_print_rate:
|
255
|
-
hbd_interest_rate:
|
256
|
-
head_block_number:
|
257
|
-
vesting_reward_percent:
|
258
|
-
virtual_supply:
|
258
|
+
const e = await i.hiveClient.database.getDynamicGlobalProperties().then((f) => ({
|
259
|
+
total_vesting_fund_hive: f.total_vesting_fund_hive || f.total_vesting_fund_steem,
|
260
|
+
total_vesting_shares: f.total_vesting_shares,
|
261
|
+
hbd_print_rate: f.hbd_print_rate || f.sbd_print_rate,
|
262
|
+
hbd_interest_rate: f.hbd_interest_rate,
|
263
|
+
head_block_number: f.head_block_number,
|
264
|
+
vesting_reward_percent: f.vesting_reward_percent,
|
265
|
+
virtual_supply: f.virtual_supply
|
259
266
|
})), t = await i.hiveClient.database.call("get_feed_history"), n = await i.hiveClient.database.call(
|
260
267
|
"get_chain_properties"
|
261
268
|
), o = await i.hiveClient.database.call(
|
262
269
|
"get_reward_fund",
|
263
270
|
["post"]
|
264
|
-
), r = g(e.total_vesting_fund_hive).amount / g(e.total_vesting_shares).amount * 1e6, c = g(t.current_median_history.base).amount,
|
271
|
+
), r = g(e.total_vesting_fund_hive).amount / g(e.total_vesting_shares).amount * 1e6, c = g(t.current_median_history.base).amount, s = g(t.current_median_history.quote).amount, a = parseFloat(o.recent_claims), l = g(o.reward_balance).amount, w = e.hbd_print_rate, H = e.hbd_interest_rate, I = e.head_block_number, M = g(
|
265
272
|
e.total_vesting_fund_hive
|
266
|
-
).amount,
|
273
|
+
).amount, J = g(
|
267
274
|
e.total_vesting_shares
|
268
|
-
).amount,
|
275
|
+
).amount, N = g(e.virtual_supply).amount, x = e.vesting_reward_percent, G = n.account_creation_fee;
|
269
276
|
return {
|
270
277
|
hivePerMVests: r,
|
271
278
|
base: c,
|
272
|
-
quote:
|
273
|
-
fundRecentClaims:
|
274
|
-
fundRewardBalance:
|
279
|
+
quote: s,
|
280
|
+
fundRecentClaims: a,
|
281
|
+
fundRewardBalance: l,
|
275
282
|
hbdPrintRate: w,
|
276
|
-
hbdInterestRate:
|
277
|
-
headBlock:
|
278
|
-
totalVestingFund:
|
279
|
-
totalVestingShares:
|
280
|
-
virtualSupply:
|
281
|
-
vestingRewardPercent:
|
282
|
-
accountCreationFee:
|
283
|
+
hbdInterestRate: H,
|
284
|
+
headBlock: I,
|
285
|
+
totalVestingFund: M,
|
286
|
+
totalVestingShares: J,
|
287
|
+
virtualSupply: N,
|
288
|
+
vestingRewardPercent: x,
|
289
|
+
accountCreationFee: G
|
283
290
|
};
|
284
291
|
}
|
285
292
|
});
|
286
293
|
}
|
287
|
-
function
|
294
|
+
function T(e) {
|
288
295
|
return p({
|
289
296
|
queryKey: ["get-account-full", e],
|
290
297
|
queryFn: async () => {
|
@@ -359,7 +366,7 @@ function ee(e) {
|
|
359
366
|
staleTime: 6e4
|
360
367
|
});
|
361
368
|
}
|
362
|
-
function
|
369
|
+
function ve(e, t = 5, n = []) {
|
363
370
|
return p({
|
364
371
|
queryKey: ["accounts", "search", e, n],
|
365
372
|
enabled: !!e,
|
@@ -371,7 +378,7 @@ function fe(e, t = 5, n = []) {
|
|
371
378
|
)
|
372
379
|
});
|
373
380
|
}
|
374
|
-
function
|
381
|
+
function we(e) {
|
375
382
|
return p({
|
376
383
|
queryKey: ["accounts", "check-wallet-pending", e],
|
377
384
|
queryFn: async () => await (await fetch(
|
@@ -390,7 +397,7 @@ function ge(e) {
|
|
390
397
|
refetchOnMount: !0
|
391
398
|
});
|
392
399
|
}
|
393
|
-
function
|
400
|
+
function re(e, t) {
|
394
401
|
return p({
|
395
402
|
queryKey: ["accounts", "relations", e, t],
|
396
403
|
enabled: !!e && !!t,
|
@@ -403,7 +410,7 @@ function te(e, t) {
|
|
403
410
|
)
|
404
411
|
});
|
405
412
|
}
|
406
|
-
function
|
413
|
+
function me(e) {
|
407
414
|
return p({
|
408
415
|
queryKey: ["accounts", "subscriptions", e],
|
409
416
|
enabled: !!e,
|
@@ -416,7 +423,7 @@ function _e(e) {
|
|
416
423
|
) ?? []
|
417
424
|
});
|
418
425
|
}
|
419
|
-
function
|
426
|
+
function be(e) {
|
420
427
|
return p({
|
421
428
|
queryKey: ["accounts", "bookmarks", e],
|
422
429
|
enabled: !!e,
|
@@ -436,7 +443,7 @@ function ve(e) {
|
|
436
443
|
}
|
437
444
|
});
|
438
445
|
}
|
439
|
-
function
|
446
|
+
function Ce(e) {
|
440
447
|
return p({
|
441
448
|
queryKey: ["accounts", "favourites", e],
|
442
449
|
enabled: !!e,
|
@@ -456,54 +463,76 @@ function we(e) {
|
|
456
463
|
}
|
457
464
|
});
|
458
465
|
}
|
459
|
-
function
|
460
|
-
|
461
|
-
|
462
|
-
|
466
|
+
function Q({
|
467
|
+
profile: e,
|
468
|
+
tokens: t,
|
469
|
+
data: n
|
470
|
+
}) {
|
471
|
+
const o = C.pipe(
|
472
|
+
JSON.parse((n == null ? void 0 : n.posting_json_metadata) || "{}"),
|
473
|
+
C.mergeDeep(e ?? {})
|
474
|
+
);
|
475
|
+
return t && t.length > 0 && (o.tokens = t), o;
|
476
|
+
}
|
477
|
+
function Se(e) {
|
478
|
+
const t = U(), { data: n } = j(T(e));
|
479
|
+
return ne(
|
480
|
+
["accounts", "update", n == null ? void 0 : n.name],
|
463
481
|
e,
|
464
|
-
(
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
};
|
469
|
-
return o && o.length > 0 && (r.tokens = o), [
|
482
|
+
(o) => {
|
483
|
+
if (!n)
|
484
|
+
throw new Error("[SDK][Accounts] – cannot update not existing account");
|
485
|
+
return [
|
470
486
|
[
|
471
487
|
"account_update2",
|
472
488
|
{
|
473
489
|
account: e,
|
474
|
-
|
490
|
+
json_metadata: "",
|
491
|
+
extensions: [],
|
492
|
+
posting_json_metadata: JSON.stringify({
|
493
|
+
profile: Q({ ...o, data: n })
|
494
|
+
})
|
475
495
|
}
|
476
496
|
]
|
477
497
|
];
|
478
|
-
}
|
498
|
+
},
|
499
|
+
(o, r) => t.setQueryData(
|
500
|
+
T(e).queryKey,
|
501
|
+
(c) => {
|
502
|
+
if (!c)
|
503
|
+
return c;
|
504
|
+
const s = C.clone(c);
|
505
|
+
return s.profile = Q({ ...r, data: c }), s;
|
506
|
+
}
|
507
|
+
)
|
479
508
|
);
|
480
509
|
}
|
481
|
-
function
|
510
|
+
function Oe(e, t, n, o) {
|
482
511
|
return d({
|
483
512
|
mutationKey: [],
|
484
513
|
mutationFn: async (r) => {
|
485
|
-
const c =
|
514
|
+
const c = re(
|
486
515
|
e,
|
487
516
|
t
|
488
517
|
);
|
489
518
|
await u().prefetchQuery(c);
|
490
|
-
const
|
519
|
+
const s = u().getQueryData(
|
491
520
|
c.queryKey
|
492
521
|
);
|
493
|
-
return await
|
522
|
+
return await oe(e, "follow", [
|
494
523
|
"follow",
|
495
524
|
{
|
496
525
|
follower: e,
|
497
526
|
following: t,
|
498
527
|
what: [
|
499
|
-
...r === "toggle-ignore" && !(
|
500
|
-
...r === "toggle-follow" && !(
|
528
|
+
...r === "toggle-ignore" && !(s != null && s.ignores) ? ["ignore"] : [],
|
529
|
+
...r === "toggle-follow" && !(s != null && s.follows) ? ["blog"] : []
|
501
530
|
]
|
502
531
|
}
|
503
532
|
]), {
|
504
|
-
...
|
505
|
-
ignores: r === "toggle-ignore" ? !(
|
506
|
-
follows: r === "toggle-follow" ? !(
|
533
|
+
...s,
|
534
|
+
ignores: r === "toggle-ignore" ? !(s != null && s.ignores) : s == null ? void 0 : s.ignores,
|
535
|
+
follows: r === "toggle-follow" ? !(s != null && s.follows) : s == null ? void 0 : s.follows
|
507
536
|
};
|
508
537
|
},
|
509
538
|
onError: o,
|
@@ -515,7 +544,7 @@ function be(e, t, n, o) {
|
|
515
544
|
}
|
516
545
|
});
|
517
546
|
}
|
518
|
-
function
|
547
|
+
function ke(e, t, n) {
|
519
548
|
return d({
|
520
549
|
mutationKey: ["accounts", "bookmarks", "add", e],
|
521
550
|
mutationFn: async ({ author: o, permlink: r }) => {
|
@@ -544,7 +573,7 @@ function Ce(e, t, n) {
|
|
544
573
|
onError: n
|
545
574
|
});
|
546
575
|
}
|
547
|
-
function
|
576
|
+
function Ke(e, t, n) {
|
548
577
|
return d({
|
549
578
|
mutationKey: ["accounts", "bookmarks", "delete", e],
|
550
579
|
mutationFn: async (o) => {
|
@@ -572,7 +601,7 @@ function Se(e, t, n) {
|
|
572
601
|
onError: n
|
573
602
|
});
|
574
603
|
}
|
575
|
-
function
|
604
|
+
function qe(e, t, n) {
|
576
605
|
return d({
|
577
606
|
mutationKey: ["accounts", "favourites", "add", e],
|
578
607
|
mutationFn: async (o) => {
|
@@ -600,7 +629,7 @@ function Oe(e, t, n) {
|
|
600
629
|
onError: n
|
601
630
|
});
|
602
631
|
}
|
603
|
-
function
|
632
|
+
function Te(e, t, n) {
|
604
633
|
return d({
|
605
634
|
mutationKey: ["accounts", "favourites", "add", e],
|
606
635
|
mutationFn: async (o) => {
|
@@ -628,7 +657,7 @@ function ke(e, t, n) {
|
|
628
657
|
onError: n
|
629
658
|
});
|
630
659
|
}
|
631
|
-
function
|
660
|
+
function Qe(e) {
|
632
661
|
return d({
|
633
662
|
mutationKey: ["operations", "sign", e],
|
634
663
|
mutationFn: ({
|
@@ -638,14 +667,14 @@ function Ke(e) {
|
|
638
667
|
if (!e)
|
639
668
|
throw new Error("[Operations][Sign] – cannot sign op with anon user");
|
640
669
|
let o;
|
641
|
-
return n.split(" ").length === 12 ? o = v.fromLogin(e, n, "active") :
|
670
|
+
return n.split(" ").length === 12 ? o = v.fromLogin(e, n, "active") : X.isWif(n) ? o = v.fromString(n) : o = v.from(n), i.hiveClient.broadcast.sendOperations(
|
642
671
|
[t],
|
643
672
|
o
|
644
673
|
);
|
645
674
|
}
|
646
675
|
});
|
647
676
|
}
|
648
|
-
function
|
677
|
+
function Ae(e, t = "Active") {
|
649
678
|
return d({
|
650
679
|
mutationKey: ["operations", "sign-keychain", e],
|
651
680
|
mutationFn: ({ operation: n }) => {
|
@@ -657,21 +686,21 @@ function qe(e, t = "Active") {
|
|
657
686
|
}
|
658
687
|
});
|
659
688
|
}
|
660
|
-
function
|
689
|
+
function je(e = "/") {
|
661
690
|
return d({
|
662
691
|
mutationKey: ["operations", "sign-hivesigner", e],
|
663
692
|
mutationFn: async ({ operation: t }) => m.sendOperation(t, { callback: e }, () => {
|
664
693
|
})
|
665
694
|
});
|
666
695
|
}
|
667
|
-
function
|
696
|
+
function De() {
|
668
697
|
return p({
|
669
698
|
queryKey: ["operations", "chain-properties"],
|
670
699
|
queryFn: async () => await i.hiveClient.database.getChainProperties()
|
671
700
|
});
|
672
701
|
}
|
673
|
-
function
|
674
|
-
return
|
702
|
+
function Fe(e = 20) {
|
703
|
+
return $({
|
675
704
|
queryKey: ["posts", "trending-tags"],
|
676
705
|
queryFn: async ({ pageParam: { afterTag: t } }) => i.hiveClient.database.call("get_trending_tags", [t, e]).then(
|
677
706
|
(n) => n.filter((o) => o.name !== "").filter((o) => !o.name.startsWith("hive-")).map((o) => o.name)
|
@@ -684,7 +713,7 @@ function Ae(e = 20) {
|
|
684
713
|
refetchOnMount: !0
|
685
714
|
});
|
686
715
|
}
|
687
|
-
function
|
716
|
+
function O(e) {
|
688
717
|
return p({
|
689
718
|
queryKey: ["posts", "fragments", e],
|
690
719
|
queryFn: async () => (await fetch(
|
@@ -702,7 +731,7 @@ function S(e) {
|
|
702
731
|
enabled: !!e
|
703
732
|
});
|
704
733
|
}
|
705
|
-
function
|
734
|
+
function Pe(e = "feed") {
|
706
735
|
return p({
|
707
736
|
queryKey: ["posts", "promoted", e],
|
708
737
|
queryFn: async () => {
|
@@ -718,7 +747,7 @@ function je(e = "feed") {
|
|
718
747
|
}
|
719
748
|
});
|
720
749
|
}
|
721
|
-
function
|
750
|
+
function Ee(e) {
|
722
751
|
return d({
|
723
752
|
mutationKey: ["posts", "add-fragment", e],
|
724
753
|
mutationFn: async ({ title: t, body: n }) => (await fetch(
|
@@ -737,13 +766,13 @@ function Fe(e) {
|
|
737
766
|
)).json(),
|
738
767
|
onSuccess(t) {
|
739
768
|
u().setQueryData(
|
740
|
-
|
769
|
+
O(e).queryKey,
|
741
770
|
(n) => [t, ...n ?? []]
|
742
771
|
);
|
743
772
|
}
|
744
773
|
});
|
745
774
|
}
|
746
|
-
function
|
775
|
+
function Be(e, t) {
|
747
776
|
return d({
|
748
777
|
mutationKey: ["posts", "edit-fragment", e, t],
|
749
778
|
mutationFn: async ({ title: n, body: o }) => (await fetch(
|
@@ -763,7 +792,7 @@ function De(e, t) {
|
|
763
792
|
)).json(),
|
764
793
|
onSuccess(n) {
|
765
794
|
u().setQueryData(
|
766
|
-
|
795
|
+
O(e).queryKey,
|
767
796
|
(o) => {
|
768
797
|
if (!o)
|
769
798
|
return [];
|
@@ -774,7 +803,7 @@ function De(e, t) {
|
|
774
803
|
}
|
775
804
|
});
|
776
805
|
}
|
777
|
-
function
|
806
|
+
function He(e, t) {
|
778
807
|
return d({
|
779
808
|
mutationKey: ["posts", "remove-fragment", e],
|
780
809
|
mutationFn: async () => fetch(i.privateApiHost + "/private-api/fragments-delete", {
|
@@ -789,13 +818,13 @@ function Pe(e, t) {
|
|
789
818
|
}),
|
790
819
|
onSuccess() {
|
791
820
|
u().setQueryData(
|
792
|
-
|
821
|
+
O(e).queryKey,
|
793
822
|
(n) => [...n ?? []].filter(({ id: o }) => o !== t)
|
794
823
|
);
|
795
824
|
}
|
796
825
|
});
|
797
826
|
}
|
798
|
-
function
|
827
|
+
function B(e, t) {
|
799
828
|
return d({
|
800
829
|
mutationKey: ["analytics", t],
|
801
830
|
mutationFn: async () => {
|
@@ -818,11 +847,11 @@ function D(e, t) {
|
|
818
847
|
}
|
819
848
|
});
|
820
849
|
}
|
821
|
-
const
|
850
|
+
const Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
822
851
|
__proto__: null,
|
823
|
-
useRecordActivity:
|
852
|
+
useRecordActivity: B
|
824
853
|
}, Symbol.toStringTag, { value: "Module" }));
|
825
|
-
function
|
854
|
+
function ie(e, t) {
|
826
855
|
return p({
|
827
856
|
queryKey: ["integrations", "hivesigner", "decode-memo", e],
|
828
857
|
queryFn: async () => {
|
@@ -834,13 +863,13 @@ function ne(e, t) {
|
|
834
863
|
}
|
835
864
|
});
|
836
865
|
}
|
837
|
-
const
|
866
|
+
const se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
838
867
|
__proto__: null,
|
839
|
-
getDecodeMemoQueryOptions:
|
840
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
841
|
-
queries:
|
868
|
+
getDecodeMemoQueryOptions: ie
|
869
|
+
}, Symbol.toStringTag, { value: "Module" })), ae = {
|
870
|
+
queries: se
|
842
871
|
};
|
843
|
-
function
|
872
|
+
function S(e) {
|
844
873
|
return p({
|
845
874
|
queryKey: ["integrations", "3speak", "authenticate", e],
|
846
875
|
enabled: !!e,
|
@@ -854,7 +883,7 @@ function C(e) {
|
|
854
883
|
"Content-Type": "application/json"
|
855
884
|
}
|
856
885
|
}
|
857
|
-
), n =
|
886
|
+
), n = ae.queries.getDecodeMemoQueryOptions(
|
858
887
|
e,
|
859
888
|
(await t.json()).memo
|
860
889
|
);
|
@@ -866,16 +895,16 @@ function C(e) {
|
|
866
895
|
}
|
867
896
|
});
|
868
897
|
}
|
869
|
-
function
|
898
|
+
function ce(e) {
|
870
899
|
return p({
|
871
900
|
queryKey: ["integrations", "3speak", "videos", e],
|
872
901
|
enabled: !!e,
|
873
902
|
queryFn: async () => {
|
874
903
|
await u().prefetchQuery(
|
875
|
-
|
904
|
+
S(e)
|
876
905
|
);
|
877
906
|
const t = u().getQueryData(
|
878
|
-
|
907
|
+
S(e).queryKey
|
879
908
|
);
|
880
909
|
return await (await fetch(
|
881
910
|
"https://studio.3speak.tv/mobile/api/my-videos",
|
@@ -889,14 +918,14 @@ function ie(e) {
|
|
889
918
|
}
|
890
919
|
});
|
891
920
|
}
|
892
|
-
const
|
921
|
+
const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
893
922
|
__proto__: null,
|
894
|
-
getAccountTokenQueryOptions:
|
895
|
-
getAccountVideosQueryOptions:
|
896
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
897
|
-
queries:
|
923
|
+
getAccountTokenQueryOptions: S,
|
924
|
+
getAccountVideosQueryOptions: ce
|
925
|
+
}, Symbol.toStringTag, { value: "Module" })), Me = {
|
926
|
+
queries: ue
|
898
927
|
};
|
899
|
-
function
|
928
|
+
function Je(e) {
|
900
929
|
return p({
|
901
930
|
queryKey: ["integrations", "hiveposh", "links", e],
|
902
931
|
queryFn: async () => {
|
@@ -921,7 +950,7 @@ function Ie(e) {
|
|
921
950
|
}
|
922
951
|
});
|
923
952
|
}
|
924
|
-
function
|
953
|
+
function Ne() {
|
925
954
|
return p({
|
926
955
|
queryKey: ["resource-credits", "stats"],
|
927
956
|
queryFn: async () => (await i.hiveClient.call(
|
@@ -931,14 +960,14 @@ function Me() {
|
|
931
960
|
)).rc_stats
|
932
961
|
});
|
933
962
|
}
|
934
|
-
function
|
963
|
+
function xe(e) {
|
935
964
|
return p({
|
936
965
|
queryKey: ["resource-credits", "account", e],
|
937
|
-
queryFn: async () => new
|
966
|
+
queryFn: async () => new Y(i.hiveClient).findRCAccounts([e]),
|
938
967
|
enabled: !!e
|
939
968
|
});
|
940
969
|
}
|
941
|
-
function
|
970
|
+
function Ge(e, t) {
|
942
971
|
return p({
|
943
972
|
queryKey: ["games", "status-check", t, e],
|
944
973
|
enabled: !!e,
|
@@ -961,8 +990,8 @@ function Je(e, t) {
|
|
961
990
|
}
|
962
991
|
});
|
963
992
|
}
|
964
|
-
function
|
965
|
-
const { mutateAsync: o } =
|
993
|
+
function Ve(e, t, n) {
|
994
|
+
const { mutateAsync: o } = B(
|
966
995
|
e,
|
967
996
|
"spin-rolled"
|
968
997
|
);
|
@@ -991,7 +1020,7 @@ function Ne(e, t, n) {
|
|
991
1020
|
}
|
992
1021
|
});
|
993
1022
|
}
|
994
|
-
function
|
1023
|
+
function We(e, t, n = 100, o = void 0, r = !0) {
|
995
1024
|
return p({
|
996
1025
|
queryKey: ["communities", "list", e, t, n],
|
997
1026
|
enabled: r,
|
@@ -1011,7 +1040,7 @@ function xe(e, t, n = 100, o = void 0, r = !0) {
|
|
1011
1040
|
}
|
1012
1041
|
});
|
1013
1042
|
}
|
1014
|
-
function
|
1043
|
+
function ze(e, t) {
|
1015
1044
|
return p({
|
1016
1045
|
queryKey: ["community", "context", e, t],
|
1017
1046
|
enabled: !!e && !!t,
|
@@ -1031,8 +1060,8 @@ function Ge(e, t) {
|
|
1031
1060
|
}
|
1032
1061
|
});
|
1033
1062
|
}
|
1034
|
-
var
|
1035
|
-
const
|
1063
|
+
var h = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(h || {});
|
1064
|
+
const Ue = {
|
1036
1065
|
owner: [
|
1037
1066
|
"admin",
|
1038
1067
|
"mod",
|
@@ -1055,27 +1084,27 @@ const Ve = {
|
|
1055
1084
|
/* MUTED */
|
1056
1085
|
]
|
1057
1086
|
};
|
1058
|
-
function
|
1087
|
+
function $e(e, t) {
|
1059
1088
|
return e.startsWith("hive-3") || t === 3 ? "Council" : e.startsWith("hive-2") || t === 2 ? "Journal" : "Topic";
|
1060
1089
|
}
|
1061
|
-
function
|
1090
|
+
function Re({
|
1062
1091
|
communityType: e,
|
1063
1092
|
userRole: t,
|
1064
1093
|
subscribed: n
|
1065
1094
|
}) {
|
1066
|
-
const o = t ===
|
1095
|
+
const o = t === h.MUTED ? !1 : e === "Topic" ? !0 : [h.OWNER, h.ADMIN, h.MOD, h.MEMBER].includes(
|
1067
1096
|
t
|
1068
1097
|
), r = (() => {
|
1069
|
-
if (t ===
|
1098
|
+
if (t === h.MUTED) return !1;
|
1070
1099
|
switch (e) {
|
1071
1100
|
case "Topic":
|
1072
1101
|
return !0;
|
1073
1102
|
case "Journal":
|
1074
|
-
return t !==
|
1103
|
+
return t !== h.GUEST || n;
|
1075
1104
|
case "Council":
|
1076
1105
|
return o;
|
1077
1106
|
}
|
1078
|
-
})(), c = [
|
1107
|
+
})(), c = [h.OWNER, h.ADMIN, h.MOD].includes(t);
|
1079
1108
|
return {
|
1080
1109
|
canPost: o,
|
1081
1110
|
canComment: r,
|
@@ -1084,54 +1113,54 @@ function ze({
|
|
1084
1113
|
}
|
1085
1114
|
export {
|
1086
1115
|
i as CONFIG,
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1116
|
+
K as ConfigManager,
|
1117
|
+
Ie as EcencyAnalytics,
|
1118
|
+
q as EcencyQueriesManager,
|
1119
|
+
ae as HiveSignerIntegration,
|
1120
|
+
fe as Keychain,
|
1121
|
+
h as ROLES,
|
1122
|
+
Me as ThreeSpeakIntegration,
|
1123
|
+
oe as broadcastJson,
|
1124
|
+
we as checkUsernameWalletsPendingQueryOptions,
|
1096
1125
|
y as getAccessToken,
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1126
|
+
T as getAccountFullQueryOptions,
|
1127
|
+
xe as getAccountRcQueryOptions,
|
1128
|
+
me as getAccountSubscriptionsQueryOptions,
|
1129
|
+
be as getActiveAccountBookmarksQueryOptions,
|
1130
|
+
Ce as getActiveAccountFavouritesQueryOptions,
|
1131
|
+
De as getChainPropertiesQueryOptions,
|
1132
|
+
We as getCommunitiesQueryOptions,
|
1133
|
+
ze as getCommunityContextQueryOptions,
|
1134
|
+
Re as getCommunityPermissions,
|
1135
|
+
$e as getCommunityType,
|
1136
|
+
_e as getDynamicPropsQueryOptions,
|
1137
|
+
O as getFragmentsQueryOptions,
|
1138
|
+
Ge as getGameStatusCheckQueryOptions,
|
1139
|
+
Je as getHivePoshLinksQueryOptions,
|
1140
|
+
E as getLoginType,
|
1141
|
+
P as getPostingKey,
|
1142
|
+
Pe as getPromotedPostsQuery,
|
1114
1143
|
u as getQueryClient,
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1144
|
+
Ne as getRcStatsQueryOptions,
|
1145
|
+
he as getRefreshToken,
|
1146
|
+
re as getRelationshipBetweenAccountsQueryOptions,
|
1147
|
+
ve as getSearchAccountsByUsernameQueryOptions,
|
1148
|
+
Fe as getTrendingTagsQueryOptions,
|
1120
1149
|
_ as getUser,
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1150
|
+
ge as makeQueryClient,
|
1151
|
+
Ue as roleMap,
|
1152
|
+
qe as useAccountFavouriteAdd,
|
1153
|
+
Te as useAccountFavouriteDelete,
|
1154
|
+
Oe as useAccountRelationsUpdate,
|
1155
|
+
Se as useAccountUpdate,
|
1156
|
+
Ee as useAddFragment,
|
1157
|
+
ke as useBookmarkAdd,
|
1158
|
+
Ke as useBookmarkDelete,
|
1159
|
+
ne as useBroadcastMutation,
|
1160
|
+
Be as useEditFragment,
|
1161
|
+
Ve as useGameClaim,
|
1162
|
+
He as useRemoveFragment,
|
1163
|
+
je as useSignOperationByHivesigner,
|
1164
|
+
Qe as useSignOperationByKey,
|
1165
|
+
Ae as useSignOperationByKeychain
|
1137
1166
|
};
|
@@ -1,12 +1,7 @@
|
|
1
1
|
import { AccountProfile } from '../types';
|
2
2
|
interface Payload {
|
3
3
|
profile: Partial<AccountProfile>;
|
4
|
-
tokens:
|
5
|
-
symbol: string;
|
6
|
-
meta: {
|
7
|
-
address: string;
|
8
|
-
};
|
9
|
-
}[];
|
4
|
+
tokens: AccountProfile["tokens"];
|
10
5
|
}
|
11
|
-
export declare function useAccountUpdate(username: string): import('@tanstack/react-query').UseMutationResult<
|
6
|
+
export declare function useAccountUpdate(username: string): import('@tanstack/react-query').UseMutationResult<unknown, Error, Partial<Payload>, unknown>;
|
12
7
|
export {};
|
@@ -52,6 +52,11 @@ export declare function getAccountFullQueryOptions(username: string): import('@t
|
|
52
52
|
account: string;
|
53
53
|
weight: number;
|
54
54
|
};
|
55
|
+
tokens?: {
|
56
|
+
symbol: string;
|
57
|
+
type: string;
|
58
|
+
meta: Record<string, any>;
|
59
|
+
}[];
|
55
60
|
};
|
56
61
|
}, Error, {
|
57
62
|
name: any;
|
@@ -106,6 +111,11 @@ export declare function getAccountFullQueryOptions(username: string): import('@t
|
|
106
111
|
account: string;
|
107
112
|
weight: number;
|
108
113
|
};
|
114
|
+
tokens?: {
|
115
|
+
symbol: string;
|
116
|
+
type: string;
|
117
|
+
meta: Record<string, any>;
|
118
|
+
}[];
|
109
119
|
};
|
110
120
|
}, string[]>, "queryFn"> & {
|
111
121
|
queryFn?: import('@tanstack/query-core').QueryFunction<{
|
@@ -161,6 +171,11 @@ export declare function getAccountFullQueryOptions(username: string): import('@t
|
|
161
171
|
account: string;
|
162
172
|
weight: number;
|
163
173
|
};
|
174
|
+
tokens?: {
|
175
|
+
symbol: string;
|
176
|
+
type: string;
|
177
|
+
meta: Record<string, any>;
|
178
|
+
}[];
|
164
179
|
};
|
165
180
|
}, string[], never> | undefined;
|
166
181
|
} & {
|
@@ -218,6 +233,11 @@ export declare function getAccountFullQueryOptions(username: string): import('@t
|
|
218
233
|
account: string;
|
219
234
|
weight: number;
|
220
235
|
};
|
236
|
+
tokens?: {
|
237
|
+
symbol: string;
|
238
|
+
type: string;
|
239
|
+
meta: Record<string, any>;
|
240
|
+
}[];
|
221
241
|
};
|
222
242
|
};
|
223
243
|
[dataTagErrorSymbol]: Error;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { useMutation } from '@tanstack/react-query';
|
2
2
|
import { Operation } from '@hiveio/dhive';
|
3
|
-
export declare function useBroadcastMutation<T>(mutationKey: Parameters<typeof useMutation>[0]["mutationKey"], username: string | undefined, operations: (payload: T) => Operation[]): import('@tanstack/react-query').UseMutationResult<
|
3
|
+
export declare function useBroadcastMutation<T>(mutationKey: Parameters<typeof useMutation>[0]["mutationKey"], username: string | undefined, operations: (payload: T) => Operation[], onSuccess?: Parameters<typeof useMutation<unknown, unknown, T>>[0]["onSuccess"]): import('@tanstack/react-query').UseMutationResult<unknown, Error, T, unknown>;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ecency/sdk",
|
3
3
|
"private": false,
|
4
|
-
"version": "1.1.
|
4
|
+
"version": "1.1.3",
|
5
5
|
"type": "module",
|
6
6
|
"license": "MIT",
|
7
7
|
"main": "./dist/ecency-sdk.umd.js",
|
@@ -17,20 +17,21 @@
|
|
17
17
|
"preview": "vite preview"
|
18
18
|
},
|
19
19
|
"devDependencies": {
|
20
|
+
"@hiveio/dhive": "^1.3.2",
|
21
|
+
"@tanstack/react-query": "^5.74.4",
|
20
22
|
"@types/node": "^22.13.8",
|
21
23
|
"@types/react": "^19.0.10",
|
22
24
|
"@vitejs/plugin-react": "^4.3.4",
|
25
|
+
"bip39": "^3.1.0",
|
23
26
|
"eslint": "^9.21.0",
|
27
|
+
"hivesigner": "3.3.4",
|
28
|
+
"lru-cache": "^11.0.2",
|
24
29
|
"prettier": "^3.5.2",
|
30
|
+
"react": "^19.0.0",
|
31
|
+
"remeda": "^2.30.0",
|
25
32
|
"vite": "^6.2.0",
|
26
33
|
"vite-plugin-dts": "4.5.3",
|
27
|
-
"vite-plugin-node-polyfills": "^0.23.0"
|
28
|
-
"lru-cache": "^11.0.2",
|
29
|
-
"@hiveio/dhive": "^1.3.2",
|
30
|
-
"@tanstack/react-query": "^5.74.4",
|
31
|
-
"react": "^19.0.0",
|
32
|
-
"bip39": "^3.1.0",
|
33
|
-
"hivesigner": "3.3.4"
|
34
|
+
"vite-plugin-node-polyfills": "^0.23.0"
|
34
35
|
},
|
35
36
|
"dependencies": {}
|
36
37
|
}
|