Skip to content

Commit 2707db1

Browse files
feat: allow linking identities when using in-app + smart wallets (#4737)
1 parent ca23a95 commit 2707db1

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

.changeset/brave-socks-impress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Allow linking accounts when using in-app + smart wallets

packages/thirdweb/src/react/core/hooks/others/useProfiles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wa
33
import type { Profile } from "../../../../wallets/in-app/core/authentication/types.js";
44
import { getProfiles } from "../../../../wallets/in-app/core/wallet/profiles.js";
55
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
6-
import { useActiveWallet } from "../wallets/useActiveWallet.js";
6+
import { useAdminWallet } from "../wallets/useAdminAccount.js";
77

88
/**
99
* Retrieves all linked profiles for the current wallet.
@@ -25,7 +25,7 @@ import { useActiveWallet } from "../wallets/useActiveWallet.js";
2525
* @wallet
2626
*/
2727
export function useProfiles(): UseQueryResult<Profile[]> {
28-
const wallet = useActiveWallet();
28+
const wallet = useAdminWallet();
2929

3030
return useQuery({
3131
queryKey: ["profiles", wallet?.id],

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkProfileScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { isEcosystemWallet } from "../../../../../wallets/ecosystem/is-ecosystem
77
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
88
import type { EcosystemWalletId } from "../../../../../wallets/wallet-types.js";
99
import { iconSize } from "../../../../core/design-system/index.js";
10-
import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js";
1110
import { useActiveWalletChain } from "../../../../core/hooks/wallets/useActiveWalletChain.js";
11+
import { useAdminWallet } from "../../../../core/hooks/wallets/useAdminAccount.js";
1212
import EcosystemWalletConnectUI from "../../../wallets/ecosystem/EcosystemWalletConnectUI.js";
1313
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
1414
import { Container, Line, ModalHeader } from "../../components/basic.js";
@@ -28,7 +28,7 @@ export function LinkProfileScreen(props: {
2828
client: ThirdwebClient;
2929
walletConnect: { projectId?: string } | undefined;
3030
}) {
31-
const activeWallet = useActiveWallet();
31+
const activeWallet = useAdminWallet();
3232
const chain = useActiveWalletChain();
3333
const queryClient = useQueryClient();
3434

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/ManageWalletScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { isInAppWallet } from "../../../../../wallets/in-app/core/wallet/index.j
66
import { injectedProvider } from "../../../../../wallets/injected/mipdStore.js";
77
import { fontSize, iconSize } from "../../../../core/design-system/index.js";
88
import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js";
9+
import { useAdminWallet } from "../../../../core/hooks/wallets/useAdminAccount.js";
910
import { Spacer } from "../../components/Spacer.js";
1011
import { Container, Line, ModalHeader } from "../../components/basic.js";
1112
import { Text } from "../../components/text.js";
@@ -26,7 +27,7 @@ export function ManageWalletScreen(props: {
2627
locale: ConnectLocale;
2728
client: ThirdwebClient;
2829
}) {
29-
const activeWallet = useActiveWallet();
30+
const activeWallet = useAdminWallet();
3031

3132
return (
3233
<Container

packages/thirdweb/src/react/web/wallets/in-app/InAppWalletConnectUI.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ function InAppWalletConnectUI(props: {
5353

5454
// if the the modal starts out with the wallet's connect ui instead of wallet selector - going back to main screen requires staying on the same component and clearing the selection data
5555
// otherwise, we go back to the wallet selector by calling props.goBack
56-
const goBackToMain =
57-
initialScreen === props.wallet
58-
? () => {
59-
setSelectionData({});
60-
}
61-
: props.goBack;
56+
const goBackToMain = () => {
57+
if (initialScreen === props.wallet) {
58+
setSelectionData({});
59+
} else {
60+
props.goBack?.();
61+
setSelectionData({});
62+
}
63+
};
6264

6365
const done = () => {
6466
props.done();

0 commit comments

Comments
 (0)