Skip to content

fix(nft): verify builds for the upgraded MomoSwap NFT program (#108, #110–#114) - #14

Merged
fibanachos merged 3 commits into
mainfrom
fix/nft-program-upgrade
Oct 28, 2026
Merged

fibanachos merged 3 commits into
mainfrom
fix/nft-program-upgrade

Conversation

@fibanachos

Copy link
Copy Markdown
Collaborator

Why

develop-momo/anchor-launchpad-momoswap #108 and #110–#114 are merged to anchor main but not deployed. develop-momo/momoswap-backend#333 makes the API build for both the live momoDc2L… binary and the upgraded one. Without this PR, cookie-mcp's pre-sign check (verify.ts, exact account count and every PDA re-derived from the vendored IDL) refuses:

  • every create with a royalty partner once #333 ships, because the partner comes after create_collection's accounts (#110);
  • every create after the program upgrade, because the collection NFT moves to the collection authority's ATA (#111).

What changed

IDL. src/idl/momo_nft_launchpad.json is re-vendored from anchor main 79973de (upstream sha256 4d2561e0…c134, the same file backend #333 pins), Prettier-formatted, and the content hash in verify.test.ts is re-pinned. Instruction changes: create_collection (the collection_token_account seed) and the new set_live_graduation_target (no kind signs it). Also the Collection type (#107 created_slot, which cookie-mcp doesn't decode) and errors 6055–6059.

verify.ts, create. This mirrors momoswap-frontend#449.

  • create_collection may pass one extra account after its IDL accounts, only when its decoded CollectionParams name a non-default royalty_partner with partner_share_bps > 0. The extra account must be that partner, and it can't be a signer or writable. Two extra accounts fail the count check. A partner create with no extra account still passes, because that's how the live binary is built.
  • collection_token_account may be the collection authority's ATA (the IDL's new seed, the default derivation) or, for one release, the creator's ATA (LEGACY_SEED_PATHS, marked TEMPORARY). Any other address is refused. The legacy seed is the creator slot, which must already be our wallet, so this doesn't let in a stranger's ATA.
  • New: the build's royalty_partner and partner_share_bps must be the ones create_nft_drop asked for. Without this, the extra-account rule would only hold the build to its own params.
  • CollectionParams is Borsh-decoded by its IDL field list. Data cut short, bytes left over, or a field type the decoder doesn't know are refused.

max_cost (#112). No functional change was needed. verify.ts already held max_cost to the user's approved all-in spend (maxSpend, which is also the maxSpendRaw sent to the API) on buy_nft, buy_returned and request_mint, and it never adds the fee on top. So it accepts the backend's all-in builds (max_cost == maxSpendRaw) as well as today's cost-leg builds. Like frontend #450, a build whose data has no max_cost is now refused instead of being read as 0. Comments now say "all-in", and the build types document maxCostAllInRaw. mintBudget and requestBudget are unchanged: #333 changes only the instruction arg, and the wrap and escrow are still the same worstCase ≤ maxSpendRaw.

create_nft_drop. It now refuses, before anything is uploaded, a mint window longer than /v1/nft/status maxSaleWindowSeconds (default 30 days, the program's MAX_SALE_WINDOW_SECS, #113). A share without a partner was already refused, and the partner field's description now says "plain wallet".

CODE_HINTS. Added hints for 6055 to 6059 (GraduationTargetAlreadyMet, …AlreadySet, …WindowClosed, InvalidRoyaltyPartner, SaleWindowTooLong). The 6001 Paused hint now says refunds still work, and settling does too once #108 is deployed.

Settle (#108). nft_drop_settle never treated paused as a reason not to settle, so only the hint changed.

List/cancel (#114). Nothing in cookie-mcp builds or signs list_on_marketplace or cancel_listing for pool inventory. verify.ts refuses both under every kind. cancel_listing in src/core/nft is the holder's own Baked Bazaar Auction House listing, which is a different program.

Tests

  • yarn test (lint, format:check, typecheck, unit, smoke): 56 files / 887 tests, smoke 76 tools. yarn build passes.
  • New create tests, built from the IDL. Both collection-NFT addresses pass. A stranger's ATA and a random key are refused. The partner passes read-only, and is refused when writable, a signer, the wrong key, extra with no partner or no share, or passed twice. A partner or share other than the one asked for is refused. Params cut short or with trailing bytes are refused.
  • New max_cost tests on buy_nft (the real API build), buy_returned and request_mint. All-in == spend passes, the cost-leg value passes, spend + 1 is refused, and a missing max_cost is refused.
  • planNftDrop: exactly 720 h passes, a window over the API-stated maximum is refused. nftSimError: hints for 6055–6059 and the new 6001 wording.
  • Mutation-checked (each reverted alone, at least one test fails): legacy ATA, partner-slot count exception, partner key match, read-only check, no-partner check, partner pin, short max_cost guard, > → >=, the fee added on top, the window check.

Rollout

  1. Merge and release this before backend #333 deploys. Until then the live API keeps building what cookie-mcp already accepts (no partner account, the creator's ATA). Both shapes pass here. If #333 goes first, partner creates are refused, and after the program upgrade every create would be.
  2. Backend #333, then the program upgrade (Squads). Nothing to do here between those steps.
  3. Removing the temporary acceptance: once #111 is deployed on momoDc2L… and GET /v1/nft/status reports collectionNftHolder: "program", delete the create_collection entry in LEGACY_SEED_PATHS (and its "or the creator's" test). The partner-account allowance stays, because the upgraded program requires it.

Not in scope: frontend #449 also holds every CollectionParams field (name, URIs, curve, schedule, allowlist root…) to what the creator sent. Here only the partner and share are pinned. The rest is still bounded only by the seal and the simulation, which is worth a follow-up.

@fibanachos fibanachos self-assigned this Oct 27, 2026
@fibanachos
fibanachos requested a review from rugruts October 27, 2026 11:04
@fibanachos
fibanachos merged commit f4916c6 into main Oct 28, 2026
1 check passed
@fibanachos
fibanachos deleted the fix/nft-program-upgrade branch October 28, 2026 00:03
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.

1 participant