@ecency/sdk 1.3.2 → 1.3.4

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.
@@ -725,19 +725,27 @@ function sanitizeTokens(tokens) {
725
725
  return { ...rest, meta: safeMeta };
726
726
  });
727
727
  }
728
+ function getExistingProfile(data) {
729
+ try {
730
+ const parsed = JSON.parse(data?.posting_json_metadata || "{}");
731
+ if (parsed && typeof parsed === "object" && parsed.profile && typeof parsed.profile === "object") {
732
+ return parsed.profile;
733
+ }
734
+ } catch (e) {
735
+ }
736
+ return {};
737
+ }
728
738
  function getBuiltProfile({
729
739
  profile,
730
740
  tokens,
731
741
  data
732
742
  }) {
733
- const metadata = R__namespace.pipe(
734
- JSON.parse(data?.posting_json_metadata || "{}").profile,
735
- R__namespace.mergeDeep(profile ?? {})
736
- );
743
+ const metadata = R__namespace.mergeDeep(getExistingProfile(data), profile ?? {});
737
744
  if (tokens && tokens.length > 0) {
738
745
  metadata.tokens = tokens;
739
746
  }
740
747
  metadata.tokens = sanitizeTokens(metadata.tokens);
748
+ metadata.version = 2;
741
749
  return metadata;
742
750
  }
743
751
  function useAccountUpdate(username) {