Skip to content

Commit 655df03

Browse files
[SDK] fix hiddenWallets prop (#7183)
1 parent cbde32e commit 655df03

File tree

7 files changed

+40
-4
lines changed

7 files changed

+40
-4
lines changed

.changeset/hidden-wallets-prop.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+
Add a `hiddenWallets` prop to `ConnectEmbed`, `ConnectButton`, and `useConnectModal` to hide specific wallets from the connect list.

packages/thirdweb/src/react/core/hooks/connection/ConnectButtonProps.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,11 @@ export type ConnectButtonProps = {
981981
*/
982982
showAllWallets?: boolean;
983983

984+
/**
985+
* All wallet IDs included in this array will be hidden from the wallet selection list.
986+
*/
987+
hiddenWallets?: WalletId[];
988+
984989
/**
985990
* Enable SIWE (Sign in with Ethererum) by passing an object of type `SiweAuthOptions` to
986991
* enforce the users to sign a message after connecting their wallet to authenticate themselves.

packages/thirdweb/src/react/core/hooks/connection/ConnectEmbedProps.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
33
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
44
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
55
import type { AppMetadata } from "../../../../wallets/types.js";
6+
import type { WalletId } from "../../../../wallets/wallet-types.js";
67
import type { WelcomeScreen } from "../../../web/ui/ConnectWallet/screens/types.js";
78
import type { LocaleId } from "../../../web/ui/types.js";
89
import type { Theme } from "../../design-system/index.js";
@@ -272,6 +273,11 @@ export type ConnectEmbedProps = {
272273
*/
273274
showAllWallets?: boolean;
274275

276+
/**
277+
* All wallet IDs included in this array will be hidden from the wallet selection list.
278+
*/
279+
hiddenWallets?: WalletId[];
280+
275281
/**
276282
* ConnectEmbed supports two modal size variants: `compact` and `wide`.
277283
*

packages/thirdweb/src/react/web/ui/ConnectWallet/ConnectButton.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ export function ConnectButton(props: ConnectButtonProps) {
300300
const activeAccount = useActiveAccount();
301301
const activeWallet = useActiveWallet();
302302
const siweAuth = useSiweAuth(activeWallet, activeAccount, props.auth);
303+
const hiddenWallets =
304+
props.hiddenWallets || props.detailsModal?.hiddenWallets;
303305

304306
usePreloadWalletProviders({
305307
wallets,
@@ -393,6 +395,7 @@ export function ConnectButton(props: ConnectButtonProps) {
393395
onConnect={props.onConnect}
394396
recommendedWallets={props.recommendedWallets}
395397
showAllWallets={props.showAllWallets}
398+
hiddenWallets={hiddenWallets}
396399
walletConnect={props.walletConnect}
397400
wallets={wallets}
398401
/>
@@ -410,6 +413,8 @@ function ConnectButtonInner(
410413
const siweAuth = props.siweAuth;
411414
const activeAccount = useActiveAccount();
412415
const [showSignatureModal, setShowSignatureModal] = useState(false);
416+
const hiddenWallets =
417+
props.hiddenWallets || props.detailsModal?.hiddenWallets;
413418

414419
// if wallet gets disconnected suddently, close the signature modal if it's open
415420
useEffect(() => {
@@ -557,7 +562,10 @@ function ConnectButtonInner(
557562
<ConnectedWalletDetails
558563
theme={theme}
559564
detailsButton={props.detailsButton}
560-
detailsModal={props.detailsModal}
565+
detailsModal={{
566+
...props.detailsModal,
567+
hiddenWallets: hiddenWallets,
568+
}}
561569
supportedTokens={supportedTokens}
562570
supportedNFTs={props.supportedNFTs}
563571
onDisconnect={(info) => {
@@ -582,7 +590,7 @@ function ConnectButtonInner(
582590
showAllWallets: props.showAllWallets,
583591
walletConnect: props.walletConnect,
584592
wallets: props.wallets,
585-
hiddenWallets: props.detailsModal?.hiddenWallets,
593+
hiddenWallets: hiddenWallets,
586594
}}
587595
/>
588596
</AccountProvider>

packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ThirdwebClient } from "../../../../../client/client.js";
55
import { getDefaultWallets } from "../../../../../wallets/defaultWallets.js";
66
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
77
import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js";
8+
import type { WalletId } from "../../../../../wallets/wallet-types.js";
89
import {
910
CustomThemeProvider,
1011
useCustomTheme,
@@ -295,6 +296,7 @@ export function ConnectEmbed(props: ConnectEmbedProps) {
295296
modalSize={modalSize}
296297
style={props.style}
297298
welcomeScreen={props.welcomeScreen}
299+
hiddenWallets={props.hiddenWallets}
298300
/>
299301
{autoConnectComp}
300302
</WalletUIStatesProvider>
@@ -337,6 +339,7 @@ const ConnectEmbedContent = (props: {
337339
onConnect: ((wallet: Wallet) => void) | undefined;
338340
recommendedWallets: Wallet[] | undefined;
339341
showAllWallets: boolean | undefined;
342+
hiddenWallets: WalletId[] | undefined;
340343
walletConnect:
341344
| {
342345
projectId?: string;
@@ -415,7 +418,7 @@ const ConnectEmbedContent = (props: {
415418
walletConnect={props.walletConnect}
416419
wallets={props.wallets}
417420
modalHeader={undefined}
418-
walletIdsToHide={undefined}
421+
walletIdsToHide={props.hiddenWallets}
419422
/>
420423
);
421424
}

packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/ConnectModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Chain } from "../../../../../chains/types.js";
44
import type { ThirdwebClient } from "../../../../../client/client.js";
55
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
66
import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js";
7+
import type { WalletId } from "../../../../../wallets/wallet-types.js";
78
import type { SiweAuthOptions } from "../../../../core/hooks/auth/useSiweAuth.js";
89
import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js";
910
import {
@@ -42,6 +43,7 @@ type ConnectModalOptions = {
4243
localeId: LocaleId;
4344
chain: Chain | undefined;
4445
showAllWallets: boolean | undefined;
46+
hiddenWallets: WalletId[] | undefined;
4547
chains: Chain[] | undefined;
4648
walletConnect:
4749
| {
@@ -151,7 +153,7 @@ const ConnectModal = (props: ConnectModalOptions) => {
151153
chains={props.chains}
152154
walletConnect={props.walletConnect}
153155
modalHeader={undefined}
154-
walletIdsToHide={undefined}
156+
walletIdsToHide={props.hiddenWallets}
155157
/>
156158
</Modal>
157159
);

packages/thirdweb/src/react/web/ui/ConnectWallet/useConnectModal.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getDefaultWallets } from "../../../../wallets/defaultWallets.js";
55
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
66
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
77
import type { AppMetadata } from "../../../../wallets/types.js";
8+
import type { WalletId } from "../../../../wallets/wallet-types.js";
89
import type { Theme } from "../../../core/design-system/index.js";
910
import type { SiweAuthOptions } from "../../../core/hooks/auth/useSiweAuth.js";
1011
import { SetRootElementContext } from "../../../core/providers/RootElementContext.js";
@@ -142,6 +143,7 @@ function Modal(
142143
onConnect={props.onConnect}
143144
recommendedWallets={props.recommendedWallets}
144145
showAllWallets={props.showAllWallets}
146+
hiddenWallets={props.hiddenWallets}
145147
wallets={wallets}
146148
chains={props.chains}
147149
walletConnect={props.walletConnect}
@@ -364,6 +366,11 @@ export type UseConnectModalOptions = {
364366
*/
365367
showAllWallets?: boolean;
366368

369+
/**
370+
* All wallet IDs included in this array will be hidden from the wallet selection list.
371+
*/
372+
hiddenWallets?: WalletId[];
373+
367374
/**
368375
* Title to show in Connect Modal
369376
*

0 commit comments

Comments
 (0)