@@ -63,6 +63,7 @@ import { useActionButtonContent } from './hooks/useActionButtonContent';
63
63
import { endSale } from './utils/endSale' ;
64
64
import { useInstantSaleState } from './hooks/useInstantSaleState' ;
65
65
import { useTokenList } from '../../contexts/tokenList' ;
66
+ import { FundsIssueModal } from "../FundsIssueModal" ;
66
67
67
68
async function calculateTotalCostOfRedeemingOtherPeoplesBids (
68
69
connection : Connection ,
@@ -228,6 +229,7 @@ export const AuctionCard = ({
228
229
const [ showPlaceBid , setShowPlaceBid ] = useState < boolean > ( false ) ;
229
230
const [ lastBid , setLastBid ] = useState < { amount : BN } | undefined > ( undefined ) ;
230
231
const [ purchaseFinished , setPurchaseFinished ] = useState < boolean > ( false ) ;
232
+ const [ showFundsIssueModal , setShowFundsIssueModal ] = useState ( false )
231
233
232
234
const [ showWarningModal , setShowWarningModal ] = useState < boolean > ( false ) ;
233
235
const [ printingCost , setPrintingCost ] = useState < number > ( ) ;
@@ -251,6 +253,9 @@ export const AuctionCard = ({
251
253
252
254
//console.log("[--P]AuctionCard", tokenInfo, mintKey)
253
255
const myPayingAccount = balance . accounts [ 0 ] ;
256
+ const instantSalePrice = useMemo ( ( ) =>
257
+ auctionView . auctionDataExtended ?. info . instantSalePrice
258
+ , [ auctionView . auctionDataExtended ] ) ;
254
259
let winnerIndex : number | null = null ;
255
260
if ( auctionView . myBidderPot ?. pubkey )
256
261
winnerIndex = auctionView . auction . info . bidState . getWinnerIndex (
@@ -355,6 +360,12 @@ export const AuctionCard = ({
355
360
setLoading ( false ) ;
356
361
} ;
357
362
const instantSaleAction = ( ) => {
363
+ const isNotEnoughLamports = balance . balanceLamports < ( instantSalePrice ?. toNumber ( ) || 0 )
364
+ if ( isNotEnoughLamports ) {
365
+ setShowFundsIssueModal ( true ) ;
366
+ return ;
367
+ }
368
+
358
369
if ( canEndInstantSale ) {
359
370
return endInstantSale ( ) ;
360
371
}
@@ -364,8 +375,6 @@ export const AuctionCard = ({
364
375
365
376
const instantSale = async ( ) => {
366
377
setLoading ( true ) ;
367
- const instantSalePrice =
368
- auctionView . auctionDataExtended ?. info . instantSalePrice ;
369
378
const winningConfigType =
370
379
auctionView . participationItem ?. winningConfigType ||
371
380
auctionView . items [ 0 ] [ 0 ] . winningConfigType ;
@@ -777,18 +786,25 @@ export const AuctionCard = ({
777
786
< Spin />
778
787
) : (
779
788
auctionView . isInstantSale &&
780
- ! isAlreadyBought &&
781
- ! purchaseFinished && (
782
- < Button
783
- type = "primary"
784
- size = "large"
785
- className = "ant-btn secondary-btn"
786
- disabled = { loading }
787
- onClick = { instantSaleAction }
788
- style = { { marginTop : 20 , width : '100%' } }
789
- >
790
- { actionButtonContent }
789
+ ! isAlreadyBought && ! purchaseFinished && ( < >
790
+ < FundsIssueModal
791
+ message = { "Price" }
792
+ minimumFunds = { fromLamports ( instantSalePrice ?. toNumber ( ) , mintInfo ) }
793
+ currentFunds = { balance . balance }
794
+ isModalVisible = { showFundsIssueModal }
795
+ onClose = { ( ) => setShowFundsIssueModal ( false ) }
796
+ />
797
+ < Button
798
+ type = "primary"
799
+ size = "large"
800
+ className = "ant-btn secondary-btn"
801
+ disabled = { loading }
802
+ onClick = { instantSaleAction }
803
+ style = { { marginTop : 20 , width : '100%' } }
804
+ >
805
+ { actionButtonContent }
791
806
</ Button >
807
+ </ >
792
808
)
793
809
) ) }
794
810
{ ! hideDefaultAction && ! wallet . connected && (
0 commit comments