Send place bid accept BNs

This commit is contained in:
adamjeffries 2021-08-30 13:22:03 -05:00
parent babe5bfa6d
commit 705d311bd9
No known key found for this signature in database
GPG Key ID: 71C4DC054797A48C
1 changed files with 9 additions and 3 deletions

View File

@ -29,7 +29,7 @@ export async function sendPlaceBid(
auctionView: AuctionView, auctionView: AuctionView,
accountsByMint: Map<string, TokenAccount>, accountsByMint: Map<string, TokenAccount>,
// value entered by the user adjust to decimals of the mint // value entered by the user adjust to decimals of the mint
amount: number, amount: number | BN,
) { ) {
let signers: Keypair[][] = []; let signers: Keypair[][] = [];
let instructions: TransactionInstruction[][] = []; let instructions: TransactionInstruction[][] = [];
@ -64,7 +64,8 @@ export async function setupPlaceBid(
auctionView: AuctionView, auctionView: AuctionView,
accountsByMint: Map<string, TokenAccount>, accountsByMint: Map<string, TokenAccount>,
// value entered by the user adjust to decimals of the mint // value entered by the user adjust to decimals of the mint
amount: number, // If BN, then assume instant sale and decimals already adjusted.
amount: number | BN,
overallInstructions: TransactionInstruction[][], overallInstructions: TransactionInstruction[][],
overallSigners: Keypair[][], overallSigners: Keypair[][],
): Promise<BN> { ): Promise<BN> {
@ -84,7 +85,12 @@ export async function setupPlaceBid(
const mint = cache.get( const mint = cache.get(
tokenAccount ? tokenAccount.info.mint : QUOTE_MINT, tokenAccount ? tokenAccount.info.mint : QUOTE_MINT,
) as ParsedAccount<MintInfo>; ) as ParsedAccount<MintInfo>;
let lamports = toLamports(amount, mint.info) + accountRentExempt;
let lamports =
accountRentExempt +
(typeof amount === 'number'
? toLamports(amount, mint.info)
: amount.toNumber());
let bidderPotTokenAccount: string; let bidderPotTokenAccount: string;
if (!auctionView.myBidderPot) { if (!auctionView.myBidderPot) {