Skip to content

Commit da4a4a5

Browse files
Yash094cursoragent
andauthored
Wallet details export screen (#8698)
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Yash <Yash094@users.noreply.github.com>
1 parent 5e5c82f commit da4a4a5

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

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 `screen` prop to `useWalletDetailsModal` to allow opening the modal directly at a specific screen. Use `screen: "export"` to open directly at the Export Private Key screen.

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,11 @@ export function DetailsModal(props: {
383383
connectOptions: DetailsModalConnectOptions | undefined;
384384
assetTabs?: AssetTabs[];
385385
showBalanceInFiat?: SupportedFiatCurrency;
386+
initialScreen?: WalletDetailsModalScreen;
386387
}) {
387-
const [screen, setScreen] = useState<WalletDetailsModalScreen>("main");
388+
const [screen, setScreen] = useState<WalletDetailsModalScreen>(
389+
props.initialScreen || "main",
390+
);
388391
const { disconnect } = useDisconnect();
389392
const [isOpen, setIsOpen] = useState(true);
390393

@@ -887,7 +890,7 @@ export function DetailsModal(props: {
887890
supportedTokens={props.supportedTokens}
888891
/>
889892
);
890-
} else if (screen === "private-key") {
893+
} else if (screen === "private-key" || screen === "export") {
891894
content = (
892895
<PrivateKey
893896
client={client} // do not use the useCustomTheme hook to get this, it's not valid here
@@ -1724,6 +1727,22 @@ export type UseWalletDetailsModalOptions = {
17241727
* @param screen The name of the screen that was being shown when user closed the modal
17251728
*/
17261729
onClose?: (screen: string) => void;
1730+
1731+
/**
1732+
* The initial screen to show when the modal opens.
1733+
*
1734+
* @defaultValue "main"
1735+
*
1736+
* @example
1737+
* ```tsx
1738+
* // Open directly to the Export Private Key screen
1739+
* detailsModal.open({
1740+
* client,
1741+
* screen: "export"
1742+
* });
1743+
* ```
1744+
*/
1745+
screen?: WalletDetailsModalScreen;
17271746
};
17281747

17291748
/**
@@ -1750,6 +1769,14 @@ export type UseWalletDetailsModalOptions = {
17501769
* }
17511770
* ```
17521771
*
1772+
* ### Open directly to Export Private Key screen
1773+
* ```tsx
1774+
* detailsModal.open({
1775+
* client,
1776+
* screen: "export"
1777+
* });
1778+
* ```
1779+
*
17531780
* ### Callback for when the modal is closed
17541781
* ```tsx
17551782
* detailsModal.open({
@@ -1800,6 +1827,7 @@ export function useWalletDetailsModal() {
18001827
showTestnetFaucet: props.showTestnetFaucet,
18011828
}}
18021829
displayBalanceToken={props.displayBalanceToken}
1830+
initialScreen={props.screen}
18031831
locale={locale}
18041832
onDisconnect={(info) => {
18051833
props.onDisconnect?.(info);

0 commit comments

Comments
 (0)