Repository navigation
Keep Anchor v1 copies in step with Anchor v2, starting with the betting market - #156
Merged
Merged
Conversation
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
This was referenced Sep 23, 2026
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.
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
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.Draft. A newopen_bettinghandler fixes the outcome list before any bet can land, and needs at least two outcomes.initialize_eventtakes abetting_closes_attime, and bets stop at it. Settlement is allowed only from that time on.cancel_eventaccepts a draft as well as an open event.event_id, betting_closes_at, description), and the same new tests as the v2 copy, which assert specific error codes.anchor_lang'sClock, so there's no new dependency and no lockfile change.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
too_many_argumentsinshared.rs, is already onmain.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