Skip to content

Commit 9c75db7

Browse files
Use new BuyWidget in wallet details modal
1 parent 67c3d86 commit 9c75db7

File tree

13 files changed

+66
-63
lines changed

13 files changed

+66
-63
lines changed

.changeset/dirty-bananas-fall.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+
Use new BuyWidget in wallet details modal

packages/thirdweb/src/react/core/hooks/usePaymentMethods.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ export function usePaymentMethods(options: {
141141
limit: 100,
142142
maxSteps: 3,
143143
originChainId: chainId,
144-
sortBy: "popularity",
145144
});
146145

147146
// Add all origin tokens from this chain's routes

packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ export function BridgeOrchestrator({
227227
<ErrorBanner
228228
client={client}
229229
error={state.context.currentError}
230-
onCancel={onCancel}
230+
onCancel={() => {
231+
send({ type: "RESET" });
232+
onCancel?.();
233+
}}
231234
onRetry={handleRetry}
232235
/>
233236
)}

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

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from "react";
2121
import { trackPayEvent } from "../../../../analytics/track/pay.js";
2222
import type { Chain } from "../../../../chains/types.js";
23+
import { getCachedChain } from "../../../../chains/utils.js";
2324
import type { ThirdwebClient } from "../../../../client/client.js";
2425
import { getContract } from "../../../../contract/contract.js";
2526
import type { SupportedFiatCurrency } from "../../../../pay/convert/type.js";
@@ -61,7 +62,10 @@ import type {
6162
ConnectButtonProps,
6263
PayUIOptions,
6364
} from "../../../core/hooks/connection/ConnectButtonProps.js";
64-
import { useChainFaucets } from "../../../core/hooks/others/useChainQuery.js";
65+
import {
66+
useChainFaucets,
67+
useChainMetadata,
68+
} from "../../../core/hooks/others/useChainQuery.js";
6569
import { useActiveAccount } from "../../../core/hooks/wallets/useActiveAccount.js";
6670
import { useActiveWallet } from "../../../core/hooks/wallets/useActiveWallet.js";
6771
import { useActiveWalletChain } from "../../../core/hooks/wallets/useActiveWalletChain.js";
@@ -80,6 +84,7 @@ import type {
8084
} from "../../../core/utils/defaultTokens.js";
8185
import { useWalletInfo } from "../../../core/utils/wallet.js";
8286
import { WalletUIStatesProvider } from "../../providers/wallet-ui-states-provider.js";
87+
import { BuyWidget } from "../Bridge/BuyWidget.js";
8388
import { Container, Line } from "../components/basic.js";
8489
import { Button, IconButton } from "../components/buttons.js";
8590
import { ChainActiveDot } from "../components/ChainActiveDot.js";
@@ -116,7 +121,6 @@ import {
116121
NetworkSelectorContent,
117122
type NetworkSelectorProps,
118123
} from "./NetworkSelector.js";
119-
import { LazyBuyScreen } from "./screens/Buy/LazyBuyScreen.js";
120124
import { WalletManagerScreen } from "./screens/Details/WalletManagerScreen.js";
121125
import { LinkedProfilesScreen } from "./screens/LinkedProfilesScreen.js";
122126
import { LinkProfileScreen } from "./screens/LinkProfileScreen.js";
@@ -390,6 +394,7 @@ export function DetailsModal(props: {
390394

391395
const activeWallet = useActiveWallet();
392396
const chainFaucetsQuery = useChainFaucets(walletChain);
397+
const chainMetadataQuery = useChainMetadata(walletChain);
393398

394399
const disableSwitchChain = !activeWallet?.switchChain;
395400

@@ -622,33 +627,35 @@ export function DetailsModal(props: {
622627
</Button>
623628
)}
624629

625-
{!hideBuyFunds && (
626-
<Button
627-
onClick={() => {
628-
trackPayEvent({
629-
client: client,
630-
event: "details_modal_buy_click",
631-
walletAddress: activeAccount?.address,
632-
walletType: activeWallet?.id,
633-
});
634-
setScreen("buy");
635-
}}
636-
style={{
637-
alignItems: "center",
638-
display: "flex",
639-
flex: 1,
640-
fontSize: fontSize.sm,
641-
gap: spacing.xs,
642-
padding: spacing.sm,
643-
}}
644-
variant="outline"
645-
>
646-
<Container center="both" color="secondaryText" flex="row">
647-
<PlusIcon height={iconSize.sm} width={iconSize.sm} />
648-
</Container>
649-
{locale.buy}
650-
</Button>
651-
)}
630+
{!hideBuyFunds &&
631+
chainMetadataQuery.data &&
632+
!chainMetadataQuery.data.testnet && (
633+
<Button
634+
onClick={() => {
635+
trackPayEvent({
636+
client: client,
637+
event: "details_modal_buy_click",
638+
walletAddress: activeAccount?.address,
639+
walletType: activeWallet?.id,
640+
});
641+
setScreen("buy");
642+
}}
643+
style={{
644+
alignItems: "center",
645+
display: "flex",
646+
flex: 1,
647+
fontSize: fontSize.sm,
648+
gap: spacing.xs,
649+
padding: spacing.sm,
650+
}}
651+
variant="outline"
652+
>
653+
<Container center="both" color="secondaryText" flex="row">
654+
<PlusIcon height={iconSize.sm} width={iconSize.sm} />
655+
</Container>
656+
{locale.buy}
657+
</Button>
658+
)}
652659
</Container>
653660
</Container>
654661

@@ -956,23 +963,26 @@ export function DetailsModal(props: {
956963

957964
// thirdweb pay
958965
else if (screen === "buy") {
966+
const requestedChainId =
967+
props.detailsModal?.payOptions?.prefillBuy?.chain?.id ||
968+
walletChain?.id ||
969+
props.chains[0]?.id ||
970+
1;
959971
content = (
960-
<LazyBuyScreen
972+
<BuyWidget
973+
amount={props.detailsModal?.payOptions?.prefillBuy?.amount || "0.01"}
974+
chain={getCachedChain(requestedChainId)}
961975
client={client}
962-
connectLocale={locale}
963-
connectOptions={undefined}
964976
hiddenWallets={props.detailsModal?.hiddenWallets}
965-
isEmbed={false}
966-
onBack={() => setScreen("main")}
967-
onDone={closeModal}
968-
payOptions={
969-
props.detailsModal?.payOptions || {
970-
mode: "fund_wallet",
971-
}
972-
}
977+
locale={locale.id}
978+
onCancel={() => setScreen("main")}
979+
onSuccess={() => setScreen("main")}
973980
supportedTokens={props.supportedTokens}
974-
theme={typeof props.theme === "string" ? props.theme : props.theme.type}
975-
title={locale.buy}
981+
tokenAddress={
982+
props.displayBalanceToken?.[Number(requestedChainId)] as
983+
| `0x${string}`
984+
| undefined
985+
}
976986
/>
977987
);
978988
}
@@ -1143,7 +1153,6 @@ const WalletInfoButton = /* @__PURE__ */ StyledButton((_) => {
11431153
transition: "background 250ms ease",
11441154
},
11451155
alignItems: "center",
1146-
all: "unset",
11471156
animation: `${fadeInAnimation} 300ms ease`,
11481157
background: theme.colors.connectedButtonBg,
11491158
border: `1px solid ${theme.colors.borderColor}`,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const MenuButton = /* @__PURE__ */ StyledButton((_) => {
2525
cursor: "not-allowed",
2626
},
2727
alignItems: "center",
28-
all: "unset",
2928
backgroundColor: "transparent",
3029
borderRadius: radius.md,
3130
// border: `1px solid ${theme.colors.borderColor}`,

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -690,12 +690,10 @@ export const ChainButton = /* @__PURE__ */ memo(function ChainButton(props: {
690690
)}
691691
</Container>
692692
{confirming || switchingFailed ? (
693-
<div
694-
style={{
695-
display: "flex",
696-
flexDirection: "column",
697-
gap: spacing.xs,
698-
}}
693+
<Container
694+
flex="column"
695+
gap="3xs"
696+
style={{ alignItems: "flex-start", width: "100%" }}
699697
>
700698
<ChainName
701699
loadingComponent={<Skeleton height="20px" width="150px" />}
@@ -718,7 +716,7 @@ export const ChainButton = /* @__PURE__ */ memo(function ChainButton(props: {
718716
</Container>
719717
)}
720718
</Container>
721-
</div>
719+
</Container>
722720
) : (
723721
<ChainName
724722
className="tw-chain-icon-none-confirming"
@@ -741,7 +739,6 @@ export const TabButton = /* @__PURE__ */ (() =>
741739
background: theme.colors.secondaryButtonBg,
742740
color: theme.colors.primaryText,
743741
},
744-
all: "unset",
745742
borderRadius: radius.lg,
746743
color: theme.colors.secondaryText,
747744
cursor: "pointer",
@@ -787,7 +784,6 @@ export const NetworkButton = /* @__PURE__ */ StyledButton((_) => {
787784
background: theme.colors.secondaryButtonBg,
788785
},
789786
alignItems: "center",
790-
all: "unset",
791787
borderRadius: radius.md,
792788
boxSizing: "border-box",
793789
color: theme.colors.primaryText,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,6 @@ const ShowAllWalletsIcon = /* @__PURE__ */ StyledDiv(() => {
720720
});
721721

722722
const WalletList = /* @__PURE__ */ StyledUl({
723-
all: "unset",
724723
boxSizing: "border-box",
725724
display: "flex",
726725
flex: 1,

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/ReceiveFunds.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ const WalletAddressContainer = /* @__PURE__ */ StyledButton((_) => {
8888
"&:hover": {
8989
borderColor: theme.colors.accentText,
9090
},
91-
all: "unset",
9291
border: `1px solid ${theme.colors.borderColor}`,
9392
borderRadius: radius.md,
9493
boxSizing: "border-box",

packages/thirdweb/src/react/web/ui/TransactionButton/DepositScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ const WalletAddressContainer = /* @__PURE__ */ StyledButton((_) => {
286286
"&:hover": {
287287
borderColor: theme.colors.accentText,
288288
},
289-
all: "unset",
290289
border: `1px solid ${theme.colors.borderColor}`,
291290
borderRadius: `0 0 ${radius.md} ${radius.md}`,
292291
boxSizing: "border-box",

packages/thirdweb/src/react/web/ui/components/buttons.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const Button = /* @__PURE__ */ StyledButton((props: ButtonProps) => {
3838
cursor: "not-allowed",
3939
},
4040
alignItems: "center",
41-
all: "unset",
4241
background: (() => {
4342
if (props.bg) {
4443
return theme.colors[props.bg];
@@ -152,7 +151,6 @@ export const IconButton = /* @__PURE__ */ StyledButton((_) => {
152151
cursor: "not-allowed",
153152
},
154153
alignItems: "center",
155-
all: "unset",
156154
borderRadius: radius.sm,
157155
color: theme.colors.secondaryIconColor,
158156
cursor: "pointer",

0 commit comments

Comments
 (0)