Skip to content

Commit

Permalink
feat: allow linking identities when using in-app + smart wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges committed Sep 21, 2024
1 parent ca23a95 commit e55497c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-socks-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Allow linking accounts when using in-app + smart wallets
4 changes: 2 additions & 2 deletions packages/thirdweb/src/react/core/hooks/others/useProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wa
import type { Profile } from "../../../../wallets/in-app/core/authentication/types.js";
import { getProfiles } from "../../../../wallets/in-app/core/wallet/profiles.js";
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
import { useActiveWallet } from "../wallets/useActiveWallet.js";
import { useAdminWallet } from "../wallets/useAdminAccount.js";

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

Check warning on line 28 in packages/thirdweb/src/react/core/hooks/others/useProfiles.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L28 was not covered by tests

return useQuery({
queryKey: ["profiles", wallet?.id],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ 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/useAdminAccount.js";
import EcosystemWalletConnectUI from "../../../wallets/ecosystem/EcosystemWalletConnectUI.js";
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
import { Container, Line, ModalHeader } from "../../components/basic.js";
Expand All @@ -28,7 +28,7 @@ export function LinkProfileScreen(props: {
client: ThirdwebClient;
walletConnect: { projectId?: string } | undefined;
}) {
const activeWallet = useActiveWallet();
const activeWallet = useAdminWallet();

Check warning on line 31 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkProfileScreen.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L31 was not covered by tests
const chain = useActiveWalletChain();
const queryClient = useQueryClient();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { isInAppWallet } from "../../../../../wallets/in-app/core/wallet/index.j
import { injectedProvider } from "../../../../../wallets/injected/mipdStore.js";
import { fontSize, iconSize } from "../../../../core/design-system/index.js";
import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js";
import { useAdminWallet } from "../../../../core/hooks/wallets/useAdminAccount.js";
import { Spacer } from "../../components/Spacer.js";
import { Container, Line, ModalHeader } from "../../components/basic.js";
import { Text } from "../../components/text.js";
Expand All @@ -26,7 +27,7 @@ export function ManageWalletScreen(props: {
locale: ConnectLocale;
client: ThirdwebClient;
}) {
const activeWallet = useActiveWallet();
const activeWallet = useAdminWallet();

Check warning on line 30 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/ManageWalletScreen.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L30 was not covered by tests

return (
<Container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ function InAppWalletConnectUI(props: {

// 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
// otherwise, we go back to the wallet selector by calling props.goBack
const goBackToMain =
initialScreen === props.wallet
? () => {
setSelectionData({});
}
: props.goBack;
const goBackToMain = () => {
if (initialScreen === props.wallet) {
setSelectionData({});
} else {
props.goBack?.();
setSelectionData({});
}
};

const done = () => {
props.done();
Expand Down

0 comments on commit e55497c

Please sign in to comment.