Skip to content

fix(nft): make_offer fails with 3012 when the bidder has no token account - #7

Merged
fibanachos merged 3 commits into
cookiechain:mainfrom
Vicape7:fix/make-offer-ata
Oct 1, 2026
Merged

fibanachos merged 3 commits into
cookiechain:mainfrom
Vicape7:fix/make-offer-ata

Conversation

@Vicape7

@Vicape7 Vicape7 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

make_offer fails on almost every first offer: public_buy reads the bidder's ATA for the NFT as token_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 createAssociatedTokenAccountIdempotentInstruction for that ATA, the same instruction buy_nft already 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:

  • before: simulation failed: … hausS13j…BBmk failed: custom program error: 0xbc4 (3012)
  • after: needs_signature with 3 instructions (ATA create, deposit, public_buy), simulated clean

A unit test pins that public_buy's token_account is 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, smoke pass; test:unit 653 pass. The two failures in imageFile.test.ts are on main too and Windows-only (path separators).

…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.
@fibanachos

Copy link
Copy Markdown
Collaborator

LGTM

@fibanachos
fibanachos enabled auto-merge (squash) October 1, 2026 10:05
@fibanachos
fibanachos merged commit a25d003 into cookiechain:main Oct 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants