Skip to content

Keep Anchor v1 copies in step with Anchor v2, starting with the betting market - #156

Merged
mikemaccana merged 2 commits into
mainfrom
claude/kind-pasteur-2sw8p5
Sep 23, 2026
Merged

mikemaccana merged 2 commits into
mainfrom
claude/kind-pasteur-2sw8p5

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Summary

CONTRIBUTING.md described each anchor-v1/ copy as a frozen snapshot that changed only to keep its build green. Several v2 examples have since gained behavior their v1 copies don't have, so someone reading a v1 copy learns a different program from the one the v2 copy and the book describe. This PR changes the policy and brings the betting market's v1 copy up to date as the first example under it.

Changes

  • CONTRIBUTING.md (first commit): anchor-v1/ now tracks its v2 counterpart. A change to what an example does (a new handler, a new check, a fix, a renamed field) goes into both copies, in the same PR where practical. The copies differ only where the Anchor version forces it: account types and lifetimes, context syntax, and the test harness. A change that needs something only v2 has is called out in the PR and in the v1 copy's changelog.
  • Betting market, Anchor v1 (second commit): ports Add draft state and betting close time to betting market events #154.
    • Events start as Draft. A new open_betting handler fixes the outcome list before any bet can land, and needs at least two outcomes.
    • initialize_event takes a betting_closes_at time, and bets stop at it. Settlement is allowed only from that time on.
    • cancel_event accepts a draft as well as an open event.
    • Same errors, same argument order (event_id, betting_closes_at, description), and the same new tests as the v2 copy, which assert specific error codes.
    • The tests warp the clock with anchor_lang's Clock, so there's no new dependency and no lockfile change.
  • Docs: the v1 README body now matches v2's, apart from the header note, and I re-wrapped one overlong paragraph in the v2 README. Changelog entries are in the root and the v1 copy.

Still out of step

Two v1 copies still lack behavior their v2 copies gained under the old rule: the token fundraiser's close_contributor, and the order book's vaults as market PDAs. Porting them is separate work.

Verification

  • Checked locally: the v1 program and its tests compile, and clippy adds no warnings. The one warning, too_many_arguments in shared.rs, is already on main.
  • Not run locally: the LiteSVM suite, which needs the SBF build. The Anchor v1 workflow in this PR's CI runs it.
  • Formatting: the v1 copy wasn't rustfmt-clean on main, and CI doesn't format-check it, so I matched its existing wide-line style rather than reformatting unrelated code.

🤖 Generated with Claude Code

https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK


Generated by Claude Code

anchor-v1/ was described as a frozen snapshot that changed only to keep its
build green. Several v2 examples have since gained behavior their v1 copies
lack, so a v1 reader learns a different program from the one the v2 copy and
the book describe. A change to what an example does now goes into both
copies; they differ only where the Anchor version forces it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK
…close time

The v1 copy still locked the outcome list by checking for an empty pool and
accepted bets until settlement. It now matches the v2 copy: events start as
Draft, open_betting fixes the outcome list before any bet can land, bets stop
at betting_closes_at and settlement is allowed only from then on, and
cancel_event accepts a draft. Same errors, same argument order, same new
tests; the README body now matches the v2 copy's, whose testing paragraph is
rewrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F8Wo5zNLqZ2NQqSjGD7WpK
@mikemaccana
mikemaccana merged commit d6571a1 into main Sep 23, 2026
33 checks 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