@chipi-stack/chipi-react 14.2.0 → 14.2.1

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/hooks.js CHANGED
@@ -555,6 +555,7 @@ function useChipiSession(config) {
555
555
  }
556
556
  function useMigrateWalletToPasskey() {
557
557
  const { chipiSDK } = useChipiContext();
558
+ const queryClient = reactQuery.useQueryClient();
558
559
  const mutation = reactQuery.useMutation({
559
560
  mutationFn: async (input) => {
560
561
  const { wallet, oldEncryptKey, externalUserId, bearerToken } = input;
@@ -576,10 +577,27 @@ function useMigrateWalletToPasskey() {
576
577
  decryptedPrivateKey,
577
578
  passkeyResult.encryptKey
578
579
  );
580
+ const updateResult = await chipiSDK.wallets.updateWalletEncryption(
581
+ {
582
+ externalUserId,
583
+ newEncryptedPrivateKey,
584
+ publicKey: wallet.publicKey
585
+ },
586
+ bearerToken
587
+ );
588
+ if (updateResult?.success === false) {
589
+ throw new Error("Backend rejected wallet encryption update");
590
+ }
579
591
  const updatedWallet = {
580
592
  ...wallet,
581
593
  encryptedPrivateKey: newEncryptedPrivateKey
582
594
  };
595
+ queryClient.invalidateQueries({
596
+ queryKey: ["chipi-wallet", externalUserId]
597
+ });
598
+ queryClient.invalidateQueries({
599
+ queryKey: ["wallet", externalUserId]
600
+ });
583
601
  return {
584
602
  success: true,
585
603
  wallet: updatedWallet,