@ecency/sdk 1.3.3 → 1.3.5
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 +12 -1
- package/dist/browser/index.js +48 -22
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +51 -22
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +48 -22
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryClient, useQuery, useInfiniteQuery, useMutation, queryOptions, useQueryClient, infiniteQueryOptions } from '@tanstack/react-query';
|
|
2
2
|
import { Client, PrivateKey, cryptoUtils, RCAPI } from '@hiveio/dhive';
|
|
3
3
|
import hs from 'hivesigner';
|
|
4
|
-
import * as
|
|
4
|
+
import * as R4 from 'remeda';
|
|
5
5
|
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
@@ -402,11 +402,7 @@ function getAccountFullQueryOptions(username) {
|
|
|
402
402
|
if (!response[0]) {
|
|
403
403
|
throw new Error("[SDK] No account with given username");
|
|
404
404
|
}
|
|
405
|
-
|
|
406
|
-
try {
|
|
407
|
-
profile = JSON.parse(response[0].posting_json_metadata).profile;
|
|
408
|
-
} catch (e) {
|
|
409
|
-
}
|
|
405
|
+
const profile = parseProfileMetadata(response[0].posting_json_metadata);
|
|
410
406
|
let follow_stats;
|
|
411
407
|
try {
|
|
412
408
|
follow_stats = await CONFIG.hiveClient.database.call(
|
|
@@ -700,21 +696,42 @@ function sanitizeTokens(tokens) {
|
|
|
700
696
|
return { ...rest, meta: safeMeta };
|
|
701
697
|
});
|
|
702
698
|
}
|
|
703
|
-
function
|
|
699
|
+
function parseProfileMetadata(postingJsonMetadata) {
|
|
700
|
+
if (!postingJsonMetadata) {
|
|
701
|
+
return {};
|
|
702
|
+
}
|
|
703
|
+
try {
|
|
704
|
+
const parsed = JSON.parse(postingJsonMetadata);
|
|
705
|
+
if (parsed && typeof parsed === "object" && parsed.profile && typeof parsed.profile === "object") {
|
|
706
|
+
return parsed.profile;
|
|
707
|
+
}
|
|
708
|
+
} catch (err) {
|
|
709
|
+
}
|
|
710
|
+
return {};
|
|
711
|
+
}
|
|
712
|
+
function extractAccountProfile(data) {
|
|
713
|
+
return parseProfileMetadata(data?.posting_json_metadata);
|
|
714
|
+
}
|
|
715
|
+
function buildProfileMetadata({
|
|
716
|
+
existingProfile,
|
|
704
717
|
profile,
|
|
705
|
-
tokens
|
|
706
|
-
data
|
|
718
|
+
tokens
|
|
707
719
|
}) {
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
720
|
+
const { tokens: profileTokens, version: _ignoredVersion, ...profileRest } = profile ?? {};
|
|
721
|
+
const metadata = R4.mergeDeep(
|
|
722
|
+
existingProfile ?? {},
|
|
723
|
+
profileRest
|
|
711
724
|
);
|
|
712
|
-
|
|
713
|
-
|
|
725
|
+
const nextTokens = tokens ?? profileTokens;
|
|
726
|
+
if (nextTokens && nextTokens.length > 0) {
|
|
727
|
+
metadata.tokens = nextTokens;
|
|
714
728
|
}
|
|
715
729
|
metadata.tokens = sanitizeTokens(metadata.tokens);
|
|
730
|
+
metadata.version = 2;
|
|
716
731
|
return metadata;
|
|
717
732
|
}
|
|
733
|
+
|
|
734
|
+
// src/modules/accounts/mutations/use-account-update.ts
|
|
718
735
|
function useAccountUpdate(username) {
|
|
719
736
|
const queryClient = useQueryClient();
|
|
720
737
|
const { data } = useQuery(getAccountFullQueryOptions(username));
|
|
@@ -725,6 +742,11 @@ function useAccountUpdate(username) {
|
|
|
725
742
|
if (!data) {
|
|
726
743
|
throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
|
|
727
744
|
}
|
|
745
|
+
const profile = buildProfileMetadata({
|
|
746
|
+
existingProfile: extractAccountProfile(data),
|
|
747
|
+
profile: payload.profile,
|
|
748
|
+
tokens: payload.tokens
|
|
749
|
+
});
|
|
728
750
|
return [
|
|
729
751
|
[
|
|
730
752
|
"account_update2",
|
|
@@ -733,7 +755,7 @@ function useAccountUpdate(username) {
|
|
|
733
755
|
json_metadata: "",
|
|
734
756
|
extensions: [],
|
|
735
757
|
posting_json_metadata: JSON.stringify({
|
|
736
|
-
profile
|
|
758
|
+
profile
|
|
737
759
|
})
|
|
738
760
|
}
|
|
739
761
|
]
|
|
@@ -745,8 +767,12 @@ function useAccountUpdate(username) {
|
|
|
745
767
|
if (!data2) {
|
|
746
768
|
return data2;
|
|
747
769
|
}
|
|
748
|
-
const obj =
|
|
749
|
-
obj.profile =
|
|
770
|
+
const obj = R4.clone(data2);
|
|
771
|
+
obj.profile = buildProfileMetadata({
|
|
772
|
+
existingProfile: extractAccountProfile(data2),
|
|
773
|
+
profile: variables.profile,
|
|
774
|
+
tokens: variables.tokens
|
|
775
|
+
});
|
|
750
776
|
return obj;
|
|
751
777
|
}
|
|
752
778
|
)
|
|
@@ -941,7 +967,7 @@ function useAccountUpdateKeyAuths(username, options) {
|
|
|
941
967
|
);
|
|
942
968
|
}
|
|
943
969
|
const prepareAuth = (keyName) => {
|
|
944
|
-
const auth =
|
|
970
|
+
const auth = R4.clone(accountData[keyName]);
|
|
945
971
|
auth.key_auths = dedupeAndSortKeyAuths(
|
|
946
972
|
keepCurrent ? auth.key_auths : [],
|
|
947
973
|
keys.map(
|
|
@@ -1012,9 +1038,9 @@ function useAccountRevokePosting(username, options) {
|
|
|
1012
1038
|
"[SDK][Accounts] \u2013\xA0cannot revoke posting for anonymous user"
|
|
1013
1039
|
);
|
|
1014
1040
|
}
|
|
1015
|
-
const posting =
|
|
1041
|
+
const posting = R4.pipe(
|
|
1016
1042
|
{},
|
|
1017
|
-
|
|
1043
|
+
R4.mergeDeep(data.posting)
|
|
1018
1044
|
);
|
|
1019
1045
|
posting.account_auths = posting.account_auths.filter(
|
|
1020
1046
|
([account]) => account !== accountName
|
|
@@ -1131,7 +1157,7 @@ function useAccountRevokeKey(username, options) {
|
|
|
1131
1157
|
);
|
|
1132
1158
|
}
|
|
1133
1159
|
const prepareAuth = (keyName) => {
|
|
1134
|
-
const auth =
|
|
1160
|
+
const auth = R4.clone(accountData[keyName]);
|
|
1135
1161
|
auth.key_auths = auth.key_auths.filter(
|
|
1136
1162
|
([key]) => key !== revokingKey.toString()
|
|
1137
1163
|
);
|
|
@@ -1716,6 +1742,6 @@ function getCommunityPermissions({
|
|
|
1716
1742
|
};
|
|
1717
1743
|
}
|
|
1718
1744
|
|
|
1719
|
-
export { CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, keychain_exports as Keychain, NaiMap, ROLES, Symbol2 as Symbol, ThreeSpeakIntegration, 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 };
|
|
1745
|
+
export { CONFIG, ConfigManager, mutations_exports as EcencyAnalytics, EcencyQueriesManager, HiveSignerIntegration, keychain_exports as Keychain, NaiMap, ROLES, Symbol2 as Symbol, ThreeSpeakIntegration, broadcastJson, buildProfileMetadata, checkUsernameWalletsPendingQueryOptions, decodeObj, dedupeAndSortKeyAuths, encodeObj, extractAccountProfile, 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, parseProfileMetadata, roleMap, useAccountFavouriteAdd, useAccountFavouriteDelete, useAccountRelationsUpdate, useAccountRevokeKey, useAccountRevokePosting, useAccountUpdate, useAccountUpdateKeyAuths, useAccountUpdatePassword, useAccountUpdateRecovery, useAddFragment, useBookmarkAdd, useBookmarkDelete, useBroadcastMutation, useEditFragment, useGameClaim, useRemoveFragment, useSignOperationByHivesigner, useSignOperationByKey, useSignOperationByKeychain };
|
|
1720
1746
|
//# sourceMappingURL=index.mjs.map
|
|
1721
1747
|
//# sourceMappingURL=index.mjs.map
|