File tree Expand file tree Collapse file tree 5 files changed +33
-4
lines changed
packages/thirdweb/src/react
ConnectWallet/screens/Buy Expand file tree Collapse file tree 5 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Fix PayEmbed purchase success callback and insufficient funds displayed when no metadata is passed in
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import type { SupportedFiatCurrency } from "../../../../pay/convert/type.js";
77import type { FiatProvider } from "../../../../pay/utils/commonTypes.js" ;
88import type { AssetTabs } from "../../../../react/web/ui/ConnectWallet/screens/ViewAssets.js" ;
99import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js" ;
10+ import type { Hex } from "../../../../utils/encoding/hex.js" ;
1011import type { Prettify } from "../../../../utils/type-utils.js" ;
1112import type { Account , Wallet } from "../../../../wallets/interfaces/wallet.js" ;
1213import type { SmartWalletOptions } from "../../../../wallets/smart/types.js" ;
@@ -114,6 +115,11 @@ export type PayUIOptions = Prettify<
114115 | {
115116 type : "fiat" ;
116117 status : BuyWithFiatStatus ;
118+ }
119+ | {
120+ type : "transaction" ;
121+ chainId : number ;
122+ transactionHash : Hex ;
117123 } ,
118124 ) => void ;
119125 /**
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { sendTransaction } from "../../../../transaction/actions/send-transactio
88import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js" ;
99import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js" ;
1010import { getTransactionGasCost } from "../../../../transaction/utils.js" ;
11+ import type { Hex } from "../../../../utils/encoding/hex.js" ;
1112import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js" ;
1213import type { Wallet } from "../../../../wallets/interfaces/wallet.js" ;
1314import { getTokenBalance } from "../../../../wallets/utils/getTokenBalance.js" ;
@@ -74,6 +75,11 @@ export type SendTransactionPayModalConfig =
7475 | {
7576 type : "fiat" ;
7677 status : BuyWithFiatStatus ;
78+ }
79+ | {
80+ type : "transaction" ;
81+ chainId : number ;
82+ transactionHash : Hex ;
7783 } ,
7884 ) => void ;
7985 }
Original file line number Diff line number Diff line change @@ -125,6 +125,10 @@ export function TransactionModeScreen(props: {
125125 return < LoadingScreen /> ;
126126 }
127127
128+ const insufficientFunds =
129+ balanceQuery . data &&
130+ balanceQuery . data . value < transactionCostAndData . transactionValueWei ;
131+
128132 return (
129133 < Container p = "lg" >
130134 < ModalHeader title = { metadata ?. name || "Transaction" } />
@@ -144,9 +148,11 @@ export function TransactionModeScreen(props: {
144148 />
145149 ) : activeAccount ? (
146150 < Container flex = "column" gap = "sm" >
147- < Text size = "sm" color = "danger" style = { { textAlign : "center" } } >
148- Insufficient funds
149- </ Text >
151+ { insufficientFunds && (
152+ < Text size = "sm" color = "danger" style = { { textAlign : "center" } } >
153+ Insufficient funds
154+ </ Text >
155+ ) }
150156 < Container
151157 flex = "row"
152158 style = { {
Original file line number Diff line number Diff line change @@ -365,7 +365,13 @@ export function PayEmbed(props: PayEmbedProps) {
365365 onBack = { ( ) => {
366366 setScreen ( "buy" ) ;
367367 } }
368- onTxSent = { ( ) => { } }
368+ onTxSent = { ( data ) => {
369+ props . payOptions ?. onPurchaseSuccess ?.( {
370+ type : "transaction" ,
371+ chainId : data . chain . id ,
372+ transactionHash : data . transactionHash ,
373+ } ) ;
374+ } }
369375 />
370376 ) }
371377 </ >
You can’t perform that action at this time.
0 commit comments