From 4ce73e3895540187b99da755fcfc210115b2764b Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 27 Jan 2025 14:39:42 -0800 Subject: [PATCH] [SDK] fix: Account linking for ecosystem smart wallets --- .changeset/new-maps-enjoy.md | 5 +++++ .../ConnectWallet/screens/LinkProfileScreen.tsx | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 .changeset/new-maps-enjoy.md diff --git a/.changeset/new-maps-enjoy.md b/.changeset/new-maps-enjoy.md new file mode 100644 index 00000000000..31b47264dbf --- /dev/null +++ b/.changeset/new-maps-enjoy.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Fix account linking for ecosystem smart wallets diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkProfileScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkProfileScreen.tsx index dcfac333282..caed3ecfb32 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkProfileScreen.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkProfileScreen.tsx @@ -7,6 +7,7 @@ import { isEcosystemWallet } from "../../../../../wallets/ecosystem/is-ecosystem import type { Wallet } from "../../../../../wallets/interfaces/wallet.js"; import type { EcosystemWalletId } from "../../../../../wallets/wallet-types.js"; import { iconSize } from "../../../../core/design-system/index.js"; +import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js"; import { useActiveWalletChain } from "../../../../core/hooks/wallets/useActiveWalletChain.js"; import { useAdminWallet } from "../../../../core/hooks/wallets/useAdminWallet.js"; import EcosystemWalletConnectUI from "../../../wallets/ecosystem/EcosystemWalletConnectUI.js"; @@ -28,20 +29,23 @@ export function LinkProfileScreen(props: { client: ThirdwebClient; walletConnect: { projectId?: string } | undefined; }) { - const activeWallet = useAdminWallet(); + const adminWallet = useAdminWallet(); + const activeWallet = useActiveWallet(); const chain = useActiveWalletChain(); const queryClient = useQueryClient(); - if (!activeWallet) { + const wallet = adminWallet || activeWallet; + + if (!wallet) { return ; } - if (activeWallet.id === "inApp") { + if (wallet.id === "inApp") { return ( }> } + wallet={wallet as Wallet<"inApp">} done={() => { setTimeout(() => { queryClient.invalidateQueries({ queryKey: ["profiles"] }); @@ -63,11 +67,11 @@ export function LinkProfileScreen(props: { ); } - if (isEcosystemWallet(activeWallet)) { + if (isEcosystemWallet(wallet)) { return ( }> } + wallet={wallet as Wallet} done={() => { setTimeout(() => { queryClient.invalidateQueries({ queryKey: ["profiles"] });