@ecency/sdk 1.3.4 → 1.3.6
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 +11 -1
- package/dist/browser/index.js +41 -23
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +44 -23
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +41 -23
- package/dist/node/index.mjs.map +1 -1
- package/package.json +17 -12
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,29 +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
|
+
}
|
|
704
703
|
try {
|
|
705
|
-
const parsed = JSON.parse(
|
|
704
|
+
const parsed = JSON.parse(postingJsonMetadata);
|
|
706
705
|
if (parsed && typeof parsed === "object" && parsed.profile && typeof parsed.profile === "object") {
|
|
707
706
|
return parsed.profile;
|
|
708
707
|
}
|
|
709
|
-
} catch (
|
|
708
|
+
} catch (err) {
|
|
710
709
|
}
|
|
711
710
|
return {};
|
|
712
711
|
}
|
|
713
|
-
function
|
|
712
|
+
function extractAccountProfile(data) {
|
|
713
|
+
return parseProfileMetadata(data?.posting_json_metadata);
|
|
714
|
+
}
|
|
715
|
+
function buildProfileMetadata({
|
|
716
|
+
existingProfile,
|
|
714
717
|
profile,
|
|
715
|
-
tokens
|
|
716
|
-
data
|
|
718
|
+
tokens
|
|
717
719
|
}) {
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
720
|
+
const { tokens: profileTokens, version: _ignoredVersion, ...profileRest } = profile ?? {};
|
|
721
|
+
const metadata = R4.mergeDeep(
|
|
722
|
+
existingProfile ?? {},
|
|
723
|
+
profileRest
|
|
724
|
+
);
|
|
725
|
+
const nextTokens = tokens ?? profileTokens;
|
|
726
|
+
if (nextTokens && nextTokens.length > 0) {
|
|
727
|
+
metadata.tokens = nextTokens;
|
|
721
728
|
}
|
|
722
729
|
metadata.tokens = sanitizeTokens(metadata.tokens);
|
|
723
730
|
metadata.version = 2;
|
|
724
731
|
return metadata;
|
|
725
732
|
}
|
|
733
|
+
|
|
734
|
+
// src/modules/accounts/mutations/use-account-update.ts
|
|
726
735
|
function useAccountUpdate(username) {
|
|
727
736
|
const queryClient = useQueryClient();
|
|
728
737
|
const { data } = useQuery(getAccountFullQueryOptions(username));
|
|
@@ -733,6 +742,11 @@ function useAccountUpdate(username) {
|
|
|
733
742
|
if (!data) {
|
|
734
743
|
throw new Error("[SDK][Accounts] \u2013 cannot update not existing account");
|
|
735
744
|
}
|
|
745
|
+
const profile = buildProfileMetadata({
|
|
746
|
+
existingProfile: extractAccountProfile(data),
|
|
747
|
+
profile: payload.profile,
|
|
748
|
+
tokens: payload.tokens
|
|
749
|
+
});
|
|
736
750
|
return [
|
|
737
751
|
[
|
|
738
752
|
"account_update2",
|
|
@@ -741,7 +755,7 @@ function useAccountUpdate(username) {
|
|
|
741
755
|
json_metadata: "",
|
|
742
756
|
extensions: [],
|
|
743
757
|
posting_json_metadata: JSON.stringify({
|
|
744
|
-
profile
|
|
758
|
+
profile
|
|
745
759
|
})
|
|
746
760
|
}
|
|
747
761
|
]
|
|
@@ -753,8 +767,12 @@ function useAccountUpdate(username) {
|
|
|
753
767
|
if (!data2) {
|
|
754
768
|
return data2;
|
|
755
769
|
}
|
|
756
|
-
const obj =
|
|
757
|
-
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
|
+
});
|
|
758
776
|
return obj;
|
|
759
777
|
}
|
|
760
778
|
)
|
|
@@ -949,7 +967,7 @@ function useAccountUpdateKeyAuths(username, options) {
|
|
|
949
967
|
);
|
|
950
968
|
}
|
|
951
969
|
const prepareAuth = (keyName) => {
|
|
952
|
-
const auth =
|
|
970
|
+
const auth = R4.clone(accountData[keyName]);
|
|
953
971
|
auth.key_auths = dedupeAndSortKeyAuths(
|
|
954
972
|
keepCurrent ? auth.key_auths : [],
|
|
955
973
|
keys.map(
|
|
@@ -1020,9 +1038,9 @@ function useAccountRevokePosting(username, options) {
|
|
|
1020
1038
|
"[SDK][Accounts] \u2013\xA0cannot revoke posting for anonymous user"
|
|
1021
1039
|
);
|
|
1022
1040
|
}
|
|
1023
|
-
const posting =
|
|
1041
|
+
const posting = R4.pipe(
|
|
1024
1042
|
{},
|
|
1025
|
-
|
|
1043
|
+
R4.mergeDeep(data.posting)
|
|
1026
1044
|
);
|
|
1027
1045
|
posting.account_auths = posting.account_auths.filter(
|
|
1028
1046
|
([account]) => account !== accountName
|
|
@@ -1139,7 +1157,7 @@ function useAccountRevokeKey(username, options) {
|
|
|
1139
1157
|
);
|
|
1140
1158
|
}
|
|
1141
1159
|
const prepareAuth = (keyName) => {
|
|
1142
|
-
const auth =
|
|
1160
|
+
const auth = R4.clone(accountData[keyName]);
|
|
1143
1161
|
auth.key_auths = auth.key_auths.filter(
|
|
1144
1162
|
([key]) => key !== revokingKey.toString()
|
|
1145
1163
|
);
|
|
@@ -1724,6 +1742,6 @@ function getCommunityPermissions({
|
|
|
1724
1742
|
};
|
|
1725
1743
|
}
|
|
1726
1744
|
|
|
1727
|
-
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 };
|
|
1728
1746
|
//# sourceMappingURL=index.mjs.map
|
|
1729
1747
|
//# sourceMappingURL=index.mjs.map
|