Repository navigation
fix(nft): make_offer fails with 3012 when the bidder has no token account - #7
Merged
Merged
Conversation
…c_buy `public_buy` reads the bidder's ATA for the NFT as `token_account`. When it does not exist yet — a first offer in a collection the wallet does not hold, which is most offers — the program fails with Anchor 3012 (`AccountNotInitialized`). `make_offer` now prepends an idempotent ATA create, the same instruction `buy_nft` already uses. The rent stays with the bidder.
Collaborator
|
LGTM |
fibanachos
approved these changes
Oct 1, 2026
fibanachos
enabled auto-merge (squash)
October 1, 2026 10:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
make_offerfails on almost every first offer:public_buyreads the bidder's ATA for the NFT astoken_account, and when the wallet does not hold anything from that collection the account does not exist, so the program returns Anchor 3012 (AccountNotInitialized).The fix prepends
createAssociatedTokenAccountIdempotentInstructionfor that ATA, the same instructionbuy_nftalready uses. The rent stays with the bidder.Reproduced on the live chain (simulation only, nothing signed or sent)
COOKIE_SIGNER=external,makeOffer({ mint, price: 0.01 })for the first active listing (6P8pcgau…kqGu1) and a wallet that holds COOK but not that collection:simulation failed: … hausS13j…BBmk failed: custom program error: 0xbc4(3012)needs_signaturewith 3 instructions (ATA create, deposit,public_buy), simulated cleanA unit test pins that
public_buy'stoken_accountis exactly the bidder's ATA for the mint, so the reason for the extra instruction is written down next to the builder.Checked
yarn lint,format:check,typecheck,smokepass;test:unit653 pass. The two failures inimageFile.test.tsare onmaintoo and Windows-only (path separators).