|
2 | 2 | import { Cross2Icon } from "@radix-ui/react-icons"; |
3 | 3 | import { useMutation, useQueryClient } from "@tanstack/react-query"; |
4 | 4 | import type { ThirdwebClient } from "../../../../../client/client.js"; |
| 5 | +import { useActiveWallet } from "../../../../../react/core/hooks/wallets/useActiveWallet.js"; |
5 | 6 | import { shortenAddress } from "../../../../../utils/address.js"; |
| 7 | +import { isEcosystemWallet } from "../../../../../wallets/ecosystem/is-ecosystem-wallet.js"; |
6 | 8 | import type { Profile } from "../../../../../wallets/in-app/core/authentication/types.js"; |
7 | 9 | import type { Ecosystem } from "../../../../../wallets/in-app/core/wallet/types.js"; |
8 | 10 | import { unlinkProfile } from "../../../../../wallets/in-app/web/lib/auth/index.js"; |
| 11 | +import type { Wallet } from "../../../../../wallets/interfaces/wallet.js"; |
| 12 | +import type { EcosystemWalletId } from "../../../../../wallets/wallet-types.js"; |
9 | 13 | import { fontSize, iconSize } from "../../../../core/design-system/index.js"; |
10 | 14 | import { useSocialProfiles } from "../../../../core/social/useSocialProfiles.js"; |
11 | 15 | import { getSocialIcon } from "../../../../core/utils/walletIcon.js"; |
@@ -51,7 +55,6 @@ export function LinkedProfilesScreen(props: { |
51 | 55 | setScreen: (screen: WalletDetailsModalScreen) => void; |
52 | 56 | locale: ConnectLocale; |
53 | 57 | client: ThirdwebClient; |
54 | | - ecosystem?: Ecosystem; |
55 | 58 | }) { |
56 | 59 | const { data: connectedProfiles, isLoading } = useProfiles({ |
57 | 60 | client: props.client, |
@@ -122,20 +125,34 @@ function LinkedProfile({ |
122 | 125 | profile, |
123 | 126 | enableUnlinking, |
124 | 127 | client, |
125 | | - ecosystem, |
126 | 128 | }: { |
127 | 129 | profile: Profile; |
128 | 130 | enableUnlinking: boolean; |
129 | 131 | client: ThirdwebClient; |
130 | | - ecosystem?: Ecosystem; |
131 | 132 | }) { |
| 133 | + const activeWallet = useActiveWallet(); |
132 | 134 | const { data: socialProfiles } = useSocialProfiles({ |
133 | 135 | client, |
134 | 136 | address: profile.details.address, |
135 | 137 | }); |
136 | 138 | const queryClient = useQueryClient(); |
137 | 139 | const { mutate: unlinkProfileMutation, isPending } = useMutation({ |
138 | 140 | mutationFn: async () => { |
| 141 | + let ecosystem: Ecosystem | undefined; |
| 142 | + |
| 143 | + if (!activeWallet) { |
| 144 | + throw new Error("No active wallet found"); |
| 145 | + } |
| 146 | + |
| 147 | + if (isEcosystemWallet(activeWallet)) { |
| 148 | + const ecosystemWallet = activeWallet as Wallet<EcosystemWalletId>; |
| 149 | + const partnerId = ecosystemWallet.getConfig()?.partnerId; |
| 150 | + ecosystem = { |
| 151 | + id: ecosystemWallet.id, |
| 152 | + partnerId, |
| 153 | + }; |
| 154 | + } |
| 155 | + |
139 | 156 | await unlinkProfile({ |
140 | 157 | client, |
141 | 158 | ecosystem, |
|
0 commit comments