Anchor Project UpdatesRelease Notes

1.2.2

Anchor - Release Notes 1.2.2

1.2.2 improves account safety, Borsh support, CLI automation, and project toolchain resolution. These notes cover the major changes since 1.2.1.


How to upgrade

Install and select the CLI with AVM:

avm install 1.2.2
avm use 1.2.2

Or install it directly from the repository:

cargo install --git https://github.com/otter-sec/anchor --tag v1.2.2 anchor-cli --locked

Update Anchor crate(s) and TypeScript package(s) to 1.2.2. Update AVM itself with avm self-update to use its toolchain-resolution improvements.

The recommended Solana version is 4.1.2, with platform-tools v1.57 and SBPF architecture v3.


Lang

Account safety and mint validation

Closing an account into itself now returns ConstraintClose, including manual .close() calls. Account exit also rejects data modifications after an account has changed ownership; unchanged data remains allowed.

When init_if_needed reuses a Token-2022 mint, Anchor validates its requested extension constraints as well as its base mint properties. Generated account validation uses more hygienic bindings to avoid collisions with user account names.

Initialize prefunded accounts

Account initialization uses CreateAccountAllowPrefund for accounts that already hold lamports, replacing the separate transfer, allocate, and assign CPIs.

Borsh attributes and account space

InitSpace excludes fields marked #[borsh(skip)] in structs, tuples, and enums, matching their serialized size. IDL generation accepts field-level Borsh bounds and enum #[borsh(init = ...)] attributes. Custom serialize_with and deserialize_with attributes are rejected by IDL generation and InitSpace because their encoded size and layout cannot be inferred.

access_control syntax change

#[access_control(...)] accepts comma-separated Rust expressions. Replace the previously accepted, undocumented whitespace-separated form with commas:

// Before
#[access_control(check_authority(&ctx) check_state(&ctx))]
 
// After
#[access_control(check_authority(&ctx), check_state(&ctx))]

CLI and AVM

Non-interactive commands with NO_DNA

Set NO_DNA=1 to skip supported interactive waits and confirmation prompts in CI, scripts, and agent workflows:

NO_DNA=1 anchor test --detach

Destructive operations still require their explicit bypass flags. See the NO_DNA reference.

Project toolchains and LiteSVM

When invoking anchor through AVM, AVM resolves the project's Anchor version and installs the corresponding Solana CLI and platform-tools when needed. It also selects a pinned Rust nightly for IDL builds and handles older Cargo versions that need an opt-in to read version 4 lockfiles.

New Rust LiteSVM projects use LiteSVM 0.15.0 and include a dependency lockfile compatible with Rust 1.89.

Safer CLI output and refreshed certificate roots

The CLI redacts credentials and secrets from cluster/RPC URLs in deployment and key-sync output. anchor keygen new --silent withholds the seed phrase. The repository lockfile also refreshes TLS certificate-validation and root-certificate dependencies used by Anchor tooling.

Rust Client

Event subscriptions ignore logs from failed transactions, so reverted executions do not produce application events.


See the full list of notable changes in the CHANGELOG.