Skip to content

[SDK] fix hiddenWallets prop #7183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hidden-wallets-prop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Add a `hiddenWallets` prop to `ConnectEmbed`, `ConnectButton`, and `useConnectModal` to hide specific wallets from the connect list.
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,11 @@ export type ConnectButtonProps = {
*/
showAllWallets?: boolean;

/**
* All wallet IDs included in this array will be hidden from the wallet selection list.
*/
hiddenWallets?: WalletId[];

/**
* Enable SIWE (Sign in with Ethererum) by passing an object of type `SiweAuthOptions` to
* enforce the users to sign a message after connecting their wallet to authenticate themselves.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ThirdwebClient } from "../../../../client/client.js";
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
import type { AppMetadata } from "../../../../wallets/types.js";
import type { WalletId } from "../../../../wallets/wallet-types.js";
import type { WelcomeScreen } from "../../../web/ui/ConnectWallet/screens/types.js";
import type { LocaleId } from "../../../web/ui/types.js";
import type { Theme } from "../../design-system/index.js";
Expand Down Expand Up @@ -272,6 +273,11 @@ export type ConnectEmbedProps = {
*/
showAllWallets?: boolean;

/**
* All wallet IDs included in this array will be hidden from the wallet selection list.
*/
hiddenWallets?: WalletId[];

/**
* ConnectEmbed supports two modal size variants: `compact` and `wide`.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@
const activeAccount = useActiveAccount();
const activeWallet = useActiveWallet();
const siweAuth = useSiweAuth(activeWallet, activeAccount, props.auth);
const hiddenWallets =
props.hiddenWallets || props.detailsModal?.hiddenWallets;

usePreloadWalletProviders({
wallets,
Expand Down Expand Up @@ -393,6 +395,7 @@
onConnect={props.onConnect}
recommendedWallets={props.recommendedWallets}
showAllWallets={props.showAllWallets}
hiddenWallets={hiddenWallets}
walletConnect={props.walletConnect}
wallets={wallets}
/>
Expand All @@ -410,6 +413,8 @@
const siweAuth = props.siweAuth;
const activeAccount = useActiveAccount();
const [showSignatureModal, setShowSignatureModal] = useState(false);
const hiddenWallets =
props.hiddenWallets || props.detailsModal?.hiddenWallets;

// if wallet gets disconnected suddently, close the signature modal if it's open
useEffect(() => {
Expand Down Expand Up @@ -557,7 +562,10 @@
<ConnectedWalletDetails
theme={theme}
detailsButton={props.detailsButton}
detailsModal={props.detailsModal}
detailsModal={{
...props.detailsModal,
hiddenWallets: hiddenWallets,
}}

Check warning on line 568 in packages/thirdweb/src/react/web/ui/ConnectWallet/ConnectButton.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/ConnectButton.tsx#L565-L568

Added lines #L565 - L568 were not covered by tests
supportedTokens={supportedTokens}
supportedNFTs={props.supportedNFTs}
onDisconnect={(info) => {
Expand All @@ -582,7 +590,7 @@
showAllWallets: props.showAllWallets,
walletConnect: props.walletConnect,
wallets: props.wallets,
hiddenWallets: props.detailsModal?.hiddenWallets,
hiddenWallets: hiddenWallets,
}}
/>
</AccountProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { getDefaultWallets } from "../../../../../wallets/defaultWallets.js";
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js";
import type { WalletId } from "../../../../../wallets/wallet-types.js";
import {
CustomThemeProvider,
useCustomTheme,
Expand Down Expand Up @@ -295,6 +296,7 @@
modalSize={modalSize}
style={props.style}
welcomeScreen={props.welcomeScreen}
hiddenWallets={props.hiddenWallets}

Check warning on line 299 in packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L299 was not covered by tests
/>
{autoConnectComp}
</WalletUIStatesProvider>
Expand Down Expand Up @@ -337,6 +339,7 @@
onConnect: ((wallet: Wallet) => void) | undefined;
recommendedWallets: Wallet[] | undefined;
showAllWallets: boolean | undefined;
hiddenWallets: WalletId[] | undefined;
walletConnect:
| {
projectId?: string;
Expand Down Expand Up @@ -415,7 +418,7 @@
walletConnect={props.walletConnect}
wallets={props.wallets}
modalHeader={undefined}
walletIdsToHide={undefined}
walletIdsToHide={props.hiddenWallets}

Check warning on line 421 in packages/thirdweb/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L421 was not covered by tests
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Chain } from "../../../../../chains/types.js";
import type { ThirdwebClient } from "../../../../../client/client.js";
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js";
import type { WalletId } from "../../../../../wallets/wallet-types.js";
import type { SiweAuthOptions } from "../../../../core/hooks/auth/useSiweAuth.js";
import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js";
import {
Expand Down Expand Up @@ -42,6 +43,7 @@ type ConnectModalOptions = {
localeId: LocaleId;
chain: Chain | undefined;
showAllWallets: boolean | undefined;
hiddenWallets: WalletId[] | undefined;
chains: Chain[] | undefined;
walletConnect:
| {
Expand Down Expand Up @@ -151,7 +153,7 @@ const ConnectModal = (props: ConnectModalOptions) => {
chains={props.chains}
walletConnect={props.walletConnect}
modalHeader={undefined}
walletIdsToHide={undefined}
walletIdsToHide={props.hiddenWallets}
/>
</Modal>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getDefaultWallets } from "../../../../wallets/defaultWallets.js";
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js";
import type { AppMetadata } from "../../../../wallets/types.js";
import type { WalletId } from "../../../../wallets/wallet-types.js";
import type { Theme } from "../../../core/design-system/index.js";
import type { SiweAuthOptions } from "../../../core/hooks/auth/useSiweAuth.js";
import { SetRootElementContext } from "../../../core/providers/RootElementContext.js";
Expand Down Expand Up @@ -142,6 +143,7 @@ function Modal(
onConnect={props.onConnect}
recommendedWallets={props.recommendedWallets}
showAllWallets={props.showAllWallets}
hiddenWallets={props.hiddenWallets}
wallets={wallets}
chains={props.chains}
walletConnect={props.walletConnect}
Expand Down Expand Up @@ -364,6 +366,11 @@ export type UseConnectModalOptions = {
*/
showAllWallets?: boolean;

/**
* All wallet IDs included in this array will be hidden from the wallet selection list.
*/
hiddenWallets?: WalletId[];

/**
* Title to show in Connect Modal
*
Expand Down
Loading