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";
7
7
import type { FiatProvider } from "../../../../pay/utils/commonTypes.js" ;
8
8
import type { AssetTabs } from "../../../../react/web/ui/ConnectWallet/screens/ViewAssets.js" ;
9
9
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js" ;
10
+ import type { Hex } from "../../../../utils/encoding/hex.js" ;
10
11
import type { Prettify } from "../../../../utils/type-utils.js" ;
11
12
import type { Account , Wallet } from "../../../../wallets/interfaces/wallet.js" ;
12
13
import type { SmartWalletOptions } from "../../../../wallets/smart/types.js" ;
@@ -114,6 +115,11 @@ export type PayUIOptions = Prettify<
114
115
| {
115
116
type : "fiat" ;
116
117
status : BuyWithFiatStatus ;
118
+ }
119
+ | {
120
+ type : "transaction" ;
121
+ chainId : number ;
122
+ transactionHash : Hex ;
117
123
} ,
118
124
) => void ;
119
125
/**
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { sendTransaction } from "../../../../transaction/actions/send-transactio
8
8
import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js" ;
9
9
import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js" ;
10
10
import { getTransactionGasCost } from "../../../../transaction/utils.js" ;
11
+ import type { Hex } from "../../../../utils/encoding/hex.js" ;
11
12
import { resolvePromisedValue } from "../../../../utils/promise/resolve-promised-value.js" ;
12
13
import type { Wallet } from "../../../../wallets/interfaces/wallet.js" ;
13
14
import { getTokenBalance } from "../../../../wallets/utils/getTokenBalance.js" ;
@@ -74,6 +75,11 @@ export type SendTransactionPayModalConfig =
74
75
| {
75
76
type : "fiat" ;
76
77
status : BuyWithFiatStatus ;
78
+ }
79
+ | {
80
+ type : "transaction" ;
81
+ chainId : number ;
82
+ transactionHash : Hex ;
77
83
} ,
78
84
) => void ;
79
85
}
Original file line number Diff line number Diff line change @@ -125,6 +125,10 @@ export function TransactionModeScreen(props: {
125
125
return < LoadingScreen /> ;
126
126
}
127
127
128
+ const insufficientFunds =
129
+ balanceQuery . data &&
130
+ balanceQuery . data . value < transactionCostAndData . transactionValueWei ;
131
+
128
132
return (
129
133
< Container p = "lg" >
130
134
< ModalHeader title = { metadata ?. name || "Transaction" } />
@@ -144,9 +148,11 @@ export function TransactionModeScreen(props: {
144
148
/>
145
149
) : activeAccount ? (
146
150
< 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
+ ) }
150
156
< Container
151
157
flex = "row"
152
158
style = { {
Original file line number Diff line number Diff line change @@ -365,7 +365,13 @@ export function PayEmbed(props: PayEmbedProps) {
365
365
onBack = { ( ) => {
366
366
setScreen ( "buy" ) ;
367
367
} }
368
- onTxSent = { ( ) => { } }
368
+ onTxSent = { ( data ) => {
369
+ props . payOptions ?. onPurchaseSuccess ?.( {
370
+ type : "transaction" ,
371
+ chainId : data . chain . id ,
372
+ transactionHash : data . transactionHash ,
373
+ } ) ;
374
+ } }
369
375
/>
370
376
) }
371
377
</ >
You can’t perform that action at this time.
0 commit comments