@ecency/sdk 1.3.0 → 1.3.2
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 +22 -88
- package/dist/browser/index.js +96 -17
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +96 -17
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +96 -17
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -245,25 +245,7 @@ declare function getAccountFullQueryOptions(username: string | undefined): _tans
|
|
|
245
245
|
downvote_manabar: any;
|
|
246
246
|
follow_stats: AccountFollowStats | undefined;
|
|
247
247
|
reputation: number;
|
|
248
|
-
profile:
|
|
249
|
-
reputation: number;
|
|
250
|
-
about?: string;
|
|
251
|
-
cover_image?: string;
|
|
252
|
-
location?: string;
|
|
253
|
-
name?: string;
|
|
254
|
-
profile_image?: string;
|
|
255
|
-
website?: string;
|
|
256
|
-
pinned?: string;
|
|
257
|
-
beneficiary?: {
|
|
258
|
-
account: string;
|
|
259
|
-
weight: number;
|
|
260
|
-
};
|
|
261
|
-
tokens?: {
|
|
262
|
-
symbol: string;
|
|
263
|
-
type: string;
|
|
264
|
-
meta: Record<string, any>;
|
|
265
|
-
}[];
|
|
266
|
-
};
|
|
248
|
+
profile: AccountProfile;
|
|
267
249
|
}, Error, {
|
|
268
250
|
name: any;
|
|
269
251
|
owner: any;
|
|
@@ -304,25 +286,7 @@ declare function getAccountFullQueryOptions(username: string | undefined): _tans
|
|
|
304
286
|
downvote_manabar: any;
|
|
305
287
|
follow_stats: AccountFollowStats | undefined;
|
|
306
288
|
reputation: number;
|
|
307
|
-
profile:
|
|
308
|
-
reputation: number;
|
|
309
|
-
about?: string;
|
|
310
|
-
cover_image?: string;
|
|
311
|
-
location?: string;
|
|
312
|
-
name?: string;
|
|
313
|
-
profile_image?: string;
|
|
314
|
-
website?: string;
|
|
315
|
-
pinned?: string;
|
|
316
|
-
beneficiary?: {
|
|
317
|
-
account: string;
|
|
318
|
-
weight: number;
|
|
319
|
-
};
|
|
320
|
-
tokens?: {
|
|
321
|
-
symbol: string;
|
|
322
|
-
type: string;
|
|
323
|
-
meta: Record<string, any>;
|
|
324
|
-
}[];
|
|
325
|
-
};
|
|
289
|
+
profile: AccountProfile;
|
|
326
290
|
}, (string | undefined)[]>, "queryFn"> & {
|
|
327
291
|
queryFn?: _tanstack_react_query.QueryFunction<{
|
|
328
292
|
name: any;
|
|
@@ -364,25 +328,7 @@ declare function getAccountFullQueryOptions(username: string | undefined): _tans
|
|
|
364
328
|
downvote_manabar: any;
|
|
365
329
|
follow_stats: AccountFollowStats | undefined;
|
|
366
330
|
reputation: number;
|
|
367
|
-
profile:
|
|
368
|
-
reputation: number;
|
|
369
|
-
about?: string;
|
|
370
|
-
cover_image?: string;
|
|
371
|
-
location?: string;
|
|
372
|
-
name?: string;
|
|
373
|
-
profile_image?: string;
|
|
374
|
-
website?: string;
|
|
375
|
-
pinned?: string;
|
|
376
|
-
beneficiary?: {
|
|
377
|
-
account: string;
|
|
378
|
-
weight: number;
|
|
379
|
-
};
|
|
380
|
-
tokens?: {
|
|
381
|
-
symbol: string;
|
|
382
|
-
type: string;
|
|
383
|
-
meta: Record<string, any>;
|
|
384
|
-
}[];
|
|
385
|
-
};
|
|
331
|
+
profile: AccountProfile;
|
|
386
332
|
}, (string | undefined)[], never> | undefined;
|
|
387
333
|
} & {
|
|
388
334
|
queryKey: (string | undefined)[] & {
|
|
@@ -426,25 +372,7 @@ declare function getAccountFullQueryOptions(username: string | undefined): _tans
|
|
|
426
372
|
downvote_manabar: any;
|
|
427
373
|
follow_stats: AccountFollowStats | undefined;
|
|
428
374
|
reputation: number;
|
|
429
|
-
profile:
|
|
430
|
-
reputation: number;
|
|
431
|
-
about?: string;
|
|
432
|
-
cover_image?: string;
|
|
433
|
-
location?: string;
|
|
434
|
-
name?: string;
|
|
435
|
-
profile_image?: string;
|
|
436
|
-
website?: string;
|
|
437
|
-
pinned?: string;
|
|
438
|
-
beneficiary?: {
|
|
439
|
-
account: string;
|
|
440
|
-
weight: number;
|
|
441
|
-
};
|
|
442
|
-
tokens?: {
|
|
443
|
-
symbol: string;
|
|
444
|
-
type: string;
|
|
445
|
-
meta: Record<string, any>;
|
|
446
|
-
}[];
|
|
447
|
-
};
|
|
375
|
+
profile: AccountProfile;
|
|
448
376
|
};
|
|
449
377
|
[dataTagErrorSymbol]: Error;
|
|
450
378
|
};
|
|
@@ -459,19 +387,25 @@ declare function getSearchAccountsByUsernameQueryOptions(query: string, limit?:
|
|
|
459
387
|
};
|
|
460
388
|
};
|
|
461
389
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
390
|
+
type AccountProfileToken = NonNullable<AccountProfile["tokens"]>[number];
|
|
391
|
+
type WalletMetadataCandidate = Partial<AccountProfileToken> & {
|
|
392
|
+
currency?: string;
|
|
393
|
+
show?: boolean;
|
|
394
|
+
address?: string;
|
|
395
|
+
publicKey?: string;
|
|
396
|
+
privateKey?: string;
|
|
397
|
+
username?: string;
|
|
398
|
+
};
|
|
399
|
+
interface CheckUsernameWalletsPendingResponse {
|
|
465
400
|
exist: boolean;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
401
|
+
tokens?: WalletMetadataCandidate[];
|
|
402
|
+
wallets?: WalletMetadataCandidate[];
|
|
403
|
+
}
|
|
404
|
+
declare function checkUsernameWalletsPendingQueryOptions(username: string, code: string | undefined): _tanstack_react_query.OmitKeyof<_tanstack_react_query.UseQueryOptions<CheckUsernameWalletsPendingResponse, Error, CheckUsernameWalletsPendingResponse, readonly unknown[]>, "queryFn"> & {
|
|
405
|
+
queryFn?: _tanstack_react_query.QueryFunction<CheckUsernameWalletsPendingResponse, readonly unknown[], never> | undefined;
|
|
470
406
|
} & {
|
|
471
|
-
queryKey:
|
|
472
|
-
[dataTagSymbol]:
|
|
473
|
-
exist: boolean;
|
|
474
|
-
};
|
|
407
|
+
queryKey: readonly unknown[] & {
|
|
408
|
+
[dataTagSymbol]: CheckUsernameWalletsPendingResponse;
|
|
475
409
|
[dataTagErrorSymbol]: Error;
|
|
476
410
|
};
|
|
477
411
|
};
|
|
@@ -1094,4 +1028,4 @@ declare function getCommunityPermissions({ communityType, userRole, subscribed,
|
|
|
1094
1028
|
isModerator: boolean;
|
|
1095
1029
|
};
|
|
1096
1030
|
|
|
1097
|
-
export { type AccountBookmark, type AccountFavorite, type AccountFollowStats, type AccountProfile, type AccountRelationship, type AccountReputation, type Asset, CONFIG, type CantAfford, type Communities, type Community, type CommunityRole, type CommunityTeam, type CommunityType, ConfigManager, type DynamicProps, index as EcencyAnalytics, EcencyQueriesManager, type Fragment, type FullAccount, type GameClaim, type GetGameStatus, type GetRecoveriesEmailResponse, HiveSignerIntegration, keychain as Keychain, type Keys, NaiMap, type Payer, ROLES, type RcStats, type Recoveries, type StatsResponse, type StoringUser, Symbol, ThreeSpeakIntegration, type ThreeSpeakVideo, type TrendingTag, broadcastJson, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, getAccessToken, getAccountFullQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityType, getDynamicPropsQueryOptions, getFragmentsQueryOptions, getGameStatusCheckQueryOptions, getHivePoshLinksQueryOptions, getLoginType, getPostingKey, getPromotedPostsQuery, getQueryClient, getRcStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getSearchAccountsByUsernameQueryOptions, getStatsQueryOptions, getTrendingTagsQueryOptions, getUser, makeQueryClient, parseAsset, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
|
|
1031
|
+
export { type AccountBookmark, type AccountFavorite, type AccountFollowStats, type AccountProfile, type AccountRelationship, type AccountReputation, type Asset, CONFIG, type CantAfford, type CheckUsernameWalletsPendingResponse, type Communities, type Community, type CommunityRole, type CommunityTeam, type CommunityType, ConfigManager, type DynamicProps, index as EcencyAnalytics, EcencyQueriesManager, type Fragment, type FullAccount, type GameClaim, type GetGameStatus, type GetRecoveriesEmailResponse, HiveSignerIntegration, keychain as Keychain, type Keys, NaiMap, type Payer, ROLES, type RcStats, type Recoveries, type StatsResponse, type StoringUser, Symbol, ThreeSpeakIntegration, type ThreeSpeakVideo, type TrendingTag, type WalletMetadataCandidate, broadcastJson, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, getAccessToken, getAccountFullQueryOptions, getAccountPendingRecoveryQueryOptions, getAccountRcQueryOptions, getAccountRecoveriesQueryOptions, getAccountSubscriptionsQueryOptions, getActiveAccountBookmarksQueryOptions, getActiveAccountFavouritesQueryOptions, getBoundFetch, getChainPropertiesQueryOptions, getCommunitiesQueryOptions, getCommunityContextQueryOptions, getCommunityPermissions, getCommunityType, getDynamicPropsQueryOptions, getFragmentsQueryOptions, getGameStatusCheckQueryOptions, getHivePoshLinksQueryOptions, getLoginType, getPostingKey, getPromotedPostsQuery, getQueryClient, getRcStatsQueryOptions, getRefreshToken, getRelationshipBetweenAccountsQueryOptions, getSearchAccountsByUsernameQueryOptions, getStatsQueryOptions, getTrendingTagsQueryOptions, getUser, makeQueryClient, parseAsset, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
|
package/dist/browser/index.js
CHANGED
|
@@ -406,7 +406,11 @@ function getAccountFullQueryOptions(username) {
|
|
|
406
406
|
if (!response[0]) {
|
|
407
407
|
throw new Error("[SDK] No account with given username");
|
|
408
408
|
}
|
|
409
|
-
|
|
409
|
+
let profile = {};
|
|
410
|
+
try {
|
|
411
|
+
profile = JSON.parse(response[0].posting_json_metadata).profile;
|
|
412
|
+
} catch (e) {
|
|
413
|
+
}
|
|
410
414
|
let follow_stats;
|
|
411
415
|
try {
|
|
412
416
|
follow_stats = await CONFIG.hiveClient.database.call(
|
|
@@ -415,11 +419,16 @@ function getAccountFullQueryOptions(username) {
|
|
|
415
419
|
);
|
|
416
420
|
} catch (e) {
|
|
417
421
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
422
|
+
let reputationValue = 0;
|
|
423
|
+
try {
|
|
424
|
+
const reputation = await CONFIG.hiveClient.call(
|
|
425
|
+
"condenser_api",
|
|
426
|
+
"get_account_reputations",
|
|
427
|
+
[username, 1]
|
|
428
|
+
);
|
|
429
|
+
reputationValue = reputation[0]?.reputation ?? 0;
|
|
430
|
+
} catch (e) {
|
|
431
|
+
}
|
|
423
432
|
return {
|
|
424
433
|
name: response[0].name,
|
|
425
434
|
owner: response[0].owner,
|
|
@@ -459,11 +468,8 @@ function getAccountFullQueryOptions(username) {
|
|
|
459
468
|
voting_power: response[0].voting_power,
|
|
460
469
|
downvote_manabar: response[0].downvote_manabar,
|
|
461
470
|
follow_stats,
|
|
462
|
-
reputation:
|
|
463
|
-
profile
|
|
464
|
-
...profile,
|
|
465
|
-
reputation: reputation[0].reputation
|
|
466
|
-
}
|
|
471
|
+
reputation: reputationValue,
|
|
472
|
+
profile
|
|
467
473
|
};
|
|
468
474
|
},
|
|
469
475
|
enabled: !!username,
|
|
@@ -485,26 +491,99 @@ function getSearchAccountsByUsernameQueryOptions(query, limit = 5, excludeList =
|
|
|
485
491
|
}
|
|
486
492
|
});
|
|
487
493
|
}
|
|
488
|
-
|
|
494
|
+
var RESERVED_META_KEYS = /* @__PURE__ */ new Set([
|
|
495
|
+
"ownerPublicKey",
|
|
496
|
+
"activePublicKey",
|
|
497
|
+
"postingPublicKey",
|
|
498
|
+
"memoPublicKey"
|
|
499
|
+
]);
|
|
500
|
+
function checkUsernameWalletsPendingQueryOptions(username, code) {
|
|
489
501
|
return queryOptions({
|
|
490
|
-
queryKey: [
|
|
502
|
+
queryKey: [
|
|
503
|
+
"accounts",
|
|
504
|
+
"check-wallet-pending",
|
|
505
|
+
username,
|
|
506
|
+
code ?? null
|
|
507
|
+
],
|
|
491
508
|
queryFn: async () => {
|
|
509
|
+
if (!username || !code) {
|
|
510
|
+
return { exist: false };
|
|
511
|
+
}
|
|
492
512
|
const fetchApi = getBoundFetch();
|
|
493
513
|
const response = await fetchApi(
|
|
494
|
-
CONFIG.privateApiHost + "/private-api/wallets
|
|
514
|
+
CONFIG.privateApiHost + "/private-api/wallets",
|
|
495
515
|
{
|
|
496
516
|
method: "POST",
|
|
497
517
|
headers: {
|
|
498
518
|
"Content-Type": "application/json"
|
|
499
519
|
},
|
|
500
520
|
body: JSON.stringify({
|
|
501
|
-
username
|
|
521
|
+
username,
|
|
522
|
+
code
|
|
502
523
|
})
|
|
503
524
|
}
|
|
504
525
|
);
|
|
505
|
-
|
|
526
|
+
if (!response.ok) {
|
|
527
|
+
return { exist: false };
|
|
528
|
+
}
|
|
529
|
+
const payload = await response.json();
|
|
530
|
+
const wallets = Array.isArray(payload) ? payload.flatMap((item) => {
|
|
531
|
+
if (!item || typeof item !== "object") {
|
|
532
|
+
return [];
|
|
533
|
+
}
|
|
534
|
+
const walletItem = item;
|
|
535
|
+
const symbol = typeof walletItem.token === "string" ? walletItem.token : void 0;
|
|
536
|
+
if (!symbol) {
|
|
537
|
+
return [];
|
|
538
|
+
}
|
|
539
|
+
const meta = walletItem.meta && typeof walletItem.meta === "object" ? { ...walletItem.meta } : {};
|
|
540
|
+
const sanitizedMeta = {};
|
|
541
|
+
const address = typeof walletItem.address === "string" && walletItem.address ? walletItem.address : void 0;
|
|
542
|
+
const statusShow = typeof walletItem.status === "number" ? walletItem.status === 3 : void 0;
|
|
543
|
+
const showFlag = statusShow ?? false;
|
|
544
|
+
if (address) {
|
|
545
|
+
sanitizedMeta.address = address;
|
|
546
|
+
}
|
|
547
|
+
sanitizedMeta.show = showFlag;
|
|
548
|
+
const baseCandidate = {
|
|
549
|
+
symbol,
|
|
550
|
+
currency: symbol,
|
|
551
|
+
address,
|
|
552
|
+
show: showFlag,
|
|
553
|
+
type: "CHAIN",
|
|
554
|
+
meta: sanitizedMeta
|
|
555
|
+
};
|
|
556
|
+
const metaTokenCandidates = [];
|
|
557
|
+
for (const [metaSymbol, metaValue] of Object.entries(meta)) {
|
|
558
|
+
if (typeof metaSymbol !== "string") {
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
if (RESERVED_META_KEYS.has(metaSymbol)) {
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
if (typeof metaValue !== "string" || !metaValue) {
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
if (!/^[A-Z0-9]{2,10}$/.test(metaSymbol)) {
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
metaTokenCandidates.push({
|
|
571
|
+
symbol: metaSymbol,
|
|
572
|
+
currency: metaSymbol,
|
|
573
|
+
address: metaValue,
|
|
574
|
+
show: showFlag,
|
|
575
|
+
type: "CHAIN",
|
|
576
|
+
meta: { address: metaValue, show: showFlag }
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
return [baseCandidate, ...metaTokenCandidates];
|
|
580
|
+
}) : [];
|
|
581
|
+
return {
|
|
582
|
+
exist: wallets.length > 0,
|
|
583
|
+
tokens: wallets.length ? wallets : void 0,
|
|
584
|
+
wallets: wallets.length ? wallets : void 0
|
|
585
|
+
};
|
|
506
586
|
},
|
|
507
|
-
enabled: !!username,
|
|
508
587
|
refetchOnMount: true
|
|
509
588
|
});
|
|
510
589
|
}
|