@ecency/sdk 1.5.12 → 1.5.14
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 +162 -9
- package/dist/browser/index.js +1642 -1375
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +1652 -1374
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +1642 -1375
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -3288,10 +3288,14 @@ function useAddFragment(username, code) {
|
|
|
3288
3288
|
}
|
|
3289
3289
|
});
|
|
3290
3290
|
}
|
|
3291
|
-
function useEditFragment(username,
|
|
3291
|
+
function useEditFragment(username, code) {
|
|
3292
3292
|
return useMutation({
|
|
3293
|
-
mutationKey: ["posts", "edit-fragment", username
|
|
3294
|
-
mutationFn: async ({
|
|
3293
|
+
mutationKey: ["posts", "edit-fragment", username],
|
|
3294
|
+
mutationFn: async ({
|
|
3295
|
+
fragmentId,
|
|
3296
|
+
title,
|
|
3297
|
+
body
|
|
3298
|
+
}) => {
|
|
3295
3299
|
if (!code) {
|
|
3296
3300
|
throw new Error("[SDK][Posts] Missing access token");
|
|
3297
3301
|
}
|
|
@@ -3313,14 +3317,14 @@ function useEditFragment(username, fragmentId, code) {
|
|
|
3313
3317
|
);
|
|
3314
3318
|
return response.json();
|
|
3315
3319
|
},
|
|
3316
|
-
onSuccess(response) {
|
|
3320
|
+
onSuccess(response, variables) {
|
|
3317
3321
|
getQueryClient().setQueryData(
|
|
3318
3322
|
getFragmentsQueryOptions(username, code).queryKey,
|
|
3319
3323
|
(data) => {
|
|
3320
3324
|
if (!data) {
|
|
3321
3325
|
return [];
|
|
3322
3326
|
}
|
|
3323
|
-
const index = data.findIndex(({ id }) => id === fragmentId);
|
|
3327
|
+
const index = data.findIndex(({ id }) => id === variables.fragmentId);
|
|
3324
3328
|
if (index >= 0) {
|
|
3325
3329
|
data[index] = response;
|
|
3326
3330
|
}
|
|
@@ -3330,10 +3334,10 @@ function useEditFragment(username, fragmentId, code) {
|
|
|
3330
3334
|
}
|
|
3331
3335
|
});
|
|
3332
3336
|
}
|
|
3333
|
-
function useRemoveFragment(username,
|
|
3337
|
+
function useRemoveFragment(username, code) {
|
|
3334
3338
|
return useMutation({
|
|
3335
3339
|
mutationKey: ["posts", "remove-fragment", username],
|
|
3336
|
-
mutationFn: async () => {
|
|
3340
|
+
mutationFn: async ({ fragmentId }) => {
|
|
3337
3341
|
if (!code) {
|
|
3338
3342
|
throw new Error("[SDK][Posts] Missing access token");
|
|
3339
3343
|
}
|
|
@@ -3349,160 +3353,630 @@ function useRemoveFragment(username, fragmentId, code) {
|
|
|
3349
3353
|
}
|
|
3350
3354
|
});
|
|
3351
3355
|
},
|
|
3352
|
-
onSuccess() {
|
|
3356
|
+
onSuccess(_data, variables) {
|
|
3353
3357
|
getQueryClient().setQueryData(
|
|
3354
3358
|
getFragmentsQueryOptions(username, code).queryKey,
|
|
3355
|
-
(data) => [...data ?? []].filter(({ id }) => id !== fragmentId)
|
|
3359
|
+
(data) => [...data ?? []].filter(({ id }) => id !== variables.fragmentId)
|
|
3356
3360
|
);
|
|
3357
3361
|
}
|
|
3358
3362
|
});
|
|
3359
3363
|
}
|
|
3360
3364
|
|
|
3361
|
-
// src/modules/
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
}
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3365
|
+
// src/modules/private-api/requests.ts
|
|
3366
|
+
async function parseJsonResponse(response) {
|
|
3367
|
+
if (!response.ok) {
|
|
3368
|
+
let errorData = void 0;
|
|
3369
|
+
try {
|
|
3370
|
+
errorData = await response.json();
|
|
3371
|
+
} catch {
|
|
3372
|
+
errorData = void 0;
|
|
3373
|
+
}
|
|
3374
|
+
const error = new Error(`Request failed with status ${response.status}`);
|
|
3375
|
+
error.status = response.status;
|
|
3376
|
+
error.data = errorData;
|
|
3377
|
+
throw error;
|
|
3378
|
+
}
|
|
3379
|
+
const text = await response.text();
|
|
3380
|
+
if (!text || text.trim() === "") {
|
|
3381
|
+
return "";
|
|
3382
|
+
}
|
|
3373
3383
|
try {
|
|
3374
|
-
|
|
3384
|
+
return JSON.parse(text);
|
|
3375
3385
|
} catch (e) {
|
|
3376
|
-
response
|
|
3386
|
+
console.warn("[SDK] Failed to parse JSON response:", e, "Response:", text);
|
|
3387
|
+
return "";
|
|
3377
3388
|
}
|
|
3378
|
-
|
|
3379
|
-
|
|
3389
|
+
}
|
|
3390
|
+
async function signUp(username, email, referral) {
|
|
3391
|
+
const fetchApi = getBoundFetch();
|
|
3392
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/account-create", {
|
|
3393
|
+
method: "POST",
|
|
3394
|
+
headers: {
|
|
3395
|
+
"Content-Type": "application/json"
|
|
3396
|
+
},
|
|
3397
|
+
body: JSON.stringify({ username, email, referral })
|
|
3398
|
+
});
|
|
3399
|
+
const data = await parseJsonResponse(response);
|
|
3400
|
+
return { status: response.status, data };
|
|
3401
|
+
}
|
|
3402
|
+
async function subscribeEmail(email) {
|
|
3403
|
+
const fetchApi = getBoundFetch();
|
|
3404
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/subscribe", {
|
|
3405
|
+
method: "POST",
|
|
3406
|
+
headers: {
|
|
3407
|
+
"Content-Type": "application/json"
|
|
3408
|
+
},
|
|
3409
|
+
body: JSON.stringify({ email })
|
|
3410
|
+
});
|
|
3411
|
+
const data = await parseJsonResponse(response);
|
|
3412
|
+
return { status: response.status, data };
|
|
3413
|
+
}
|
|
3414
|
+
async function usrActivity(code, ty, bl = "", tx = "") {
|
|
3415
|
+
const params = { code, ty };
|
|
3416
|
+
if (bl) {
|
|
3417
|
+
params.bl = bl;
|
|
3380
3418
|
}
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
await delay(waitMs);
|
|
3419
|
+
if (tx) {
|
|
3420
|
+
params.tx = tx;
|
|
3384
3421
|
}
|
|
3385
|
-
|
|
3422
|
+
const fetchApi = getBoundFetch();
|
|
3423
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/usr-activity", {
|
|
3424
|
+
method: "POST",
|
|
3425
|
+
headers: {
|
|
3426
|
+
"Content-Type": "application/json"
|
|
3427
|
+
},
|
|
3428
|
+
body: JSON.stringify(params)
|
|
3429
|
+
});
|
|
3430
|
+
await parseJsonResponse(response);
|
|
3386
3431
|
}
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
function getLocationInfo() {
|
|
3394
|
-
if (typeof window !== "undefined" && window.location) {
|
|
3395
|
-
return {
|
|
3396
|
-
url: window.location.href,
|
|
3397
|
-
domain: window.location.host
|
|
3398
|
-
};
|
|
3432
|
+
async function getNotifications(code, filter, since = null, user = null) {
|
|
3433
|
+
const data = {
|
|
3434
|
+
code
|
|
3435
|
+
};
|
|
3436
|
+
if (filter) {
|
|
3437
|
+
data.filter = filter;
|
|
3399
3438
|
}
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
await fetchApi(CONFIG.plausibleHost + "/api/event", {
|
|
3414
|
-
method: "POST",
|
|
3415
|
-
headers: {
|
|
3416
|
-
"Content-Type": "application/json"
|
|
3417
|
-
},
|
|
3418
|
-
body: JSON.stringify({
|
|
3419
|
-
name: activityType,
|
|
3420
|
-
url,
|
|
3421
|
-
domain,
|
|
3422
|
-
props: {
|
|
3423
|
-
username
|
|
3424
|
-
}
|
|
3425
|
-
})
|
|
3426
|
-
});
|
|
3427
|
-
}
|
|
3439
|
+
if (since) {
|
|
3440
|
+
data.since = since;
|
|
3441
|
+
}
|
|
3442
|
+
if (user) {
|
|
3443
|
+
data.user = user;
|
|
3444
|
+
}
|
|
3445
|
+
const fetchApi = getBoundFetch();
|
|
3446
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications", {
|
|
3447
|
+
method: "POST",
|
|
3448
|
+
headers: {
|
|
3449
|
+
"Content-Type": "application/json"
|
|
3450
|
+
},
|
|
3451
|
+
body: JSON.stringify(data)
|
|
3428
3452
|
});
|
|
3453
|
+
return parseJsonResponse(response);
|
|
3429
3454
|
}
|
|
3430
|
-
function
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3455
|
+
async function saveNotificationSetting(code, username, system, allows_notify, notify_types, token) {
|
|
3456
|
+
const data = {
|
|
3457
|
+
code,
|
|
3458
|
+
username,
|
|
3459
|
+
token,
|
|
3460
|
+
system,
|
|
3461
|
+
allows_notify,
|
|
3462
|
+
notify_types
|
|
3463
|
+
};
|
|
3464
|
+
const fetchApi = getBoundFetch();
|
|
3465
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/register-device", {
|
|
3466
|
+
method: "POST",
|
|
3467
|
+
headers: {
|
|
3468
|
+
"Content-Type": "application/json"
|
|
3469
|
+
},
|
|
3470
|
+
body: JSON.stringify(data)
|
|
3443
3471
|
});
|
|
3472
|
+
return parseJsonResponse(response);
|
|
3444
3473
|
}
|
|
3445
|
-
function
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
throw new Error(`Failed to fetch curation data: ${response.status}`);
|
|
3455
|
-
}
|
|
3456
|
-
const data = await response.json();
|
|
3457
|
-
const accounts = data.map((item) => item.account);
|
|
3458
|
-
const accountsResponse = await CONFIG.hiveClient.database.getAccounts(accounts);
|
|
3459
|
-
for (let index = 0; index < accountsResponse.length; index++) {
|
|
3460
|
-
const element = accountsResponse[index];
|
|
3461
|
-
const curator = data[index];
|
|
3462
|
-
const vestingShares = typeof element.vesting_shares === "string" ? element.vesting_shares : element.vesting_shares.toString();
|
|
3463
|
-
const receivedVestingShares = typeof element.received_vesting_shares === "string" ? element.received_vesting_shares : element.received_vesting_shares.toString();
|
|
3464
|
-
const delegatedVestingShares = typeof element.delegated_vesting_shares === "string" ? element.delegated_vesting_shares : element.delegated_vesting_shares.toString();
|
|
3465
|
-
const vestingWithdrawRate = typeof element.vesting_withdraw_rate === "string" ? element.vesting_withdraw_rate : element.vesting_withdraw_rate.toString();
|
|
3466
|
-
const effectiveVest = parseFloat(vestingShares) + parseFloat(receivedVestingShares) - parseFloat(delegatedVestingShares) - parseFloat(vestingWithdrawRate);
|
|
3467
|
-
curator.efficiency = curator.vests / effectiveVest;
|
|
3468
|
-
}
|
|
3469
|
-
data.sort((a, b) => b.efficiency - a.efficiency);
|
|
3470
|
-
return data;
|
|
3471
|
-
}
|
|
3474
|
+
async function getNotificationSetting(code, username, token) {
|
|
3475
|
+
const data = { code, username, token };
|
|
3476
|
+
const fetchApi = getBoundFetch();
|
|
3477
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/detail-device", {
|
|
3478
|
+
method: "POST",
|
|
3479
|
+
headers: {
|
|
3480
|
+
"Content-Type": "application/json"
|
|
3481
|
+
},
|
|
3482
|
+
body: JSON.stringify(data)
|
|
3472
3483
|
});
|
|
3484
|
+
return parseJsonResponse(response);
|
|
3473
3485
|
}
|
|
3474
|
-
function
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
dimensions,
|
|
3487
|
-
date_range: dateRange
|
|
3488
|
-
}),
|
|
3489
|
-
signal
|
|
3490
|
-
});
|
|
3491
|
-
if (!response.ok) {
|
|
3492
|
-
throw new Error(`Failed to fetch page stats: ${response.status}`);
|
|
3493
|
-
}
|
|
3494
|
-
return response.json();
|
|
3486
|
+
async function markNotifications(code, id) {
|
|
3487
|
+
const data = {
|
|
3488
|
+
code
|
|
3489
|
+
};
|
|
3490
|
+
if (id) {
|
|
3491
|
+
data.id = id;
|
|
3492
|
+
}
|
|
3493
|
+
const fetchApi = getBoundFetch();
|
|
3494
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications/mark", {
|
|
3495
|
+
method: "POST",
|
|
3496
|
+
headers: {
|
|
3497
|
+
"Content-Type": "application/json"
|
|
3495
3498
|
},
|
|
3496
|
-
|
|
3499
|
+
body: JSON.stringify(data)
|
|
3497
3500
|
});
|
|
3501
|
+
return parseJsonResponse(response);
|
|
3498
3502
|
}
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3503
|
+
async function addImage(code, url) {
|
|
3504
|
+
const data = { code, url };
|
|
3505
|
+
const fetchApi = getBoundFetch();
|
|
3506
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images-add", {
|
|
3507
|
+
method: "POST",
|
|
3508
|
+
headers: {
|
|
3509
|
+
"Content-Type": "application/json"
|
|
3510
|
+
},
|
|
3511
|
+
body: JSON.stringify(data)
|
|
3512
|
+
});
|
|
3513
|
+
return parseJsonResponse(response);
|
|
3514
|
+
}
|
|
3515
|
+
async function uploadImage(file, token, signal) {
|
|
3516
|
+
const fetchApi = getBoundFetch();
|
|
3517
|
+
const formData = new FormData();
|
|
3518
|
+
formData.append("file", file);
|
|
3519
|
+
const response = await fetchApi(`${CONFIG.imageHost}/hs/${token}`, {
|
|
3520
|
+
method: "POST",
|
|
3521
|
+
body: formData,
|
|
3522
|
+
signal
|
|
3523
|
+
});
|
|
3524
|
+
return parseJsonResponse(response);
|
|
3525
|
+
}
|
|
3526
|
+
async function deleteImage(code, imageId) {
|
|
3527
|
+
const data = { code, id: imageId };
|
|
3528
|
+
const fetchApi = getBoundFetch();
|
|
3529
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/images-delete", {
|
|
3530
|
+
method: "POST",
|
|
3531
|
+
headers: {
|
|
3532
|
+
"Content-Type": "application/json"
|
|
3533
|
+
},
|
|
3534
|
+
body: JSON.stringify(data)
|
|
3535
|
+
});
|
|
3536
|
+
return parseJsonResponse(response);
|
|
3537
|
+
}
|
|
3538
|
+
async function addDraft(code, title, body, tags, meta) {
|
|
3539
|
+
const data = { code, title, body, tags, meta };
|
|
3540
|
+
const fetchApi = getBoundFetch();
|
|
3541
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-add", {
|
|
3542
|
+
method: "POST",
|
|
3543
|
+
headers: {
|
|
3544
|
+
"Content-Type": "application/json"
|
|
3545
|
+
},
|
|
3546
|
+
body: JSON.stringify(data)
|
|
3547
|
+
});
|
|
3548
|
+
return parseJsonResponse(response);
|
|
3549
|
+
}
|
|
3550
|
+
async function updateDraft(code, draftId, title, body, tags, meta) {
|
|
3551
|
+
const data = { code, id: draftId, title, body, tags, meta };
|
|
3552
|
+
const fetchApi = getBoundFetch();
|
|
3553
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-update", {
|
|
3554
|
+
method: "POST",
|
|
3555
|
+
headers: {
|
|
3556
|
+
"Content-Type": "application/json"
|
|
3557
|
+
},
|
|
3558
|
+
body: JSON.stringify(data)
|
|
3559
|
+
});
|
|
3560
|
+
return parseJsonResponse(response);
|
|
3561
|
+
}
|
|
3562
|
+
async function deleteDraft(code, draftId) {
|
|
3563
|
+
const data = { code, id: draftId };
|
|
3564
|
+
const fetchApi = getBoundFetch();
|
|
3565
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/drafts-delete", {
|
|
3566
|
+
method: "POST",
|
|
3567
|
+
headers: {
|
|
3568
|
+
"Content-Type": "application/json"
|
|
3569
|
+
},
|
|
3570
|
+
body: JSON.stringify(data)
|
|
3571
|
+
});
|
|
3572
|
+
return parseJsonResponse(response);
|
|
3573
|
+
}
|
|
3574
|
+
async function addSchedule(code, permlink, title, body, meta, options, schedule, reblog) {
|
|
3575
|
+
const data = {
|
|
3576
|
+
code,
|
|
3577
|
+
permlink,
|
|
3578
|
+
title,
|
|
3579
|
+
body,
|
|
3580
|
+
meta,
|
|
3581
|
+
schedule,
|
|
3582
|
+
reblog
|
|
3583
|
+
};
|
|
3584
|
+
if (options) {
|
|
3585
|
+
data.options = options;
|
|
3586
|
+
}
|
|
3587
|
+
const fetchApi = getBoundFetch();
|
|
3588
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-add", {
|
|
3589
|
+
method: "POST",
|
|
3590
|
+
headers: {
|
|
3591
|
+
"Content-Type": "application/json"
|
|
3592
|
+
},
|
|
3593
|
+
body: JSON.stringify(data)
|
|
3594
|
+
});
|
|
3595
|
+
return parseJsonResponse(response);
|
|
3596
|
+
}
|
|
3597
|
+
async function deleteSchedule(code, id) {
|
|
3598
|
+
const data = { code, id };
|
|
3599
|
+
const fetchApi = getBoundFetch();
|
|
3600
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-delete", {
|
|
3601
|
+
method: "POST",
|
|
3602
|
+
headers: {
|
|
3603
|
+
"Content-Type": "application/json"
|
|
3604
|
+
},
|
|
3605
|
+
body: JSON.stringify(data)
|
|
3606
|
+
});
|
|
3607
|
+
return parseJsonResponse(response);
|
|
3608
|
+
}
|
|
3609
|
+
async function moveSchedule(code, id) {
|
|
3610
|
+
const data = { code, id };
|
|
3611
|
+
const fetchApi = getBoundFetch();
|
|
3612
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/schedules-move", {
|
|
3613
|
+
method: "POST",
|
|
3614
|
+
headers: {
|
|
3615
|
+
"Content-Type": "application/json"
|
|
3616
|
+
},
|
|
3617
|
+
body: JSON.stringify(data)
|
|
3618
|
+
});
|
|
3619
|
+
return parseJsonResponse(response);
|
|
3620
|
+
}
|
|
3621
|
+
async function getPromotedPost(code, author, permlink) {
|
|
3622
|
+
const data = { code, author, permlink };
|
|
3623
|
+
const fetchApi = getBoundFetch();
|
|
3624
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/promoted-post", {
|
|
3625
|
+
method: "POST",
|
|
3626
|
+
headers: {
|
|
3627
|
+
"Content-Type": "application/json"
|
|
3628
|
+
},
|
|
3629
|
+
body: JSON.stringify(data)
|
|
3630
|
+
});
|
|
3631
|
+
return parseJsonResponse(response);
|
|
3632
|
+
}
|
|
3633
|
+
async function onboardEmail(username, email, friend) {
|
|
3634
|
+
const dataBody = {
|
|
3635
|
+
username,
|
|
3636
|
+
email,
|
|
3637
|
+
friend
|
|
3638
|
+
};
|
|
3639
|
+
const fetchApi = getBoundFetch();
|
|
3640
|
+
const response = await fetchApi(
|
|
3641
|
+
CONFIG.privateApiHost + "/private-api/account-create-friend",
|
|
3642
|
+
{
|
|
3643
|
+
method: "POST",
|
|
3644
|
+
headers: {
|
|
3645
|
+
"Content-Type": "application/json"
|
|
3646
|
+
},
|
|
3647
|
+
body: JSON.stringify(dataBody)
|
|
3648
|
+
}
|
|
3649
|
+
);
|
|
3650
|
+
return parseJsonResponse(response);
|
|
3651
|
+
}
|
|
3652
|
+
|
|
3653
|
+
// src/modules/posts/mutations/use-add-draft.ts
|
|
3654
|
+
function useAddDraft(username, code, onSuccess, onError) {
|
|
3655
|
+
return useMutation({
|
|
3656
|
+
mutationKey: ["posts", "drafts", "add", username],
|
|
3657
|
+
mutationFn: async ({
|
|
3658
|
+
title,
|
|
3659
|
+
body,
|
|
3660
|
+
tags,
|
|
3661
|
+
meta
|
|
3662
|
+
}) => {
|
|
3663
|
+
if (!username || !code) {
|
|
3664
|
+
throw new Error("[SDK][Posts] \u2013 missing auth for addDraft");
|
|
3665
|
+
}
|
|
3666
|
+
return addDraft(code, title, body, tags, meta);
|
|
3667
|
+
},
|
|
3668
|
+
onSuccess: () => {
|
|
3669
|
+
onSuccess?.();
|
|
3670
|
+
getQueryClient().invalidateQueries({
|
|
3671
|
+
queryKey: ["posts", "drafts", username]
|
|
3672
|
+
});
|
|
3673
|
+
},
|
|
3674
|
+
onError
|
|
3675
|
+
});
|
|
3676
|
+
}
|
|
3677
|
+
function useUpdateDraft(username, code, onSuccess, onError) {
|
|
3678
|
+
return useMutation({
|
|
3679
|
+
mutationKey: ["posts", "drafts", "update", username],
|
|
3680
|
+
mutationFn: async ({
|
|
3681
|
+
draftId,
|
|
3682
|
+
title,
|
|
3683
|
+
body,
|
|
3684
|
+
tags,
|
|
3685
|
+
meta
|
|
3686
|
+
}) => {
|
|
3687
|
+
if (!username || !code) {
|
|
3688
|
+
throw new Error("[SDK][Posts] \u2013 missing auth for updateDraft");
|
|
3689
|
+
}
|
|
3690
|
+
return updateDraft(code, draftId, title, body, tags, meta);
|
|
3691
|
+
},
|
|
3692
|
+
onSuccess: () => {
|
|
3693
|
+
onSuccess?.();
|
|
3694
|
+
getQueryClient().invalidateQueries({
|
|
3695
|
+
queryKey: ["posts", "drafts", username]
|
|
3696
|
+
});
|
|
3697
|
+
},
|
|
3698
|
+
onError
|
|
3699
|
+
});
|
|
3700
|
+
}
|
|
3701
|
+
function useDeleteDraft(username, code, onSuccess, onError) {
|
|
3702
|
+
return useMutation({
|
|
3703
|
+
mutationKey: ["posts", "drafts", "delete", username],
|
|
3704
|
+
mutationFn: async ({ draftId }) => {
|
|
3705
|
+
if (!username || !code) {
|
|
3706
|
+
throw new Error("[SDK][Posts] \u2013 missing auth for deleteDraft");
|
|
3707
|
+
}
|
|
3708
|
+
return deleteDraft(code, draftId);
|
|
3709
|
+
},
|
|
3710
|
+
onSuccess: () => {
|
|
3711
|
+
onSuccess?.();
|
|
3712
|
+
getQueryClient().invalidateQueries({
|
|
3713
|
+
queryKey: ["posts", "drafts", username]
|
|
3714
|
+
});
|
|
3715
|
+
},
|
|
3716
|
+
onError
|
|
3717
|
+
});
|
|
3718
|
+
}
|
|
3719
|
+
function useAddSchedule(username, code, onSuccess, onError) {
|
|
3720
|
+
return useMutation({
|
|
3721
|
+
mutationKey: ["posts", "schedules", "add", username],
|
|
3722
|
+
mutationFn: async ({
|
|
3723
|
+
permlink,
|
|
3724
|
+
title,
|
|
3725
|
+
body,
|
|
3726
|
+
meta,
|
|
3727
|
+
options,
|
|
3728
|
+
schedule,
|
|
3729
|
+
reblog
|
|
3730
|
+
}) => {
|
|
3731
|
+
if (!username || !code) {
|
|
3732
|
+
throw new Error("[SDK][Posts] \u2013 missing auth for addSchedule");
|
|
3733
|
+
}
|
|
3734
|
+
return addSchedule(code, permlink, title, body, meta, options, schedule, reblog);
|
|
3735
|
+
},
|
|
3736
|
+
onSuccess: () => {
|
|
3737
|
+
onSuccess?.();
|
|
3738
|
+
getQueryClient().invalidateQueries({
|
|
3739
|
+
queryKey: ["posts", "schedules", username]
|
|
3740
|
+
});
|
|
3741
|
+
},
|
|
3742
|
+
onError
|
|
3743
|
+
});
|
|
3744
|
+
}
|
|
3745
|
+
function useDeleteSchedule(username, code, onSuccess, onError) {
|
|
3746
|
+
return useMutation({
|
|
3747
|
+
mutationKey: ["posts", "schedules", "delete", username],
|
|
3748
|
+
mutationFn: async ({ id }) => {
|
|
3749
|
+
if (!username || !code) {
|
|
3750
|
+
throw new Error("[SDK][Posts] \u2013 missing auth for deleteSchedule");
|
|
3751
|
+
}
|
|
3752
|
+
return deleteSchedule(code, id);
|
|
3753
|
+
},
|
|
3754
|
+
onSuccess: () => {
|
|
3755
|
+
onSuccess?.();
|
|
3756
|
+
getQueryClient().invalidateQueries({
|
|
3757
|
+
queryKey: ["posts", "schedules", username]
|
|
3758
|
+
});
|
|
3759
|
+
},
|
|
3760
|
+
onError
|
|
3761
|
+
});
|
|
3762
|
+
}
|
|
3763
|
+
function useMoveSchedule(username, code, onSuccess, onError) {
|
|
3764
|
+
return useMutation({
|
|
3765
|
+
mutationKey: ["posts", "schedules", "move", username],
|
|
3766
|
+
mutationFn: async ({ id }) => {
|
|
3767
|
+
if (!username || !code) {
|
|
3768
|
+
throw new Error("[SDK][Posts] \u2013 missing auth for moveSchedule");
|
|
3769
|
+
}
|
|
3770
|
+
return moveSchedule(code, id);
|
|
3771
|
+
},
|
|
3772
|
+
onSuccess: () => {
|
|
3773
|
+
onSuccess?.();
|
|
3774
|
+
getQueryClient().invalidateQueries({
|
|
3775
|
+
queryKey: ["posts", "schedules", username]
|
|
3776
|
+
});
|
|
3777
|
+
getQueryClient().invalidateQueries({
|
|
3778
|
+
queryKey: ["posts", "drafts", username]
|
|
3779
|
+
});
|
|
3780
|
+
},
|
|
3781
|
+
onError
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
function useAddImage(username, code, onSuccess, onError) {
|
|
3785
|
+
return useMutation({
|
|
3786
|
+
mutationKey: ["posts", "images", "add", username],
|
|
3787
|
+
mutationFn: async ({ url }) => {
|
|
3788
|
+
if (!username || !code) {
|
|
3789
|
+
throw new Error("[SDK][Posts] \u2013 missing auth for addImage");
|
|
3790
|
+
}
|
|
3791
|
+
return addImage(code, url);
|
|
3792
|
+
},
|
|
3793
|
+
onSuccess: () => {
|
|
3794
|
+
onSuccess?.();
|
|
3795
|
+
getQueryClient().invalidateQueries({
|
|
3796
|
+
queryKey: ["posts", "images", username]
|
|
3797
|
+
});
|
|
3798
|
+
},
|
|
3799
|
+
onError
|
|
3800
|
+
});
|
|
3801
|
+
}
|
|
3802
|
+
function useDeleteImage(username, code, onSuccess, onError) {
|
|
3803
|
+
return useMutation({
|
|
3804
|
+
mutationKey: ["posts", "images", "delete", username],
|
|
3805
|
+
mutationFn: async ({ imageId }) => {
|
|
3806
|
+
if (!username || !code) {
|
|
3807
|
+
throw new Error("[SDK][Posts] \u2013 missing auth for deleteImage");
|
|
3808
|
+
}
|
|
3809
|
+
return deleteImage(code, imageId);
|
|
3810
|
+
},
|
|
3811
|
+
onSuccess: () => {
|
|
3812
|
+
onSuccess?.();
|
|
3813
|
+
getQueryClient().invalidateQueries({
|
|
3814
|
+
queryKey: ["posts", "images", username]
|
|
3815
|
+
});
|
|
3816
|
+
},
|
|
3817
|
+
onError
|
|
3818
|
+
});
|
|
3819
|
+
}
|
|
3820
|
+
function useUploadImage(onSuccess, onError) {
|
|
3821
|
+
return useMutation({
|
|
3822
|
+
mutationKey: ["posts", "images", "upload"],
|
|
3823
|
+
mutationFn: async ({
|
|
3824
|
+
file,
|
|
3825
|
+
token,
|
|
3826
|
+
signal
|
|
3827
|
+
}) => {
|
|
3828
|
+
return uploadImage(file, token, signal);
|
|
3829
|
+
},
|
|
3830
|
+
onSuccess,
|
|
3831
|
+
onError
|
|
3832
|
+
});
|
|
3833
|
+
}
|
|
3834
|
+
|
|
3835
|
+
// src/modules/posts/utils/validate-post-creating.ts
|
|
3836
|
+
var DEFAULT_VALIDATE_POST_DELAYS = [3e3, 3e3, 3e3];
|
|
3837
|
+
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
3838
|
+
async function getContent(author, permlink) {
|
|
3839
|
+
return CONFIG.hiveClient.call("condenser_api", "get_content", [
|
|
3840
|
+
author,
|
|
3841
|
+
permlink
|
|
3842
|
+
]);
|
|
3843
|
+
}
|
|
3844
|
+
async function validatePostCreating(author, permlink, attempts = 0, options) {
|
|
3845
|
+
const delays = options?.delays ?? DEFAULT_VALIDATE_POST_DELAYS;
|
|
3846
|
+
let response;
|
|
3847
|
+
try {
|
|
3848
|
+
response = await getContent(author, permlink);
|
|
3849
|
+
} catch (e) {
|
|
3850
|
+
response = void 0;
|
|
3851
|
+
}
|
|
3852
|
+
if (response || attempts >= delays.length) {
|
|
3853
|
+
return;
|
|
3854
|
+
}
|
|
3855
|
+
const waitMs = delays[attempts];
|
|
3856
|
+
if (waitMs > 0) {
|
|
3857
|
+
await delay(waitMs);
|
|
3858
|
+
}
|
|
3859
|
+
return validatePostCreating(author, permlink, attempts + 1, options);
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3862
|
+
// src/modules/analytics/mutations/index.ts
|
|
3863
|
+
var mutations_exports = {};
|
|
3864
|
+
__export(mutations_exports, {
|
|
3865
|
+
useRecordActivity: () => useRecordActivity
|
|
3866
|
+
});
|
|
3867
|
+
function getLocationInfo() {
|
|
3868
|
+
if (typeof window !== "undefined" && window.location) {
|
|
3869
|
+
return {
|
|
3870
|
+
url: window.location.href,
|
|
3871
|
+
domain: window.location.host
|
|
3872
|
+
};
|
|
3873
|
+
}
|
|
3874
|
+
return { url: "", domain: "" };
|
|
3875
|
+
}
|
|
3876
|
+
function useRecordActivity(username, activityType, options) {
|
|
3877
|
+
return useMutation({
|
|
3878
|
+
mutationKey: ["analytics", activityType],
|
|
3879
|
+
mutationFn: async () => {
|
|
3880
|
+
if (!activityType) {
|
|
3881
|
+
throw new Error("[SDK][Analytics] \u2013 no activity type provided");
|
|
3882
|
+
}
|
|
3883
|
+
const fetchApi = getBoundFetch();
|
|
3884
|
+
const locationInfo = getLocationInfo();
|
|
3885
|
+
const url = options?.url ?? locationInfo.url;
|
|
3886
|
+
const domain = options?.domain ?? locationInfo.domain;
|
|
3887
|
+
await fetchApi(CONFIG.plausibleHost + "/api/event", {
|
|
3888
|
+
method: "POST",
|
|
3889
|
+
headers: {
|
|
3890
|
+
"Content-Type": "application/json"
|
|
3891
|
+
},
|
|
3892
|
+
body: JSON.stringify({
|
|
3893
|
+
name: activityType,
|
|
3894
|
+
url,
|
|
3895
|
+
domain,
|
|
3896
|
+
props: {
|
|
3897
|
+
username
|
|
3898
|
+
}
|
|
3899
|
+
})
|
|
3900
|
+
});
|
|
3901
|
+
}
|
|
3902
|
+
});
|
|
3903
|
+
}
|
|
3904
|
+
function getDiscoverLeaderboardQueryOptions(duration) {
|
|
3905
|
+
return queryOptions({
|
|
3906
|
+
queryKey: ["analytics", "discover-leaderboard", duration],
|
|
3907
|
+
queryFn: async ({ signal }) => {
|
|
3908
|
+
const response = await fetch(
|
|
3909
|
+
CONFIG.privateApiHost + `/private-api/leaderboard/${duration}`,
|
|
3910
|
+
{ signal }
|
|
3911
|
+
);
|
|
3912
|
+
if (!response.ok) {
|
|
3913
|
+
throw new Error(`Failed to fetch leaderboard: ${response.status}`);
|
|
3914
|
+
}
|
|
3915
|
+
return response.json();
|
|
3916
|
+
}
|
|
3917
|
+
});
|
|
3918
|
+
}
|
|
3919
|
+
function getDiscoverCurationQueryOptions(duration) {
|
|
3920
|
+
return queryOptions({
|
|
3921
|
+
queryKey: ["analytics", "discover-curation", duration],
|
|
3922
|
+
queryFn: async ({ signal }) => {
|
|
3923
|
+
const response = await fetch(
|
|
3924
|
+
CONFIG.privateApiHost + `/private-api/curation/${duration}`,
|
|
3925
|
+
{ signal }
|
|
3926
|
+
);
|
|
3927
|
+
if (!response.ok) {
|
|
3928
|
+
throw new Error(`Failed to fetch curation data: ${response.status}`);
|
|
3929
|
+
}
|
|
3930
|
+
const data = await response.json();
|
|
3931
|
+
const accounts = data.map((item) => item.account);
|
|
3932
|
+
const accountsResponse = await CONFIG.hiveClient.database.getAccounts(accounts);
|
|
3933
|
+
for (let index = 0; index < accountsResponse.length; index++) {
|
|
3934
|
+
const element = accountsResponse[index];
|
|
3935
|
+
const curator = data[index];
|
|
3936
|
+
const vestingShares = typeof element.vesting_shares === "string" ? element.vesting_shares : element.vesting_shares.toString();
|
|
3937
|
+
const receivedVestingShares = typeof element.received_vesting_shares === "string" ? element.received_vesting_shares : element.received_vesting_shares.toString();
|
|
3938
|
+
const delegatedVestingShares = typeof element.delegated_vesting_shares === "string" ? element.delegated_vesting_shares : element.delegated_vesting_shares.toString();
|
|
3939
|
+
const vestingWithdrawRate = typeof element.vesting_withdraw_rate === "string" ? element.vesting_withdraw_rate : element.vesting_withdraw_rate.toString();
|
|
3940
|
+
const effectiveVest = parseFloat(vestingShares) + parseFloat(receivedVestingShares) - parseFloat(delegatedVestingShares) - parseFloat(vestingWithdrawRate);
|
|
3941
|
+
curator.efficiency = curator.vests / effectiveVest;
|
|
3942
|
+
}
|
|
3943
|
+
data.sort((a, b) => b.efficiency - a.efficiency);
|
|
3944
|
+
return data;
|
|
3945
|
+
}
|
|
3946
|
+
});
|
|
3947
|
+
}
|
|
3948
|
+
function getPageStatsQueryOptions(url, dimensions = [], metrics = ["visitors", "pageviews", "visit_duration"], dateRange) {
|
|
3949
|
+
return queryOptions({
|
|
3950
|
+
queryKey: ["analytics", "page-stats", url, dimensions, metrics, dateRange],
|
|
3951
|
+
queryFn: async ({ signal }) => {
|
|
3952
|
+
const response = await fetch(CONFIG.privateApiHost + "/api/stats", {
|
|
3953
|
+
method: "POST",
|
|
3954
|
+
headers: {
|
|
3955
|
+
"Content-Type": "application/json"
|
|
3956
|
+
},
|
|
3957
|
+
body: JSON.stringify({
|
|
3958
|
+
metrics,
|
|
3959
|
+
url: encodeURIComponent(url),
|
|
3960
|
+
dimensions,
|
|
3961
|
+
date_range: dateRange
|
|
3962
|
+
}),
|
|
3963
|
+
signal
|
|
3964
|
+
});
|
|
3965
|
+
if (!response.ok) {
|
|
3966
|
+
throw new Error(`Failed to fetch page stats: ${response.status}`);
|
|
3967
|
+
}
|
|
3968
|
+
return response.json();
|
|
3969
|
+
},
|
|
3970
|
+
enabled: !!url
|
|
3971
|
+
});
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
// src/modules/integrations/3speak/queries/index.ts
|
|
3975
|
+
var queries_exports2 = {};
|
|
3976
|
+
__export(queries_exports2, {
|
|
3977
|
+
getAccountTokenQueryOptions: () => getAccountTokenQueryOptions,
|
|
3978
|
+
getAccountVideosQueryOptions: () => getAccountVideosQueryOptions
|
|
3979
|
+
});
|
|
3506
3980
|
|
|
3507
3981
|
// src/modules/integrations/hivesigner/queries/index.ts
|
|
3508
3982
|
var queries_exports = {};
|
|
@@ -3631,1391 +4105,1181 @@ function getHivePoshLinksQueryOptions(username) {
|
|
|
3631
4105
|
profile: data.reddit_profile
|
|
3632
4106
|
}
|
|
3633
4107
|
};
|
|
3634
|
-
} catch (err) {
|
|
3635
|
-
return null;
|
|
3636
|
-
}
|
|
3637
|
-
}
|
|
3638
|
-
});
|
|
3639
|
-
}
|
|
3640
|
-
function getStatsQueryOptions({
|
|
3641
|
-
url,
|
|
3642
|
-
dimensions = [],
|
|
3643
|
-
metrics = ["visitors", "pageviews", "visit_duration"],
|
|
3644
|
-
enabled = true
|
|
3645
|
-
}) {
|
|
3646
|
-
return queryOptions({
|
|
3647
|
-
queryKey: ["integrations", "plausible", url, dimensions, metrics],
|
|
3648
|
-
queryFn: async () => {
|
|
3649
|
-
const fetchApi = getBoundFetch();
|
|
3650
|
-
const response = await fetchApi(`${CONFIG.privateApiHost}/api/stats`, {
|
|
3651
|
-
method: "POST",
|
|
3652
|
-
body: JSON.stringify({
|
|
3653
|
-
metrics,
|
|
3654
|
-
url: encodeURIComponent(url),
|
|
3655
|
-
dimensions
|
|
3656
|
-
}),
|
|
3657
|
-
headers: {
|
|
3658
|
-
"Content-Type": "application/json"
|
|
3659
|
-
}
|
|
3660
|
-
});
|
|
3661
|
-
return await response.json();
|
|
3662
|
-
},
|
|
3663
|
-
enabled: !!url && enabled
|
|
3664
|
-
});
|
|
3665
|
-
}
|
|
3666
|
-
function getRcStatsQueryOptions() {
|
|
3667
|
-
return queryOptions({
|
|
3668
|
-
queryKey: ["resource-credits", "stats"],
|
|
3669
|
-
queryFn: async () => {
|
|
3670
|
-
const response = await CONFIG.hiveClient.call(
|
|
3671
|
-
"rc_api",
|
|
3672
|
-
"get_rc_stats",
|
|
3673
|
-
{}
|
|
3674
|
-
);
|
|
3675
|
-
return response.rc_stats;
|
|
3676
|
-
}
|
|
3677
|
-
});
|
|
3678
|
-
}
|
|
3679
|
-
function getAccountRcQueryOptions(username) {
|
|
3680
|
-
return queryOptions({
|
|
3681
|
-
queryKey: ["resource-credits", "account", username],
|
|
3682
|
-
queryFn: async () => {
|
|
3683
|
-
const rcClient = new RCAPI(CONFIG.hiveClient);
|
|
3684
|
-
return rcClient.findRCAccounts([username]);
|
|
3685
|
-
},
|
|
3686
|
-
enabled: !!username
|
|
3687
|
-
});
|
|
3688
|
-
}
|
|
3689
|
-
function getGameStatusCheckQueryOptions(username, code, gameType) {
|
|
3690
|
-
return queryOptions({
|
|
3691
|
-
queryKey: ["games", "status-check", gameType, username],
|
|
3692
|
-
enabled: !!username && !!code,
|
|
3693
|
-
queryFn: async () => {
|
|
3694
|
-
if (!username || !code) {
|
|
3695
|
-
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
3696
|
-
}
|
|
3697
|
-
const fetchApi = getBoundFetch();
|
|
3698
|
-
const response = await fetchApi(
|
|
3699
|
-
CONFIG.privateApiHost + "/private-api/get-game",
|
|
3700
|
-
{
|
|
3701
|
-
method: "POST",
|
|
3702
|
-
body: JSON.stringify({
|
|
3703
|
-
game_type: gameType,
|
|
3704
|
-
code
|
|
3705
|
-
}),
|
|
3706
|
-
headers: {
|
|
3707
|
-
"Content-Type": "application/json"
|
|
3708
|
-
}
|
|
3709
|
-
}
|
|
3710
|
-
);
|
|
3711
|
-
return await response.json();
|
|
3712
|
-
}
|
|
3713
|
-
});
|
|
3714
|
-
}
|
|
3715
|
-
function useGameClaim(username, code, gameType, key) {
|
|
3716
|
-
const { mutateAsync: recordActivity } = useRecordActivity(
|
|
3717
|
-
username,
|
|
3718
|
-
"spin-rolled"
|
|
3719
|
-
);
|
|
3720
|
-
return useMutation({
|
|
3721
|
-
mutationKey: ["games", "post", gameType, username],
|
|
3722
|
-
mutationFn: async () => {
|
|
3723
|
-
if (!username || !code) {
|
|
3724
|
-
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
3725
|
-
}
|
|
3726
|
-
const fetchApi = getBoundFetch();
|
|
3727
|
-
const response = await fetchApi(
|
|
3728
|
-
CONFIG.privateApiHost + "/private-api/post-game",
|
|
3729
|
-
{
|
|
3730
|
-
method: "POST",
|
|
3731
|
-
body: JSON.stringify({
|
|
3732
|
-
game_type: gameType,
|
|
3733
|
-
code,
|
|
3734
|
-
key
|
|
3735
|
-
}),
|
|
3736
|
-
headers: {
|
|
3737
|
-
"Content-Type": "application/json"
|
|
3738
|
-
}
|
|
3739
|
-
}
|
|
3740
|
-
);
|
|
3741
|
-
return await response.json();
|
|
3742
|
-
},
|
|
3743
|
-
onSuccess() {
|
|
3744
|
-
recordActivity();
|
|
3745
|
-
}
|
|
3746
|
-
});
|
|
3747
|
-
}
|
|
3748
|
-
function getCommunitiesQueryOptions(sort, query, limit = 100, observer = void 0, enabled = true) {
|
|
3749
|
-
return queryOptions({
|
|
3750
|
-
queryKey: ["communities", "list", sort, query, limit],
|
|
3751
|
-
enabled,
|
|
3752
|
-
queryFn: async () => {
|
|
3753
|
-
const response = await CONFIG.hiveClient.call(
|
|
3754
|
-
"bridge",
|
|
3755
|
-
"list_communities",
|
|
3756
|
-
{
|
|
3757
|
-
last: "",
|
|
3758
|
-
limit,
|
|
3759
|
-
sort: sort === "hot" ? "rank" : sort,
|
|
3760
|
-
query: query ? query : null,
|
|
3761
|
-
observer
|
|
3762
|
-
}
|
|
3763
|
-
);
|
|
3764
|
-
return response ? sort === "hot" ? response.sort(() => Math.random() - 0.5) : response : [];
|
|
3765
|
-
}
|
|
3766
|
-
});
|
|
3767
|
-
}
|
|
3768
|
-
function getCommunityContextQueryOptions(username, communityName) {
|
|
3769
|
-
return queryOptions({
|
|
3770
|
-
queryKey: ["community", "context", username, communityName],
|
|
3771
|
-
enabled: !!username && !!communityName,
|
|
3772
|
-
queryFn: async () => {
|
|
3773
|
-
const response = await CONFIG.hiveClient.call(
|
|
3774
|
-
"bridge",
|
|
3775
|
-
"get_community_context",
|
|
3776
|
-
{
|
|
3777
|
-
account: username,
|
|
3778
|
-
name: communityName
|
|
3779
|
-
}
|
|
3780
|
-
);
|
|
3781
|
-
return {
|
|
3782
|
-
role: response?.role ?? "guest",
|
|
3783
|
-
subscribed: response?.subscribed ?? false
|
|
3784
|
-
};
|
|
3785
|
-
}
|
|
3786
|
-
});
|
|
3787
|
-
}
|
|
3788
|
-
function getCommunityQueryOptions(name, observer = "", enabled = true) {
|
|
3789
|
-
return queryOptions({
|
|
3790
|
-
queryKey: ["community", "single", name, observer],
|
|
3791
|
-
enabled: enabled && !!name,
|
|
3792
|
-
queryFn: async () => getCommunity(name ?? "", observer)
|
|
4108
|
+
} catch (err) {
|
|
4109
|
+
return null;
|
|
4110
|
+
}
|
|
4111
|
+
}
|
|
3793
4112
|
});
|
|
3794
4113
|
}
|
|
3795
|
-
function
|
|
4114
|
+
function getStatsQueryOptions({
|
|
4115
|
+
url,
|
|
4116
|
+
dimensions = [],
|
|
4117
|
+
metrics = ["visitors", "pageviews", "visit_duration"],
|
|
4118
|
+
enabled = true
|
|
4119
|
+
}) {
|
|
3796
4120
|
return queryOptions({
|
|
3797
|
-
queryKey: ["
|
|
4121
|
+
queryKey: ["integrations", "plausible", url, dimensions, metrics],
|
|
3798
4122
|
queryFn: async () => {
|
|
3799
|
-
const
|
|
3800
|
-
|
|
4123
|
+
const fetchApi = getBoundFetch();
|
|
4124
|
+
const response = await fetchApi(`${CONFIG.privateApiHost}/api/stats`, {
|
|
4125
|
+
method: "POST",
|
|
4126
|
+
body: JSON.stringify({
|
|
4127
|
+
metrics,
|
|
4128
|
+
url: encodeURIComponent(url),
|
|
4129
|
+
dimensions
|
|
4130
|
+
}),
|
|
4131
|
+
headers: {
|
|
4132
|
+
"Content-Type": "application/json"
|
|
4133
|
+
}
|
|
3801
4134
|
});
|
|
3802
|
-
return response
|
|
3803
|
-
},
|
|
3804
|
-
staleTime: 6e4
|
|
3805
|
-
});
|
|
3806
|
-
}
|
|
3807
|
-
function getAccountNotificationsInfiniteQueryOptions(account, limit) {
|
|
3808
|
-
return infiniteQueryOptions({
|
|
3809
|
-
queryKey: ["communities", "account-notifications", account, limit],
|
|
3810
|
-
initialPageParam: null,
|
|
3811
|
-
queryFn: async ({ pageParam }) => {
|
|
3812
|
-
try {
|
|
3813
|
-
const response = await CONFIG.hiveClient.call("bridge", "account_notifications", {
|
|
3814
|
-
account,
|
|
3815
|
-
limit,
|
|
3816
|
-
last_id: pageParam ?? void 0
|
|
3817
|
-
});
|
|
3818
|
-
return response ?? [];
|
|
3819
|
-
} catch {
|
|
3820
|
-
return [];
|
|
3821
|
-
}
|
|
4135
|
+
return await response.json();
|
|
3822
4136
|
},
|
|
3823
|
-
|
|
4137
|
+
enabled: !!url && enabled
|
|
3824
4138
|
});
|
|
3825
4139
|
}
|
|
3826
|
-
function
|
|
4140
|
+
function getRcStatsQueryOptions() {
|
|
3827
4141
|
return queryOptions({
|
|
3828
|
-
queryKey: ["
|
|
4142
|
+
queryKey: ["resource-credits", "stats"],
|
|
3829
4143
|
queryFn: async () => {
|
|
3830
|
-
const response = await
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
headers: {
|
|
3835
|
-
"Content-Type": "application/json"
|
|
3836
|
-
}
|
|
3837
|
-
}
|
|
4144
|
+
const response = await CONFIG.hiveClient.call(
|
|
4145
|
+
"rc_api",
|
|
4146
|
+
"get_rc_stats",
|
|
4147
|
+
{}
|
|
3838
4148
|
);
|
|
3839
|
-
|
|
3840
|
-
throw new Error(`Failed to fetch rewarded communities: ${response.status}`);
|
|
3841
|
-
}
|
|
3842
|
-
return response.json();
|
|
4149
|
+
return response.rc_stats;
|
|
3843
4150
|
}
|
|
3844
4151
|
});
|
|
3845
4152
|
}
|
|
3846
|
-
|
|
3847
|
-
// src/modules/communities/types/community.ts
|
|
3848
|
-
var ROLES = /* @__PURE__ */ ((ROLES2) => {
|
|
3849
|
-
ROLES2["OWNER"] = "owner";
|
|
3850
|
-
ROLES2["ADMIN"] = "admin";
|
|
3851
|
-
ROLES2["MOD"] = "mod";
|
|
3852
|
-
ROLES2["MEMBER"] = "member";
|
|
3853
|
-
ROLES2["GUEST"] = "guest";
|
|
3854
|
-
ROLES2["MUTED"] = "muted";
|
|
3855
|
-
return ROLES2;
|
|
3856
|
-
})(ROLES || {});
|
|
3857
|
-
var roleMap = {
|
|
3858
|
-
["owner" /* OWNER */]: [
|
|
3859
|
-
"admin" /* ADMIN */,
|
|
3860
|
-
"mod" /* MOD */,
|
|
3861
|
-
"member" /* MEMBER */,
|
|
3862
|
-
"guest" /* GUEST */,
|
|
3863
|
-
"muted" /* MUTED */
|
|
3864
|
-
],
|
|
3865
|
-
["admin" /* ADMIN */]: ["mod" /* MOD */, "member" /* MEMBER */, "guest" /* GUEST */, "muted" /* MUTED */],
|
|
3866
|
-
["mod" /* MOD */]: ["member" /* MEMBER */, "guest" /* GUEST */, "muted" /* MUTED */]
|
|
3867
|
-
};
|
|
3868
|
-
|
|
3869
|
-
// src/modules/communities/utils/index.ts
|
|
3870
|
-
function getCommunityType(name, type_id) {
|
|
3871
|
-
if (name.startsWith("hive-3") || type_id === 3) return "Council";
|
|
3872
|
-
if (name.startsWith("hive-2") || type_id === 2) return "Journal";
|
|
3873
|
-
return "Topic";
|
|
3874
|
-
}
|
|
3875
|
-
function getCommunityPermissions({
|
|
3876
|
-
communityType,
|
|
3877
|
-
userRole,
|
|
3878
|
-
subscribed
|
|
3879
|
-
}) {
|
|
3880
|
-
const canPost = (() => {
|
|
3881
|
-
if (userRole === "muted" /* MUTED */) return false;
|
|
3882
|
-
if (communityType === "Topic") return true;
|
|
3883
|
-
return ["owner" /* OWNER */, "admin" /* ADMIN */, "mod" /* MOD */, "member" /* MEMBER */].includes(
|
|
3884
|
-
userRole
|
|
3885
|
-
);
|
|
3886
|
-
})();
|
|
3887
|
-
const canComment = (() => {
|
|
3888
|
-
if (userRole === "muted" /* MUTED */) return false;
|
|
3889
|
-
switch (communityType) {
|
|
3890
|
-
case "Topic":
|
|
3891
|
-
return true;
|
|
3892
|
-
case "Journal":
|
|
3893
|
-
return userRole !== "guest" /* GUEST */ || subscribed;
|
|
3894
|
-
case "Council":
|
|
3895
|
-
return canPost;
|
|
3896
|
-
}
|
|
3897
|
-
})();
|
|
3898
|
-
const isModerator = ["owner" /* OWNER */, "admin" /* ADMIN */, "mod" /* MOD */].includes(userRole);
|
|
3899
|
-
return {
|
|
3900
|
-
canPost,
|
|
3901
|
-
canComment,
|
|
3902
|
-
isModerator
|
|
3903
|
-
};
|
|
3904
|
-
}
|
|
3905
|
-
function getNotificationsUnreadCountQueryOptions(activeUsername, code) {
|
|
4153
|
+
function getAccountRcQueryOptions(username) {
|
|
3906
4154
|
return queryOptions({
|
|
3907
|
-
queryKey: ["
|
|
4155
|
+
queryKey: ["resource-credits", "account", username],
|
|
3908
4156
|
queryFn: async () => {
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
}
|
|
3912
|
-
const response = await fetch(
|
|
3913
|
-
`${CONFIG.privateApiHost}/private-api/notifications/unread`,
|
|
3914
|
-
{
|
|
3915
|
-
method: "POST",
|
|
3916
|
-
body: JSON.stringify({ code }),
|
|
3917
|
-
headers: {
|
|
3918
|
-
"Content-Type": "application/json"
|
|
3919
|
-
}
|
|
3920
|
-
}
|
|
3921
|
-
);
|
|
3922
|
-
const data = await response.json();
|
|
3923
|
-
return data.count;
|
|
4157
|
+
const rcClient = new RCAPI(CONFIG.hiveClient);
|
|
4158
|
+
return rcClient.findRCAccounts([username]);
|
|
3924
4159
|
},
|
|
3925
|
-
enabled: !!
|
|
3926
|
-
initialData: 0,
|
|
3927
|
-
refetchInterval: 6e4
|
|
4160
|
+
enabled: !!username
|
|
3928
4161
|
});
|
|
3929
4162
|
}
|
|
3930
|
-
function
|
|
3931
|
-
return
|
|
3932
|
-
queryKey: ["
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
4163
|
+
function getGameStatusCheckQueryOptions(username, code, gameType) {
|
|
4164
|
+
return queryOptions({
|
|
4165
|
+
queryKey: ["games", "status-check", gameType, username],
|
|
4166
|
+
enabled: !!username && !!code,
|
|
4167
|
+
queryFn: async () => {
|
|
4168
|
+
if (!username || !code) {
|
|
4169
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
3936
4170
|
}
|
|
3937
|
-
const
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
since: pageParam,
|
|
3941
|
-
user: void 0
|
|
3942
|
-
};
|
|
3943
|
-
const response = await fetch(
|
|
3944
|
-
CONFIG.privateApiHost + "/private-api/notifications",
|
|
4171
|
+
const fetchApi = getBoundFetch();
|
|
4172
|
+
const response = await fetchApi(
|
|
4173
|
+
CONFIG.privateApiHost + "/private-api/get-game",
|
|
3945
4174
|
{
|
|
3946
4175
|
method: "POST",
|
|
4176
|
+
body: JSON.stringify({
|
|
4177
|
+
game_type: gameType,
|
|
4178
|
+
code
|
|
4179
|
+
}),
|
|
3947
4180
|
headers: {
|
|
3948
4181
|
"Content-Type": "application/json"
|
|
3949
|
-
}
|
|
3950
|
-
body: JSON.stringify(data)
|
|
4182
|
+
}
|
|
3951
4183
|
}
|
|
3952
4184
|
);
|
|
3953
|
-
return response.json();
|
|
3954
|
-
}
|
|
3955
|
-
enabled: !!activeUsername && !!code,
|
|
3956
|
-
initialData: { pages: [], pageParams: [] },
|
|
3957
|
-
initialPageParam: "",
|
|
3958
|
-
getNextPageParam: (lastPage) => lastPage?.[lastPage.length - 1]?.id ?? "",
|
|
3959
|
-
refetchOnMount: true
|
|
4185
|
+
return await response.json();
|
|
4186
|
+
}
|
|
3960
4187
|
});
|
|
3961
4188
|
}
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
NotificationFilter2["TRANSFERS"] = "transfers";
|
|
3973
|
-
NotificationFilter2["DELEGATIONS"] = "delegations";
|
|
3974
|
-
return NotificationFilter2;
|
|
3975
|
-
})(NotificationFilter || {});
|
|
3976
|
-
|
|
3977
|
-
// src/modules/notifications/enums/notify-types.ts
|
|
3978
|
-
var NotifyTypes = /* @__PURE__ */ ((NotifyTypes2) => {
|
|
3979
|
-
NotifyTypes2[NotifyTypes2["VOTE"] = 1] = "VOTE";
|
|
3980
|
-
NotifyTypes2[NotifyTypes2["MENTION"] = 2] = "MENTION";
|
|
3981
|
-
NotifyTypes2[NotifyTypes2["FOLLOW"] = 3] = "FOLLOW";
|
|
3982
|
-
NotifyTypes2[NotifyTypes2["COMMENT"] = 4] = "COMMENT";
|
|
3983
|
-
NotifyTypes2[NotifyTypes2["RE_BLOG"] = 5] = "RE_BLOG";
|
|
3984
|
-
NotifyTypes2[NotifyTypes2["TRANSFERS"] = 6] = "TRANSFERS";
|
|
3985
|
-
NotifyTypes2[NotifyTypes2["FAVORITES"] = 13] = "FAVORITES";
|
|
3986
|
-
NotifyTypes2[NotifyTypes2["BOOKMARKS"] = 15] = "BOOKMARKS";
|
|
3987
|
-
NotifyTypes2["ALLOW_NOTIFY"] = "ALLOW_NOTIFY";
|
|
3988
|
-
return NotifyTypes2;
|
|
3989
|
-
})(NotifyTypes || {});
|
|
3990
|
-
var ALL_NOTIFY_TYPES = [
|
|
3991
|
-
1 /* VOTE */,
|
|
3992
|
-
2 /* MENTION */,
|
|
3993
|
-
3 /* FOLLOW */,
|
|
3994
|
-
4 /* COMMENT */,
|
|
3995
|
-
5 /* RE_BLOG */,
|
|
3996
|
-
6 /* TRANSFERS */,
|
|
3997
|
-
13 /* FAVORITES */,
|
|
3998
|
-
15 /* BOOKMARKS */
|
|
3999
|
-
];
|
|
4000
|
-
var NotificationViewType = /* @__PURE__ */ ((NotificationViewType2) => {
|
|
4001
|
-
NotificationViewType2["ALL"] = "All";
|
|
4002
|
-
NotificationViewType2["UNREAD"] = "Unread";
|
|
4003
|
-
NotificationViewType2["READ"] = "Read";
|
|
4004
|
-
return NotificationViewType2;
|
|
4005
|
-
})(NotificationViewType || {});
|
|
4006
|
-
|
|
4007
|
-
// src/modules/notifications/queries/get-notifications-settings-query-options.ts
|
|
4008
|
-
function getNotificationsSettingsQueryOptions(activeUsername, code, initialMuted) {
|
|
4009
|
-
return queryOptions({
|
|
4010
|
-
queryKey: ["notifications", "settings", activeUsername],
|
|
4011
|
-
queryFn: async () => {
|
|
4012
|
-
let token = activeUsername + "-web";
|
|
4013
|
-
if (!code) {
|
|
4014
|
-
throw new Error("Missing access token");
|
|
4189
|
+
function useGameClaim(username, code, gameType, key) {
|
|
4190
|
+
const { mutateAsync: recordActivity } = useRecordActivity(
|
|
4191
|
+
username,
|
|
4192
|
+
"spin-rolled"
|
|
4193
|
+
);
|
|
4194
|
+
return useMutation({
|
|
4195
|
+
mutationKey: ["games", "post", gameType, username],
|
|
4196
|
+
mutationFn: async () => {
|
|
4197
|
+
if (!username || !code) {
|
|
4198
|
+
throw new Error("[SDK][Games] \u2013 missing auth");
|
|
4015
4199
|
}
|
|
4016
|
-
const
|
|
4017
|
-
|
|
4200
|
+
const fetchApi = getBoundFetch();
|
|
4201
|
+
const response = await fetchApi(
|
|
4202
|
+
CONFIG.privateApiHost + "/private-api/post-game",
|
|
4018
4203
|
{
|
|
4204
|
+
method: "POST",
|
|
4019
4205
|
body: JSON.stringify({
|
|
4206
|
+
game_type: gameType,
|
|
4020
4207
|
code,
|
|
4021
|
-
|
|
4022
|
-
token
|
|
4208
|
+
key
|
|
4023
4209
|
}),
|
|
4024
|
-
method: "POST",
|
|
4025
4210
|
headers: {
|
|
4026
4211
|
"Content-Type": "application/json"
|
|
4027
4212
|
}
|
|
4028
4213
|
}
|
|
4029
4214
|
);
|
|
4030
|
-
|
|
4031
|
-
throw new Error(`Failed to fetch notification settings: ${response.status}`);
|
|
4032
|
-
}
|
|
4033
|
-
return response.json();
|
|
4215
|
+
return await response.json();
|
|
4034
4216
|
},
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
initialData: () => {
|
|
4038
|
-
return {
|
|
4039
|
-
status: 0,
|
|
4040
|
-
system: "web",
|
|
4041
|
-
allows_notify: 0,
|
|
4042
|
-
notify_types: initialMuted ? [] : [
|
|
4043
|
-
4 /* COMMENT */,
|
|
4044
|
-
3 /* FOLLOW */,
|
|
4045
|
-
2 /* MENTION */,
|
|
4046
|
-
13 /* FAVORITES */,
|
|
4047
|
-
15 /* BOOKMARKS */,
|
|
4048
|
-
1 /* VOTE */,
|
|
4049
|
-
5 /* RE_BLOG */,
|
|
4050
|
-
6 /* TRANSFERS */
|
|
4051
|
-
]
|
|
4052
|
-
};
|
|
4217
|
+
onSuccess() {
|
|
4218
|
+
recordActivity();
|
|
4053
4219
|
}
|
|
4054
4220
|
});
|
|
4055
4221
|
}
|
|
4056
|
-
function
|
|
4222
|
+
function getCommunitiesQueryOptions(sort, query, limit = 100, observer = void 0, enabled = true) {
|
|
4057
4223
|
return queryOptions({
|
|
4058
|
-
queryKey: ["
|
|
4224
|
+
queryKey: ["communities", "list", sort, query, limit],
|
|
4225
|
+
enabled,
|
|
4059
4226
|
queryFn: async () => {
|
|
4060
|
-
const response = await
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4227
|
+
const response = await CONFIG.hiveClient.call(
|
|
4228
|
+
"bridge",
|
|
4229
|
+
"list_communities",
|
|
4230
|
+
{
|
|
4231
|
+
last: "",
|
|
4232
|
+
limit,
|
|
4233
|
+
sort: sort === "hot" ? "rank" : sort,
|
|
4234
|
+
query: query ? query : null,
|
|
4235
|
+
observer
|
|
4064
4236
|
}
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
throw new Error(`Failed to fetch announcements: ${response.status}`);
|
|
4068
|
-
}
|
|
4069
|
-
const data = await response.json();
|
|
4070
|
-
return data || [];
|
|
4071
|
-
},
|
|
4072
|
-
staleTime: 36e5
|
|
4073
|
-
});
|
|
4074
|
-
}
|
|
4075
|
-
function getProposalQueryOptions(id) {
|
|
4076
|
-
return queryOptions({
|
|
4077
|
-
queryKey: ["proposals", "proposal", id],
|
|
4078
|
-
queryFn: async () => {
|
|
4079
|
-
const r = await CONFIG.hiveClient.call("condenser_api", "find_proposals", [[id]]);
|
|
4080
|
-
const proposal = r[0];
|
|
4081
|
-
if (new Date(proposal.start_date) < /* @__PURE__ */ new Date() && new Date(proposal.end_date) >= /* @__PURE__ */ new Date()) {
|
|
4082
|
-
proposal.status = "active";
|
|
4083
|
-
} else if (new Date(proposal.end_date) < /* @__PURE__ */ new Date()) {
|
|
4084
|
-
proposal.status = "expired";
|
|
4085
|
-
} else {
|
|
4086
|
-
proposal.status = "inactive";
|
|
4087
|
-
}
|
|
4088
|
-
return proposal;
|
|
4237
|
+
);
|
|
4238
|
+
return response ? sort === "hot" ? response.sort(() => Math.random() - 0.5) : response : [];
|
|
4089
4239
|
}
|
|
4090
4240
|
});
|
|
4091
4241
|
}
|
|
4092
|
-
function
|
|
4242
|
+
function getCommunityContextQueryOptions(username, communityName) {
|
|
4093
4243
|
return queryOptions({
|
|
4094
|
-
queryKey: ["
|
|
4244
|
+
queryKey: ["community", "context", username, communityName],
|
|
4245
|
+
enabled: !!username && !!communityName,
|
|
4095
4246
|
queryFn: async () => {
|
|
4096
|
-
const response = await CONFIG.hiveClient.call(
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4247
|
+
const response = await CONFIG.hiveClient.call(
|
|
4248
|
+
"bridge",
|
|
4249
|
+
"get_community_context",
|
|
4250
|
+
{
|
|
4251
|
+
account: username,
|
|
4252
|
+
name: communityName
|
|
4253
|
+
}
|
|
4254
|
+
);
|
|
4255
|
+
return {
|
|
4256
|
+
role: response?.role ?? "guest",
|
|
4257
|
+
subscribed: response?.subscribed ?? false
|
|
4258
|
+
};
|
|
4107
4259
|
}
|
|
4108
4260
|
});
|
|
4109
4261
|
}
|
|
4110
|
-
function
|
|
4111
|
-
return
|
|
4112
|
-
queryKey: ["
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
staleTime: 0,
|
|
4116
|
-
// Always refetch on mount
|
|
4117
|
-
queryFn: async ({ pageParam }) => {
|
|
4118
|
-
const startParam = pageParam ?? voter;
|
|
4119
|
-
const response = await CONFIG.hiveClient.call("condenser_api", "list_proposal_votes", [
|
|
4120
|
-
[proposalId, startParam],
|
|
4121
|
-
limit,
|
|
4122
|
-
"by_proposal_voter"
|
|
4123
|
-
]);
|
|
4124
|
-
const list = response.filter((x) => x.proposal?.proposal_id === proposalId).map((x) => ({ id: x.id, voter: x.voter }));
|
|
4125
|
-
const rawAccounts = await CONFIG.hiveClient.database.getAccounts(list.map((l) => l.voter));
|
|
4126
|
-
const accounts = parseAccounts(rawAccounts);
|
|
4127
|
-
const page = list.map((i) => ({
|
|
4128
|
-
...i,
|
|
4129
|
-
voterAccount: accounts.find((a) => i.voter === a.name)
|
|
4130
|
-
}));
|
|
4131
|
-
return page;
|
|
4132
|
-
},
|
|
4133
|
-
getNextPageParam: (lastPage) => {
|
|
4134
|
-
const last = lastPage?.[lastPage.length - 1];
|
|
4135
|
-
return last?.voter ?? void 0;
|
|
4136
|
-
}
|
|
4262
|
+
function getCommunityQueryOptions(name, observer = "", enabled = true) {
|
|
4263
|
+
return queryOptions({
|
|
4264
|
+
queryKey: ["community", "single", name, observer],
|
|
4265
|
+
enabled: enabled && !!name,
|
|
4266
|
+
queryFn: async () => getCommunity(name ?? "", observer)
|
|
4137
4267
|
});
|
|
4138
4268
|
}
|
|
4139
|
-
function
|
|
4269
|
+
function getCommunitySubscribersQueryOptions(communityName) {
|
|
4140
4270
|
return queryOptions({
|
|
4141
|
-
queryKey: ["
|
|
4142
|
-
enabled: !!voter && voter !== "",
|
|
4143
|
-
staleTime: 60 * 1e3,
|
|
4144
|
-
// Cache for 1 minute
|
|
4271
|
+
queryKey: ["communities", "subscribers", communityName],
|
|
4145
4272
|
queryFn: async () => {
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
}
|
|
4149
|
-
const response = await CONFIG.hiveClient.call("database_api", "list_proposal_votes", {
|
|
4150
|
-
start: [voter],
|
|
4151
|
-
limit: 1e3,
|
|
4152
|
-
order: "by_voter_proposal",
|
|
4153
|
-
order_direction: "ascending",
|
|
4154
|
-
status: "votable"
|
|
4273
|
+
const response = await CONFIG.hiveClient.call("bridge", "list_subscribers", {
|
|
4274
|
+
community: communityName
|
|
4155
4275
|
});
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
});
|
|
4160
|
-
}
|
|
4161
|
-
function getVestingDelegationsQueryOptions(username, from, limit = 50) {
|
|
4162
|
-
return queryOptions({
|
|
4163
|
-
queryKey: ["wallet", "vesting-delegations", username, from, limit],
|
|
4164
|
-
queryFn: () => CONFIG.hiveClient.database.call("get_vesting_delegations", [
|
|
4165
|
-
username,
|
|
4166
|
-
from,
|
|
4167
|
-
limit
|
|
4168
|
-
]),
|
|
4169
|
-
enabled: !!username
|
|
4170
|
-
});
|
|
4171
|
-
}
|
|
4172
|
-
function getConversionRequestsQueryOptions(account) {
|
|
4173
|
-
return queryOptions({
|
|
4174
|
-
queryKey: ["wallet", "conversion-requests", account],
|
|
4175
|
-
queryFn: () => CONFIG.hiveClient.database.call("get_conversion_requests", [
|
|
4176
|
-
account
|
|
4177
|
-
]),
|
|
4178
|
-
select: (data) => data.sort((a, b) => a.requestid - b.requestid)
|
|
4179
|
-
});
|
|
4180
|
-
}
|
|
4181
|
-
function getCollateralizedConversionRequestsQueryOptions(account) {
|
|
4182
|
-
return queryOptions({
|
|
4183
|
-
queryKey: ["wallet", "collateralized-conversion-requests", account],
|
|
4184
|
-
queryFn: () => CONFIG.hiveClient.database.call("get_collateralized_conversion_requests", [
|
|
4185
|
-
account
|
|
4186
|
-
]),
|
|
4187
|
-
select: (data) => data.sort((a, b) => a.requestid - b.requestid)
|
|
4188
|
-
});
|
|
4189
|
-
}
|
|
4190
|
-
function getSavingsWithdrawFromQueryOptions(account) {
|
|
4191
|
-
return queryOptions({
|
|
4192
|
-
queryKey: ["wallet", "savings-withdraw", account],
|
|
4193
|
-
queryFn: () => CONFIG.hiveClient.database.call("get_savings_withdraw_from", [
|
|
4194
|
-
account
|
|
4195
|
-
]),
|
|
4196
|
-
select: (data) => data.sort((a, b) => a.request_id - b.request_id)
|
|
4197
|
-
});
|
|
4198
|
-
}
|
|
4199
|
-
function getWithdrawRoutesQueryOptions(account) {
|
|
4200
|
-
return queryOptions({
|
|
4201
|
-
queryKey: ["wallet", "withdraw-routes", account],
|
|
4202
|
-
queryFn: () => CONFIG.hiveClient.database.call("get_withdraw_routes", [
|
|
4203
|
-
account,
|
|
4204
|
-
"outgoing"
|
|
4205
|
-
])
|
|
4206
|
-
});
|
|
4207
|
-
}
|
|
4208
|
-
function getOpenOrdersQueryOptions(user) {
|
|
4209
|
-
return queryOptions({
|
|
4210
|
-
queryKey: ["wallet", "open-orders", user],
|
|
4211
|
-
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_open_orders", [
|
|
4212
|
-
user
|
|
4213
|
-
]),
|
|
4214
|
-
select: (data) => data.sort((a, b) => a.orderid - b.orderid),
|
|
4215
|
-
enabled: !!user
|
|
4276
|
+
return response ?? [];
|
|
4277
|
+
},
|
|
4278
|
+
staleTime: 6e4
|
|
4216
4279
|
});
|
|
4217
4280
|
}
|
|
4218
|
-
function
|
|
4281
|
+
function getAccountNotificationsInfiniteQueryOptions(account, limit) {
|
|
4219
4282
|
return infiniteQueryOptions({
|
|
4220
|
-
queryKey: ["
|
|
4283
|
+
queryKey: ["communities", "account-notifications", account, limit],
|
|
4221
4284
|
initialPageParam: null,
|
|
4222
4285
|
queryFn: async ({ pageParam }) => {
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4286
|
+
try {
|
|
4287
|
+
const response = await CONFIG.hiveClient.call("bridge", "account_notifications", {
|
|
4288
|
+
account,
|
|
4289
|
+
limit,
|
|
4290
|
+
last_id: pageParam ?? void 0
|
|
4291
|
+
});
|
|
4292
|
+
return response ?? [];
|
|
4293
|
+
} catch {
|
|
4294
|
+
return [];
|
|
4230
4295
|
}
|
|
4231
|
-
return delegations;
|
|
4232
4296
|
},
|
|
4233
|
-
getNextPageParam: (lastPage) => lastPage
|
|
4297
|
+
getNextPageParam: (lastPage) => lastPage?.length > 0 ? lastPage[lastPage.length - 1].id : null
|
|
4234
4298
|
});
|
|
4235
4299
|
}
|
|
4236
|
-
function
|
|
4300
|
+
function getRewardedCommunitiesQueryOptions() {
|
|
4237
4301
|
return queryOptions({
|
|
4238
|
-
queryKey: ["
|
|
4239
|
-
enabled: !!username,
|
|
4302
|
+
queryKey: ["communities", "rewarded"],
|
|
4240
4303
|
queryFn: async () => {
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4304
|
+
const response = await fetch(
|
|
4305
|
+
CONFIG.privateApiHost + "/private-api/rewarded-communities",
|
|
4306
|
+
{
|
|
4307
|
+
method: "GET",
|
|
4308
|
+
headers: {
|
|
4309
|
+
"Content-Type": "application/json"
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4247
4312
|
);
|
|
4248
4313
|
if (!response.ok) {
|
|
4249
|
-
throw new Error(`Failed to fetch
|
|
4314
|
+
throw new Error(`Failed to fetch rewarded communities: ${response.status}`);
|
|
4250
4315
|
}
|
|
4251
4316
|
return response.json();
|
|
4252
4317
|
}
|
|
4253
4318
|
});
|
|
4254
4319
|
}
|
|
4255
|
-
|
|
4320
|
+
|
|
4321
|
+
// src/modules/communities/types/community.ts
|
|
4322
|
+
var ROLES = /* @__PURE__ */ ((ROLES2) => {
|
|
4323
|
+
ROLES2["OWNER"] = "owner";
|
|
4324
|
+
ROLES2["ADMIN"] = "admin";
|
|
4325
|
+
ROLES2["MOD"] = "mod";
|
|
4326
|
+
ROLES2["MEMBER"] = "member";
|
|
4327
|
+
ROLES2["GUEST"] = "guest";
|
|
4328
|
+
ROLES2["MUTED"] = "muted";
|
|
4329
|
+
return ROLES2;
|
|
4330
|
+
})(ROLES || {});
|
|
4331
|
+
var roleMap = {
|
|
4332
|
+
["owner" /* OWNER */]: [
|
|
4333
|
+
"admin" /* ADMIN */,
|
|
4334
|
+
"mod" /* MOD */,
|
|
4335
|
+
"member" /* MEMBER */,
|
|
4336
|
+
"guest" /* GUEST */,
|
|
4337
|
+
"muted" /* MUTED */
|
|
4338
|
+
],
|
|
4339
|
+
["admin" /* ADMIN */]: ["mod" /* MOD */, "member" /* MEMBER */, "guest" /* GUEST */, "muted" /* MUTED */],
|
|
4340
|
+
["mod" /* MOD */]: ["member" /* MEMBER */, "guest" /* GUEST */, "muted" /* MUTED */]
|
|
4341
|
+
};
|
|
4342
|
+
|
|
4343
|
+
// src/modules/communities/utils/index.ts
|
|
4344
|
+
function getCommunityType(name, type_id) {
|
|
4345
|
+
if (name.startsWith("hive-3") || type_id === 3) return "Council";
|
|
4346
|
+
if (name.startsWith("hive-2") || type_id === 2) return "Journal";
|
|
4347
|
+
return "Topic";
|
|
4348
|
+
}
|
|
4349
|
+
function getCommunityPermissions({
|
|
4350
|
+
communityType,
|
|
4351
|
+
userRole,
|
|
4352
|
+
subscribed
|
|
4353
|
+
}) {
|
|
4354
|
+
const canPost = (() => {
|
|
4355
|
+
if (userRole === "muted" /* MUTED */) return false;
|
|
4356
|
+
if (communityType === "Topic") return true;
|
|
4357
|
+
return ["owner" /* OWNER */, "admin" /* ADMIN */, "mod" /* MOD */, "member" /* MEMBER */].includes(
|
|
4358
|
+
userRole
|
|
4359
|
+
);
|
|
4360
|
+
})();
|
|
4361
|
+
const canComment = (() => {
|
|
4362
|
+
if (userRole === "muted" /* MUTED */) return false;
|
|
4363
|
+
switch (communityType) {
|
|
4364
|
+
case "Topic":
|
|
4365
|
+
return true;
|
|
4366
|
+
case "Journal":
|
|
4367
|
+
return userRole !== "guest" /* GUEST */ || subscribed;
|
|
4368
|
+
case "Council":
|
|
4369
|
+
return canPost;
|
|
4370
|
+
}
|
|
4371
|
+
})();
|
|
4372
|
+
const isModerator = ["owner" /* OWNER */, "admin" /* ADMIN */, "mod" /* MOD */].includes(userRole);
|
|
4373
|
+
return {
|
|
4374
|
+
canPost,
|
|
4375
|
+
canComment,
|
|
4376
|
+
isModerator
|
|
4377
|
+
};
|
|
4378
|
+
}
|
|
4379
|
+
function getNotificationsUnreadCountQueryOptions(activeUsername, code) {
|
|
4256
4380
|
return queryOptions({
|
|
4257
|
-
queryKey: ["
|
|
4381
|
+
queryKey: ["notifications", "unread", activeUsername],
|
|
4258
4382
|
queryFn: async () => {
|
|
4383
|
+
if (!code) {
|
|
4384
|
+
return 0;
|
|
4385
|
+
}
|
|
4259
4386
|
const response = await fetch(
|
|
4260
|
-
CONFIG.privateApiHost
|
|
4387
|
+
`${CONFIG.privateApiHost}/private-api/notifications/unread`,
|
|
4388
|
+
{
|
|
4389
|
+
method: "POST",
|
|
4390
|
+
body: JSON.stringify({ code }),
|
|
4391
|
+
headers: {
|
|
4392
|
+
"Content-Type": "application/json"
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4261
4395
|
);
|
|
4262
|
-
if (!response.ok) {
|
|
4263
|
-
throw new Error(`Failed to fetch received vesting shares: ${response.status}`);
|
|
4264
|
-
}
|
|
4265
4396
|
const data = await response.json();
|
|
4266
|
-
return data.
|
|
4267
|
-
}
|
|
4397
|
+
return data.count;
|
|
4398
|
+
},
|
|
4399
|
+
enabled: !!activeUsername && !!code,
|
|
4400
|
+
initialData: 0,
|
|
4401
|
+
refetchInterval: 6e4
|
|
4268
4402
|
});
|
|
4269
4403
|
}
|
|
4270
|
-
function
|
|
4404
|
+
function getNotificationsInfiniteQueryOptions(activeUsername, code, filter = void 0) {
|
|
4271
4405
|
return infiniteQueryOptions({
|
|
4272
|
-
queryKey: ["
|
|
4406
|
+
queryKey: ["notifications", activeUsername, filter],
|
|
4407
|
+
queryFn: async ({ pageParam }) => {
|
|
4408
|
+
if (!code) {
|
|
4409
|
+
return [];
|
|
4410
|
+
}
|
|
4411
|
+
const data = {
|
|
4412
|
+
code,
|
|
4413
|
+
filter,
|
|
4414
|
+
since: pageParam,
|
|
4415
|
+
user: void 0
|
|
4416
|
+
};
|
|
4417
|
+
const response = await fetch(
|
|
4418
|
+
CONFIG.privateApiHost + "/private-api/notifications",
|
|
4419
|
+
{
|
|
4420
|
+
method: "POST",
|
|
4421
|
+
headers: {
|
|
4422
|
+
"Content-Type": "application/json"
|
|
4423
|
+
},
|
|
4424
|
+
body: JSON.stringify(data)
|
|
4425
|
+
}
|
|
4426
|
+
);
|
|
4427
|
+
return response.json();
|
|
4428
|
+
},
|
|
4429
|
+
enabled: !!activeUsername && !!code,
|
|
4430
|
+
initialData: { pages: [], pageParams: [] },
|
|
4273
4431
|
initialPageParam: "",
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
limit
|
|
4277
|
-
]),
|
|
4278
|
-
getNextPageParam: (lastPage) => {
|
|
4279
|
-
const last = lastPage?.[lastPage.length - 1];
|
|
4280
|
-
return last ? last.owner : void 0;
|
|
4281
|
-
}
|
|
4282
|
-
});
|
|
4283
|
-
}
|
|
4284
|
-
function getOrderBookQueryOptions(limit = 500) {
|
|
4285
|
-
return queryOptions({
|
|
4286
|
-
queryKey: ["market", "order-book", limit],
|
|
4287
|
-
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_order_book", [
|
|
4288
|
-
limit
|
|
4289
|
-
])
|
|
4290
|
-
});
|
|
4291
|
-
}
|
|
4292
|
-
function getMarketStatisticsQueryOptions() {
|
|
4293
|
-
return queryOptions({
|
|
4294
|
-
queryKey: ["market", "statistics"],
|
|
4295
|
-
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_ticker", [])
|
|
4296
|
-
});
|
|
4297
|
-
}
|
|
4298
|
-
function getMarketHistoryQueryOptions(seconds, startDate, endDate) {
|
|
4299
|
-
const formatDate2 = (date) => {
|
|
4300
|
-
return date.toISOString().replace(/\.\d{3}Z$/, "");
|
|
4301
|
-
};
|
|
4302
|
-
return queryOptions({
|
|
4303
|
-
queryKey: ["market", "history", seconds, startDate.getTime(), endDate.getTime()],
|
|
4304
|
-
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_market_history", [
|
|
4305
|
-
seconds,
|
|
4306
|
-
formatDate2(startDate),
|
|
4307
|
-
formatDate2(endDate)
|
|
4308
|
-
])
|
|
4432
|
+
getNextPageParam: (lastPage) => lastPage?.[lastPage.length - 1]?.id ?? "",
|
|
4433
|
+
refetchOnMount: true
|
|
4309
4434
|
});
|
|
4310
4435
|
}
|
|
4311
|
-
|
|
4436
|
+
|
|
4437
|
+
// src/modules/notifications/enums/notification-filter.ts
|
|
4438
|
+
var NotificationFilter = /* @__PURE__ */ ((NotificationFilter2) => {
|
|
4439
|
+
NotificationFilter2["VOTES"] = "rvotes";
|
|
4440
|
+
NotificationFilter2["MENTIONS"] = "mentions";
|
|
4441
|
+
NotificationFilter2["FAVORITES"] = "nfavorites";
|
|
4442
|
+
NotificationFilter2["BOOKMARKS"] = "nbookmarks";
|
|
4443
|
+
NotificationFilter2["FOLLOWS"] = "follows";
|
|
4444
|
+
NotificationFilter2["REPLIES"] = "replies";
|
|
4445
|
+
NotificationFilter2["REBLOGS"] = "reblogs";
|
|
4446
|
+
NotificationFilter2["TRANSFERS"] = "transfers";
|
|
4447
|
+
NotificationFilter2["DELEGATIONS"] = "delegations";
|
|
4448
|
+
return NotificationFilter2;
|
|
4449
|
+
})(NotificationFilter || {});
|
|
4450
|
+
|
|
4451
|
+
// src/modules/notifications/enums/notify-types.ts
|
|
4452
|
+
var NotifyTypes = /* @__PURE__ */ ((NotifyTypes2) => {
|
|
4453
|
+
NotifyTypes2[NotifyTypes2["VOTE"] = 1] = "VOTE";
|
|
4454
|
+
NotifyTypes2[NotifyTypes2["MENTION"] = 2] = "MENTION";
|
|
4455
|
+
NotifyTypes2[NotifyTypes2["FOLLOW"] = 3] = "FOLLOW";
|
|
4456
|
+
NotifyTypes2[NotifyTypes2["COMMENT"] = 4] = "COMMENT";
|
|
4457
|
+
NotifyTypes2[NotifyTypes2["RE_BLOG"] = 5] = "RE_BLOG";
|
|
4458
|
+
NotifyTypes2[NotifyTypes2["TRANSFERS"] = 6] = "TRANSFERS";
|
|
4459
|
+
NotifyTypes2[NotifyTypes2["FAVORITES"] = 13] = "FAVORITES";
|
|
4460
|
+
NotifyTypes2[NotifyTypes2["BOOKMARKS"] = 15] = "BOOKMARKS";
|
|
4461
|
+
NotifyTypes2["ALLOW_NOTIFY"] = "ALLOW_NOTIFY";
|
|
4462
|
+
return NotifyTypes2;
|
|
4463
|
+
})(NotifyTypes || {});
|
|
4464
|
+
var ALL_NOTIFY_TYPES = [
|
|
4465
|
+
1 /* VOTE */,
|
|
4466
|
+
2 /* MENTION */,
|
|
4467
|
+
3 /* FOLLOW */,
|
|
4468
|
+
4 /* COMMENT */,
|
|
4469
|
+
5 /* RE_BLOG */,
|
|
4470
|
+
6 /* TRANSFERS */,
|
|
4471
|
+
13 /* FAVORITES */,
|
|
4472
|
+
15 /* BOOKMARKS */
|
|
4473
|
+
];
|
|
4474
|
+
var NotificationViewType = /* @__PURE__ */ ((NotificationViewType2) => {
|
|
4475
|
+
NotificationViewType2["ALL"] = "All";
|
|
4476
|
+
NotificationViewType2["UNREAD"] = "Unread";
|
|
4477
|
+
NotificationViewType2["READ"] = "Read";
|
|
4478
|
+
return NotificationViewType2;
|
|
4479
|
+
})(NotificationViewType || {});
|
|
4480
|
+
|
|
4481
|
+
// src/modules/notifications/queries/get-notifications-settings-query-options.ts
|
|
4482
|
+
function getNotificationsSettingsQueryOptions(activeUsername, code, initialMuted) {
|
|
4312
4483
|
return queryOptions({
|
|
4313
|
-
queryKey: ["
|
|
4484
|
+
queryKey: ["notifications", "settings", activeUsername],
|
|
4314
4485
|
queryFn: async () => {
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
"
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4486
|
+
let token = activeUsername + "-web";
|
|
4487
|
+
if (!code) {
|
|
4488
|
+
throw new Error("Missing access token");
|
|
4489
|
+
}
|
|
4490
|
+
const response = await fetch(
|
|
4491
|
+
CONFIG.privateApiHost + "/private-api/detail-device",
|
|
4492
|
+
{
|
|
4493
|
+
body: JSON.stringify({
|
|
4494
|
+
code,
|
|
4495
|
+
username: activeUsername,
|
|
4496
|
+
token
|
|
4497
|
+
}),
|
|
4498
|
+
method: "POST",
|
|
4499
|
+
headers: {
|
|
4500
|
+
"Content-Type": "application/json"
|
|
4501
|
+
}
|
|
4502
|
+
}
|
|
4329
4503
|
);
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4504
|
+
if (!response.ok) {
|
|
4505
|
+
throw new Error(`Failed to fetch notification settings: ${response.status}`);
|
|
4506
|
+
}
|
|
4507
|
+
return response.json();
|
|
4508
|
+
},
|
|
4509
|
+
enabled: !!activeUsername && !!code,
|
|
4510
|
+
refetchOnMount: false,
|
|
4511
|
+
initialData: () => {
|
|
4512
|
+
return {
|
|
4513
|
+
status: 0,
|
|
4514
|
+
system: "web",
|
|
4515
|
+
allows_notify: 0,
|
|
4516
|
+
notify_types: initialMuted ? [] : [
|
|
4517
|
+
4 /* COMMENT */,
|
|
4518
|
+
3 /* FOLLOW */,
|
|
4519
|
+
2 /* MENTION */,
|
|
4520
|
+
13 /* FAVORITES */,
|
|
4521
|
+
15 /* BOOKMARKS */,
|
|
4522
|
+
1 /* VOTE */,
|
|
4523
|
+
5 /* RE_BLOG */,
|
|
4524
|
+
6 /* TRANSFERS */
|
|
4525
|
+
]
|
|
4338
4526
|
};
|
|
4339
|
-
return result;
|
|
4340
4527
|
}
|
|
4341
4528
|
});
|
|
4342
4529
|
}
|
|
4343
|
-
function
|
|
4530
|
+
function getAnnouncementsQueryOptions() {
|
|
4344
4531
|
return queryOptions({
|
|
4345
|
-
queryKey: ["
|
|
4346
|
-
queryFn: async (
|
|
4347
|
-
const
|
|
4348
|
-
|
|
4349
|
-
|
|
4532
|
+
queryKey: ["notifications", "announcements"],
|
|
4533
|
+
queryFn: async () => {
|
|
4534
|
+
const response = await fetch(CONFIG.privateApiHost + "/private-api/announcements", {
|
|
4535
|
+
method: "GET",
|
|
4536
|
+
headers: {
|
|
4537
|
+
"Content-Type": "application/json"
|
|
4538
|
+
}
|
|
4539
|
+
});
|
|
4350
4540
|
if (!response.ok) {
|
|
4351
|
-
throw new Error(`Failed to fetch
|
|
4541
|
+
throw new Error(`Failed to fetch announcements: ${response.status}`);
|
|
4352
4542
|
}
|
|
4353
|
-
|
|
4354
|
-
|
|
4543
|
+
const data = await response.json();
|
|
4544
|
+
return data || [];
|
|
4545
|
+
},
|
|
4546
|
+
staleTime: 36e5
|
|
4355
4547
|
});
|
|
4356
4548
|
}
|
|
4357
|
-
function
|
|
4358
|
-
|
|
4549
|
+
function useMarkNotificationsRead(username, code, onSuccess, onError) {
|
|
4550
|
+
const queryClient = getQueryClient();
|
|
4551
|
+
return useMutation({
|
|
4552
|
+
mutationKey: ["notifications", "mark-read", username],
|
|
4553
|
+
mutationFn: async ({ id }) => {
|
|
4554
|
+
if (!username || !code) {
|
|
4555
|
+
throw new Error("[SDK][Notifications] \u2013 missing auth for markNotifications");
|
|
4556
|
+
}
|
|
4557
|
+
return markNotifications(code, id);
|
|
4558
|
+
},
|
|
4559
|
+
// Optimistic update: Immediately mark notifications as read in cache
|
|
4560
|
+
onMutate: async ({ id }) => {
|
|
4561
|
+
await queryClient.cancelQueries({ queryKey: ["notifications"] });
|
|
4562
|
+
const previousNotifications = [];
|
|
4563
|
+
const queriesData = queryClient.getQueriesData({
|
|
4564
|
+
queryKey: ["notifications"]
|
|
4565
|
+
});
|
|
4566
|
+
queriesData.forEach(([queryKey, data]) => {
|
|
4567
|
+
if (data) {
|
|
4568
|
+
previousNotifications.push([queryKey, data]);
|
|
4569
|
+
const updatedData = data.map((item) => ({
|
|
4570
|
+
...item,
|
|
4571
|
+
// If specific ID provided: mark only that notification
|
|
4572
|
+
// If no ID (mark all): mark ALL notifications
|
|
4573
|
+
read: !id || id === item.id ? 1 : item.read
|
|
4574
|
+
}));
|
|
4575
|
+
queryClient.setQueryData(queryKey, updatedData);
|
|
4576
|
+
}
|
|
4577
|
+
});
|
|
4578
|
+
return { previousNotifications };
|
|
4579
|
+
},
|
|
4580
|
+
onSuccess: (response, variables) => {
|
|
4581
|
+
const unreadCount = typeof response === "object" && response !== null ? response.unread : void 0;
|
|
4582
|
+
onSuccess?.(unreadCount);
|
|
4583
|
+
if (!variables.id) {
|
|
4584
|
+
queryClient.invalidateQueries({
|
|
4585
|
+
queryKey: ["notifications"]
|
|
4586
|
+
});
|
|
4587
|
+
}
|
|
4588
|
+
},
|
|
4589
|
+
// Rollback optimistic update on error
|
|
4590
|
+
onError: (error, _variables, context) => {
|
|
4591
|
+
if (context?.previousNotifications) {
|
|
4592
|
+
context.previousNotifications.forEach(([queryKey, data]) => {
|
|
4593
|
+
queryClient.setQueryData(queryKey, data);
|
|
4594
|
+
});
|
|
4595
|
+
}
|
|
4596
|
+
onError?.(error);
|
|
4597
|
+
},
|
|
4598
|
+
// Always refetch after mutation settles
|
|
4599
|
+
onSettled: () => {
|
|
4600
|
+
queryClient.invalidateQueries({
|
|
4601
|
+
queryKey: ["notifications"]
|
|
4602
|
+
});
|
|
4603
|
+
}
|
|
4604
|
+
});
|
|
4359
4605
|
}
|
|
4360
|
-
function
|
|
4361
|
-
const end = endDate ?? /* @__PURE__ */ new Date();
|
|
4362
|
-
const start = startDate ?? new Date(end.getTime() - 10 * 60 * 60 * 1e3);
|
|
4606
|
+
function getProposalQueryOptions(id) {
|
|
4363
4607
|
return queryOptions({
|
|
4364
|
-
queryKey: ["
|
|
4365
|
-
queryFn: () =>
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4608
|
+
queryKey: ["proposals", "proposal", id],
|
|
4609
|
+
queryFn: async () => {
|
|
4610
|
+
const r = await CONFIG.hiveClient.call("condenser_api", "find_proposals", [[id]]);
|
|
4611
|
+
const proposal = r[0];
|
|
4612
|
+
if (new Date(proposal.start_date) < /* @__PURE__ */ new Date() && new Date(proposal.end_date) >= /* @__PURE__ */ new Date()) {
|
|
4613
|
+
proposal.status = "active";
|
|
4614
|
+
} else if (new Date(proposal.end_date) < /* @__PURE__ */ new Date()) {
|
|
4615
|
+
proposal.status = "expired";
|
|
4616
|
+
} else {
|
|
4617
|
+
proposal.status = "inactive";
|
|
4618
|
+
}
|
|
4619
|
+
return proposal;
|
|
4620
|
+
}
|
|
4370
4621
|
});
|
|
4371
4622
|
}
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
}
|
|
4390
|
-
async function getCurrencyRate(cur) {
|
|
4391
|
-
if (cur === "hbd") {
|
|
4392
|
-
return 1;
|
|
4393
|
-
}
|
|
4394
|
-
const fetchApi = getBoundFetch();
|
|
4395
|
-
const url = `https://api.coingecko.com/api/v3/simple/price?ids=hive_dollar&vs_currencies=${cur}`;
|
|
4396
|
-
const response = await fetchApi(url);
|
|
4397
|
-
const data = await parseJsonResponse(response);
|
|
4398
|
-
return data.hive_dollar[cur];
|
|
4399
|
-
}
|
|
4400
|
-
async function getCurrencyTokenRate(currency, token) {
|
|
4401
|
-
const fetchApi = getBoundFetch();
|
|
4402
|
-
const response = await fetchApi(
|
|
4403
|
-
CONFIG.privateApiHost + `/private-api/market-data/${currency === "hbd" ? "usd" : currency}/${token}`
|
|
4404
|
-
);
|
|
4405
|
-
return parseJsonResponse(response);
|
|
4406
|
-
}
|
|
4407
|
-
async function getCurrencyRates() {
|
|
4408
|
-
const fetchApi = getBoundFetch();
|
|
4409
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/market-data/latest");
|
|
4410
|
-
return parseJsonResponse(response);
|
|
4623
|
+
function getProposalsQueryOptions() {
|
|
4624
|
+
return queryOptions({
|
|
4625
|
+
queryKey: ["proposals", "list"],
|
|
4626
|
+
queryFn: async () => {
|
|
4627
|
+
const response = await CONFIG.hiveClient.call("database_api", "list_proposals", {
|
|
4628
|
+
start: [-1],
|
|
4629
|
+
limit: 500,
|
|
4630
|
+
order: "by_total_votes",
|
|
4631
|
+
order_direction: "descending",
|
|
4632
|
+
status: "all"
|
|
4633
|
+
});
|
|
4634
|
+
const proposals = response.proposals;
|
|
4635
|
+
const expired = proposals.filter((x) => x.status === "expired");
|
|
4636
|
+
const others = proposals.filter((x) => x.status !== "expired");
|
|
4637
|
+
return [...others, ...expired];
|
|
4638
|
+
}
|
|
4639
|
+
});
|
|
4411
4640
|
}
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4641
|
+
function getProposalVotesInfiniteQueryOptions(proposalId, voter, limit) {
|
|
4642
|
+
return infiniteQueryOptions({
|
|
4643
|
+
queryKey: ["proposals", "votes", proposalId, voter, limit],
|
|
4644
|
+
initialPageParam: voter,
|
|
4645
|
+
refetchOnMount: true,
|
|
4646
|
+
staleTime: 0,
|
|
4647
|
+
// Always refetch on mount
|
|
4648
|
+
queryFn: async ({ pageParam }) => {
|
|
4649
|
+
const startParam = pageParam ?? voter;
|
|
4650
|
+
const response = await CONFIG.hiveClient.call("condenser_api", "list_proposal_votes", [
|
|
4651
|
+
[proposalId, startParam],
|
|
4652
|
+
limit,
|
|
4653
|
+
"by_proposal_voter"
|
|
4654
|
+
]);
|
|
4655
|
+
const list = response.filter((x) => x.proposal?.proposal_id === proposalId).map((x) => ({ id: x.id, voter: x.voter }));
|
|
4656
|
+
const rawAccounts = await CONFIG.hiveClient.database.getAccounts(list.map((l) => l.voter));
|
|
4657
|
+
const accounts = parseAccounts(rawAccounts);
|
|
4658
|
+
const page = list.map((i) => ({
|
|
4659
|
+
...i,
|
|
4660
|
+
voterAccount: accounts.find((a) => i.voter === a.name)
|
|
4661
|
+
}));
|
|
4662
|
+
return page;
|
|
4663
|
+
},
|
|
4664
|
+
getNextPageParam: (lastPage) => {
|
|
4665
|
+
const last = lastPage?.[lastPage.length - 1];
|
|
4666
|
+
return last?.voter ?? void 0;
|
|
4667
|
+
}
|
|
4668
|
+
});
|
|
4418
4669
|
}
|
|
4419
|
-
function
|
|
4670
|
+
function getUserProposalVotesQueryOptions(voter) {
|
|
4420
4671
|
return queryOptions({
|
|
4421
|
-
queryKey: ["
|
|
4672
|
+
queryKey: ["proposals", "votes", "by-user", voter],
|
|
4673
|
+
enabled: !!voter && voter !== "",
|
|
4674
|
+
staleTime: 60 * 1e3,
|
|
4675
|
+
// Cache for 1 minute
|
|
4422
4676
|
queryFn: async () => {
|
|
4423
|
-
if (!
|
|
4424
|
-
|
|
4677
|
+
if (!voter || voter === "") {
|
|
4678
|
+
return [];
|
|
4425
4679
|
}
|
|
4426
|
-
const
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
body: JSON.stringify({ username: name })
|
|
4680
|
+
const response = await CONFIG.hiveClient.call("database_api", "list_proposal_votes", {
|
|
4681
|
+
start: [voter],
|
|
4682
|
+
limit: 1e3,
|
|
4683
|
+
order: "by_voter_proposal",
|
|
4684
|
+
order_direction: "ascending",
|
|
4685
|
+
status: "votable"
|
|
4433
4686
|
});
|
|
4434
|
-
|
|
4435
|
-
|
|
4687
|
+
const userVotes = (response.proposal_votes || []).filter((vote) => vote.voter === voter);
|
|
4688
|
+
return userVotes;
|
|
4689
|
+
}
|
|
4690
|
+
});
|
|
4691
|
+
}
|
|
4692
|
+
function getVestingDelegationsQueryOptions(username, limit = 50) {
|
|
4693
|
+
return infiniteQueryOptions({
|
|
4694
|
+
queryKey: ["wallet", "vesting-delegations", username, limit],
|
|
4695
|
+
initialPageParam: "",
|
|
4696
|
+
queryFn: async ({ pageParam }) => {
|
|
4697
|
+
const fetchLimit = pageParam ? limit + 1 : limit;
|
|
4698
|
+
const result = await CONFIG.hiveClient.database.call("get_vesting_delegations", [
|
|
4699
|
+
username,
|
|
4700
|
+
pageParam || "",
|
|
4701
|
+
fetchLimit
|
|
4702
|
+
]);
|
|
4703
|
+
if (pageParam && result.length > 0 && result[0]?.delegatee === pageParam) {
|
|
4704
|
+
return result.slice(1, limit + 1);
|
|
4436
4705
|
}
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
headers: {
|
|
4443
|
-
"Content-Type": "application/json"
|
|
4444
|
-
},
|
|
4445
|
-
body: JSON.stringify({ username: name, type: filter })
|
|
4446
|
-
}
|
|
4447
|
-
);
|
|
4448
|
-
if (!transactionsResponse.ok) {
|
|
4449
|
-
throw new Error(`Failed to fetch point transactions: ${transactionsResponse.status}`);
|
|
4706
|
+
return result;
|
|
4707
|
+
},
|
|
4708
|
+
getNextPageParam: (lastPage) => {
|
|
4709
|
+
if (!lastPage || lastPage.length < limit) {
|
|
4710
|
+
return void 0;
|
|
4450
4711
|
}
|
|
4451
|
-
const
|
|
4452
|
-
return
|
|
4453
|
-
points: points.points,
|
|
4454
|
-
uPoints: points.unclaimed_points,
|
|
4455
|
-
transactions
|
|
4456
|
-
};
|
|
4712
|
+
const lastDelegation = lastPage[lastPage.length - 1];
|
|
4713
|
+
return lastDelegation?.delegatee;
|
|
4457
4714
|
},
|
|
4458
|
-
staleTime: 3e4,
|
|
4459
|
-
refetchOnMount: true,
|
|
4460
4715
|
enabled: !!username
|
|
4461
4716
|
});
|
|
4462
4717
|
}
|
|
4463
|
-
function
|
|
4718
|
+
function getConversionRequestsQueryOptions(account) {
|
|
4719
|
+
return queryOptions({
|
|
4720
|
+
queryKey: ["wallet", "conversion-requests", account],
|
|
4721
|
+
queryFn: () => CONFIG.hiveClient.database.call("get_conversion_requests", [
|
|
4722
|
+
account
|
|
4723
|
+
]),
|
|
4724
|
+
select: (data) => data.sort((a, b) => a.requestid - b.requestid)
|
|
4725
|
+
});
|
|
4726
|
+
}
|
|
4727
|
+
function getCollateralizedConversionRequestsQueryOptions(account) {
|
|
4728
|
+
return queryOptions({
|
|
4729
|
+
queryKey: ["wallet", "collateralized-conversion-requests", account],
|
|
4730
|
+
queryFn: () => CONFIG.hiveClient.database.call("get_collateralized_conversion_requests", [
|
|
4731
|
+
account
|
|
4732
|
+
]),
|
|
4733
|
+
select: (data) => data.sort((a, b) => a.requestid - b.requestid)
|
|
4734
|
+
});
|
|
4735
|
+
}
|
|
4736
|
+
function getSavingsWithdrawFromQueryOptions(account) {
|
|
4737
|
+
return queryOptions({
|
|
4738
|
+
queryKey: ["wallet", "savings-withdraw", account],
|
|
4739
|
+
queryFn: () => CONFIG.hiveClient.database.call("get_savings_withdraw_from", [
|
|
4740
|
+
account
|
|
4741
|
+
]),
|
|
4742
|
+
select: (data) => data.sort((a, b) => a.request_id - b.request_id)
|
|
4743
|
+
});
|
|
4744
|
+
}
|
|
4745
|
+
function getWithdrawRoutesQueryOptions(account) {
|
|
4746
|
+
return queryOptions({
|
|
4747
|
+
queryKey: ["wallet", "withdraw-routes", account],
|
|
4748
|
+
queryFn: () => CONFIG.hiveClient.database.call("get_withdraw_routes", [
|
|
4749
|
+
account,
|
|
4750
|
+
"outgoing"
|
|
4751
|
+
])
|
|
4752
|
+
});
|
|
4753
|
+
}
|
|
4754
|
+
function getOpenOrdersQueryOptions(user) {
|
|
4464
4755
|
return queryOptions({
|
|
4465
|
-
queryKey: ["
|
|
4466
|
-
queryFn:
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
const response = await fetch(CONFIG.privateApiHost + "/search-api/search", {
|
|
4472
|
-
method: "POST",
|
|
4473
|
-
headers: {
|
|
4474
|
-
"Content-Type": "application/json"
|
|
4475
|
-
},
|
|
4476
|
-
body: JSON.stringify(data)
|
|
4477
|
-
});
|
|
4478
|
-
if (!response.ok) {
|
|
4479
|
-
throw new Error(`Search failed: ${response.status}`);
|
|
4480
|
-
}
|
|
4481
|
-
return response.json();
|
|
4482
|
-
}
|
|
4756
|
+
queryKey: ["wallet", "open-orders", user],
|
|
4757
|
+
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_open_orders", [
|
|
4758
|
+
user
|
|
4759
|
+
]),
|
|
4760
|
+
select: (data) => data.sort((a, b) => a.orderid - b.orderid),
|
|
4761
|
+
enabled: !!user
|
|
4483
4762
|
});
|
|
4484
4763
|
}
|
|
4485
|
-
function
|
|
4764
|
+
function getOutgoingRcDelegationsInfiniteQueryOptions(username, limit = 100) {
|
|
4486
4765
|
return infiniteQueryOptions({
|
|
4487
|
-
queryKey: ["
|
|
4488
|
-
initialPageParam:
|
|
4766
|
+
queryKey: ["wallet", "outgoing-rc-delegations", username, limit],
|
|
4767
|
+
initialPageParam: null,
|
|
4489
4768
|
queryFn: async ({ pageParam }) => {
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
let sinceDate;
|
|
4498
|
-
const now = /* @__PURE__ */ new Date();
|
|
4499
|
-
switch (tag) {
|
|
4500
|
-
case "today":
|
|
4501
|
-
sinceDate = new Date(now.getTime() - 24 * 60 * 60 * 1e3);
|
|
4502
|
-
break;
|
|
4503
|
-
case "week":
|
|
4504
|
-
sinceDate = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1e3);
|
|
4505
|
-
break;
|
|
4506
|
-
case "month":
|
|
4507
|
-
sinceDate = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3);
|
|
4508
|
-
break;
|
|
4509
|
-
case "year":
|
|
4510
|
-
sinceDate = new Date(now.getTime() - 365 * 24 * 60 * 60 * 1e3);
|
|
4511
|
-
break;
|
|
4512
|
-
default:
|
|
4513
|
-
sinceDate = void 0;
|
|
4514
|
-
}
|
|
4515
|
-
const q = "* type:post";
|
|
4516
|
-
const sort = what === "rising" ? "children" : what;
|
|
4517
|
-
const since = sinceDate ? sinceDate.toISOString().split(".")[0] : void 0;
|
|
4518
|
-
const hideLow = "0";
|
|
4519
|
-
const votes = tag === "today" ? 50 : 200;
|
|
4520
|
-
const data = { q, sort, hide_low: hideLow };
|
|
4521
|
-
if (since) data.since = since;
|
|
4522
|
-
if (pageParam.sid) data.scroll_id = pageParam.sid;
|
|
4523
|
-
data.votes = votes;
|
|
4524
|
-
const response = await fetch(CONFIG.privateApiHost + "/search-api/search", {
|
|
4525
|
-
method: "POST",
|
|
4526
|
-
headers: {
|
|
4527
|
-
"Content-Type": "application/json"
|
|
4528
|
-
},
|
|
4529
|
-
body: JSON.stringify(data)
|
|
4530
|
-
});
|
|
4531
|
-
if (!response.ok) {
|
|
4532
|
-
throw new Error(`Search failed: ${response.status}`);
|
|
4769
|
+
const response = await CONFIG.hiveClient.call("rc_api", "list_rc_direct_delegations", {
|
|
4770
|
+
start: [username, pageParam ?? ""],
|
|
4771
|
+
limit
|
|
4772
|
+
}).then((r) => r);
|
|
4773
|
+
let delegations = response.rc_direct_delegations || [];
|
|
4774
|
+
if (pageParam) {
|
|
4775
|
+
delegations = delegations.filter((delegation) => delegation.to !== pageParam);
|
|
4533
4776
|
}
|
|
4534
|
-
return
|
|
4535
|
-
},
|
|
4536
|
-
getNextPageParam: (resp) => {
|
|
4537
|
-
return {
|
|
4538
|
-
sid: resp?.scroll_id,
|
|
4539
|
-
hasNextPage: resp.results.length > 0
|
|
4540
|
-
};
|
|
4777
|
+
return delegations;
|
|
4541
4778
|
},
|
|
4542
|
-
|
|
4779
|
+
getNextPageParam: (lastPage) => lastPage.length === limit ? lastPage[lastPage.length - 1].to : null
|
|
4543
4780
|
});
|
|
4544
4781
|
}
|
|
4545
|
-
function
|
|
4546
|
-
const { json_metadata, permlink } = entry;
|
|
4547
|
-
let q = "*";
|
|
4548
|
-
q += ` -dporn type:post`;
|
|
4549
|
-
let tags;
|
|
4550
|
-
if (json_metadata && json_metadata.tags && Array.isArray(json_metadata.tags)) {
|
|
4551
|
-
tags = json_metadata.tags.filter((tag) => tag && tag !== "" && typeof tag === "string").filter((tag) => !tag.startsWith("hive-")).filter((_tag, ind) => ind < +retry).join(",");
|
|
4552
|
-
}
|
|
4553
|
-
if (tags && tags.length > 0) {
|
|
4554
|
-
q += ` tag:${tags}`;
|
|
4555
|
-
} else {
|
|
4556
|
-
const fperm = permlink.split("-");
|
|
4557
|
-
tags = fperm.filter((part) => part !== "").filter((part) => !/^-?\d+$/.test(part)).filter((part) => part.length > 2).join(",");
|
|
4558
|
-
q += ` tag:${tags}`;
|
|
4559
|
-
}
|
|
4560
|
-
return q;
|
|
4561
|
-
}
|
|
4562
|
-
function getSimilarEntriesQueryOptions(entry) {
|
|
4563
|
-
const query = buildQuery(entry);
|
|
4782
|
+
function getIncomingRcQueryOptions(username) {
|
|
4564
4783
|
return queryOptions({
|
|
4565
|
-
queryKey: ["
|
|
4784
|
+
queryKey: ["wallet", "incoming-rc", username],
|
|
4785
|
+
enabled: !!username,
|
|
4566
4786
|
queryFn: async () => {
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
sort: "newest",
|
|
4570
|
-
hide_low: "0"
|
|
4571
|
-
};
|
|
4572
|
-
const response = await fetch(CONFIG.privateApiHost + "/search-api/search", {
|
|
4573
|
-
method: "POST",
|
|
4574
|
-
headers: {
|
|
4575
|
-
"Content-Type": "application/json"
|
|
4576
|
-
},
|
|
4577
|
-
body: JSON.stringify(data)
|
|
4578
|
-
});
|
|
4579
|
-
if (!response.ok) {
|
|
4580
|
-
throw new Error(`Search failed: ${response.status}`);
|
|
4787
|
+
if (!username) {
|
|
4788
|
+
throw new Error("[SDK][Wallet] - Missing username for incoming RC");
|
|
4581
4789
|
}
|
|
4582
|
-
const
|
|
4583
|
-
const
|
|
4584
|
-
|
|
4790
|
+
const fetchApi = getBoundFetch();
|
|
4791
|
+
const response = await fetchApi(
|
|
4792
|
+
`${CONFIG.privateApiHost}/private-api/received-rc/${username}`
|
|
4585
4793
|
);
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
if (entries.find((y) => y.author === result.author) === void 0) {
|
|
4589
|
-
entries.push(result);
|
|
4590
|
-
}
|
|
4794
|
+
if (!response.ok) {
|
|
4795
|
+
throw new Error(`Failed to fetch incoming RC: ${response.status}`);
|
|
4591
4796
|
}
|
|
4592
|
-
return
|
|
4797
|
+
return response.json();
|
|
4593
4798
|
}
|
|
4594
4799
|
});
|
|
4595
4800
|
}
|
|
4596
|
-
function
|
|
4801
|
+
function getReceivedVestingSharesQueryOptions(username) {
|
|
4597
4802
|
return queryOptions({
|
|
4598
|
-
queryKey: ["
|
|
4803
|
+
queryKey: ["wallet", "received-vesting-shares", username],
|
|
4599
4804
|
queryFn: async () => {
|
|
4600
|
-
const
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
headers: {
|
|
4604
|
-
"Content-Type": "application/json"
|
|
4605
|
-
},
|
|
4606
|
-
body: JSON.stringify(data)
|
|
4607
|
-
});
|
|
4805
|
+
const response = await fetch(
|
|
4806
|
+
CONFIG.privateApiHost + `/private-api/received-vesting/${username}`
|
|
4807
|
+
);
|
|
4608
4808
|
if (!response.ok) {
|
|
4609
|
-
throw new Error(`Failed to
|
|
4809
|
+
throw new Error(`Failed to fetch received vesting shares: ${response.status}`);
|
|
4610
4810
|
}
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4811
|
+
const data = await response.json();
|
|
4812
|
+
return data.list;
|
|
4813
|
+
}
|
|
4614
4814
|
});
|
|
4615
4815
|
}
|
|
4616
|
-
function
|
|
4816
|
+
function getRecurrentTransfersQueryOptions(username) {
|
|
4617
4817
|
return queryOptions({
|
|
4618
|
-
queryKey: ["
|
|
4818
|
+
queryKey: ["wallet", "recurrent-transfers", username],
|
|
4819
|
+
queryFn: () => CONFIG.hiveClient.call("condenser_api", "find_recurrent_transfers", [
|
|
4820
|
+
username
|
|
4821
|
+
]),
|
|
4822
|
+
enabled: !!username
|
|
4823
|
+
});
|
|
4824
|
+
}
|
|
4825
|
+
function getWitnessesInfiniteQueryOptions(limit) {
|
|
4826
|
+
return infiniteQueryOptions({
|
|
4827
|
+
queryKey: ["witnesses", "list", limit],
|
|
4828
|
+
initialPageParam: "",
|
|
4829
|
+
queryFn: async ({ pageParam }) => CONFIG.hiveClient.call("condenser_api", "get_witnesses_by_vote", [
|
|
4830
|
+
pageParam,
|
|
4831
|
+
limit
|
|
4832
|
+
]),
|
|
4833
|
+
getNextPageParam: (lastPage) => {
|
|
4834
|
+
const last = lastPage?.[lastPage.length - 1];
|
|
4835
|
+
return last ? last.owner : void 0;
|
|
4836
|
+
}
|
|
4837
|
+
});
|
|
4838
|
+
}
|
|
4839
|
+
function getOrderBookQueryOptions(limit = 500) {
|
|
4840
|
+
return queryOptions({
|
|
4841
|
+
queryKey: ["market", "order-book", limit],
|
|
4842
|
+
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_order_book", [
|
|
4843
|
+
limit
|
|
4844
|
+
])
|
|
4845
|
+
});
|
|
4846
|
+
}
|
|
4847
|
+
function getMarketStatisticsQueryOptions() {
|
|
4848
|
+
return queryOptions({
|
|
4849
|
+
queryKey: ["market", "statistics"],
|
|
4850
|
+
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_ticker", [])
|
|
4851
|
+
});
|
|
4852
|
+
}
|
|
4853
|
+
function getMarketHistoryQueryOptions(seconds, startDate, endDate) {
|
|
4854
|
+
const formatDate2 = (date) => {
|
|
4855
|
+
return date.toISOString().replace(/\.\d{3}Z$/, "");
|
|
4856
|
+
};
|
|
4857
|
+
return queryOptions({
|
|
4858
|
+
queryKey: ["market", "history", seconds, startDate.getTime(), endDate.getTime()],
|
|
4859
|
+
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_market_history", [
|
|
4860
|
+
seconds,
|
|
4861
|
+
formatDate2(startDate),
|
|
4862
|
+
formatDate2(endDate)
|
|
4863
|
+
])
|
|
4864
|
+
});
|
|
4865
|
+
}
|
|
4866
|
+
function getHiveHbdStatsQueryOptions() {
|
|
4867
|
+
return queryOptions({
|
|
4868
|
+
queryKey: ["market", "hive-hbd-stats"],
|
|
4619
4869
|
queryFn: async () => {
|
|
4620
|
-
const
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4870
|
+
const stats = await CONFIG.hiveClient.call(
|
|
4871
|
+
"condenser_api",
|
|
4872
|
+
"get_ticker",
|
|
4873
|
+
[]
|
|
4874
|
+
);
|
|
4875
|
+
const now = /* @__PURE__ */ new Date();
|
|
4876
|
+
const oneDayAgo = new Date(now.getTime() - 864e5);
|
|
4877
|
+
const formatDate2 = (date) => {
|
|
4878
|
+
return date.toISOString().replace(/\.\d{3}Z$/, "");
|
|
4879
|
+
};
|
|
4880
|
+
const dayChange = await CONFIG.hiveClient.call(
|
|
4881
|
+
"condenser_api",
|
|
4882
|
+
"get_market_history",
|
|
4883
|
+
[86400, formatDate2(oneDayAgo), formatDate2(now)]
|
|
4884
|
+
);
|
|
4885
|
+
const result = {
|
|
4886
|
+
price: +stats.latest,
|
|
4887
|
+
close: dayChange[0] ? dayChange[0].non_hive.open / dayChange[0].hive.open : 0,
|
|
4888
|
+
high: dayChange[0] ? dayChange[0].non_hive.high / dayChange[0].hive.high : 0,
|
|
4889
|
+
low: dayChange[0] ? dayChange[0].non_hive.low / dayChange[0].hive.low : 0,
|
|
4890
|
+
percent: dayChange[0] ? 100 - dayChange[0].non_hive.open / dayChange[0].hive.open * 100 / +stats.latest : 0,
|
|
4891
|
+
totalFromAsset: stats.hive_volume.split(" ")[0],
|
|
4892
|
+
totalToAsset: stats.hbd_volume.split(" ")[0]
|
|
4893
|
+
};
|
|
4894
|
+
return result;
|
|
4895
|
+
}
|
|
4634
4896
|
});
|
|
4635
4897
|
}
|
|
4636
|
-
function
|
|
4637
|
-
return
|
|
4638
|
-
queryKey: ["
|
|
4639
|
-
queryFn: async ({
|
|
4640
|
-
const
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
}
|
|
4644
|
-
if (pageParam) {
|
|
4645
|
-
payload.scroll_id = pageParam;
|
|
4646
|
-
}
|
|
4647
|
-
if (votes !== void 0) {
|
|
4648
|
-
payload.votes = votes;
|
|
4649
|
-
}
|
|
4650
|
-
const response = await fetch(CONFIG.privateApiHost + "/search-api/search", {
|
|
4651
|
-
method: "POST",
|
|
4652
|
-
headers: {
|
|
4653
|
-
"Content-Type": "application/json"
|
|
4654
|
-
},
|
|
4655
|
-
body: JSON.stringify(payload)
|
|
4656
|
-
});
|
|
4898
|
+
function getMarketDataQueryOptions(coin, vsCurrency, fromTs, toTs) {
|
|
4899
|
+
return queryOptions({
|
|
4900
|
+
queryKey: ["market", "data", coin, vsCurrency, fromTs, toTs],
|
|
4901
|
+
queryFn: async ({ signal }) => {
|
|
4902
|
+
const fetchApi = getBoundFetch();
|
|
4903
|
+
const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
|
|
4904
|
+
const response = await fetchApi(url, { signal });
|
|
4657
4905
|
if (!response.ok) {
|
|
4658
|
-
throw new Error(`
|
|
4906
|
+
throw new Error(`Failed to fetch market data: ${response.status}`);
|
|
4659
4907
|
}
|
|
4660
4908
|
return response.json();
|
|
4661
|
-
}
|
|
4662
|
-
initialPageParam: void 0,
|
|
4663
|
-
getNextPageParam: (lastPage) => lastPage?.scroll_id,
|
|
4664
|
-
enabled: !!q
|
|
4909
|
+
}
|
|
4665
4910
|
});
|
|
4666
4911
|
}
|
|
4667
|
-
function
|
|
4912
|
+
function formatDate(date) {
|
|
4913
|
+
return date.toISOString().replace(/\.\d{3}Z$/, "");
|
|
4914
|
+
}
|
|
4915
|
+
function getTradeHistoryQueryOptions(limit = 1e3, startDate, endDate) {
|
|
4916
|
+
const end = endDate ?? /* @__PURE__ */ new Date();
|
|
4917
|
+
const start = startDate ?? new Date(end.getTime() - 10 * 60 * 60 * 1e3);
|
|
4668
4918
|
return queryOptions({
|
|
4669
|
-
queryKey: ["
|
|
4670
|
-
queryFn:
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
},
|
|
4676
|
-
body: JSON.stringify({ q })
|
|
4677
|
-
});
|
|
4678
|
-
if (!response.ok) {
|
|
4679
|
-
throw new Error(`Search path failed: ${response.status}`);
|
|
4680
|
-
}
|
|
4681
|
-
const data = await response.json();
|
|
4682
|
-
if (data?.length > 0) {
|
|
4683
|
-
return data;
|
|
4684
|
-
}
|
|
4685
|
-
return [q];
|
|
4686
|
-
}
|
|
4919
|
+
queryKey: ["market", "trade-history", limit, start.getTime(), end.getTime()],
|
|
4920
|
+
queryFn: () => CONFIG.hiveClient.call("condenser_api", "get_trade_history", [
|
|
4921
|
+
formatDate(start),
|
|
4922
|
+
formatDate(end),
|
|
4923
|
+
limit
|
|
4924
|
+
])
|
|
4687
4925
|
});
|
|
4688
4926
|
}
|
|
4689
4927
|
|
|
4690
|
-
// src/modules/
|
|
4928
|
+
// src/modules/market/requests.ts
|
|
4691
4929
|
async function parseJsonResponse2(response) {
|
|
4692
|
-
const
|
|
4693
|
-
try {
|
|
4694
|
-
return await response.json();
|
|
4695
|
-
} catch {
|
|
4696
|
-
try {
|
|
4697
|
-
return await response.text();
|
|
4698
|
-
} catch {
|
|
4699
|
-
return void 0;
|
|
4700
|
-
}
|
|
4701
|
-
}
|
|
4702
|
-
};
|
|
4703
|
-
const data = await parseBody();
|
|
4930
|
+
const data = await response.json();
|
|
4704
4931
|
if (!response.ok) {
|
|
4705
4932
|
const error = new Error(`Request failed with status ${response.status}`);
|
|
4706
4933
|
error.status = response.status;
|
|
4707
4934
|
error.data = data;
|
|
4708
4935
|
throw error;
|
|
4709
4936
|
}
|
|
4710
|
-
if (data === void 0) {
|
|
4711
|
-
throw new Error("Response body was empty or invalid JSON");
|
|
4712
|
-
}
|
|
4713
4937
|
return data;
|
|
4714
4938
|
}
|
|
4715
|
-
async function
|
|
4716
|
-
const data = { q, sort, hide_low: hideLow };
|
|
4717
|
-
if (since) {
|
|
4718
|
-
data.since = since;
|
|
4719
|
-
}
|
|
4720
|
-
if (scroll_id) {
|
|
4721
|
-
data.scroll_id = scroll_id;
|
|
4722
|
-
}
|
|
4723
|
-
if (votes) {
|
|
4724
|
-
data.votes = votes;
|
|
4725
|
-
}
|
|
4939
|
+
async function getMarketData(coin, vsCurrency, fromTs, toTs) {
|
|
4726
4940
|
const fetchApi = getBoundFetch();
|
|
4727
|
-
const
|
|
4728
|
-
|
|
4729
|
-
headers: {
|
|
4730
|
-
"Content-Type": "application/json"
|
|
4731
|
-
},
|
|
4732
|
-
body: JSON.stringify(data)
|
|
4733
|
-
});
|
|
4941
|
+
const url = `https://api.coingecko.com/api/v3/coins/${coin}/market_chart/range?vs_currency=${vsCurrency}&from=${fromTs}&to=${toTs}`;
|
|
4942
|
+
const response = await fetchApi(url);
|
|
4734
4943
|
return parseJsonResponse2(response);
|
|
4735
4944
|
}
|
|
4736
|
-
async function
|
|
4737
|
-
|
|
4945
|
+
async function getCurrencyRate(cur) {
|
|
4946
|
+
if (cur === "hbd") {
|
|
4947
|
+
return 1;
|
|
4948
|
+
}
|
|
4738
4949
|
const fetchApi = getBoundFetch();
|
|
4739
|
-
const
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4950
|
+
const url = `https://api.coingecko.com/api/v3/simple/price?ids=hive_dollar&vs_currencies=${cur}`;
|
|
4951
|
+
const response = await fetchApi(url);
|
|
4952
|
+
const data = await parseJsonResponse2(response);
|
|
4953
|
+
return data.hive_dollar[cur];
|
|
4954
|
+
}
|
|
4955
|
+
async function getCurrencyTokenRate(currency, token) {
|
|
4956
|
+
const fetchApi = getBoundFetch();
|
|
4957
|
+
const response = await fetchApi(
|
|
4958
|
+
CONFIG.privateApiHost + `/private-api/market-data/${currency === "hbd" ? "usd" : currency}/${token}`
|
|
4959
|
+
);
|
|
4746
4960
|
return parseJsonResponse2(response);
|
|
4747
4961
|
}
|
|
4748
|
-
async function
|
|
4749
|
-
const data = { q, limit, random };
|
|
4962
|
+
async function getCurrencyRates() {
|
|
4750
4963
|
const fetchApi = getBoundFetch();
|
|
4751
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/
|
|
4752
|
-
method: "POST",
|
|
4753
|
-
headers: {
|
|
4754
|
-
"Content-Type": "application/json"
|
|
4755
|
-
},
|
|
4756
|
-
body: JSON.stringify(data)
|
|
4757
|
-
});
|
|
4964
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/market-data/latest");
|
|
4758
4965
|
return parseJsonResponse2(response);
|
|
4759
4966
|
}
|
|
4760
|
-
async function
|
|
4967
|
+
async function getHivePrice() {
|
|
4761
4968
|
const fetchApi = getBoundFetch();
|
|
4762
|
-
const response = await fetchApi(
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4969
|
+
const response = await fetchApi(
|
|
4970
|
+
"https://api.coingecko.com/api/v3/simple/price?ids=hive&vs_currencies=usd"
|
|
4971
|
+
);
|
|
4972
|
+
return parseJsonResponse2(response);
|
|
4973
|
+
}
|
|
4974
|
+
function getPointsQueryOptions(username, filter = 0) {
|
|
4975
|
+
return queryOptions({
|
|
4976
|
+
queryKey: ["points", username, filter],
|
|
4977
|
+
queryFn: async () => {
|
|
4978
|
+
if (!username) {
|
|
4979
|
+
throw new Error("Get points query \u2013 username wasn't provided");
|
|
4980
|
+
}
|
|
4981
|
+
const name = username.replace("@", "");
|
|
4982
|
+
const pointsResponse = await fetch(CONFIG.privateApiHost + "/private-api/points", {
|
|
4983
|
+
method: "POST",
|
|
4984
|
+
headers: {
|
|
4985
|
+
"Content-Type": "application/json"
|
|
4986
|
+
},
|
|
4987
|
+
body: JSON.stringify({ username: name })
|
|
4988
|
+
});
|
|
4989
|
+
if (!pointsResponse.ok) {
|
|
4990
|
+
throw new Error(`Failed to fetch points: ${pointsResponse.status}`);
|
|
4991
|
+
}
|
|
4992
|
+
const points = await pointsResponse.json();
|
|
4993
|
+
const transactionsResponse = await fetch(
|
|
4994
|
+
CONFIG.privateApiHost + "/private-api/point-list",
|
|
4995
|
+
{
|
|
4996
|
+
method: "POST",
|
|
4997
|
+
headers: {
|
|
4998
|
+
"Content-Type": "application/json"
|
|
4999
|
+
},
|
|
5000
|
+
body: JSON.stringify({ username: name, type: filter })
|
|
5001
|
+
}
|
|
5002
|
+
);
|
|
5003
|
+
if (!transactionsResponse.ok) {
|
|
5004
|
+
throw new Error(`Failed to fetch point transactions: ${transactionsResponse.status}`);
|
|
5005
|
+
}
|
|
5006
|
+
const transactions = await transactionsResponse.json();
|
|
5007
|
+
return {
|
|
5008
|
+
points: points.points,
|
|
5009
|
+
uPoints: points.unclaimed_points,
|
|
5010
|
+
transactions
|
|
5011
|
+
};
|
|
4766
5012
|
},
|
|
4767
|
-
|
|
5013
|
+
staleTime: 3e4,
|
|
5014
|
+
refetchOnMount: true,
|
|
5015
|
+
enabled: !!username
|
|
4768
5016
|
});
|
|
4769
|
-
const data = await parseJsonResponse2(response);
|
|
4770
|
-
return data?.length > 0 ? data : [q];
|
|
4771
5017
|
}
|
|
4772
|
-
function
|
|
5018
|
+
function searchQueryOptions(q, sort, hideLow, since, scroll_id, votes) {
|
|
4773
5019
|
return queryOptions({
|
|
4774
|
-
queryKey: ["
|
|
5020
|
+
queryKey: ["search", q, sort, hideLow, since, scroll_id, votes],
|
|
4775
5021
|
queryFn: async () => {
|
|
4776
|
-
|
|
4777
|
-
|
|
5022
|
+
const data = { q, sort, hide_low: hideLow };
|
|
5023
|
+
if (since) data.since = since;
|
|
5024
|
+
if (scroll_id) data.scroll_id = scroll_id;
|
|
5025
|
+
if (votes) data.votes = votes;
|
|
5026
|
+
const response = await fetch(CONFIG.privateApiHost + "/search-api/search", {
|
|
5027
|
+
method: "POST",
|
|
5028
|
+
headers: {
|
|
5029
|
+
"Content-Type": "application/json"
|
|
5030
|
+
},
|
|
5031
|
+
body: JSON.stringify(data)
|
|
5032
|
+
});
|
|
5033
|
+
if (!response.ok) {
|
|
5034
|
+
throw new Error(`Search failed: ${response.status}`);
|
|
5035
|
+
}
|
|
5036
|
+
return response.json();
|
|
5037
|
+
}
|
|
5038
|
+
});
|
|
5039
|
+
}
|
|
5040
|
+
function getControversialRisingInfiniteQueryOptions(what, tag, enabled = true) {
|
|
5041
|
+
return infiniteQueryOptions({
|
|
5042
|
+
queryKey: ["search", "controversial-rising", what, tag],
|
|
5043
|
+
initialPageParam: { sid: void 0, hasNextPage: true },
|
|
5044
|
+
queryFn: async ({ pageParam }) => {
|
|
5045
|
+
if (!pageParam.hasNextPage) {
|
|
5046
|
+
return {
|
|
5047
|
+
hits: 0,
|
|
5048
|
+
took: 0,
|
|
5049
|
+
results: []
|
|
5050
|
+
};
|
|
5051
|
+
}
|
|
5052
|
+
let sinceDate;
|
|
5053
|
+
const now = /* @__PURE__ */ new Date();
|
|
5054
|
+
switch (tag) {
|
|
5055
|
+
case "today":
|
|
5056
|
+
sinceDate = new Date(now.getTime() - 24 * 60 * 60 * 1e3);
|
|
5057
|
+
break;
|
|
5058
|
+
case "week":
|
|
5059
|
+
sinceDate = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1e3);
|
|
5060
|
+
break;
|
|
5061
|
+
case "month":
|
|
5062
|
+
sinceDate = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3);
|
|
5063
|
+
break;
|
|
5064
|
+
case "year":
|
|
5065
|
+
sinceDate = new Date(now.getTime() - 365 * 24 * 60 * 60 * 1e3);
|
|
5066
|
+
break;
|
|
5067
|
+
default:
|
|
5068
|
+
sinceDate = void 0;
|
|
4778
5069
|
}
|
|
4779
|
-
const
|
|
5070
|
+
const q = "* type:post";
|
|
5071
|
+
const sort = what === "rising" ? "children" : what;
|
|
5072
|
+
const since = sinceDate ? sinceDate.toISOString().split(".")[0] : void 0;
|
|
5073
|
+
const hideLow = "0";
|
|
5074
|
+
const votes = tag === "today" ? 50 : 200;
|
|
5075
|
+
const data = { q, sort, hide_low: hideLow };
|
|
5076
|
+
if (since) data.since = since;
|
|
5077
|
+
if (pageParam.sid) data.scroll_id = pageParam.sid;
|
|
5078
|
+
data.votes = votes;
|
|
5079
|
+
const response = await fetch(CONFIG.privateApiHost + "/search-api/search", {
|
|
4780
5080
|
method: "POST",
|
|
4781
5081
|
headers: {
|
|
4782
5082
|
"Content-Type": "application/json"
|
|
4783
5083
|
},
|
|
4784
|
-
body: JSON.stringify(
|
|
5084
|
+
body: JSON.stringify(data)
|
|
4785
5085
|
});
|
|
4786
5086
|
if (!response.ok) {
|
|
4787
|
-
throw new Error(`
|
|
5087
|
+
throw new Error(`Search failed: ${response.status}`);
|
|
4788
5088
|
}
|
|
4789
|
-
return
|
|
5089
|
+
return response.json();
|
|
4790
5090
|
},
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
5091
|
+
getNextPageParam: (resp) => {
|
|
5092
|
+
return {
|
|
5093
|
+
sid: resp?.scroll_id,
|
|
5094
|
+
hasNextPage: resp.results.length > 0
|
|
5095
|
+
};
|
|
5096
|
+
},
|
|
5097
|
+
enabled
|
|
4794
5098
|
});
|
|
4795
5099
|
}
|
|
4796
|
-
function
|
|
5100
|
+
function buildQuery(entry, retry = 3) {
|
|
5101
|
+
const { json_metadata, permlink } = entry;
|
|
5102
|
+
let q = "*";
|
|
5103
|
+
q += ` -dporn type:post`;
|
|
5104
|
+
let tags;
|
|
5105
|
+
if (json_metadata && json_metadata.tags && Array.isArray(json_metadata.tags)) {
|
|
5106
|
+
tags = json_metadata.tags.filter((tag) => tag && tag !== "" && typeof tag === "string").filter((tag) => !tag.startsWith("hive-")).filter((_tag, ind) => ind < +retry).join(",");
|
|
5107
|
+
}
|
|
5108
|
+
if (tags && tags.length > 0) {
|
|
5109
|
+
q += ` tag:${tags}`;
|
|
5110
|
+
} else {
|
|
5111
|
+
const fperm = permlink.split("-");
|
|
5112
|
+
tags = fperm.filter((part) => part !== "").filter((part) => !/^-?\d+$/.test(part)).filter((part) => part.length > 2).join(",");
|
|
5113
|
+
q += ` tag:${tags}`;
|
|
5114
|
+
}
|
|
5115
|
+
return q;
|
|
5116
|
+
}
|
|
5117
|
+
function getSimilarEntriesQueryOptions(entry) {
|
|
5118
|
+
const query = buildQuery(entry);
|
|
4797
5119
|
return queryOptions({
|
|
4798
|
-
queryKey: ["
|
|
5120
|
+
queryKey: ["search", "similar-entries", entry.author, entry.permlink, query],
|
|
4799
5121
|
queryFn: async () => {
|
|
4800
|
-
const
|
|
5122
|
+
const data = {
|
|
5123
|
+
q: query,
|
|
5124
|
+
sort: "newest",
|
|
5125
|
+
hide_low: "0"
|
|
5126
|
+
};
|
|
5127
|
+
const response = await fetch(CONFIG.privateApiHost + "/search-api/search", {
|
|
4801
5128
|
method: "POST",
|
|
4802
5129
|
headers: {
|
|
4803
5130
|
"Content-Type": "application/json"
|
|
4804
5131
|
},
|
|
4805
|
-
body: JSON.stringify(
|
|
5132
|
+
body: JSON.stringify(data)
|
|
4806
5133
|
});
|
|
4807
5134
|
if (!response.ok) {
|
|
4808
|
-
throw new Error(`
|
|
5135
|
+
throw new Error(`Search failed: ${response.status}`);
|
|
4809
5136
|
}
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
5137
|
+
const searchResponse = await response.json();
|
|
5138
|
+
const rawEntries = searchResponse.results.filter(
|
|
5139
|
+
(r) => r.permlink !== entry.permlink && r.tags.indexOf("nsfw") === -1
|
|
5140
|
+
);
|
|
5141
|
+
const entries = [];
|
|
5142
|
+
for (const result of rawEntries) {
|
|
5143
|
+
if (entries.find((y) => y.author === result.author) === void 0) {
|
|
5144
|
+
entries.push(result);
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
return entries.slice(0, 3);
|
|
5148
|
+
}
|
|
4813
5149
|
});
|
|
4814
5150
|
}
|
|
4815
|
-
function
|
|
5151
|
+
function getSearchAccountQueryOptions(q, limit = 5, random = false) {
|
|
4816
5152
|
return queryOptions({
|
|
4817
|
-
queryKey: ["
|
|
5153
|
+
queryKey: ["search", "account", q, limit],
|
|
4818
5154
|
queryFn: async () => {
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
}
|
|
4822
|
-
const response = await fetch(CONFIG.privateApiHost + "/private-api/boosted-plus-account", {
|
|
5155
|
+
const data = { q, limit, random: +random };
|
|
5156
|
+
const response = await fetch(CONFIG.privateApiHost + "/search-api/search-account", {
|
|
4823
5157
|
method: "POST",
|
|
4824
5158
|
headers: {
|
|
4825
5159
|
"Content-Type": "application/json"
|
|
4826
5160
|
},
|
|
4827
|
-
body: JSON.stringify(
|
|
5161
|
+
body: JSON.stringify(data)
|
|
4828
5162
|
});
|
|
4829
5163
|
if (!response.ok) {
|
|
4830
|
-
throw new Error(`Failed to
|
|
5164
|
+
throw new Error(`Failed to search accounts: ${response.status}`);
|
|
4831
5165
|
}
|
|
4832
|
-
|
|
4833
|
-
return responseData ? {
|
|
4834
|
-
account: responseData.account,
|
|
4835
|
-
expires: new Date(responseData.expires)
|
|
4836
|
-
} : null;
|
|
4837
|
-
},
|
|
4838
|
-
enabled: !!account && !!accessToken
|
|
4839
|
-
});
|
|
4840
|
-
}
|
|
4841
|
-
|
|
4842
|
-
// src/modules/private-api/requests.ts
|
|
4843
|
-
async function parseJsonResponse3(response) {
|
|
4844
|
-
if (!response.ok) {
|
|
4845
|
-
let errorData = void 0;
|
|
4846
|
-
try {
|
|
4847
|
-
errorData = await response.json();
|
|
4848
|
-
} catch {
|
|
4849
|
-
errorData = void 0;
|
|
4850
|
-
}
|
|
4851
|
-
const error = new Error(`Request failed with status ${response.status}`);
|
|
4852
|
-
error.status = response.status;
|
|
4853
|
-
error.data = errorData;
|
|
4854
|
-
throw error;
|
|
4855
|
-
}
|
|
4856
|
-
const text = await response.text();
|
|
4857
|
-
if (!text || text.trim() === "") {
|
|
4858
|
-
return "";
|
|
4859
|
-
}
|
|
4860
|
-
try {
|
|
4861
|
-
return JSON.parse(text);
|
|
4862
|
-
} catch (e) {
|
|
4863
|
-
console.warn("[SDK] Failed to parse JSON response:", e, "Response:", text);
|
|
4864
|
-
return "";
|
|
4865
|
-
}
|
|
4866
|
-
}
|
|
4867
|
-
async function signUp(username, email, referral) {
|
|
4868
|
-
const fetchApi = getBoundFetch();
|
|
4869
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/account-create", {
|
|
4870
|
-
method: "POST",
|
|
4871
|
-
headers: {
|
|
4872
|
-
"Content-Type": "application/json"
|
|
4873
|
-
},
|
|
4874
|
-
body: JSON.stringify({ username, email, referral })
|
|
4875
|
-
});
|
|
4876
|
-
const data = await parseJsonResponse3(response);
|
|
4877
|
-
return { status: response.status, data };
|
|
4878
|
-
}
|
|
4879
|
-
async function subscribeEmail(email) {
|
|
4880
|
-
const fetchApi = getBoundFetch();
|
|
4881
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/subscribe", {
|
|
4882
|
-
method: "POST",
|
|
4883
|
-
headers: {
|
|
4884
|
-
"Content-Type": "application/json"
|
|
4885
|
-
},
|
|
4886
|
-
body: JSON.stringify({ email })
|
|
4887
|
-
});
|
|
4888
|
-
const data = await parseJsonResponse3(response);
|
|
4889
|
-
return { status: response.status, data };
|
|
4890
|
-
}
|
|
4891
|
-
async function usrActivity(code, ty, bl = "", tx = "") {
|
|
4892
|
-
const params = { code, ty };
|
|
4893
|
-
if (bl) {
|
|
4894
|
-
params.bl = bl;
|
|
4895
|
-
}
|
|
4896
|
-
if (tx) {
|
|
4897
|
-
params.tx = tx;
|
|
4898
|
-
}
|
|
4899
|
-
const fetchApi = getBoundFetch();
|
|
4900
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/usr-activity", {
|
|
4901
|
-
method: "POST",
|
|
4902
|
-
headers: {
|
|
4903
|
-
"Content-Type": "application/json"
|
|
4904
|
-
},
|
|
4905
|
-
body: JSON.stringify(params)
|
|
4906
|
-
});
|
|
4907
|
-
await parseJsonResponse3(response);
|
|
4908
|
-
}
|
|
4909
|
-
async function getNotifications(code, filter, since = null, user = null) {
|
|
4910
|
-
const data = {
|
|
4911
|
-
code
|
|
4912
|
-
};
|
|
4913
|
-
if (filter) {
|
|
4914
|
-
data.filter = filter;
|
|
4915
|
-
}
|
|
4916
|
-
if (since) {
|
|
4917
|
-
data.since = since;
|
|
4918
|
-
}
|
|
4919
|
-
if (user) {
|
|
4920
|
-
data.user = user;
|
|
4921
|
-
}
|
|
4922
|
-
const fetchApi = getBoundFetch();
|
|
4923
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications", {
|
|
4924
|
-
method: "POST",
|
|
4925
|
-
headers: {
|
|
4926
|
-
"Content-Type": "application/json"
|
|
4927
|
-
},
|
|
4928
|
-
body: JSON.stringify(data)
|
|
4929
|
-
});
|
|
4930
|
-
return parseJsonResponse3(response);
|
|
4931
|
-
}
|
|
4932
|
-
async function saveNotificationSetting(code, username, system, allows_notify, notify_types, token) {
|
|
4933
|
-
const data = {
|
|
4934
|
-
code,
|
|
4935
|
-
username,
|
|
4936
|
-
token,
|
|
4937
|
-
system,
|
|
4938
|
-
allows_notify,
|
|
4939
|
-
notify_types
|
|
4940
|
-
};
|
|
4941
|
-
const fetchApi = getBoundFetch();
|
|
4942
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/register-device", {
|
|
4943
|
-
method: "POST",
|
|
4944
|
-
headers: {
|
|
4945
|
-
"Content-Type": "application/json"
|
|
4946
|
-
},
|
|
4947
|
-
body: JSON.stringify(data)
|
|
4948
|
-
});
|
|
4949
|
-
return parseJsonResponse3(response);
|
|
4950
|
-
}
|
|
4951
|
-
async function getNotificationSetting(code, username, token) {
|
|
4952
|
-
const data = { code, username, token };
|
|
4953
|
-
const fetchApi = getBoundFetch();
|
|
4954
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/detail-device", {
|
|
4955
|
-
method: "POST",
|
|
4956
|
-
headers: {
|
|
4957
|
-
"Content-Type": "application/json"
|
|
4958
|
-
},
|
|
4959
|
-
body: JSON.stringify(data)
|
|
4960
|
-
});
|
|
4961
|
-
return parseJsonResponse3(response);
|
|
4962
|
-
}
|
|
4963
|
-
async function markNotifications(code, id) {
|
|
4964
|
-
const data = {
|
|
4965
|
-
code
|
|
4966
|
-
};
|
|
4967
|
-
if (id) {
|
|
4968
|
-
data.id = id;
|
|
4969
|
-
}
|
|
4970
|
-
const fetchApi = getBoundFetch();
|
|
4971
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/private-api/notifications/mark", {
|
|
4972
|
-
method: "POST",
|
|
4973
|
-
headers: {
|
|
4974
|
-
"Content-Type": "application/json"
|
|
5166
|
+
return response.json();
|
|
4975
5167
|
},
|
|
4976
|
-
|
|
5168
|
+
enabled: !!q
|
|
4977
5169
|
});
|
|
4978
|
-
return parseJsonResponse3(response);
|
|
4979
5170
|
}
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
5171
|
+
function getSearchTopicsQueryOptions(q, limit = 20, random = false) {
|
|
5172
|
+
return queryOptions({
|
|
5173
|
+
queryKey: ["search", "topics", q],
|
|
5174
|
+
queryFn: async () => {
|
|
5175
|
+
const data = { q, limit, random: +random };
|
|
5176
|
+
const response = await fetch(CONFIG.privateApiHost + "/search-api/search-tag", {
|
|
5177
|
+
method: "POST",
|
|
5178
|
+
headers: {
|
|
5179
|
+
"Content-Type": "application/json"
|
|
5180
|
+
},
|
|
5181
|
+
body: JSON.stringify(data)
|
|
5182
|
+
});
|
|
5183
|
+
if (!response.ok) {
|
|
5184
|
+
throw new Error(`Failed to search topics: ${response.status}`);
|
|
5185
|
+
}
|
|
5186
|
+
return response.json();
|
|
4987
5187
|
},
|
|
4988
|
-
|
|
5188
|
+
enabled: !!q
|
|
4989
5189
|
});
|
|
4990
|
-
return parseJsonResponse3(response);
|
|
4991
5190
|
}
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5191
|
+
function getSearchApiInfiniteQueryOptions(q, sort, hideLow, since, votes) {
|
|
5192
|
+
return infiniteQueryOptions({
|
|
5193
|
+
queryKey: ["search", "api", q, sort, hideLow, since, votes],
|
|
5194
|
+
queryFn: async ({ pageParam }) => {
|
|
5195
|
+
const payload = { q, sort, hide_low: hideLow };
|
|
5196
|
+
if (since) {
|
|
5197
|
+
payload.since = since;
|
|
5198
|
+
}
|
|
5199
|
+
if (pageParam) {
|
|
5200
|
+
payload.scroll_id = pageParam;
|
|
5201
|
+
}
|
|
5202
|
+
if (votes !== void 0) {
|
|
5203
|
+
payload.votes = votes;
|
|
5204
|
+
}
|
|
5205
|
+
const response = await fetch(CONFIG.privateApiHost + "/search-api/search", {
|
|
5206
|
+
method: "POST",
|
|
5207
|
+
headers: {
|
|
5208
|
+
"Content-Type": "application/json"
|
|
5209
|
+
},
|
|
5210
|
+
body: JSON.stringify(payload)
|
|
5211
|
+
});
|
|
5212
|
+
if (!response.ok) {
|
|
5213
|
+
throw new Error(`Search failed: ${response.status}`);
|
|
5214
|
+
}
|
|
5215
|
+
return response.json();
|
|
5216
|
+
},
|
|
5217
|
+
initialPageParam: void 0,
|
|
5218
|
+
getNextPageParam: (lastPage) => lastPage?.scroll_id,
|
|
5219
|
+
enabled: !!q
|
|
5000
5220
|
});
|
|
5001
|
-
return parseJsonResponse3(response);
|
|
5002
5221
|
}
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5222
|
+
function getSearchPathQueryOptions(q) {
|
|
5223
|
+
return queryOptions({
|
|
5224
|
+
queryKey: ["search", "path", q],
|
|
5225
|
+
queryFn: async () => {
|
|
5226
|
+
const response = await fetch(CONFIG.privateApiHost + "/search-api/search-path", {
|
|
5227
|
+
method: "POST",
|
|
5228
|
+
headers: {
|
|
5229
|
+
"Content-Type": "application/json"
|
|
5230
|
+
},
|
|
5231
|
+
body: JSON.stringify({ q })
|
|
5232
|
+
});
|
|
5233
|
+
if (!response.ok) {
|
|
5234
|
+
throw new Error(`Search path failed: ${response.status}`);
|
|
5235
|
+
}
|
|
5236
|
+
const data = await response.json();
|
|
5237
|
+
if (data?.length > 0) {
|
|
5238
|
+
return data;
|
|
5239
|
+
}
|
|
5240
|
+
return [q];
|
|
5241
|
+
}
|
|
5012
5242
|
});
|
|
5013
|
-
return parseJsonResponse3(response);
|
|
5014
5243
|
}
|
|
5015
|
-
|
|
5016
|
-
|
|
5244
|
+
|
|
5245
|
+
// src/modules/search/requests.ts
|
|
5246
|
+
async function parseJsonResponse3(response) {
|
|
5247
|
+
const parseBody = async () => {
|
|
5248
|
+
try {
|
|
5249
|
+
return await response.json();
|
|
5250
|
+
} catch {
|
|
5251
|
+
try {
|
|
5252
|
+
return await response.text();
|
|
5253
|
+
} catch {
|
|
5254
|
+
return void 0;
|
|
5255
|
+
}
|
|
5256
|
+
}
|
|
5257
|
+
};
|
|
5258
|
+
const data = await parseBody();
|
|
5259
|
+
if (!response.ok) {
|
|
5260
|
+
const error = new Error(`Request failed with status ${response.status}`);
|
|
5261
|
+
error.status = response.status;
|
|
5262
|
+
error.data = data;
|
|
5263
|
+
throw error;
|
|
5264
|
+
}
|
|
5265
|
+
if (data === void 0) {
|
|
5266
|
+
throw new Error("Response body was empty or invalid JSON");
|
|
5267
|
+
}
|
|
5268
|
+
return data;
|
|
5269
|
+
}
|
|
5270
|
+
async function search(q, sort, hideLow, since, scroll_id, votes) {
|
|
5271
|
+
const data = { q, sort, hide_low: hideLow };
|
|
5272
|
+
if (since) {
|
|
5273
|
+
data.since = since;
|
|
5274
|
+
}
|
|
5275
|
+
if (scroll_id) {
|
|
5276
|
+
data.scroll_id = scroll_id;
|
|
5277
|
+
}
|
|
5278
|
+
if (votes) {
|
|
5279
|
+
data.votes = votes;
|
|
5280
|
+
}
|
|
5017
5281
|
const fetchApi = getBoundFetch();
|
|
5018
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/
|
|
5282
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/search-api/search", {
|
|
5019
5283
|
method: "POST",
|
|
5020
5284
|
headers: {
|
|
5021
5285
|
"Content-Type": "application/json"
|
|
@@ -5024,10 +5288,10 @@ async function addDraft(code, title, body, tags, meta) {
|
|
|
5024
5288
|
});
|
|
5025
5289
|
return parseJsonResponse3(response);
|
|
5026
5290
|
}
|
|
5027
|
-
async function
|
|
5028
|
-
const data = {
|
|
5291
|
+
async function searchAccount(q = "", limit = 20, random = 1) {
|
|
5292
|
+
const data = { q, limit, random };
|
|
5029
5293
|
const fetchApi = getBoundFetch();
|
|
5030
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/
|
|
5294
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/search-api/search-account", {
|
|
5031
5295
|
method: "POST",
|
|
5032
5296
|
headers: {
|
|
5033
5297
|
"Content-Type": "application/json"
|
|
@@ -5036,10 +5300,10 @@ async function updateDraft(code, draftId, title, body, tags, meta) {
|
|
|
5036
5300
|
});
|
|
5037
5301
|
return parseJsonResponse3(response);
|
|
5038
5302
|
}
|
|
5039
|
-
async function
|
|
5040
|
-
const data = {
|
|
5303
|
+
async function searchTag(q = "", limit = 20, random = 0) {
|
|
5304
|
+
const data = { q, limit, random };
|
|
5041
5305
|
const fetchApi = getBoundFetch();
|
|
5042
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/
|
|
5306
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/search-api/search-tag", {
|
|
5043
5307
|
method: "POST",
|
|
5044
5308
|
headers: {
|
|
5045
5309
|
"Content-Type": "application/json"
|
|
@@ -5048,83 +5312,86 @@ async function deleteDraft(code, draftId) {
|
|
|
5048
5312
|
});
|
|
5049
5313
|
return parseJsonResponse3(response);
|
|
5050
5314
|
}
|
|
5051
|
-
async function
|
|
5052
|
-
const data = {
|
|
5053
|
-
code,
|
|
5054
|
-
permlink,
|
|
5055
|
-
title,
|
|
5056
|
-
body,
|
|
5057
|
-
meta,
|
|
5058
|
-
schedule,
|
|
5059
|
-
reblog
|
|
5060
|
-
};
|
|
5061
|
-
if (options) {
|
|
5062
|
-
data.options = options;
|
|
5063
|
-
}
|
|
5315
|
+
async function searchPath(q) {
|
|
5064
5316
|
const fetchApi = getBoundFetch();
|
|
5065
|
-
const response = await fetchApi(CONFIG.privateApiHost + "/
|
|
5317
|
+
const response = await fetchApi(CONFIG.privateApiHost + "/search-api/search-path", {
|
|
5066
5318
|
method: "POST",
|
|
5067
5319
|
headers: {
|
|
5068
5320
|
"Content-Type": "application/json"
|
|
5069
5321
|
},
|
|
5070
|
-
body: JSON.stringify(
|
|
5322
|
+
body: JSON.stringify({ q })
|
|
5071
5323
|
});
|
|
5072
|
-
|
|
5324
|
+
const data = await parseJsonResponse3(response);
|
|
5325
|
+
return data?.length > 0 ? data : [q];
|
|
5073
5326
|
}
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5327
|
+
function getBoostPlusPricesQueryOptions(accessToken) {
|
|
5328
|
+
return queryOptions({
|
|
5329
|
+
queryKey: ["promotions", "boost-plus-prices"],
|
|
5330
|
+
queryFn: async () => {
|
|
5331
|
+
if (!accessToken) {
|
|
5332
|
+
return [];
|
|
5333
|
+
}
|
|
5334
|
+
const response = await fetch(CONFIG.privateApiHost + "/private-api/boost-plus-price", {
|
|
5335
|
+
method: "POST",
|
|
5336
|
+
headers: {
|
|
5337
|
+
"Content-Type": "application/json"
|
|
5338
|
+
},
|
|
5339
|
+
body: JSON.stringify({ code: accessToken })
|
|
5340
|
+
});
|
|
5341
|
+
if (!response.ok) {
|
|
5342
|
+
throw new Error(`Failed to fetch boost plus prices: ${response.status}`);
|
|
5343
|
+
}
|
|
5344
|
+
return await response.json();
|
|
5081
5345
|
},
|
|
5082
|
-
|
|
5346
|
+
staleTime: Infinity,
|
|
5347
|
+
refetchOnMount: true,
|
|
5348
|
+
enabled: !!accessToken
|
|
5083
5349
|
});
|
|
5084
|
-
return parseJsonResponse3(response);
|
|
5085
5350
|
}
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5351
|
+
function getPromotePriceQueryOptions(accessToken) {
|
|
5352
|
+
return queryOptions({
|
|
5353
|
+
queryKey: ["promotions", "promote-price"],
|
|
5354
|
+
queryFn: async () => {
|
|
5355
|
+
const response = await fetch(CONFIG.privateApiHost + "/private-api/promote-price", {
|
|
5356
|
+
method: "POST",
|
|
5357
|
+
headers: {
|
|
5358
|
+
"Content-Type": "application/json"
|
|
5359
|
+
},
|
|
5360
|
+
body: JSON.stringify({ code: accessToken })
|
|
5361
|
+
});
|
|
5362
|
+
if (!response.ok) {
|
|
5363
|
+
throw new Error(`Failed to fetch promote prices: ${response.status}`);
|
|
5364
|
+
}
|
|
5365
|
+
return await response.json();
|
|
5093
5366
|
},
|
|
5094
|
-
|
|
5367
|
+
enabled: !!accessToken
|
|
5095
5368
|
});
|
|
5096
|
-
return parseJsonResponse3(response);
|
|
5097
5369
|
}
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5370
|
+
function getBoostPlusAccountPricesQueryOptions(account, accessToken) {
|
|
5371
|
+
return queryOptions({
|
|
5372
|
+
queryKey: ["promotions", "boost-plus-accounts", account],
|
|
5373
|
+
queryFn: async () => {
|
|
5374
|
+
if (!accessToken || !account) {
|
|
5375
|
+
return null;
|
|
5376
|
+
}
|
|
5377
|
+
const response = await fetch(CONFIG.privateApiHost + "/private-api/boosted-plus-account", {
|
|
5378
|
+
method: "POST",
|
|
5379
|
+
headers: {
|
|
5380
|
+
"Content-Type": "application/json"
|
|
5381
|
+
},
|
|
5382
|
+
body: JSON.stringify({ code: accessToken, account })
|
|
5383
|
+
});
|
|
5384
|
+
if (!response.ok) {
|
|
5385
|
+
throw new Error(`Failed to fetch boost plus account prices: ${response.status}`);
|
|
5386
|
+
}
|
|
5387
|
+
const responseData = await response.json();
|
|
5388
|
+
return responseData ? {
|
|
5389
|
+
account: responseData.account,
|
|
5390
|
+
expires: new Date(responseData.expires)
|
|
5391
|
+
} : null;
|
|
5105
5392
|
},
|
|
5106
|
-
|
|
5393
|
+
enabled: !!account && !!accessToken
|
|
5107
5394
|
});
|
|
5108
|
-
return parseJsonResponse3(response);
|
|
5109
|
-
}
|
|
5110
|
-
async function onboardEmail(username, email, friend) {
|
|
5111
|
-
const dataBody = {
|
|
5112
|
-
username,
|
|
5113
|
-
email,
|
|
5114
|
-
friend
|
|
5115
|
-
};
|
|
5116
|
-
const fetchApi = getBoundFetch();
|
|
5117
|
-
const response = await fetchApi(
|
|
5118
|
-
CONFIG.privateApiHost + "/private-api/account-create-friend",
|
|
5119
|
-
{
|
|
5120
|
-
method: "POST",
|
|
5121
|
-
headers: {
|
|
5122
|
-
"Content-Type": "application/json"
|
|
5123
|
-
},
|
|
5124
|
-
body: JSON.stringify(dataBody)
|
|
5125
|
-
}
|
|
5126
|
-
);
|
|
5127
|
-
return parseJsonResponse3(response);
|
|
5128
5395
|
}
|
|
5129
5396
|
|
|
5130
5397
|
// src/modules/auth/requests.ts
|
|
@@ -5428,6 +5695,6 @@ async function getSpkMarkets() {
|
|
|
5428
5695
|
return await response.json();
|
|
5429
5696
|
}
|
|
5430
5697
|
|
|
5431
|
-
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, 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, getDeletedEntryQueryOptions, getDiscoverCurationQueryOptions, getDiscoverLeaderboardQueryOptions, getDiscussion, getDiscussionQueryOptions, getDiscussionsQueryOptions, getDraftsInfiniteQueryOptions, getDraftsQueryOptions, getDynamicPropsQueryOptions, getEntryActiveVotesQueryOptions, getFavouritesInfiniteQueryOptions, getFavouritesQueryOptions, getFollowCountQueryOptions, 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, getPost, getPostHeader, getPostHeaderQueryOptions, getPostQueryOptions, getPostTipsQueryOptions, getPostsRanked, getPostsRankedInfiniteQueryOptions, getPostsRankedQueryOptions, getProfiles, getProfilesQueryOptions, getPromotePriceQueryOptions, getPromotedPost, getPromotedPostsQuery, getProposalQueryOptions, getProposalVotesInfiniteQueryOptions, getProposalsQueryOptions, getQueryClient, getRcStatsQueryOptions, getReblogsQueryOptions, getReceivedVestingSharesQueryOptions, getReferralsInfiniteQueryOptions, getReferralsStatsQueryOptions, getRelationshipBetweenAccounts, getRelationshipBetweenAccountsQueryOptions, getRewardedCommunitiesQueryOptions, getSavingsWithdrawFromQueryOptions, getSchedulesInfiniteQueryOptions, getSchedulesQueryOptions, getSearchAccountQueryOptions, getSearchAccountsByUsernameQueryOptions, getSearchApiInfiniteQueryOptions, getSearchFriendsQueryOptions, getSearchPathQueryOptions, getSearchTopicsQueryOptions, getSimilarEntriesQueryOptions, getSpkMarkets, getSpkWallet, getStatsQueryOptions, getSubscribers, getSubscriptions, getTradeHistoryQueryOptions, getTransactionsInfiniteQueryOptions, getTrendingTagsQueryOptions, getTrendingTagsWithStatsQueryOptions, 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, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRecordActivity, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain, usrActivity, validatePostCreating, votingPower, votingValue };
|
|
5698
|
+
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, 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, getDeletedEntryQueryOptions, getDiscoverCurationQueryOptions, getDiscoverLeaderboardQueryOptions, getDiscussion, getDiscussionQueryOptions, getDiscussionsQueryOptions, getDraftsInfiniteQueryOptions, getDraftsQueryOptions, getDynamicPropsQueryOptions, getEntryActiveVotesQueryOptions, getFavouritesInfiniteQueryOptions, getFavouritesQueryOptions, getFollowCountQueryOptions, 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, getPost, getPostHeader, getPostHeaderQueryOptions, getPostQueryOptions, getPostTipsQueryOptions, getPostsRanked, getPostsRankedInfiniteQueryOptions, getPostsRankedQueryOptions, getProfiles, getProfilesQueryOptions, getPromotePriceQueryOptions, getPromotedPost, getPromotedPostsQuery, getProposalQueryOptions, getProposalVotesInfiniteQueryOptions, getProposalsQueryOptions, getQueryClient, getRcStatsQueryOptions, getReblogsQueryOptions, getReceivedVestingSharesQueryOptions, getRecurrentTransfersQueryOptions, getReferralsInfiniteQueryOptions, getReferralsStatsQueryOptions, getRelationshipBetweenAccounts, getRelationshipBetweenAccountsQueryOptions, getRewardedCommunitiesQueryOptions, getSavingsWithdrawFromQueryOptions, getSchedulesInfiniteQueryOptions, getSchedulesQueryOptions, getSearchAccountQueryOptions, getSearchAccountsByUsernameQueryOptions, getSearchApiInfiniteQueryOptions, getSearchFriendsQueryOptions, getSearchPathQueryOptions, getSearchTopicsQueryOptions, getSimilarEntriesQueryOptions, getSpkMarkets, getSpkWallet, getStatsQueryOptions, getSubscribers, getSubscriptions, getTradeHistoryQueryOptions, getTransactionsInfiniteQueryOptions, getTrendingTagsQueryOptions, getTrendingTagsWithStatsQueryOptions, 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 };
|
|
5432
5699
|
//# sourceMappingURL=index.js.map
|
|
5433
5700
|
//# sourceMappingURL=index.js.map
|