From 322d2a1b1427170a479afd175b02479160082ea7 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 12 Feb 2025 20:40:41 +1300 Subject: [PATCH] [SDK] fix: Disable amount editing for non-wallet funding modes --- .changeset/real-timers-rhyme.md | 5 +++++ .../ConnectWallet/screens/Buy/BuyScreen.tsx | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .changeset/real-timers-rhyme.md diff --git a/.changeset/real-timers-rhyme.md b/.changeset/real-timers-rhyme.md new file mode 100644 index 00000000000..5c0ddded489 --- /dev/null +++ b/.changeset/real-timers-rhyme.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Dont allow editing amoutns for non fund_wallet modes in PayEmbed diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx index f5d81dd4064..9c014f87e03 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx @@ -517,6 +517,11 @@ function BuyScreenContent(props: BuyScreenContentProps) { screen.id === "buy-with-fiat") && payer && ( void; client: ThirdwebClient; + disabled?: boolean; }) { const getWidth = () => { let chars = props.tokenAmount.replace(".", "").length; @@ -680,7 +686,7 @@ function SelectedTokenInfo(props: { type="text" data-placeholder={props.tokenAmount === ""} value={props.tokenAmount || "0"} - disabled={false} // TODO: add disabled freeze amount + disabled={props.disabled} onClick={(e) => { // put cursor at the end of the input if (props.tokenAmount === "") { @@ -865,8 +871,13 @@ function MainScreen(props: { }} freezeAmount={payOptions.prefillBuy?.allowEdits?.amount === false} freezeChainAndToken={ - payOptions.prefillBuy?.allowEdits?.chain === false && - payOptions.prefillBuy?.allowEdits?.token === false + (payOptions.prefillBuy?.allowEdits?.chain === false && + payOptions.prefillBuy?.allowEdits?.token === false) || + (payOptions.buyWithCrypto !== false && + payOptions.buyWithCrypto?.prefillSource?.allowEdits?.token === + false && + payOptions.buyWithCrypto?.prefillSource?.allowEdits?.chain === + false) } token={toToken} chain={toChain} @@ -924,6 +935,7 @@ function TokenSelectedLayout(props: { selectedChain: Chain; client: ThirdwebClient; onBack: () => void; + disabled?: boolean; }) { return ( @@ -944,6 +956,7 @@ function TokenSelectedLayout(props: { tokenAmount={props.tokenAmount} setTokenAmount={props.setTokenAmount} client={props.client} + disabled={props.disabled} />