From 67a363f624b935e02718e6cb205856e8b568477b Mon Sep 17 00:00:00 2001 From: gregfromstl Date: Fri, 18 Oct 2024 16:23:33 +0000 Subject: [PATCH] [SDK] Fix: ConnectEmbed SIWE Revalidation (#5080) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## PR-Codex overview This PR focuses on fixing revalidation issues related to `siwe` authentication in the `ConnectEmbed` component by updating mutation keys to include the `activeAccount` address. ### Detailed summary - Updated `mutationKey` for the `login` mutation to include `activeAccount?.address`. - Updated `mutationKey` for the `logout` mutation to include `activeAccount?.address`. - Added `gcTime`, `placeholderData`, and `refetchOnWindowFocus` options in the hook configuration. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .changeset/tall-melons-sneeze.md | 5 +++++ packages/thirdweb/src/react/core/hooks/auth/useSiweAuth.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/tall-melons-sneeze.md diff --git a/.changeset/tall-melons-sneeze.md b/.changeset/tall-melons-sneeze.md new file mode 100644 index 00000000000..9c08fd4893b --- /dev/null +++ b/.changeset/tall-melons-sneeze.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Fix revalidation with siwe auth in ConnectEmbed diff --git a/packages/thirdweb/src/react/core/hooks/auth/useSiweAuth.ts b/packages/thirdweb/src/react/core/hooks/auth/useSiweAuth.ts index 1419b5affae..4df6dcbd616 100644 --- a/packages/thirdweb/src/react/core/hooks/auth/useSiweAuth.ts +++ b/packages/thirdweb/src/react/core/hooks/auth/useSiweAuth.ts @@ -66,12 +66,13 @@ export function useSiweAuth( } return authOptions.isLoggedIn(activeAccount.address); }, + gcTime: 0, placeholderData: false, refetchOnWindowFocus: false, }); const loginMutation = useMutation({ - mutationKey: ["siwe_auth", "login"], + mutationKey: ["siwe_auth", "login", activeAccount?.address], mutationFn: async () => { if (!authOptions) { throw new Error("No auth options provided"); @@ -117,7 +118,7 @@ export function useSiweAuth( }); const logoutMutation = useMutation({ - mutationKey: ["siwe_auth", "logout"], + mutationKey: ["siwe_auth", "logout", activeAccount?.address], mutationFn: async () => { if (!authOptions) { throw new Error("No auth options provided");