Skip to content

Commit 6b286c7

Browse files
[SDK] fix: Disable amount editing for non-wallet funding modes (#6236)
1 parent 159ffbf commit 6b286c7

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

.changeset/real-timers-rhyme.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+
Dont allow editing amoutns for non fund_wallet modes in PayEmbed

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,11 @@ function BuyScreenContent(props: BuyScreenContentProps) {
517517
screen.id === "buy-with-fiat") &&
518518
payer && (
519519
<TokenSelectedLayout
520+
disabled={
521+
("prefillBuy" in payOptions &&
522+
payOptions.prefillBuy?.allowEdits?.amount === false) ||
523+
payOptions.mode !== "fund_wallet"
524+
}
520525
title={props.title}
521526
selectedChain={toChain}
522527
selectedToken={toToken}
@@ -651,6 +656,7 @@ function SelectedTokenInfo(props: {
651656
tokenAmount: string;
652657
setTokenAmount: (amount: string) => void;
653658
client: ThirdwebClient;
659+
disabled?: boolean;
654660
}) {
655661
const getWidth = () => {
656662
let chars = props.tokenAmount.replace(".", "").length;
@@ -680,7 +686,7 @@ function SelectedTokenInfo(props: {
680686
type="text"
681687
data-placeholder={props.tokenAmount === ""}
682688
value={props.tokenAmount || "0"}
683-
disabled={false} // TODO: add disabled freeze amount
689+
disabled={props.disabled}
684690
onClick={(e) => {
685691
// put cursor at the end of the input
686692
if (props.tokenAmount === "") {
@@ -865,8 +871,13 @@ function MainScreen(props: {
865871
}}
866872
freezeAmount={payOptions.prefillBuy?.allowEdits?.amount === false}
867873
freezeChainAndToken={
868-
payOptions.prefillBuy?.allowEdits?.chain === false &&
869-
payOptions.prefillBuy?.allowEdits?.token === false
874+
(payOptions.prefillBuy?.allowEdits?.chain === false &&
875+
payOptions.prefillBuy?.allowEdits?.token === false) ||
876+
(payOptions.buyWithCrypto !== false &&
877+
payOptions.buyWithCrypto?.prefillSource?.allowEdits?.token ===
878+
false &&
879+
payOptions.buyWithCrypto?.prefillSource?.allowEdits?.chain ===
880+
false)
870881
}
871882
token={toToken}
872883
chain={toChain}
@@ -924,6 +935,7 @@ function TokenSelectedLayout(props: {
924935
selectedChain: Chain;
925936
client: ThirdwebClient;
926937
onBack: () => void;
938+
disabled?: boolean;
927939
}) {
928940
return (
929941
<Container>
@@ -944,6 +956,7 @@ function TokenSelectedLayout(props: {
944956
tokenAmount={props.tokenAmount}
945957
setTokenAmount={props.setTokenAmount}
946958
client={props.client}
959+
disabled={props.disabled}
947960
/>
948961

949962
<Spacer y="md" />

0 commit comments

Comments
 (0)