From 45928b68acc0d54475a1240afa199ea9169efab3 Mon Sep 17 00:00:00 2001 From: Bas van Berckel Date: Wed, 2 Feb 2022 16:19:02 +0100 Subject: [PATCH 1/3] Fix instruction order in placeBid --- src/actions/placeBid.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/actions/placeBid.ts b/src/actions/placeBid.ts index 5bb0400..82cdec1 100644 --- a/src/actions/placeBid.ts +++ b/src/actions/placeBid.ts @@ -105,7 +105,6 @@ export const placeBid = async ({ closeTokenAccountTx, } = await createWrappedAccountTxs(connection, bidder, amount.toNumber() + accountRentExempt * 2); txBatch.addTransaction(createTokenAccountTx); - txBatch.addAfterTransaction(closeTokenAccountTx); txBatch.addSigner(payingAccount); //// @@ -123,6 +122,9 @@ export const placeBid = async ({ txBatch.addAfterTransaction(createRevokeTx); txBatch.addSigner(transferAuthority); //// + + // token account must be closed after the revoke instruction + txBatch.addAfterTransaction(closeTokenAccountTx); // create place bid transaction const placeBidTransaction = new PlaceBid( From 1819e67c9ab6e7b185e7e4e3b9edafa15e264f19 Mon Sep 17 00:00:00 2001 From: Bas van Berckel Date: Wed, 2 Feb 2022 20:07:59 +0100 Subject: [PATCH 2/3] Resolve UnitializedAccount error --- src/actions/placeBid.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/actions/placeBid.ts b/src/actions/placeBid.ts index 82cdec1..6db97f9 100644 --- a/src/actions/placeBid.ts +++ b/src/actions/placeBid.ts @@ -82,19 +82,11 @@ export const placeBid = async ({ //// } else { // create a new account for bid - const account = Keypair.generate(); - const createBidderPotTransaction = new CreateTokenAccount( - { feePayer: bidder }, - { - newAccountPubkey: account.publicKey, - lamports: accountRentExempt, - mint: auctionTokenMint, - owner: auction, - }, - ); - txBatch.addSigner(account); - txBatch.addTransaction(createBidderPotTransaction); - bidderPotToken = account.publicKey; + bidderPotToken = await AuctionProgram.findProgramAddress([ + Buffer.from(AuctionProgram.PREFIX), + bidderPot.toBuffer(), + Buffer.from('bidder_pot_token'), + ]); //// } From edf5c2be887fb5a9fea71a286864285f9b8b154c Mon Sep 17 00:00:00 2001 From: Bas van Berckel Date: Thu, 3 Feb 2022 09:36:09 +0100 Subject: [PATCH 3/3] Add missing import --- src/actions/placeBid.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/actions/placeBid.ts b/src/actions/placeBid.ts index 6db97f9..d57c3bd 100644 --- a/src/actions/placeBid.ts +++ b/src/actions/placeBid.ts @@ -5,6 +5,7 @@ import { Wallet } from '../wallet'; import { Connection } from '../Connection'; import { sendTransaction } from './transactions'; import { + AuctionProgram, AuctionExtended, BidderMetadata, BidderPot,