@ecency/sdk 1.5.26 → 1.5.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/browser/index.d.ts +1512 -6
- package/dist/browser/index.js +1702 -114
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +1776 -113
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +1702 -114
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/index.browser.mjs +0 -1663
- package/dist/index.browser.mjs.map +0 -1
- package/dist/index.cjs +0 -1747
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -1106
- package/dist/index.mjs +0 -1659
- package/dist/index.mjs.map +0 -1
package/dist/browser/index.js
CHANGED
|
@@ -8,8 +8,315 @@ var __export = (target, all) => {
|
|
|
8
8
|
for (var name in all)
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
|
+
|
|
12
|
+
// src/modules/core/errors/chain-errors.ts
|
|
13
|
+
var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
|
14
|
+
ErrorType2["COMMON"] = "common";
|
|
15
|
+
ErrorType2["INFO"] = "info";
|
|
16
|
+
ErrorType2["INSUFFICIENT_RESOURCE_CREDITS"] = "insufficient_resource_credits";
|
|
17
|
+
ErrorType2["MISSING_AUTHORITY"] = "missing_authority";
|
|
18
|
+
ErrorType2["TOKEN_EXPIRED"] = "token_expired";
|
|
19
|
+
ErrorType2["NETWORK"] = "network";
|
|
20
|
+
ErrorType2["TIMEOUT"] = "timeout";
|
|
21
|
+
ErrorType2["VALIDATION"] = "validation";
|
|
22
|
+
return ErrorType2;
|
|
23
|
+
})(ErrorType || {});
|
|
24
|
+
function parseChainError(error) {
|
|
25
|
+
const errorDescription = error?.error_description ? String(error.error_description) : "";
|
|
26
|
+
const errorMessage = error?.message ? String(error.message) : "";
|
|
27
|
+
const errorString = errorDescription || errorMessage || String(error || "");
|
|
28
|
+
const testPattern = (pattern) => {
|
|
29
|
+
if (errorDescription && pattern.test(errorDescription)) return true;
|
|
30
|
+
if (errorMessage && pattern.test(errorMessage)) return true;
|
|
31
|
+
if (errorString && pattern.test(errorString)) return true;
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
if (testPattern(/please wait to transact/i) || testPattern(/insufficient rc/i) || testPattern(/rc mana|rc account|resource credits/i)) {
|
|
35
|
+
return {
|
|
36
|
+
message: "Insufficient Resource Credits. Please wait or power up.",
|
|
37
|
+
type: "insufficient_resource_credits" /* INSUFFICIENT_RESOURCE_CREDITS */,
|
|
38
|
+
originalError: error
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (testPattern(/you may only post once every/i)) {
|
|
42
|
+
return {
|
|
43
|
+
message: "Please wait before posting again (minimum 3 second interval between comments).",
|
|
44
|
+
type: "common" /* COMMON */,
|
|
45
|
+
originalError: error
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (testPattern(/your current vote on this comment is identical/i)) {
|
|
49
|
+
return {
|
|
50
|
+
message: "You have already voted with the same weight.",
|
|
51
|
+
type: "info" /* INFO */,
|
|
52
|
+
originalError: error
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (testPattern(/must claim something/i)) {
|
|
56
|
+
return {
|
|
57
|
+
message: "You must claim rewards before performing this action.",
|
|
58
|
+
type: "info" /* INFO */,
|
|
59
|
+
originalError: error
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (testPattern(/cannot claim that much vests/i)) {
|
|
63
|
+
return {
|
|
64
|
+
message: "Cannot claim that amount. Please check your pending rewards.",
|
|
65
|
+
type: "info" /* INFO */,
|
|
66
|
+
originalError: error
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (testPattern(/cannot delete a comment with net positive/i)) {
|
|
70
|
+
return {
|
|
71
|
+
message: "Cannot delete a comment with positive votes.",
|
|
72
|
+
type: "info" /* INFO */,
|
|
73
|
+
originalError: error
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (testPattern(/children == 0/i)) {
|
|
77
|
+
return {
|
|
78
|
+
message: "Cannot delete a comment with replies.",
|
|
79
|
+
type: "common" /* COMMON */,
|
|
80
|
+
originalError: error
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (testPattern(/comment_cashout/i)) {
|
|
84
|
+
return {
|
|
85
|
+
message: "Cannot modify a comment that has already been paid out.",
|
|
86
|
+
type: "common" /* COMMON */,
|
|
87
|
+
originalError: error
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (testPattern(/votes evaluating for comment that is paid out is forbidden/i)) {
|
|
91
|
+
return {
|
|
92
|
+
message: "Cannot vote on posts that have already been paid out.",
|
|
93
|
+
type: "common" /* COMMON */,
|
|
94
|
+
originalError: error
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (testPattern(/missing active authority/i)) {
|
|
98
|
+
return {
|
|
99
|
+
message: "Missing active authority. This operation requires your active key.",
|
|
100
|
+
type: "missing_authority" /* MISSING_AUTHORITY */,
|
|
101
|
+
originalError: error
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (testPattern(/missing owner authority/i)) {
|
|
105
|
+
return {
|
|
106
|
+
message: "Missing owner authority. This operation requires your owner key.",
|
|
107
|
+
type: "missing_authority" /* MISSING_AUTHORITY */,
|
|
108
|
+
originalError: error
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (testPattern(/missing (required )?posting authority/i)) {
|
|
112
|
+
return {
|
|
113
|
+
message: "Missing posting authority. Please check your login method.",
|
|
114
|
+
type: "missing_authority" /* MISSING_AUTHORITY */,
|
|
115
|
+
originalError: error
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (testPattern(/token expired/i) || testPattern(/invalid token/i)) {
|
|
119
|
+
return {
|
|
120
|
+
message: "Authentication token expired. Please log in again.",
|
|
121
|
+
type: "token_expired" /* TOKEN_EXPIRED */,
|
|
122
|
+
originalError: error
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (testPattern(/has already reblogged/i) || testPattern(/already reblogged this post/i)) {
|
|
126
|
+
return {
|
|
127
|
+
message: "You have already reblogged this post.",
|
|
128
|
+
type: "info" /* INFO */,
|
|
129
|
+
originalError: error
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (testPattern(/duplicate transaction/i)) {
|
|
133
|
+
return {
|
|
134
|
+
message: "This transaction has already been processed.",
|
|
135
|
+
type: "info" /* INFO */,
|
|
136
|
+
originalError: error
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (testPattern(/econnrefused/i) || testPattern(/connection refused/i) || testPattern(/failed to fetch/i) || testPattern(/\bnetwork[-\s]?(request|error|timeout|unreachable|down|failed)\b/i)) {
|
|
140
|
+
return {
|
|
141
|
+
message: "Network error. Please check your connection and try again.",
|
|
142
|
+
type: "network" /* NETWORK */,
|
|
143
|
+
originalError: error
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (testPattern(/timeout/i) || testPattern(/timed out/i)) {
|
|
147
|
+
return {
|
|
148
|
+
message: "Request timed out. Please try again.",
|
|
149
|
+
type: "timeout" /* TIMEOUT */,
|
|
150
|
+
originalError: error
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (testPattern(/account.*does not exist/i) || testPattern(/account not found/i)) {
|
|
154
|
+
return {
|
|
155
|
+
message: "Account not found. Please check the username.",
|
|
156
|
+
type: "validation" /* VALIDATION */,
|
|
157
|
+
originalError: error
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (testPattern(/invalid memo key/i)) {
|
|
161
|
+
return {
|
|
162
|
+
message: "Invalid memo key. Cannot encrypt message.",
|
|
163
|
+
type: "validation" /* VALIDATION */,
|
|
164
|
+
originalError: error
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (testPattern(/(?:insufficient.*(?:funds|balance)|(?:funds|balance).*insufficient)/i)) {
|
|
168
|
+
return {
|
|
169
|
+
message: "Insufficient funds for this transaction.",
|
|
170
|
+
type: "validation" /* VALIDATION */,
|
|
171
|
+
originalError: error
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (testPattern(/\b(invalid|validation)\b/i)) {
|
|
175
|
+
const message2 = (error?.message || errorString).substring(0, 150) || "Validation error occurred";
|
|
176
|
+
return {
|
|
177
|
+
message: message2,
|
|
178
|
+
type: "validation" /* VALIDATION */,
|
|
179
|
+
originalError: error
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (error?.error_description && typeof error.error_description === "string") {
|
|
183
|
+
return {
|
|
184
|
+
message: error.error_description.substring(0, 150),
|
|
185
|
+
type: "common" /* COMMON */,
|
|
186
|
+
originalError: error
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (error?.message && typeof error.message === "string") {
|
|
190
|
+
return {
|
|
191
|
+
message: error.message.substring(0, 150),
|
|
192
|
+
type: "common" /* COMMON */,
|
|
193
|
+
originalError: error
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
let message;
|
|
197
|
+
if (typeof error === "object" && error !== null) {
|
|
198
|
+
if (error.error_description) {
|
|
199
|
+
message = String(error.error_description);
|
|
200
|
+
} else if (error.code) {
|
|
201
|
+
message = `Error code: ${error.code}`;
|
|
202
|
+
} else if (errorString && errorString !== "[object Object]") {
|
|
203
|
+
message = errorString.substring(0, 150);
|
|
204
|
+
} else {
|
|
205
|
+
message = "Unknown error occurred";
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
message = errorString.substring(0, 150) || "Unknown error occurred";
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
message,
|
|
212
|
+
type: "common" /* COMMON */,
|
|
213
|
+
originalError: error
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function formatError(error) {
|
|
217
|
+
const parsed = parseChainError(error);
|
|
218
|
+
return [parsed.message, parsed.type];
|
|
219
|
+
}
|
|
220
|
+
function shouldTriggerAuthFallback(error) {
|
|
221
|
+
const { type } = parseChainError(error);
|
|
222
|
+
return type === "missing_authority" /* MISSING_AUTHORITY */ || type === "token_expired" /* TOKEN_EXPIRED */;
|
|
223
|
+
}
|
|
224
|
+
function isResourceCreditsError(error) {
|
|
225
|
+
const { type } = parseChainError(error);
|
|
226
|
+
return type === "insufficient_resource_credits" /* INSUFFICIENT_RESOURCE_CREDITS */;
|
|
227
|
+
}
|
|
228
|
+
function isInfoError(error) {
|
|
229
|
+
const { type } = parseChainError(error);
|
|
230
|
+
return type === "info" /* INFO */;
|
|
231
|
+
}
|
|
232
|
+
function isNetworkError(error) {
|
|
233
|
+
const { type } = parseChainError(error);
|
|
234
|
+
return type === "network" /* NETWORK */ || type === "timeout" /* TIMEOUT */;
|
|
235
|
+
}
|
|
236
|
+
async function broadcastWithFallback(username, ops2, auth, authority = "posting") {
|
|
237
|
+
const chain = auth?.fallbackChain ?? ["key", "hiveauth", "hivesigner", "keychain", "custom"];
|
|
238
|
+
const errors = /* @__PURE__ */ new Map();
|
|
239
|
+
const adapter = auth?.adapter;
|
|
240
|
+
for (const method of chain) {
|
|
241
|
+
try {
|
|
242
|
+
switch (method) {
|
|
243
|
+
case "key": {
|
|
244
|
+
if (!adapter) {
|
|
245
|
+
errors.set(method, new Error("Skipped: No adapter provided"));
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
let key;
|
|
249
|
+
if (authority === "active" && adapter.getActiveKey) {
|
|
250
|
+
key = await adapter.getActiveKey(username);
|
|
251
|
+
} else if (authority === "posting") {
|
|
252
|
+
key = await adapter.getPostingKey(username);
|
|
253
|
+
}
|
|
254
|
+
if (!key) {
|
|
255
|
+
errors.set(method, new Error(`Skipped: No ${authority} key available`));
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
const privateKey = PrivateKey.fromString(key);
|
|
259
|
+
return await CONFIG.hiveClient.broadcast.sendOperations(ops2, privateKey);
|
|
260
|
+
}
|
|
261
|
+
case "hiveauth": {
|
|
262
|
+
if (!adapter?.broadcastWithHiveAuth) {
|
|
263
|
+
errors.set(method, new Error("Skipped: HiveAuth not supported by adapter"));
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
return await adapter.broadcastWithHiveAuth(username, ops2, authority);
|
|
267
|
+
}
|
|
268
|
+
case "hivesigner": {
|
|
269
|
+
if (!adapter) {
|
|
270
|
+
errors.set(method, new Error("Skipped: No adapter provided"));
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
const token = await adapter.getAccessToken(username);
|
|
274
|
+
if (!token) {
|
|
275
|
+
errors.set(method, new Error("Skipped: No access token available"));
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
const client = new hs.Client({ accessToken: token });
|
|
279
|
+
const response = await client.broadcast(ops2);
|
|
280
|
+
return response.result;
|
|
281
|
+
}
|
|
282
|
+
case "keychain": {
|
|
283
|
+
if (!adapter?.broadcastWithKeychain) {
|
|
284
|
+
errors.set(method, new Error("Skipped: Keychain not supported by adapter"));
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
return await adapter.broadcastWithKeychain(username, ops2, authority);
|
|
288
|
+
}
|
|
289
|
+
case "custom": {
|
|
290
|
+
if (!auth?.broadcast) {
|
|
291
|
+
errors.set(method, new Error("Skipped: No custom broadcast function provided"));
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
return await auth.broadcast(ops2, authority);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
} catch (error) {
|
|
298
|
+
errors.set(method, error);
|
|
299
|
+
if (!shouldTriggerAuthFallback(error)) {
|
|
300
|
+
throw error;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const hasRealAttempts = Array.from(errors.values()).some(
|
|
305
|
+
(error) => !error.message.startsWith("Skipped:")
|
|
306
|
+
);
|
|
307
|
+
if (!hasRealAttempts) {
|
|
308
|
+
const skipReasons = Array.from(errors.entries()).map(([method, error]) => `${method}: ${error.message}`).join(", ");
|
|
309
|
+
throw new Error(
|
|
310
|
+
`[SDK][Broadcast] No auth methods attempted for ${username}. ${skipReasons}`
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
const errorMessages = Array.from(errors.entries()).map(([method, error]) => `${method}: ${error.message}`).join(", ");
|
|
314
|
+
throw new Error(
|
|
315
|
+
`[SDK][Broadcast] All auth methods failed for ${username}. Errors: ${errorMessages}`
|
|
316
|
+
);
|
|
317
|
+
}
|
|
11
318
|
function useBroadcastMutation(mutationKey = [], username, operations, onSuccess = () => {
|
|
12
|
-
}, auth) {
|
|
319
|
+
}, auth, authority = "posting") {
|
|
13
320
|
return useMutation({
|
|
14
321
|
onSuccess,
|
|
15
322
|
mutationKey: [...mutationKey, username],
|
|
@@ -19,20 +326,23 @@ function useBroadcastMutation(mutationKey = [], username, operations, onSuccess
|
|
|
19
326
|
"[Core][Broadcast] Attempted to call broadcast API with anon user"
|
|
20
327
|
);
|
|
21
328
|
}
|
|
329
|
+
const ops2 = operations(payload);
|
|
330
|
+
if (auth?.enableFallback !== false && auth?.adapter) {
|
|
331
|
+
return broadcastWithFallback(username, ops2, auth, authority);
|
|
332
|
+
}
|
|
22
333
|
if (auth?.broadcast) {
|
|
23
|
-
return auth.broadcast(
|
|
334
|
+
return auth.broadcast(ops2, authority);
|
|
24
335
|
}
|
|
25
336
|
const postingKey = auth?.postingKey;
|
|
26
337
|
if (postingKey) {
|
|
27
338
|
const privateKey = PrivateKey.fromString(postingKey);
|
|
28
339
|
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
29
|
-
|
|
340
|
+
ops2,
|
|
30
341
|
privateKey
|
|
31
342
|
);
|
|
32
343
|
}
|
|
33
344
|
const accessToken = auth?.accessToken;
|
|
34
345
|
if (accessToken) {
|
|
35
|
-
const ops2 = operations(payload);
|
|
36
346
|
const client = new hs.Client({ accessToken });
|
|
37
347
|
const response = await client.broadcast(ops2);
|
|
38
348
|
return response.result;
|
|
@@ -3321,123 +3631,1134 @@ function votingValue(account, dynamicProps, votingPowerValue, weight = 1e4) {
|
|
|
3321
3631
|
}
|
|
3322
3632
|
return rShares / fundRecentClaims * fundRewardBalance * (base / quote);
|
|
3323
3633
|
}
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
privateKey = PrivateKey.from(keyOrSeed);
|
|
3341
|
-
}
|
|
3342
|
-
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
3343
|
-
[operation],
|
|
3344
|
-
privateKey
|
|
3345
|
-
);
|
|
3634
|
+
|
|
3635
|
+
// src/modules/operations/builders/content.ts
|
|
3636
|
+
function buildVoteOp(voter, author, permlink, weight) {
|
|
3637
|
+
if (!voter || !author || !permlink) {
|
|
3638
|
+
throw new Error("[SDK][buildVoteOp] Missing required parameters");
|
|
3639
|
+
}
|
|
3640
|
+
if (weight < -1e4 || weight > 1e4) {
|
|
3641
|
+
throw new Error("[SDK][buildVoteOp] Weight must be between -10000 and 10000");
|
|
3642
|
+
}
|
|
3643
|
+
return [
|
|
3644
|
+
"vote",
|
|
3645
|
+
{
|
|
3646
|
+
voter,
|
|
3647
|
+
author,
|
|
3648
|
+
permlink,
|
|
3649
|
+
weight
|
|
3346
3650
|
}
|
|
3347
|
-
|
|
3651
|
+
];
|
|
3348
3652
|
}
|
|
3349
|
-
function
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3653
|
+
function buildCommentOp(author, permlink, parentAuthor, parentPermlink, title, body, jsonMetadata) {
|
|
3654
|
+
if (!author || !permlink || parentPermlink === void 0 || !body) {
|
|
3655
|
+
throw new Error("[SDK][buildCommentOp] Missing required parameters");
|
|
3656
|
+
}
|
|
3657
|
+
return [
|
|
3658
|
+
"comment",
|
|
3659
|
+
{
|
|
3660
|
+
parent_author: parentAuthor,
|
|
3661
|
+
parent_permlink: parentPermlink,
|
|
3662
|
+
author,
|
|
3663
|
+
permlink,
|
|
3664
|
+
title,
|
|
3665
|
+
body,
|
|
3666
|
+
json_metadata: JSON.stringify(jsonMetadata)
|
|
3362
3667
|
}
|
|
3363
|
-
|
|
3668
|
+
];
|
|
3364
3669
|
}
|
|
3365
|
-
function
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3670
|
+
function buildCommentOptionsOp(author, permlink, maxAcceptedPayout, percentHbd, allowVotes, allowCurationRewards, extensions) {
|
|
3671
|
+
if (!author || !permlink) {
|
|
3672
|
+
throw new Error("[SDK][buildCommentOptionsOp] Missing required parameters");
|
|
3673
|
+
}
|
|
3674
|
+
return [
|
|
3675
|
+
"comment_options",
|
|
3676
|
+
{
|
|
3677
|
+
author,
|
|
3678
|
+
permlink,
|
|
3679
|
+
max_accepted_payout: maxAcceptedPayout,
|
|
3680
|
+
percent_hbd: percentHbd,
|
|
3681
|
+
allow_votes: allowVotes,
|
|
3682
|
+
allow_curation_rewards: allowCurationRewards,
|
|
3683
|
+
extensions
|
|
3371
3684
|
}
|
|
3372
|
-
|
|
3685
|
+
];
|
|
3373
3686
|
}
|
|
3374
|
-
function
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3687
|
+
function buildDeleteCommentOp(author, permlink) {
|
|
3688
|
+
if (!author || !permlink) {
|
|
3689
|
+
throw new Error("[SDK][buildDeleteCommentOp] Missing required parameters");
|
|
3690
|
+
}
|
|
3691
|
+
return [
|
|
3692
|
+
"delete_comment",
|
|
3693
|
+
{
|
|
3694
|
+
author,
|
|
3695
|
+
permlink
|
|
3379
3696
|
}
|
|
3380
|
-
|
|
3697
|
+
];
|
|
3381
3698
|
}
|
|
3382
|
-
function
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
}
|
|
3402
|
-
}
|
|
3403
|
-
);
|
|
3404
|
-
return response.json();
|
|
3405
|
-
},
|
|
3406
|
-
onSuccess(response) {
|
|
3407
|
-
const queryClient = getQueryClient();
|
|
3408
|
-
queryClient.setQueryData(
|
|
3409
|
-
getFragmentsQueryOptions(username, code).queryKey,
|
|
3410
|
-
(data) => [response, ...data ?? []]
|
|
3411
|
-
);
|
|
3412
|
-
queryClient.setQueriesData(
|
|
3413
|
-
{ queryKey: ["posts", "fragments", "infinite", username] },
|
|
3414
|
-
(oldData) => {
|
|
3415
|
-
if (!oldData) return oldData;
|
|
3416
|
-
return {
|
|
3417
|
-
...oldData,
|
|
3418
|
-
pages: oldData.pages.map(
|
|
3419
|
-
(page, index) => index === 0 ? { ...page, data: [response, ...page.data] } : page
|
|
3420
|
-
)
|
|
3421
|
-
};
|
|
3422
|
-
}
|
|
3423
|
-
);
|
|
3699
|
+
function buildReblogOp(account, author, permlink, deleteReblog = false) {
|
|
3700
|
+
if (!account || !author || !permlink) {
|
|
3701
|
+
throw new Error("[SDK][buildReblogOp] Missing required parameters");
|
|
3702
|
+
}
|
|
3703
|
+
const json = {
|
|
3704
|
+
account,
|
|
3705
|
+
author,
|
|
3706
|
+
permlink
|
|
3707
|
+
};
|
|
3708
|
+
if (deleteReblog) {
|
|
3709
|
+
json.delete = "delete";
|
|
3710
|
+
}
|
|
3711
|
+
return [
|
|
3712
|
+
"custom_json",
|
|
3713
|
+
{
|
|
3714
|
+
id: "follow",
|
|
3715
|
+
json: JSON.stringify(["reblog", json]),
|
|
3716
|
+
required_auths: [],
|
|
3717
|
+
required_posting_auths: [account]
|
|
3424
3718
|
}
|
|
3425
|
-
|
|
3719
|
+
];
|
|
3426
3720
|
}
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3721
|
+
|
|
3722
|
+
// src/modules/operations/builders/wallet.ts
|
|
3723
|
+
function buildTransferOp(from, to, amount, memo) {
|
|
3724
|
+
if (!from || !to || !amount) {
|
|
3725
|
+
throw new Error("[SDK][buildTransferOp] Missing required parameters");
|
|
3726
|
+
}
|
|
3727
|
+
return [
|
|
3728
|
+
"transfer",
|
|
3729
|
+
{
|
|
3730
|
+
from,
|
|
3731
|
+
to,
|
|
3732
|
+
amount,
|
|
3733
|
+
memo: memo || ""
|
|
3734
|
+
}
|
|
3735
|
+
];
|
|
3736
|
+
}
|
|
3737
|
+
function buildMultiTransferOps(from, destinations, amount, memo) {
|
|
3738
|
+
if (!from || !destinations || !amount) {
|
|
3739
|
+
throw new Error("[SDK][buildMultiTransferOps] Missing required parameters");
|
|
3740
|
+
}
|
|
3741
|
+
const destArray = destinations.trim().split(/[\s,]+/).filter(Boolean);
|
|
3742
|
+
return destArray.map(
|
|
3743
|
+
(dest) => buildTransferOp(from, dest.trim(), amount, memo)
|
|
3744
|
+
);
|
|
3745
|
+
}
|
|
3746
|
+
function buildRecurrentTransferOp(from, to, amount, memo, recurrence, executions) {
|
|
3747
|
+
if (!from || !to || !amount) {
|
|
3748
|
+
throw new Error("[SDK][buildRecurrentTransferOp] Missing required parameters");
|
|
3749
|
+
}
|
|
3750
|
+
if (recurrence < 24) {
|
|
3751
|
+
throw new Error("[SDK][buildRecurrentTransferOp] Recurrence must be at least 24 hours");
|
|
3752
|
+
}
|
|
3753
|
+
return [
|
|
3754
|
+
"recurrent_transfer",
|
|
3755
|
+
{
|
|
3756
|
+
from,
|
|
3757
|
+
to,
|
|
3758
|
+
amount,
|
|
3759
|
+
memo: memo || "",
|
|
3760
|
+
recurrence,
|
|
3761
|
+
executions,
|
|
3762
|
+
extensions: []
|
|
3763
|
+
}
|
|
3764
|
+
];
|
|
3765
|
+
}
|
|
3766
|
+
function buildTransferToSavingsOp(from, to, amount, memo) {
|
|
3767
|
+
if (!from || !to || !amount) {
|
|
3768
|
+
throw new Error("[SDK][buildTransferToSavingsOp] Missing required parameters");
|
|
3769
|
+
}
|
|
3770
|
+
return [
|
|
3771
|
+
"transfer_to_savings",
|
|
3772
|
+
{
|
|
3773
|
+
from,
|
|
3774
|
+
to,
|
|
3775
|
+
amount,
|
|
3776
|
+
memo: memo || ""
|
|
3777
|
+
}
|
|
3778
|
+
];
|
|
3779
|
+
}
|
|
3780
|
+
function buildTransferFromSavingsOp(from, to, amount, memo, requestId) {
|
|
3781
|
+
if (!from || !to || !amount || requestId === void 0) {
|
|
3782
|
+
throw new Error("[SDK][buildTransferFromSavingsOp] Missing required parameters");
|
|
3783
|
+
}
|
|
3784
|
+
return [
|
|
3785
|
+
"transfer_from_savings",
|
|
3786
|
+
{
|
|
3787
|
+
from,
|
|
3788
|
+
to,
|
|
3789
|
+
amount,
|
|
3790
|
+
memo: memo || "",
|
|
3791
|
+
request_id: requestId
|
|
3792
|
+
}
|
|
3793
|
+
];
|
|
3794
|
+
}
|
|
3795
|
+
function buildCancelTransferFromSavingsOp(from, requestId) {
|
|
3796
|
+
if (!from || requestId === void 0) {
|
|
3797
|
+
throw new Error("[SDK][buildCancelTransferFromSavingsOp] Missing required parameters");
|
|
3798
|
+
}
|
|
3799
|
+
return [
|
|
3800
|
+
"cancel_transfer_from_savings",
|
|
3801
|
+
{
|
|
3802
|
+
from,
|
|
3803
|
+
request_id: requestId
|
|
3804
|
+
}
|
|
3805
|
+
];
|
|
3806
|
+
}
|
|
3807
|
+
function buildClaimInterestOps(from, to, amount, memo, requestId) {
|
|
3808
|
+
if (!from || !to || !amount || requestId === void 0) {
|
|
3809
|
+
throw new Error("[SDK][buildClaimInterestOps] Missing required parameters");
|
|
3810
|
+
}
|
|
3811
|
+
return [
|
|
3812
|
+
buildTransferFromSavingsOp(from, to, amount, memo, requestId),
|
|
3813
|
+
buildCancelTransferFromSavingsOp(from, requestId)
|
|
3814
|
+
];
|
|
3815
|
+
}
|
|
3816
|
+
function buildTransferToVestingOp(from, to, amount) {
|
|
3817
|
+
if (!from || !to || !amount) {
|
|
3818
|
+
throw new Error("[SDK][buildTransferToVestingOp] Missing required parameters");
|
|
3819
|
+
}
|
|
3820
|
+
return [
|
|
3821
|
+
"transfer_to_vesting",
|
|
3822
|
+
{
|
|
3823
|
+
from,
|
|
3824
|
+
to,
|
|
3825
|
+
amount
|
|
3826
|
+
}
|
|
3827
|
+
];
|
|
3828
|
+
}
|
|
3829
|
+
function buildWithdrawVestingOp(account, vestingShares) {
|
|
3830
|
+
if (!account || !vestingShares) {
|
|
3831
|
+
throw new Error("[SDK][buildWithdrawVestingOp] Missing required parameters");
|
|
3832
|
+
}
|
|
3833
|
+
return [
|
|
3834
|
+
"withdraw_vesting",
|
|
3835
|
+
{
|
|
3836
|
+
account,
|
|
3837
|
+
vesting_shares: vestingShares
|
|
3838
|
+
}
|
|
3839
|
+
];
|
|
3840
|
+
}
|
|
3841
|
+
function buildDelegateVestingSharesOp(delegator, delegatee, vestingShares) {
|
|
3842
|
+
if (!delegator || !delegatee || !vestingShares) {
|
|
3843
|
+
throw new Error("[SDK][buildDelegateVestingSharesOp] Missing required parameters");
|
|
3844
|
+
}
|
|
3845
|
+
return [
|
|
3846
|
+
"delegate_vesting_shares",
|
|
3847
|
+
{
|
|
3848
|
+
delegator,
|
|
3849
|
+
delegatee,
|
|
3850
|
+
vesting_shares: vestingShares
|
|
3851
|
+
}
|
|
3852
|
+
];
|
|
3853
|
+
}
|
|
3854
|
+
function buildSetWithdrawVestingRouteOp(fromAccount, toAccount, percent, autoVest) {
|
|
3855
|
+
if (!fromAccount || !toAccount || percent === void 0) {
|
|
3856
|
+
throw new Error("[SDK][buildSetWithdrawVestingRouteOp] Missing required parameters");
|
|
3857
|
+
}
|
|
3858
|
+
if (percent < 0 || percent > 1e4) {
|
|
3859
|
+
throw new Error("[SDK][buildSetWithdrawVestingRouteOp] Percent must be between 0 and 10000");
|
|
3860
|
+
}
|
|
3861
|
+
return [
|
|
3862
|
+
"set_withdraw_vesting_route",
|
|
3863
|
+
{
|
|
3864
|
+
from_account: fromAccount,
|
|
3865
|
+
to_account: toAccount,
|
|
3866
|
+
percent,
|
|
3867
|
+
auto_vest: autoVest
|
|
3868
|
+
}
|
|
3869
|
+
];
|
|
3870
|
+
}
|
|
3871
|
+
function buildConvertOp(owner, amount, requestId) {
|
|
3872
|
+
if (!owner || !amount || requestId === void 0) {
|
|
3873
|
+
throw new Error("[SDK][buildConvertOp] Missing required parameters");
|
|
3874
|
+
}
|
|
3875
|
+
return [
|
|
3876
|
+
"convert",
|
|
3877
|
+
{
|
|
3878
|
+
owner,
|
|
3879
|
+
amount,
|
|
3880
|
+
requestid: requestId
|
|
3881
|
+
}
|
|
3882
|
+
];
|
|
3883
|
+
}
|
|
3884
|
+
function buildCollateralizedConvertOp(owner, amount, requestId) {
|
|
3885
|
+
if (!owner || !amount || requestId === void 0) {
|
|
3886
|
+
throw new Error("[SDK][buildCollateralizedConvertOp] Missing required parameters");
|
|
3887
|
+
}
|
|
3888
|
+
return [
|
|
3889
|
+
"collateralized_convert",
|
|
3890
|
+
{
|
|
3891
|
+
owner,
|
|
3892
|
+
amount,
|
|
3893
|
+
requestid: requestId
|
|
3894
|
+
}
|
|
3895
|
+
];
|
|
3896
|
+
}
|
|
3897
|
+
function buildDelegateRcOp(from, delegatees, maxRc) {
|
|
3898
|
+
if (!from || !delegatees || maxRc === void 0) {
|
|
3899
|
+
throw new Error("[SDK][buildDelegateRcOp] Missing required parameters");
|
|
3900
|
+
}
|
|
3901
|
+
const delegateeArray = delegatees.includes(",") ? delegatees.split(",").map((d) => d.trim()) : [delegatees];
|
|
3902
|
+
return [
|
|
3903
|
+
"custom_json",
|
|
3904
|
+
{
|
|
3905
|
+
id: "rc",
|
|
3906
|
+
json: JSON.stringify([
|
|
3907
|
+
"delegate_rc",
|
|
3908
|
+
{
|
|
3909
|
+
from,
|
|
3910
|
+
delegatees: delegateeArray,
|
|
3911
|
+
max_rc: maxRc
|
|
3912
|
+
}
|
|
3913
|
+
]),
|
|
3914
|
+
required_auths: [],
|
|
3915
|
+
required_posting_auths: [from]
|
|
3916
|
+
}
|
|
3917
|
+
];
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3920
|
+
// src/modules/operations/builders/social.ts
|
|
3921
|
+
function buildFollowOp(follower, following) {
|
|
3922
|
+
if (!follower || !following) {
|
|
3923
|
+
throw new Error("[SDK][buildFollowOp] Missing required parameters");
|
|
3924
|
+
}
|
|
3925
|
+
return [
|
|
3926
|
+
"custom_json",
|
|
3927
|
+
{
|
|
3928
|
+
id: "follow",
|
|
3929
|
+
json: JSON.stringify([
|
|
3930
|
+
"follow",
|
|
3931
|
+
{
|
|
3932
|
+
follower,
|
|
3933
|
+
following,
|
|
3934
|
+
what: ["blog"]
|
|
3935
|
+
}
|
|
3936
|
+
]),
|
|
3937
|
+
required_auths: [],
|
|
3938
|
+
required_posting_auths: [follower]
|
|
3939
|
+
}
|
|
3940
|
+
];
|
|
3941
|
+
}
|
|
3942
|
+
function buildUnfollowOp(follower, following) {
|
|
3943
|
+
if (!follower || !following) {
|
|
3944
|
+
throw new Error("[SDK][buildUnfollowOp] Missing required parameters");
|
|
3945
|
+
}
|
|
3946
|
+
return [
|
|
3947
|
+
"custom_json",
|
|
3948
|
+
{
|
|
3949
|
+
id: "follow",
|
|
3950
|
+
json: JSON.stringify([
|
|
3951
|
+
"follow",
|
|
3952
|
+
{
|
|
3953
|
+
follower,
|
|
3954
|
+
following,
|
|
3955
|
+
what: []
|
|
3956
|
+
}
|
|
3957
|
+
]),
|
|
3958
|
+
required_auths: [],
|
|
3959
|
+
required_posting_auths: [follower]
|
|
3960
|
+
}
|
|
3961
|
+
];
|
|
3962
|
+
}
|
|
3963
|
+
function buildIgnoreOp(follower, following) {
|
|
3964
|
+
if (!follower || !following) {
|
|
3965
|
+
throw new Error("[SDK][buildIgnoreOp] Missing required parameters");
|
|
3966
|
+
}
|
|
3967
|
+
return [
|
|
3968
|
+
"custom_json",
|
|
3969
|
+
{
|
|
3970
|
+
id: "follow",
|
|
3971
|
+
json: JSON.stringify([
|
|
3972
|
+
"follow",
|
|
3973
|
+
{
|
|
3974
|
+
follower,
|
|
3975
|
+
following,
|
|
3976
|
+
what: ["ignore"]
|
|
3977
|
+
}
|
|
3978
|
+
]),
|
|
3979
|
+
required_auths: [],
|
|
3980
|
+
required_posting_auths: [follower]
|
|
3981
|
+
}
|
|
3982
|
+
];
|
|
3983
|
+
}
|
|
3984
|
+
function buildUnignoreOp(follower, following) {
|
|
3985
|
+
if (!follower || !following) {
|
|
3986
|
+
throw new Error("[SDK][buildUnignoreOp] Missing required parameters");
|
|
3987
|
+
}
|
|
3988
|
+
return buildUnfollowOp(follower, following);
|
|
3989
|
+
}
|
|
3990
|
+
function buildSetLastReadOps(username, date) {
|
|
3991
|
+
if (!username) {
|
|
3992
|
+
throw new Error("[SDK][buildSetLastReadOps] Missing required parameters");
|
|
3993
|
+
}
|
|
3994
|
+
const lastReadDate = date || (/* @__PURE__ */ new Date()).toISOString().split(".")[0];
|
|
3995
|
+
const notifyOp = [
|
|
3996
|
+
"custom_json",
|
|
3997
|
+
{
|
|
3998
|
+
id: "notify",
|
|
3999
|
+
json: JSON.stringify(["setLastRead", { date: lastReadDate }]),
|
|
4000
|
+
required_auths: [],
|
|
4001
|
+
required_posting_auths: [username]
|
|
4002
|
+
}
|
|
4003
|
+
];
|
|
4004
|
+
const ecencyNotifyOp = [
|
|
4005
|
+
"custom_json",
|
|
4006
|
+
{
|
|
4007
|
+
id: "ecency_notify",
|
|
4008
|
+
json: JSON.stringify(["setLastRead", { date: lastReadDate }]),
|
|
4009
|
+
required_auths: [],
|
|
4010
|
+
required_posting_auths: [username]
|
|
4011
|
+
}
|
|
4012
|
+
];
|
|
4013
|
+
return [notifyOp, ecencyNotifyOp];
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
// src/modules/operations/builders/governance.ts
|
|
4017
|
+
function buildWitnessVoteOp(account, witness, approve) {
|
|
4018
|
+
if (!account || !witness || approve === void 0) {
|
|
4019
|
+
throw new Error("[SDK][buildWitnessVoteOp] Missing required parameters");
|
|
4020
|
+
}
|
|
4021
|
+
return [
|
|
4022
|
+
"account_witness_vote",
|
|
4023
|
+
{
|
|
4024
|
+
account,
|
|
4025
|
+
witness,
|
|
4026
|
+
approve
|
|
4027
|
+
}
|
|
4028
|
+
];
|
|
4029
|
+
}
|
|
4030
|
+
function buildWitnessProxyOp(account, proxy) {
|
|
4031
|
+
if (!account || proxy === void 0) {
|
|
4032
|
+
throw new Error("[SDK][buildWitnessProxyOp] Missing required parameters");
|
|
4033
|
+
}
|
|
4034
|
+
return [
|
|
4035
|
+
"account_witness_proxy",
|
|
4036
|
+
{
|
|
4037
|
+
account,
|
|
4038
|
+
proxy
|
|
4039
|
+
}
|
|
4040
|
+
];
|
|
4041
|
+
}
|
|
4042
|
+
function buildProposalCreateOp(creator, payload) {
|
|
4043
|
+
if (!creator || !payload.receiver || !payload.subject || !payload.permlink || !payload.start || !payload.end || !payload.dailyPay) {
|
|
4044
|
+
throw new Error("[SDK][buildProposalCreateOp] Missing required parameters");
|
|
4045
|
+
}
|
|
4046
|
+
const startDate = new Date(payload.start);
|
|
4047
|
+
const endDate = new Date(payload.end);
|
|
4048
|
+
if (startDate.toString() === "Invalid Date" || endDate.toString() === "Invalid Date") {
|
|
4049
|
+
throw new Error(
|
|
4050
|
+
"[SDK][buildProposalCreateOp] Invalid date format: start and end must be valid ISO date strings"
|
|
4051
|
+
);
|
|
4052
|
+
}
|
|
4053
|
+
return [
|
|
4054
|
+
"create_proposal",
|
|
4055
|
+
{
|
|
4056
|
+
creator,
|
|
4057
|
+
receiver: payload.receiver,
|
|
4058
|
+
start_date: payload.start,
|
|
4059
|
+
end_date: payload.end,
|
|
4060
|
+
daily_pay: payload.dailyPay,
|
|
4061
|
+
subject: payload.subject,
|
|
4062
|
+
permlink: payload.permlink,
|
|
4063
|
+
extensions: []
|
|
4064
|
+
}
|
|
4065
|
+
];
|
|
4066
|
+
}
|
|
4067
|
+
function buildProposalVoteOp(voter, proposalIds, approve) {
|
|
4068
|
+
if (!voter || !proposalIds || proposalIds.length === 0 || approve === void 0) {
|
|
4069
|
+
throw new Error("[SDK][buildProposalVoteOp] Missing required parameters");
|
|
4070
|
+
}
|
|
4071
|
+
return [
|
|
4072
|
+
"update_proposal_votes",
|
|
4073
|
+
{
|
|
4074
|
+
voter,
|
|
4075
|
+
proposal_ids: proposalIds,
|
|
4076
|
+
approve,
|
|
4077
|
+
extensions: []
|
|
4078
|
+
}
|
|
4079
|
+
];
|
|
4080
|
+
}
|
|
4081
|
+
function buildRemoveProposalOp(proposalOwner, proposalIds) {
|
|
4082
|
+
if (!proposalOwner || !proposalIds || proposalIds.length === 0) {
|
|
4083
|
+
throw new Error("[SDK][buildRemoveProposalOp] Missing required parameters");
|
|
4084
|
+
}
|
|
4085
|
+
return [
|
|
4086
|
+
"remove_proposal",
|
|
4087
|
+
{
|
|
4088
|
+
proposal_owner: proposalOwner,
|
|
4089
|
+
proposal_ids: proposalIds,
|
|
4090
|
+
extensions: []
|
|
4091
|
+
}
|
|
4092
|
+
];
|
|
4093
|
+
}
|
|
4094
|
+
function buildUpdateProposalOp(proposalId, creator, dailyPay, subject, permlink) {
|
|
4095
|
+
if (proposalId === void 0 || proposalId === null || typeof proposalId !== "number" || !creator || !dailyPay || !subject || !permlink) {
|
|
4096
|
+
throw new Error("[SDK][buildUpdateProposalOp] Missing required parameters");
|
|
4097
|
+
}
|
|
4098
|
+
return [
|
|
4099
|
+
"update_proposal",
|
|
4100
|
+
{
|
|
4101
|
+
proposal_id: proposalId,
|
|
4102
|
+
creator,
|
|
4103
|
+
daily_pay: dailyPay,
|
|
4104
|
+
subject,
|
|
4105
|
+
permlink,
|
|
4106
|
+
extensions: []
|
|
4107
|
+
}
|
|
4108
|
+
];
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
// src/modules/operations/builders/community.ts
|
|
4112
|
+
function buildSubscribeOp(username, community) {
|
|
4113
|
+
if (!username || !community) {
|
|
4114
|
+
throw new Error("[SDK][buildSubscribeOp] Missing required parameters");
|
|
4115
|
+
}
|
|
4116
|
+
return [
|
|
4117
|
+
"custom_json",
|
|
4118
|
+
{
|
|
4119
|
+
id: "community",
|
|
4120
|
+
json: JSON.stringify(["subscribe", { community }]),
|
|
4121
|
+
required_auths: [],
|
|
4122
|
+
required_posting_auths: [username]
|
|
4123
|
+
}
|
|
4124
|
+
];
|
|
4125
|
+
}
|
|
4126
|
+
function buildUnsubscribeOp(username, community) {
|
|
4127
|
+
if (!username || !community) {
|
|
4128
|
+
throw new Error("[SDK][buildUnsubscribeOp] Missing required parameters");
|
|
4129
|
+
}
|
|
4130
|
+
return [
|
|
4131
|
+
"custom_json",
|
|
4132
|
+
{
|
|
4133
|
+
id: "community",
|
|
4134
|
+
json: JSON.stringify(["unsubscribe", { community }]),
|
|
4135
|
+
required_auths: [],
|
|
4136
|
+
required_posting_auths: [username]
|
|
4137
|
+
}
|
|
4138
|
+
];
|
|
4139
|
+
}
|
|
4140
|
+
function buildSetRoleOp(username, community, account, role) {
|
|
4141
|
+
if (!username || !community || !account || !role) {
|
|
4142
|
+
throw new Error("[SDK][buildSetRoleOp] Missing required parameters");
|
|
4143
|
+
}
|
|
4144
|
+
return [
|
|
4145
|
+
"custom_json",
|
|
4146
|
+
{
|
|
4147
|
+
id: "community",
|
|
4148
|
+
json: JSON.stringify(["setRole", { community, account, role }]),
|
|
4149
|
+
required_auths: [],
|
|
4150
|
+
required_posting_auths: [username]
|
|
4151
|
+
}
|
|
4152
|
+
];
|
|
4153
|
+
}
|
|
4154
|
+
function buildUpdateCommunityOp(username, community, props) {
|
|
4155
|
+
if (!username || !community || !props) {
|
|
4156
|
+
throw new Error("[SDK][buildUpdateCommunityOp] Missing required parameters");
|
|
4157
|
+
}
|
|
4158
|
+
return [
|
|
4159
|
+
"custom_json",
|
|
4160
|
+
{
|
|
4161
|
+
id: "community",
|
|
4162
|
+
json: JSON.stringify(["updateProps", { community, props }]),
|
|
4163
|
+
required_auths: [],
|
|
4164
|
+
required_posting_auths: [username]
|
|
4165
|
+
}
|
|
4166
|
+
];
|
|
4167
|
+
}
|
|
4168
|
+
function buildPinPostOp(username, community, account, permlink, pin) {
|
|
4169
|
+
if (!username || !community || !account || !permlink || pin === void 0) {
|
|
4170
|
+
throw new Error("[SDK][buildPinPostOp] Missing required parameters");
|
|
4171
|
+
}
|
|
4172
|
+
const action = pin ? "pinPost" : "unpinPost";
|
|
4173
|
+
return [
|
|
4174
|
+
"custom_json",
|
|
4175
|
+
{
|
|
4176
|
+
id: "community",
|
|
4177
|
+
json: JSON.stringify([action, { community, account, permlink }]),
|
|
4178
|
+
required_auths: [],
|
|
4179
|
+
required_posting_auths: [username]
|
|
4180
|
+
}
|
|
4181
|
+
];
|
|
4182
|
+
}
|
|
4183
|
+
function buildMutePostOp(username, community, account, permlink, notes, mute) {
|
|
4184
|
+
if (!username || !community || !account || !permlink || mute === void 0) {
|
|
4185
|
+
throw new Error("[SDK][buildMutePostOp] Missing required parameters");
|
|
4186
|
+
}
|
|
4187
|
+
const action = mute ? "mutePost" : "unmutePost";
|
|
4188
|
+
return [
|
|
4189
|
+
"custom_json",
|
|
4190
|
+
{
|
|
4191
|
+
id: "community",
|
|
4192
|
+
json: JSON.stringify([action, { community, account, permlink, notes }]),
|
|
4193
|
+
required_auths: [],
|
|
4194
|
+
required_posting_auths: [username]
|
|
4195
|
+
}
|
|
4196
|
+
];
|
|
4197
|
+
}
|
|
4198
|
+
function buildMuteUserOp(username, community, account, notes, mute) {
|
|
4199
|
+
if (!username || !community || !account || mute === void 0) {
|
|
4200
|
+
throw new Error("[SDK][buildMuteUserOp] Missing required parameters");
|
|
4201
|
+
}
|
|
4202
|
+
const action = mute ? "muteUser" : "unmuteUser";
|
|
4203
|
+
return [
|
|
4204
|
+
"custom_json",
|
|
4205
|
+
{
|
|
4206
|
+
id: "community",
|
|
4207
|
+
json: JSON.stringify([action, { community, account, notes }]),
|
|
4208
|
+
required_auths: [],
|
|
4209
|
+
required_posting_auths: [username]
|
|
4210
|
+
}
|
|
4211
|
+
];
|
|
4212
|
+
}
|
|
4213
|
+
function buildFlagPostOp(username, community, account, permlink, notes) {
|
|
4214
|
+
if (!username || !community || !account || !permlink) {
|
|
4215
|
+
throw new Error("[SDK][buildFlagPostOp] Missing required parameters");
|
|
4216
|
+
}
|
|
4217
|
+
return [
|
|
4218
|
+
"custom_json",
|
|
4219
|
+
{
|
|
4220
|
+
id: "community",
|
|
4221
|
+
json: JSON.stringify(["flagPost", { community, account, permlink, notes }]),
|
|
4222
|
+
required_auths: [],
|
|
4223
|
+
required_posting_auths: [username]
|
|
4224
|
+
}
|
|
4225
|
+
];
|
|
4226
|
+
}
|
|
4227
|
+
|
|
4228
|
+
// src/modules/operations/builders/market.ts
|
|
4229
|
+
var BuySellTransactionType = /* @__PURE__ */ ((BuySellTransactionType2) => {
|
|
4230
|
+
BuySellTransactionType2["Buy"] = "buy";
|
|
4231
|
+
BuySellTransactionType2["Sell"] = "sell";
|
|
4232
|
+
return BuySellTransactionType2;
|
|
4233
|
+
})(BuySellTransactionType || {});
|
|
4234
|
+
var OrderIdPrefix = /* @__PURE__ */ ((OrderIdPrefix2) => {
|
|
4235
|
+
OrderIdPrefix2["EMPTY"] = "";
|
|
4236
|
+
OrderIdPrefix2["SWAP"] = "9";
|
|
4237
|
+
return OrderIdPrefix2;
|
|
4238
|
+
})(OrderIdPrefix || {});
|
|
4239
|
+
function buildLimitOrderCreateOp(owner, amountToSell, minToReceive, fillOrKill, expiration, orderId) {
|
|
4240
|
+
if (!owner || !amountToSell || !minToReceive || !expiration || orderId === void 0) {
|
|
4241
|
+
throw new Error("[SDK][buildLimitOrderCreateOp] Missing required parameters");
|
|
4242
|
+
}
|
|
4243
|
+
return [
|
|
4244
|
+
"limit_order_create",
|
|
4245
|
+
{
|
|
4246
|
+
owner,
|
|
4247
|
+
orderid: orderId,
|
|
4248
|
+
amount_to_sell: amountToSell,
|
|
4249
|
+
min_to_receive: minToReceive,
|
|
4250
|
+
fill_or_kill: fillOrKill,
|
|
4251
|
+
expiration
|
|
4252
|
+
}
|
|
4253
|
+
];
|
|
4254
|
+
}
|
|
4255
|
+
function formatNumber(value, decimals = 3) {
|
|
4256
|
+
return value.toFixed(decimals);
|
|
4257
|
+
}
|
|
4258
|
+
function buildLimitOrderCreateOpWithType(owner, amountToSell, minToReceive, orderType, idPrefix = "" /* EMPTY */) {
|
|
4259
|
+
if (!owner || orderType === void 0 || !Number.isFinite(amountToSell) || amountToSell <= 0 || !Number.isFinite(minToReceive) || minToReceive <= 0) {
|
|
4260
|
+
throw new Error("[SDK][buildLimitOrderCreateOpWithType] Missing or invalid parameters");
|
|
4261
|
+
}
|
|
4262
|
+
const expiration = new Date(Date.now());
|
|
4263
|
+
expiration.setDate(expiration.getDate() + 27);
|
|
4264
|
+
const expirationStr = expiration.toISOString().split(".")[0];
|
|
4265
|
+
const orderId = Number(
|
|
4266
|
+
`${idPrefix}${Math.floor(Date.now() / 1e3).toString().slice(2)}`
|
|
4267
|
+
);
|
|
4268
|
+
const formattedAmountToSell = orderType === "buy" /* Buy */ ? `${formatNumber(amountToSell, 3)} HBD` : `${formatNumber(amountToSell, 3)} HIVE`;
|
|
4269
|
+
const formattedMinToReceive = orderType === "buy" /* Buy */ ? `${formatNumber(minToReceive, 3)} HIVE` : `${formatNumber(minToReceive, 3)} HBD`;
|
|
4270
|
+
return buildLimitOrderCreateOp(
|
|
4271
|
+
owner,
|
|
4272
|
+
formattedAmountToSell,
|
|
4273
|
+
formattedMinToReceive,
|
|
4274
|
+
false,
|
|
4275
|
+
expirationStr,
|
|
4276
|
+
orderId
|
|
4277
|
+
);
|
|
4278
|
+
}
|
|
4279
|
+
function buildLimitOrderCancelOp(owner, orderId) {
|
|
4280
|
+
if (!owner || orderId === void 0) {
|
|
4281
|
+
throw new Error("[SDK][buildLimitOrderCancelOp] Missing required parameters");
|
|
4282
|
+
}
|
|
4283
|
+
return [
|
|
4284
|
+
"limit_order_cancel",
|
|
4285
|
+
{
|
|
4286
|
+
owner,
|
|
4287
|
+
orderid: orderId
|
|
4288
|
+
}
|
|
4289
|
+
];
|
|
4290
|
+
}
|
|
4291
|
+
function buildClaimRewardBalanceOp(account, rewardHive, rewardHbd, rewardVests) {
|
|
4292
|
+
if (!account || !rewardHive || !rewardHbd || !rewardVests) {
|
|
4293
|
+
throw new Error("[SDK][buildClaimRewardBalanceOp] Missing required parameters");
|
|
4294
|
+
}
|
|
4295
|
+
return [
|
|
4296
|
+
"claim_reward_balance",
|
|
4297
|
+
{
|
|
4298
|
+
account,
|
|
4299
|
+
reward_hive: rewardHive,
|
|
4300
|
+
reward_hbd: rewardHbd,
|
|
4301
|
+
reward_vests: rewardVests
|
|
4302
|
+
}
|
|
4303
|
+
];
|
|
4304
|
+
}
|
|
4305
|
+
|
|
4306
|
+
// src/modules/operations/builders/account.ts
|
|
4307
|
+
function buildAccountUpdateOp(account, owner, active, posting, memoKey, jsonMetadata) {
|
|
4308
|
+
if (!account || !memoKey) {
|
|
4309
|
+
throw new Error("[SDK][buildAccountUpdateOp] Missing required parameters");
|
|
4310
|
+
}
|
|
4311
|
+
return [
|
|
4312
|
+
"account_update",
|
|
4313
|
+
{
|
|
4314
|
+
account,
|
|
4315
|
+
owner,
|
|
4316
|
+
active,
|
|
4317
|
+
posting,
|
|
4318
|
+
memo_key: memoKey,
|
|
4319
|
+
json_metadata: jsonMetadata
|
|
4320
|
+
}
|
|
4321
|
+
];
|
|
4322
|
+
}
|
|
4323
|
+
function buildAccountUpdate2Op(account, jsonMetadata, postingJsonMetadata, extensions) {
|
|
4324
|
+
if (!account || postingJsonMetadata === void 0) {
|
|
4325
|
+
throw new Error("[SDK][buildAccountUpdate2Op] Missing required parameters");
|
|
4326
|
+
}
|
|
4327
|
+
return [
|
|
4328
|
+
"account_update2",
|
|
4329
|
+
{
|
|
4330
|
+
account,
|
|
4331
|
+
json_metadata: jsonMetadata || "",
|
|
4332
|
+
posting_json_metadata: postingJsonMetadata,
|
|
4333
|
+
extensions: extensions || []
|
|
4334
|
+
}
|
|
4335
|
+
];
|
|
4336
|
+
}
|
|
4337
|
+
function buildAccountCreateOp(creator, newAccountName, keys, fee) {
|
|
4338
|
+
if (!creator || !newAccountName || !keys || !fee) {
|
|
4339
|
+
throw new Error("[SDK][buildAccountCreateOp] Missing required parameters");
|
|
4340
|
+
}
|
|
4341
|
+
const owner = {
|
|
4342
|
+
weight_threshold: 1,
|
|
4343
|
+
account_auths: [],
|
|
4344
|
+
key_auths: [[keys.ownerPublicKey, 1]]
|
|
4345
|
+
};
|
|
4346
|
+
const active = {
|
|
4347
|
+
weight_threshold: 1,
|
|
4348
|
+
account_auths: [],
|
|
4349
|
+
key_auths: [[keys.activePublicKey, 1]]
|
|
4350
|
+
};
|
|
4351
|
+
const posting = {
|
|
4352
|
+
weight_threshold: 1,
|
|
4353
|
+
account_auths: [["ecency.app", 1]],
|
|
4354
|
+
key_auths: [[keys.postingPublicKey, 1]]
|
|
4355
|
+
};
|
|
4356
|
+
return [
|
|
4357
|
+
"account_create",
|
|
4358
|
+
{
|
|
4359
|
+
creator,
|
|
4360
|
+
new_account_name: newAccountName,
|
|
4361
|
+
owner,
|
|
4362
|
+
active,
|
|
4363
|
+
posting,
|
|
4364
|
+
memo_key: keys.memoPublicKey,
|
|
4365
|
+
json_metadata: "",
|
|
4366
|
+
extensions: [],
|
|
4367
|
+
fee
|
|
4368
|
+
}
|
|
4369
|
+
];
|
|
4370
|
+
}
|
|
4371
|
+
function buildCreateClaimedAccountOp(creator, newAccountName, keys) {
|
|
4372
|
+
if (!creator || !newAccountName || !keys) {
|
|
4373
|
+
throw new Error("[SDK][buildCreateClaimedAccountOp] Missing required parameters");
|
|
4374
|
+
}
|
|
4375
|
+
const owner = {
|
|
4376
|
+
weight_threshold: 1,
|
|
4377
|
+
account_auths: [],
|
|
4378
|
+
key_auths: [[keys.ownerPublicKey, 1]]
|
|
4379
|
+
};
|
|
4380
|
+
const active = {
|
|
4381
|
+
weight_threshold: 1,
|
|
4382
|
+
account_auths: [],
|
|
4383
|
+
key_auths: [[keys.activePublicKey, 1]]
|
|
4384
|
+
};
|
|
4385
|
+
const posting = {
|
|
4386
|
+
weight_threshold: 1,
|
|
4387
|
+
account_auths: [["ecency.app", 1]],
|
|
4388
|
+
key_auths: [[keys.postingPublicKey, 1]]
|
|
4389
|
+
};
|
|
4390
|
+
return [
|
|
4391
|
+
"create_claimed_account",
|
|
4392
|
+
{
|
|
4393
|
+
creator,
|
|
4394
|
+
new_account_name: newAccountName,
|
|
4395
|
+
owner,
|
|
4396
|
+
active,
|
|
4397
|
+
posting,
|
|
4398
|
+
memo_key: keys.memoPublicKey,
|
|
4399
|
+
json_metadata: "",
|
|
4400
|
+
extensions: []
|
|
4401
|
+
}
|
|
4402
|
+
];
|
|
4403
|
+
}
|
|
4404
|
+
function buildClaimAccountOp(creator, fee) {
|
|
4405
|
+
if (!creator || !fee) {
|
|
4406
|
+
throw new Error("[SDK][buildClaimAccountOp] Missing required parameters");
|
|
4407
|
+
}
|
|
4408
|
+
return [
|
|
4409
|
+
"claim_account",
|
|
4410
|
+
{
|
|
4411
|
+
creator,
|
|
4412
|
+
fee,
|
|
4413
|
+
extensions: []
|
|
4414
|
+
}
|
|
4415
|
+
];
|
|
4416
|
+
}
|
|
4417
|
+
function buildGrantPostingPermissionOp(account, currentPosting, grantedAccount, weightThreshold, memoKey, jsonMetadata) {
|
|
4418
|
+
if (!account || !currentPosting || !grantedAccount || !memoKey) {
|
|
4419
|
+
throw new Error("[SDK][buildGrantPostingPermissionOp] Missing required parameters");
|
|
4420
|
+
}
|
|
4421
|
+
const existingIndex = currentPosting.account_auths.findIndex(
|
|
4422
|
+
([acc]) => acc === grantedAccount
|
|
4423
|
+
);
|
|
4424
|
+
const newAccountAuths = [...currentPosting.account_auths];
|
|
4425
|
+
if (existingIndex >= 0) {
|
|
4426
|
+
newAccountAuths[existingIndex] = [grantedAccount, weightThreshold];
|
|
4427
|
+
} else {
|
|
4428
|
+
newAccountAuths.push([grantedAccount, weightThreshold]);
|
|
4429
|
+
}
|
|
4430
|
+
const newPosting = {
|
|
4431
|
+
...currentPosting,
|
|
4432
|
+
account_auths: newAccountAuths
|
|
4433
|
+
};
|
|
4434
|
+
newPosting.account_auths.sort((a, b) => a[0] > b[0] ? 1 : -1);
|
|
4435
|
+
return [
|
|
4436
|
+
"account_update",
|
|
4437
|
+
{
|
|
4438
|
+
account,
|
|
4439
|
+
posting: newPosting,
|
|
4440
|
+
memo_key: memoKey,
|
|
4441
|
+
json_metadata: jsonMetadata
|
|
4442
|
+
}
|
|
4443
|
+
];
|
|
4444
|
+
}
|
|
4445
|
+
function buildRevokePostingPermissionOp(account, currentPosting, revokedAccount, memoKey, jsonMetadata) {
|
|
4446
|
+
if (!account || !currentPosting || !revokedAccount || !memoKey) {
|
|
4447
|
+
throw new Error("[SDK][buildRevokePostingPermissionOp] Missing required parameters");
|
|
4448
|
+
}
|
|
4449
|
+
const newPosting = {
|
|
4450
|
+
...currentPosting,
|
|
4451
|
+
account_auths: currentPosting.account_auths.filter(
|
|
4452
|
+
([acc]) => acc !== revokedAccount
|
|
4453
|
+
)
|
|
4454
|
+
};
|
|
4455
|
+
return [
|
|
4456
|
+
"account_update",
|
|
4457
|
+
{
|
|
4458
|
+
account,
|
|
4459
|
+
posting: newPosting,
|
|
4460
|
+
memo_key: memoKey,
|
|
4461
|
+
json_metadata: jsonMetadata
|
|
4462
|
+
}
|
|
4463
|
+
];
|
|
4464
|
+
}
|
|
4465
|
+
function buildChangeRecoveryAccountOp(accountToRecover, newRecoveryAccount, extensions = []) {
|
|
4466
|
+
if (!accountToRecover || !newRecoveryAccount) {
|
|
4467
|
+
throw new Error("[SDK][buildChangeRecoveryAccountOp] Missing required parameters");
|
|
4468
|
+
}
|
|
4469
|
+
return [
|
|
4470
|
+
"change_recovery_account",
|
|
4471
|
+
{
|
|
4472
|
+
account_to_recover: accountToRecover,
|
|
4473
|
+
new_recovery_account: newRecoveryAccount,
|
|
4474
|
+
extensions
|
|
4475
|
+
}
|
|
4476
|
+
];
|
|
4477
|
+
}
|
|
4478
|
+
function buildRequestAccountRecoveryOp(recoveryAccount, accountToRecover, newOwnerAuthority, extensions = []) {
|
|
4479
|
+
if (!recoveryAccount || !accountToRecover || !newOwnerAuthority) {
|
|
4480
|
+
throw new Error("[SDK][buildRequestAccountRecoveryOp] Missing required parameters");
|
|
4481
|
+
}
|
|
4482
|
+
return [
|
|
4483
|
+
"request_account_recovery",
|
|
4484
|
+
{
|
|
4485
|
+
recovery_account: recoveryAccount,
|
|
4486
|
+
account_to_recover: accountToRecover,
|
|
4487
|
+
new_owner_authority: newOwnerAuthority,
|
|
4488
|
+
extensions
|
|
4489
|
+
}
|
|
4490
|
+
];
|
|
4491
|
+
}
|
|
4492
|
+
function buildRecoverAccountOp(accountToRecover, newOwnerAuthority, recentOwnerAuthority, extensions = []) {
|
|
4493
|
+
if (!accountToRecover || !newOwnerAuthority || !recentOwnerAuthority) {
|
|
4494
|
+
throw new Error("[SDK][buildRecoverAccountOp] Missing required parameters");
|
|
4495
|
+
}
|
|
4496
|
+
return [
|
|
4497
|
+
"recover_account",
|
|
4498
|
+
{
|
|
4499
|
+
account_to_recover: accountToRecover,
|
|
4500
|
+
new_owner_authority: newOwnerAuthority,
|
|
4501
|
+
recent_owner_authority: recentOwnerAuthority,
|
|
4502
|
+
extensions
|
|
4503
|
+
}
|
|
4504
|
+
];
|
|
4505
|
+
}
|
|
4506
|
+
|
|
4507
|
+
// src/modules/operations/builders/ecency.ts
|
|
4508
|
+
function buildBoostOp(user, author, permlink, amount) {
|
|
4509
|
+
if (!user || !author || !permlink || !amount) {
|
|
4510
|
+
throw new Error("[SDK][buildBoostOp] Missing required parameters");
|
|
4511
|
+
}
|
|
4512
|
+
return [
|
|
4513
|
+
"custom_json",
|
|
4514
|
+
{
|
|
4515
|
+
id: "ecency_boost",
|
|
4516
|
+
json: JSON.stringify({
|
|
4517
|
+
user,
|
|
4518
|
+
author,
|
|
4519
|
+
permlink,
|
|
4520
|
+
amount
|
|
4521
|
+
}),
|
|
4522
|
+
required_auths: [user],
|
|
4523
|
+
required_posting_auths: []
|
|
4524
|
+
}
|
|
4525
|
+
];
|
|
4526
|
+
}
|
|
4527
|
+
function buildBoostOpWithPoints(user, author, permlink, points) {
|
|
4528
|
+
if (!user || !author || !permlink || !Number.isFinite(points)) {
|
|
4529
|
+
throw new Error("[SDK][buildBoostOpWithPoints] Missing required parameters");
|
|
4530
|
+
}
|
|
4531
|
+
return buildBoostOp(user, author, permlink, `${points.toFixed(3)} POINT`);
|
|
4532
|
+
}
|
|
4533
|
+
function buildBoostPlusOp(user, account, duration) {
|
|
4534
|
+
if (!user || !account || !Number.isFinite(duration)) {
|
|
4535
|
+
throw new Error("[SDK][buildBoostPlusOp] Missing required parameters");
|
|
4536
|
+
}
|
|
4537
|
+
return [
|
|
4538
|
+
"custom_json",
|
|
4539
|
+
{
|
|
4540
|
+
id: "ecency_boost_plus",
|
|
4541
|
+
json: JSON.stringify({
|
|
4542
|
+
user,
|
|
4543
|
+
account,
|
|
4544
|
+
duration
|
|
4545
|
+
}),
|
|
4546
|
+
required_auths: [user],
|
|
4547
|
+
required_posting_auths: []
|
|
4548
|
+
}
|
|
4549
|
+
];
|
|
4550
|
+
}
|
|
4551
|
+
function buildPromoteOp(user, author, permlink, duration) {
|
|
4552
|
+
if (!user || !author || !permlink || !Number.isFinite(duration)) {
|
|
4553
|
+
throw new Error("[SDK][buildPromoteOp] Missing required parameters");
|
|
4554
|
+
}
|
|
4555
|
+
return [
|
|
4556
|
+
"custom_json",
|
|
4557
|
+
{
|
|
4558
|
+
id: "ecency_promote",
|
|
4559
|
+
json: JSON.stringify({
|
|
4560
|
+
user,
|
|
4561
|
+
author,
|
|
4562
|
+
permlink,
|
|
4563
|
+
duration
|
|
4564
|
+
}),
|
|
4565
|
+
required_auths: [user],
|
|
4566
|
+
required_posting_auths: []
|
|
4567
|
+
}
|
|
4568
|
+
];
|
|
4569
|
+
}
|
|
4570
|
+
function buildPointTransferOp(sender, receiver, amount, memo) {
|
|
4571
|
+
if (!sender || !receiver || !amount) {
|
|
4572
|
+
throw new Error("[SDK][buildPointTransferOp] Missing required parameters");
|
|
4573
|
+
}
|
|
4574
|
+
return [
|
|
4575
|
+
"custom_json",
|
|
4576
|
+
{
|
|
4577
|
+
id: "ecency_point_transfer",
|
|
4578
|
+
json: JSON.stringify({
|
|
4579
|
+
sender,
|
|
4580
|
+
receiver,
|
|
4581
|
+
amount,
|
|
4582
|
+
memo: memo || ""
|
|
4583
|
+
}),
|
|
4584
|
+
required_auths: [sender],
|
|
4585
|
+
required_posting_auths: []
|
|
4586
|
+
}
|
|
4587
|
+
];
|
|
4588
|
+
}
|
|
4589
|
+
function buildMultiPointTransferOps(sender, destinations, amount, memo) {
|
|
4590
|
+
if (!sender || !destinations || !amount) {
|
|
4591
|
+
throw new Error("[SDK][buildMultiPointTransferOps] Missing required parameters");
|
|
4592
|
+
}
|
|
4593
|
+
const destArray = destinations.trim().split(/[\s,]+/).filter(Boolean);
|
|
4594
|
+
if (destArray.length === 0) {
|
|
4595
|
+
throw new Error("[SDK][buildMultiPointTransferOps] Missing valid destinations");
|
|
4596
|
+
}
|
|
4597
|
+
return destArray.map(
|
|
4598
|
+
(dest) => buildPointTransferOp(sender, dest.trim(), amount, memo)
|
|
4599
|
+
);
|
|
4600
|
+
}
|
|
4601
|
+
function buildCommunityRegistrationOp(name) {
|
|
4602
|
+
if (!name) {
|
|
4603
|
+
throw new Error("[SDK][buildCommunityRegistrationOp] Missing required parameters");
|
|
4604
|
+
}
|
|
4605
|
+
return [
|
|
4606
|
+
"custom_json",
|
|
4607
|
+
{
|
|
4608
|
+
id: "ecency_registration",
|
|
4609
|
+
json: JSON.stringify({
|
|
4610
|
+
name
|
|
4611
|
+
}),
|
|
4612
|
+
required_auths: [name],
|
|
4613
|
+
required_posting_auths: []
|
|
4614
|
+
}
|
|
4615
|
+
];
|
|
4616
|
+
}
|
|
4617
|
+
function buildActiveCustomJsonOp(username, operationId, json) {
|
|
4618
|
+
if (!username || !operationId || !json) {
|
|
4619
|
+
throw new Error("[SDK][buildActiveCustomJsonOp] Missing required parameters");
|
|
4620
|
+
}
|
|
4621
|
+
return [
|
|
4622
|
+
"custom_json",
|
|
4623
|
+
{
|
|
4624
|
+
id: operationId,
|
|
4625
|
+
json: JSON.stringify(json),
|
|
4626
|
+
required_auths: [username],
|
|
4627
|
+
required_posting_auths: []
|
|
4628
|
+
}
|
|
4629
|
+
];
|
|
4630
|
+
}
|
|
4631
|
+
function buildPostingCustomJsonOp(username, operationId, json) {
|
|
4632
|
+
if (!username || !operationId || !json) {
|
|
4633
|
+
throw new Error("[SDK][buildPostingCustomJsonOp] Missing required parameters");
|
|
4634
|
+
}
|
|
4635
|
+
return [
|
|
4636
|
+
"custom_json",
|
|
4637
|
+
{
|
|
4638
|
+
id: operationId,
|
|
4639
|
+
json: JSON.stringify(json),
|
|
4640
|
+
required_auths: [],
|
|
4641
|
+
required_posting_auths: [username]
|
|
4642
|
+
}
|
|
4643
|
+
];
|
|
4644
|
+
}
|
|
4645
|
+
function useSignOperationByKey(username) {
|
|
4646
|
+
return useMutation({
|
|
4647
|
+
mutationKey: ["operations", "sign", username],
|
|
4648
|
+
mutationFn: ({
|
|
4649
|
+
operation,
|
|
4650
|
+
keyOrSeed
|
|
4651
|
+
}) => {
|
|
4652
|
+
if (!username) {
|
|
4653
|
+
throw new Error("[Operations][Sign] \u2013 cannot sign op with anon user");
|
|
4654
|
+
}
|
|
4655
|
+
let privateKey;
|
|
4656
|
+
if (keyOrSeed.split(" ").length === 12) {
|
|
4657
|
+
privateKey = PrivateKey.fromLogin(username, keyOrSeed, "active");
|
|
4658
|
+
} else if (cryptoUtils.isWif(keyOrSeed)) {
|
|
4659
|
+
privateKey = PrivateKey.fromString(keyOrSeed);
|
|
4660
|
+
} else {
|
|
4661
|
+
privateKey = PrivateKey.from(keyOrSeed);
|
|
4662
|
+
}
|
|
4663
|
+
return CONFIG.hiveClient.broadcast.sendOperations(
|
|
4664
|
+
[operation],
|
|
4665
|
+
privateKey
|
|
4666
|
+
);
|
|
4667
|
+
}
|
|
4668
|
+
});
|
|
4669
|
+
}
|
|
4670
|
+
function useSignOperationByKeychain(username, auth, keyType = "active") {
|
|
4671
|
+
return useMutation({
|
|
4672
|
+
mutationKey: ["operations", "sign-keychain", username],
|
|
4673
|
+
mutationFn: ({ operation }) => {
|
|
4674
|
+
if (!username) {
|
|
4675
|
+
throw new Error(
|
|
4676
|
+
"[SDK][Keychain] \u2013\xA0cannot sign operation with anon user"
|
|
4677
|
+
);
|
|
4678
|
+
}
|
|
4679
|
+
if (!auth?.broadcast) {
|
|
4680
|
+
throw new Error("[SDK][Keychain] \u2013 missing keychain broadcaster");
|
|
4681
|
+
}
|
|
4682
|
+
return auth.broadcast([operation], keyType);
|
|
4683
|
+
}
|
|
4684
|
+
});
|
|
4685
|
+
}
|
|
4686
|
+
function useSignOperationByHivesigner(callbackUri = "/") {
|
|
4687
|
+
return useMutation({
|
|
4688
|
+
mutationKey: ["operations", "sign-hivesigner", callbackUri],
|
|
4689
|
+
mutationFn: async ({ operation }) => {
|
|
4690
|
+
return hs.sendOperation(operation, { callback: callbackUri }, () => {
|
|
4691
|
+
});
|
|
4692
|
+
}
|
|
4693
|
+
});
|
|
4694
|
+
}
|
|
4695
|
+
function getChainPropertiesQueryOptions() {
|
|
4696
|
+
return queryOptions({
|
|
4697
|
+
queryKey: ["operations", "chain-properties"],
|
|
4698
|
+
queryFn: async () => {
|
|
4699
|
+
return await CONFIG.hiveClient.database.getChainProperties();
|
|
4700
|
+
}
|
|
4701
|
+
});
|
|
4702
|
+
}
|
|
4703
|
+
function useAddFragment(username, code) {
|
|
4704
|
+
return useMutation({
|
|
4705
|
+
mutationKey: ["posts", "add-fragment", username],
|
|
4706
|
+
mutationFn: async ({ title, body }) => {
|
|
4707
|
+
if (!code) {
|
|
4708
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
4709
|
+
}
|
|
4710
|
+
const fetchApi = getBoundFetch();
|
|
4711
|
+
const response = await fetchApi(
|
|
4712
|
+
CONFIG.privateApiHost + "/private-api/fragments-add",
|
|
4713
|
+
{
|
|
4714
|
+
method: "POST",
|
|
4715
|
+
body: JSON.stringify({
|
|
4716
|
+
code,
|
|
4717
|
+
title,
|
|
4718
|
+
body
|
|
4719
|
+
}),
|
|
4720
|
+
headers: {
|
|
4721
|
+
"Content-Type": "application/json"
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4724
|
+
);
|
|
4725
|
+
return response.json();
|
|
4726
|
+
},
|
|
4727
|
+
onSuccess(response) {
|
|
4728
|
+
const queryClient = getQueryClient();
|
|
4729
|
+
queryClient.setQueryData(
|
|
4730
|
+
getFragmentsQueryOptions(username, code).queryKey,
|
|
4731
|
+
(data) => [response, ...data ?? []]
|
|
4732
|
+
);
|
|
4733
|
+
queryClient.setQueriesData(
|
|
4734
|
+
{ queryKey: ["posts", "fragments", "infinite", username] },
|
|
4735
|
+
(oldData) => {
|
|
4736
|
+
if (!oldData) return oldData;
|
|
4737
|
+
return {
|
|
4738
|
+
...oldData,
|
|
4739
|
+
pages: oldData.pages.map(
|
|
4740
|
+
(page, index) => index === 0 ? { ...page, data: [response, ...page.data] } : page
|
|
4741
|
+
)
|
|
4742
|
+
};
|
|
4743
|
+
}
|
|
4744
|
+
);
|
|
4745
|
+
}
|
|
4746
|
+
});
|
|
4747
|
+
}
|
|
4748
|
+
function useEditFragment(username, code) {
|
|
4749
|
+
return useMutation({
|
|
4750
|
+
mutationKey: ["posts", "edit-fragment", username],
|
|
4751
|
+
mutationFn: async ({
|
|
4752
|
+
fragmentId,
|
|
4753
|
+
title,
|
|
4754
|
+
body
|
|
4755
|
+
}) => {
|
|
4756
|
+
if (!code) {
|
|
4757
|
+
throw new Error("[SDK][Posts] Missing access token");
|
|
4758
|
+
}
|
|
4759
|
+
const fetchApi = getBoundFetch();
|
|
4760
|
+
const response = await fetchApi(
|
|
4761
|
+
CONFIG.privateApiHost + "/private-api/fragments-update",
|
|
3441
4762
|
{
|
|
3442
4763
|
method: "POST",
|
|
3443
4764
|
body: JSON.stringify({
|
|
@@ -3998,6 +5319,136 @@ function useUploadImage(onSuccess, onError) {
|
|
|
3998
5319
|
});
|
|
3999
5320
|
}
|
|
4000
5321
|
|
|
5322
|
+
// src/modules/posts/mutations/use-vote.ts
|
|
5323
|
+
function useVote(username, auth) {
|
|
5324
|
+
return useBroadcastMutation(
|
|
5325
|
+
["posts", "vote"],
|
|
5326
|
+
username,
|
|
5327
|
+
({ author, permlink, weight }) => [
|
|
5328
|
+
buildVoteOp(username, author, permlink, weight)
|
|
5329
|
+
],
|
|
5330
|
+
async (result, variables) => {
|
|
5331
|
+
if (auth?.adapter?.recordActivity && result?.block_num && result?.id) {
|
|
5332
|
+
await auth.adapter.recordActivity(120, result.block_num, result.id);
|
|
5333
|
+
}
|
|
5334
|
+
if (auth?.adapter?.invalidateQueries) {
|
|
5335
|
+
await auth.adapter.invalidateQueries([
|
|
5336
|
+
["posts", "entry", `/@${variables.author}/${variables.permlink}`],
|
|
5337
|
+
["account", username, "votingPower"]
|
|
5338
|
+
]);
|
|
5339
|
+
}
|
|
5340
|
+
},
|
|
5341
|
+
auth
|
|
5342
|
+
);
|
|
5343
|
+
}
|
|
5344
|
+
|
|
5345
|
+
// src/modules/posts/mutations/use-reblog.ts
|
|
5346
|
+
function useReblog(username, auth) {
|
|
5347
|
+
return useBroadcastMutation(
|
|
5348
|
+
["posts", "reblog"],
|
|
5349
|
+
username,
|
|
5350
|
+
({ author, permlink, deleteReblog }) => [
|
|
5351
|
+
buildReblogOp(username, author, permlink, deleteReblog ?? false)
|
|
5352
|
+
],
|
|
5353
|
+
async (result, variables) => {
|
|
5354
|
+
if (auth?.adapter?.recordActivity && result?.block_num && result?.id) {
|
|
5355
|
+
await auth.adapter.recordActivity(130, result.block_num, result.id);
|
|
5356
|
+
}
|
|
5357
|
+
if (auth?.adapter?.invalidateQueries) {
|
|
5358
|
+
await auth.adapter.invalidateQueries([
|
|
5359
|
+
["posts", "blog", username],
|
|
5360
|
+
["posts", "entry", `/@${variables.author}/${variables.permlink}`]
|
|
5361
|
+
]);
|
|
5362
|
+
}
|
|
5363
|
+
},
|
|
5364
|
+
auth
|
|
5365
|
+
);
|
|
5366
|
+
}
|
|
5367
|
+
|
|
5368
|
+
// src/modules/posts/mutations/use-comment.ts
|
|
5369
|
+
function useComment(username, auth) {
|
|
5370
|
+
return useBroadcastMutation(
|
|
5371
|
+
["posts", "comment"],
|
|
5372
|
+
username,
|
|
5373
|
+
(payload) => {
|
|
5374
|
+
const operations = [];
|
|
5375
|
+
operations.push(
|
|
5376
|
+
buildCommentOp(
|
|
5377
|
+
payload.author,
|
|
5378
|
+
payload.permlink,
|
|
5379
|
+
payload.parentAuthor,
|
|
5380
|
+
payload.parentPermlink,
|
|
5381
|
+
payload.title,
|
|
5382
|
+
payload.body,
|
|
5383
|
+
payload.jsonMetadata
|
|
5384
|
+
)
|
|
5385
|
+
);
|
|
5386
|
+
if (payload.options) {
|
|
5387
|
+
const {
|
|
5388
|
+
maxAcceptedPayout = "1000000.000 HBD",
|
|
5389
|
+
percentHbd = 1e4,
|
|
5390
|
+
allowVotes = true,
|
|
5391
|
+
allowCurationRewards = true,
|
|
5392
|
+
beneficiaries = []
|
|
5393
|
+
} = payload.options;
|
|
5394
|
+
const extensions = [];
|
|
5395
|
+
if (beneficiaries.length > 0) {
|
|
5396
|
+
const sortedBeneficiaries = [...beneficiaries].sort(
|
|
5397
|
+
(a, b) => a.account.localeCompare(b.account)
|
|
5398
|
+
);
|
|
5399
|
+
extensions.push([
|
|
5400
|
+
0,
|
|
5401
|
+
{
|
|
5402
|
+
beneficiaries: sortedBeneficiaries.map((b) => ({
|
|
5403
|
+
account: b.account,
|
|
5404
|
+
weight: b.weight
|
|
5405
|
+
}))
|
|
5406
|
+
}
|
|
5407
|
+
]);
|
|
5408
|
+
}
|
|
5409
|
+
operations.push(
|
|
5410
|
+
buildCommentOptionsOp(
|
|
5411
|
+
payload.author,
|
|
5412
|
+
payload.permlink,
|
|
5413
|
+
maxAcceptedPayout,
|
|
5414
|
+
percentHbd,
|
|
5415
|
+
allowVotes,
|
|
5416
|
+
allowCurationRewards,
|
|
5417
|
+
extensions
|
|
5418
|
+
)
|
|
5419
|
+
);
|
|
5420
|
+
}
|
|
5421
|
+
return operations;
|
|
5422
|
+
},
|
|
5423
|
+
async (result, variables) => {
|
|
5424
|
+
const isPost = !variables.parentAuthor;
|
|
5425
|
+
const activityType = isPost ? 100 : 110;
|
|
5426
|
+
if (auth?.adapter?.recordActivity && result?.block_num && result?.id) {
|
|
5427
|
+
try {
|
|
5428
|
+
await auth.adapter.recordActivity(activityType, result.block_num, result.id);
|
|
5429
|
+
} catch (err) {
|
|
5430
|
+
console.warn("[useComment] Failed to record activity:", err);
|
|
5431
|
+
}
|
|
5432
|
+
}
|
|
5433
|
+
if (auth?.adapter?.invalidateQueries) {
|
|
5434
|
+
const queriesToInvalidate = [
|
|
5435
|
+
["posts", "feed", username],
|
|
5436
|
+
["posts", "blog", username]
|
|
5437
|
+
];
|
|
5438
|
+
if (!isPost) {
|
|
5439
|
+
queriesToInvalidate.push([
|
|
5440
|
+
"posts",
|
|
5441
|
+
"entry",
|
|
5442
|
+
`/@${variables.parentAuthor}/${variables.parentPermlink}`
|
|
5443
|
+
]);
|
|
5444
|
+
}
|
|
5445
|
+
await auth.adapter.invalidateQueries(queriesToInvalidate);
|
|
5446
|
+
}
|
|
5447
|
+
},
|
|
5448
|
+
auth
|
|
5449
|
+
);
|
|
5450
|
+
}
|
|
5451
|
+
|
|
4001
5452
|
// src/modules/posts/utils/validate-post-creating.ts
|
|
4002
5453
|
var DEFAULT_VALIDATE_POST_DELAYS = [3e3, 3e3, 3e3];
|
|
4003
5454
|
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -4112,8 +5563,10 @@ function getDiscoverCurationQueryOptions(duration) {
|
|
|
4112
5563
|
});
|
|
4113
5564
|
}
|
|
4114
5565
|
function getPageStatsQueryOptions(url, dimensions = [], metrics = ["visitors", "pageviews", "visit_duration"], dateRange) {
|
|
5566
|
+
const sortedDimensions = [...dimensions].sort();
|
|
5567
|
+
const sortedMetrics = [...metrics].sort();
|
|
4115
5568
|
return queryOptions({
|
|
4116
|
-
queryKey: ["analytics", "page-stats", url,
|
|
5569
|
+
queryKey: ["analytics", "page-stats", url, sortedDimensions, sortedMetrics, dateRange],
|
|
4117
5570
|
queryFn: async ({ signal }) => {
|
|
4118
5571
|
const response = await fetch(CONFIG.privateApiHost + "/api/stats", {
|
|
4119
5572
|
method: "POST",
|
|
@@ -4133,7 +5586,9 @@ function getPageStatsQueryOptions(url, dimensions = [], metrics = ["visitors", "
|
|
|
4133
5586
|
}
|
|
4134
5587
|
return response.json();
|
|
4135
5588
|
},
|
|
4136
|
-
enabled: !!url
|
|
5589
|
+
enabled: !!url,
|
|
5590
|
+
// Analytics data should always be fresh - users expect current stats when changing range
|
|
5591
|
+
staleTime: 0
|
|
4137
5592
|
});
|
|
4138
5593
|
}
|
|
4139
5594
|
|
|
@@ -4855,6 +6310,35 @@ function getUserProposalVotesQueryOptions(voter) {
|
|
|
4855
6310
|
}
|
|
4856
6311
|
});
|
|
4857
6312
|
}
|
|
6313
|
+
|
|
6314
|
+
// src/modules/proposals/mutations/use-proposal-vote.ts
|
|
6315
|
+
function useProposalVote(username, auth) {
|
|
6316
|
+
return useBroadcastMutation(
|
|
6317
|
+
["proposals", "vote"],
|
|
6318
|
+
username,
|
|
6319
|
+
({ proposalIds, approve }) => [
|
|
6320
|
+
buildProposalVoteOp(username, proposalIds, approve)
|
|
6321
|
+
],
|
|
6322
|
+
async (result) => {
|
|
6323
|
+
try {
|
|
6324
|
+
if (auth?.adapter?.recordActivity && result?.block_num && result?.id) {
|
|
6325
|
+
await auth.adapter.recordActivity(150, result.block_num, result.id);
|
|
6326
|
+
}
|
|
6327
|
+
if (auth?.adapter?.invalidateQueries) {
|
|
6328
|
+
await auth.adapter.invalidateQueries([
|
|
6329
|
+
["proposals", "list"],
|
|
6330
|
+
["proposals", "votes", username]
|
|
6331
|
+
]);
|
|
6332
|
+
}
|
|
6333
|
+
} catch (error) {
|
|
6334
|
+
console.warn("[useProposalVote] Post-broadcast side-effect failed:", error);
|
|
6335
|
+
}
|
|
6336
|
+
},
|
|
6337
|
+
auth,
|
|
6338
|
+
"active"
|
|
6339
|
+
// Use active authority for proposal votes (required by blockchain)
|
|
6340
|
+
);
|
|
6341
|
+
}
|
|
4858
6342
|
function getVestingDelegationsQueryOptions(username, limit = 50) {
|
|
4859
6343
|
return infiniteQueryOptions({
|
|
4860
6344
|
queryKey: ["wallet", "vesting-delegations", username, limit],
|
|
@@ -5145,6 +6629,110 @@ function getPortfolioQueryOptions(username, currency = "usd", onlyEnabled = true
|
|
|
5145
6629
|
}
|
|
5146
6630
|
});
|
|
5147
6631
|
}
|
|
6632
|
+
async function broadcastTransferWithFallback(username, ops2, auth) {
|
|
6633
|
+
const chain = auth?.fallbackChain ?? ["key", "hiveauth", "hivesigner", "keychain"];
|
|
6634
|
+
const errors = /* @__PURE__ */ new Map();
|
|
6635
|
+
const adapter = auth?.adapter;
|
|
6636
|
+
for (const method of chain) {
|
|
6637
|
+
try {
|
|
6638
|
+
switch (method) {
|
|
6639
|
+
case "key": {
|
|
6640
|
+
if (!adapter) break;
|
|
6641
|
+
const key = await adapter.getActiveKey?.(username);
|
|
6642
|
+
if (key) {
|
|
6643
|
+
const privateKey = PrivateKey.fromString(key);
|
|
6644
|
+
return await CONFIG.hiveClient.broadcast.sendOperations(ops2, privateKey);
|
|
6645
|
+
}
|
|
6646
|
+
break;
|
|
6647
|
+
}
|
|
6648
|
+
case "hiveauth": {
|
|
6649
|
+
if (adapter?.broadcastWithHiveAuth) {
|
|
6650
|
+
return await adapter.broadcastWithHiveAuth(username, ops2, "active");
|
|
6651
|
+
}
|
|
6652
|
+
break;
|
|
6653
|
+
}
|
|
6654
|
+
case "hivesigner": {
|
|
6655
|
+
if (!adapter) break;
|
|
6656
|
+
const token = await adapter.getAccessToken(username);
|
|
6657
|
+
if (token) {
|
|
6658
|
+
const client = new hs.Client({ accessToken: token });
|
|
6659
|
+
const response = await client.broadcast(ops2);
|
|
6660
|
+
return response.result;
|
|
6661
|
+
}
|
|
6662
|
+
break;
|
|
6663
|
+
}
|
|
6664
|
+
case "keychain": {
|
|
6665
|
+
if (adapter?.broadcastWithKeychain) {
|
|
6666
|
+
return await adapter.broadcastWithKeychain(username, ops2, "active");
|
|
6667
|
+
}
|
|
6668
|
+
break;
|
|
6669
|
+
}
|
|
6670
|
+
case "custom": {
|
|
6671
|
+
if (auth?.broadcast) {
|
|
6672
|
+
return await auth.broadcast(ops2, "active");
|
|
6673
|
+
}
|
|
6674
|
+
break;
|
|
6675
|
+
}
|
|
6676
|
+
}
|
|
6677
|
+
} catch (error) {
|
|
6678
|
+
errors.set(method, error);
|
|
6679
|
+
if (!shouldTriggerAuthFallback(error)) {
|
|
6680
|
+
throw error;
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
}
|
|
6684
|
+
const errorMessages = Array.from(errors.entries()).map(([method, error]) => `${method}: ${error.message}`).join(", ");
|
|
6685
|
+
throw new Error(
|
|
6686
|
+
`[SDK][Transfer] All auth methods failed for ${username}. Errors: ${errorMessages}`
|
|
6687
|
+
);
|
|
6688
|
+
}
|
|
6689
|
+
function useTransfer(username, auth) {
|
|
6690
|
+
return useMutation({
|
|
6691
|
+
mutationKey: ["wallet", "transfer", username],
|
|
6692
|
+
mutationFn: async (payload) => {
|
|
6693
|
+
if (!username) {
|
|
6694
|
+
throw new Error(
|
|
6695
|
+
"[SDK][Transfer] Attempted to call transfer API with anon user"
|
|
6696
|
+
);
|
|
6697
|
+
}
|
|
6698
|
+
const ops2 = [buildTransferOp(username, payload.to, payload.amount, payload.memo)];
|
|
6699
|
+
if (auth?.enableFallback !== false && auth?.adapter) {
|
|
6700
|
+
return broadcastTransferWithFallback(username, ops2, auth);
|
|
6701
|
+
}
|
|
6702
|
+
if (auth?.broadcast) {
|
|
6703
|
+
return auth.broadcast(ops2, "active");
|
|
6704
|
+
}
|
|
6705
|
+
if (auth?.adapter?.getActiveKey) {
|
|
6706
|
+
const activeKey = await auth.adapter.getActiveKey(username);
|
|
6707
|
+
if (activeKey) {
|
|
6708
|
+
const privateKey = PrivateKey.fromString(activeKey);
|
|
6709
|
+
return CONFIG.hiveClient.broadcast.sendOperations(ops2, privateKey);
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
const accessToken = auth?.accessToken;
|
|
6713
|
+
if (accessToken) {
|
|
6714
|
+
const client = new hs.Client({ accessToken });
|
|
6715
|
+
const response = await client.broadcast(ops2);
|
|
6716
|
+
return response.result;
|
|
6717
|
+
}
|
|
6718
|
+
throw new Error(
|
|
6719
|
+
"[SDK][Transfer] \u2013 cannot broadcast transfer w/o active key or token"
|
|
6720
|
+
);
|
|
6721
|
+
},
|
|
6722
|
+
onSuccess: async (result, variables) => {
|
|
6723
|
+
if (auth?.adapter?.recordActivity && result?.block_num && result?.id) {
|
|
6724
|
+
await auth.adapter.recordActivity(140, result.block_num, result.id);
|
|
6725
|
+
}
|
|
6726
|
+
if (auth?.adapter?.invalidateQueries) {
|
|
6727
|
+
await auth.adapter.invalidateQueries([
|
|
6728
|
+
["wallet", "balances", username],
|
|
6729
|
+
["wallet", "balances", variables.to],
|
|
6730
|
+
["wallet", "transactions", username]
|
|
6731
|
+
]);
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
});
|
|
6735
|
+
}
|
|
5148
6736
|
function getWitnessesInfiniteQueryOptions(limit) {
|
|
5149
6737
|
return infiniteQueryOptions({
|
|
5150
6738
|
queryKey: ["witnesses", "list", limit],
|
|
@@ -6046,6 +7634,6 @@ async function getSpkMarkets() {
|
|
|
6046
7634
|
return await response.json();
|
|
6047
7635
|
}
|
|
6048
7636
|
|
|
6049
|
-
export { ACCOUNT_OPERATION_GROUPS, ALL_ACCOUNT_OPERATIONS, ALL_NOTIFY_TYPES, CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, NaiMap, NotificationFilter, NotificationViewType, NotifyTypes, ROLES, SortOrder, Symbol2 as Symbol, ThreeSpeakIntegration, addDraft, addImage, addSchedule, bridgeApiCall, broadcastJson, buildProfileMetadata, checkFavouriteQueryOptions, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, deleteDraft, deleteImage, deleteSchedule, downVotingPower, encodeObj, extractAccountProfile, getAccountFullQueryOptions, getAccountNotificationsInfiniteQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountPosts, getAccountPostsInfiniteQueryOptions, getAccountPostsQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountReputationsQueryOptions, getAccountSubscriptionsQueryOptions, getAccountVoteHistoryInfiniteQueryOptions, getAccountsQueryOptions, getAnnouncementsQueryOptions, getBookmarksInfiniteQueryOptions, getBookmarksQueryOptions, getBoostPlusAccountPricesQueryOptions, getBoostPlusPricesQueryOptions, getBotsQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCollateralizedConversionRequestsQueryOptions, getCommentHistoryQueryOptions, getCommunities, getCommunitiesQueryOptions, getCommunity, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityQueryOptions, getCommunitySubscribersQueryOptions, getCommunityType, getContentQueryOptions, getContentRepliesQueryOptions, getControversialRisingInfiniteQueryOptions, getConversionRequestsQueryOptions, getCurrencyRate, getCurrencyRates, getCurrencyTokenRate, getCurrentMedianHistoryPriceQueryOptions, getDeletedEntryQueryOptions, getDiscoverCurationQueryOptions, getDiscoverLeaderboardQueryOptions, getDiscussion, getDiscussionQueryOptions, getDiscussionsQueryOptions, getDraftsInfiniteQueryOptions, getDraftsQueryOptions, getDynamicPropsQueryOptions, getEntryActiveVotesQueryOptions, getFavouritesInfiniteQueryOptions, getFavouritesQueryOptions, getFeedHistoryQueryOptions, getFollowCountQueryOptions, getFollowersQueryOptions, getFollowingQueryOptions, getFragmentsInfiniteQueryOptions, getFragmentsQueryOptions, getFriendsInfiniteQueryOptions, getGalleryImagesQueryOptions, getGameStatusCheckQueryOptions, getHiveEngineMetrics, getHiveEngineOpenOrders, getHiveEngineOrderBook, getHiveEngineTokenMetrics, getHiveEngineTokenTransactions, getHiveEngineTokensBalances, getHiveEngineTokensMarket, getHiveEngineTokensMetadata, getHiveEngineTradeHistory, getHiveEngineUnclaimedRewards, getHiveHbdStatsQueryOptions, getHivePoshLinksQueryOptions, getHivePrice, getImagesInfiniteQueryOptions, getImagesQueryOptions, getIncomingRcQueryOptions, getMarketData, getMarketDataQueryOptions, getMarketHistoryQueryOptions, getMarketStatisticsQueryOptions, getMutedUsersQueryOptions, getNormalizePostQueryOptions, getNotificationSetting, getNotifications, getNotificationsInfiniteQueryOptions, getNotificationsSettingsQueryOptions, getNotificationsUnreadCountQueryOptions, getOpenOrdersQueryOptions, getOrderBookQueryOptions, getOutgoingRcDelegationsInfiniteQueryOptions, getPageStatsQueryOptions, getPointsQueryOptions, getPortfolioQueryOptions, getPost, getPostHeader, getPostHeaderQueryOptions, getPostQueryOptions, getPostTipsQueryOptions, getPostsRanked, getPostsRankedInfiniteQueryOptions, getPostsRankedQueryOptions, getProfiles, getProfilesQueryOptions, getPromotePriceQueryOptions, getPromotedPost, getPromotedPostsQuery, getProposalQueryOptions, getProposalVotesInfiniteQueryOptions, getProposalsQueryOptions, getQueryClient, getRcStatsQueryOptions, getRebloggedByQueryOptions, getReblogsQueryOptions, getReceivedVestingSharesQueryOptions, getRecurrentTransfersQueryOptions, getReferralsInfiniteQueryOptions, getReferralsStatsQueryOptions, getRelationshipBetweenAccounts, getRelationshipBetweenAccountsQueryOptions, getRewardFundQueryOptions, getRewardedCommunitiesQueryOptions, getSavingsWithdrawFromQueryOptions, getSchedulesInfiniteQueryOptions, getSchedulesQueryOptions, getSearchAccountQueryOptions, getSearchAccountsByUsernameQueryOptions, getSearchApiInfiniteQueryOptions, getSearchFriendsQueryOptions, getSearchPathQueryOptions, getSearchTopicsQueryOptions, getSimilarEntriesQueryOptions, getSpkMarkets, getSpkWallet, getStatsQueryOptions, getSubscribers, getSubscriptions, getTradeHistoryQueryOptions, getTransactionsInfiniteQueryOptions, getTrendingTagsQueryOptions, getTrendingTagsWithStatsQueryOptions, getUserPostVoteQueryOptions, getUserProposalVotesQueryOptions, getVestingDelegationsQueryOptions, getVisibleFirstLevelThreadItems, getWavesByHostQueryOptions, getWavesByTagQueryOptions, getWavesFollowingQueryOptions, getWavesTrendingTagsQueryOptions, getWithdrawRoutesQueryOptions, getWitnessesInfiniteQueryOptions, hsTokenRenew, isCommunity, isWrappedResponse, lookupAccountsQueryOptions, makeQueryClient, mapThreadItemsToWaveEntries, markNotifications, moveSchedule, normalizePost, normalizeToWrappedResponse, normalizeWaveEntryFromApi, onboardEmail, parseAccounts, parseAsset, parseProfileMetadata, powerRechargeTime, rcPower, resolvePost, roleMap, saveNotificationSetting, search, searchAccount, searchPath, searchQueryOptions, searchTag, signUp, sortDiscussions, subscribeEmail, toEntryArray, updateDraft, uploadImage, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddDraft, useAddFragment, useAddImage, useAddSchedule, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useDeleteDraft, useDeleteImage, useDeleteSchedule, useEditFragment, useGameClaim, useMarkNotificationsRead, useMoveSchedule, useRecordActivity, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain, useUpdateDraft, useUploadImage, usrActivity, validatePostCreating, votingPower, votingValue };
|
|
7637
|
+
export { ACCOUNT_OPERATION_GROUPS, ALL_ACCOUNT_OPERATIONS, ALL_NOTIFY_TYPES, BuySellTransactionType, CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, ErrorType, HiveSignerIntegration, NaiMap, NotificationFilter, NotificationViewType, NotifyTypes, OrderIdPrefix, ROLES, SortOrder, Symbol2 as Symbol, ThreeSpeakIntegration, addDraft, addImage, addSchedule, bridgeApiCall, broadcastJson, buildAccountCreateOp, buildAccountUpdate2Op, buildAccountUpdateOp, buildActiveCustomJsonOp, buildBoostOp, buildBoostOpWithPoints, buildBoostPlusOp, buildCancelTransferFromSavingsOp, buildChangeRecoveryAccountOp, buildClaimAccountOp, buildClaimInterestOps, buildClaimRewardBalanceOp, buildCollateralizedConvertOp, buildCommentOp, buildCommentOptionsOp, buildCommunityRegistrationOp, buildConvertOp, buildCreateClaimedAccountOp, buildDelegateRcOp, buildDelegateVestingSharesOp, buildDeleteCommentOp, buildFlagPostOp, buildFollowOp, buildGrantPostingPermissionOp, buildIgnoreOp, buildLimitOrderCancelOp, buildLimitOrderCreateOp, buildLimitOrderCreateOpWithType, buildMultiPointTransferOps, buildMultiTransferOps, buildMutePostOp, buildMuteUserOp, buildPinPostOp, buildPointTransferOp, buildPostingCustomJsonOp, buildProfileMetadata, buildPromoteOp, buildProposalCreateOp, buildProposalVoteOp, buildReblogOp, buildRecoverAccountOp, buildRecurrentTransferOp, buildRemoveProposalOp, buildRequestAccountRecoveryOp, buildRevokePostingPermissionOp, buildSetLastReadOps, buildSetRoleOp, buildSetWithdrawVestingRouteOp, buildSubscribeOp, buildTransferFromSavingsOp, buildTransferOp, buildTransferToSavingsOp, buildTransferToVestingOp, buildUnfollowOp, buildUnignoreOp, buildUnsubscribeOp, buildUpdateCommunityOp, buildUpdateProposalOp, buildVoteOp, buildWithdrawVestingOp, buildWitnessProxyOp, buildWitnessVoteOp, checkFavouriteQueryOptions, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, deleteDraft, deleteImage, deleteSchedule, downVotingPower, encodeObj, extractAccountProfile, formatError, getAccountFullQueryOptions, getAccountNotificationsInfiniteQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountPosts, getAccountPostsInfiniteQueryOptions, getAccountPostsQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountReputationsQueryOptions, getAccountSubscriptionsQueryOptions, getAccountVoteHistoryInfiniteQueryOptions, getAccountsQueryOptions, getAnnouncementsQueryOptions, getBookmarksInfiniteQueryOptions, getBookmarksQueryOptions, getBoostPlusAccountPricesQueryOptions, getBoostPlusPricesQueryOptions, getBotsQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCollateralizedConversionRequestsQueryOptions, getCommentHistoryQueryOptions, getCommunities, getCommunitiesQueryOptions, getCommunity, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityQueryOptions, getCommunitySubscribersQueryOptions, getCommunityType, getContentQueryOptions, getContentRepliesQueryOptions, getControversialRisingInfiniteQueryOptions, getConversionRequestsQueryOptions, getCurrencyRate, getCurrencyRates, getCurrencyTokenRate, getCurrentMedianHistoryPriceQueryOptions, getDeletedEntryQueryOptions, getDiscoverCurationQueryOptions, getDiscoverLeaderboardQueryOptions, getDiscussion, getDiscussionQueryOptions, getDiscussionsQueryOptions, getDraftsInfiniteQueryOptions, getDraftsQueryOptions, getDynamicPropsQueryOptions, getEntryActiveVotesQueryOptions, getFavouritesInfiniteQueryOptions, getFavouritesQueryOptions, getFeedHistoryQueryOptions, getFollowCountQueryOptions, getFollowersQueryOptions, getFollowingQueryOptions, getFragmentsInfiniteQueryOptions, getFragmentsQueryOptions, getFriendsInfiniteQueryOptions, getGalleryImagesQueryOptions, getGameStatusCheckQueryOptions, getHiveEngineMetrics, getHiveEngineOpenOrders, getHiveEngineOrderBook, getHiveEngineTokenMetrics, getHiveEngineTokenTransactions, getHiveEngineTokensBalances, getHiveEngineTokensMarket, getHiveEngineTokensMetadata, getHiveEngineTradeHistory, getHiveEngineUnclaimedRewards, getHiveHbdStatsQueryOptions, getHivePoshLinksQueryOptions, getHivePrice, getImagesInfiniteQueryOptions, getImagesQueryOptions, getIncomingRcQueryOptions, getMarketData, getMarketDataQueryOptions, getMarketHistoryQueryOptions, getMarketStatisticsQueryOptions, getMutedUsersQueryOptions, getNormalizePostQueryOptions, getNotificationSetting, getNotifications, getNotificationsInfiniteQueryOptions, getNotificationsSettingsQueryOptions, getNotificationsUnreadCountQueryOptions, getOpenOrdersQueryOptions, getOrderBookQueryOptions, getOutgoingRcDelegationsInfiniteQueryOptions, getPageStatsQueryOptions, getPointsQueryOptions, getPortfolioQueryOptions, getPost, getPostHeader, getPostHeaderQueryOptions, getPostQueryOptions, getPostTipsQueryOptions, getPostsRanked, getPostsRankedInfiniteQueryOptions, getPostsRankedQueryOptions, getProfiles, getProfilesQueryOptions, getPromotePriceQueryOptions, getPromotedPost, getPromotedPostsQuery, getProposalQueryOptions, getProposalVotesInfiniteQueryOptions, getProposalsQueryOptions, getQueryClient, getRcStatsQueryOptions, getRebloggedByQueryOptions, getReblogsQueryOptions, getReceivedVestingSharesQueryOptions, getRecurrentTransfersQueryOptions, getReferralsInfiniteQueryOptions, getReferralsStatsQueryOptions, getRelationshipBetweenAccounts, getRelationshipBetweenAccountsQueryOptions, getRewardFundQueryOptions, getRewardedCommunitiesQueryOptions, getSavingsWithdrawFromQueryOptions, getSchedulesInfiniteQueryOptions, getSchedulesQueryOptions, getSearchAccountQueryOptions, getSearchAccountsByUsernameQueryOptions, getSearchApiInfiniteQueryOptions, getSearchFriendsQueryOptions, getSearchPathQueryOptions, getSearchTopicsQueryOptions, getSimilarEntriesQueryOptions, getSpkMarkets, getSpkWallet, getStatsQueryOptions, getSubscribers, getSubscriptions, getTradeHistoryQueryOptions, getTransactionsInfiniteQueryOptions, getTrendingTagsQueryOptions, getTrendingTagsWithStatsQueryOptions, getUserPostVoteQueryOptions, getUserProposalVotesQueryOptions, getVestingDelegationsQueryOptions, getVisibleFirstLevelThreadItems, getWavesByHostQueryOptions, getWavesByTagQueryOptions, getWavesFollowingQueryOptions, getWavesTrendingTagsQueryOptions, getWithdrawRoutesQueryOptions, getWitnessesInfiniteQueryOptions, hsTokenRenew, isCommunity, isInfoError, isNetworkError, isResourceCreditsError, isWrappedResponse, lookupAccountsQueryOptions, makeQueryClient, mapThreadItemsToWaveEntries, markNotifications, moveSchedule, normalizePost, normalizeToWrappedResponse, normalizeWaveEntryFromApi, onboardEmail, parseAccounts, parseAsset, parseChainError, parseProfileMetadata, powerRechargeTime, rcPower, resolvePost, roleMap, saveNotificationSetting, search, searchAccount, searchPath, searchQueryOptions, searchTag, shouldTriggerAuthFallback, signUp, sortDiscussions, subscribeEmail, toEntryArray, updateDraft, uploadImage, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddDraft, useAddFragment, useAddImage, useAddSchedule, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useComment, useDeleteDraft, useDeleteImage, useDeleteSchedule, useEditFragment, useGameClaim, useMarkNotificationsRead, useMoveSchedule, useProposalVote, useReblog, useRecordActivity, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain, useTransfer, useUpdateDraft, useUploadImage, useVote, usrActivity, validatePostCreating, votingPower, votingValue };
|
|
6050
7638
|
//# sourceMappingURL=index.js.map
|
|
6051
7639
|
//# sourceMappingURL=index.js.map
|