Skip to content

Commit 85aa223

Browse files
Migrate all Anchor projects from 0.32.1 to 1.0.0-rc.5 (#548)
* migrate all Anchor projects from 0.32.1 to 1.0.0-rc.5 Rust changes (48 Anchor programs): - anchor-lang 0.32.1 → 1.0.0-rc.5 - anchor-spl 0.32.1 → 1.0.0-rc.5 - CpiContext::new() program arg: .to_account_info() → .key() (Anchor 1.0 takes Pubkey) - Context lifetime params: 4 → 2 (transfer-fee project) - Removed interface-instructions feature (transfer-hook projects) - Removed [registry] section from all Anchor.toml files TypeScript changes: - @coral-xyz/anchor → @anchor-lang/core 1.0.0-rc.5 - TypeScript bumped to ^5.3.3 where needed Transfer-hook projects (7): - Added .map_err() wrappers on spl-tlv-account-resolution calls to bridge solana-program-error 2.x → 3.x ProgramError type gap - transmute_pubkey() helper for solana-pubkey 2.x → 3.x in transfer-cost - Fixed #[instruction] attribute mismatches in transfer-switch (stricter in 1.0) - AccountInfo → UncheckedAccount in Accounts structs Compression projects (3): - Replaced mpl-bubblegum 2.1.1 and spl-account-compression 1.0.0 CPI wrappers with raw invoke()/invoke_signed() — these crates depend on Solana 2.x types and have no Solana 3.x compatible release yet - New bubblegum_types.rs in cutils with reimplemented types using borsh 1.x - Added sha3 crate for keccak256 (solana_program::keccak removed in Solana 3.x) Why: Anchor 1.0 is the current release candidate. This migration ensures all program-examples build against the latest framework. Pin to RC until stable. * ci: trigger workflows on anchor-1.0 branch for testing * regenerate all pnpm-lock.yaml files for @anchor-lang/core migration * fix CI: regenerate Cargo.lock, fix borsh try_to_vec, allow clippy diverging_sub_expression - Regenerated root Cargo.lock to resolve solana-address version conflicts - basics/rent: replaced try_to_vec() with borsh::to_vec() (borsh 1.x compat) - clippy: allow diverging_sub_expression (false positive from Anchor 1.0 #[program] macro) * fix: transfer-cost stack overflow and upgrade SPL crates to Solana 3.x - Box large InterfaceAccount fields to avoid BPF stack frame overflow (12 accounts exceeded 4096-byte limit in Anchor 1.0's try_accounts) - Upgrade spl-discriminator 0.4.1→0.5.2, spl-tlv-account-resolution 0.9.0→0.11.1, spl-transfer-hook-interface 0.9.0→2.1.0 (now compatible with Solana 3.x) - Remove transmute_pubkey() hack (no longer needed with matching Pubkey types) --------- Co-authored-by: Mike MacCana <mike@mikemaccana.com>
1 parent 2b7da9b commit 85aa223

377 files changed

Lines changed: 7221 additions & 6868 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/anchor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
push:
77
branches:
88
- main
9+
- anchor-1.0
910
pull_request:
1011
types: [opened, synchronize, reopened]
1112
branches:

.github/workflows/rust.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
push:
1010
branches:
1111
- main
12+
- anchor-1.0
1213
pull_request:
1314
types: [opened, synchronize, reopened]
1415
branches:
@@ -46,4 +47,5 @@ jobs:
4647
with:
4748
components: clippy
4849
- name: Linting
49-
run: cargo clippy -- -D warnings
50+
# Allow diverging_sub_expression: false positive from Anchor 1.0's #[program] macro expansion
51+
run: cargo clippy -- -D warnings -A clippy::diverging_sub_expression

.reference/ANCHOR-1.0-MIGRATION.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Anchor 1.0.0-rc.5 Migration Reference
2+
3+
## Proven pattern (from basics/counter/anchor)
4+
5+
### Cargo.toml
6+
- Change `anchor-lang = "0.32.1"``anchor-lang = "1.0.0-rc.5"`
7+
- Change `anchor-lang = { version = "0.32.1", ... }``anchor-lang = { version = "1.0.0-rc.5", ... }`
8+
- Same for `anchor-spl` if present — change to `1.0.0-rc.5`
9+
- Add comment: `# Anchor 1.0.0-rc.5 — pin to RC until stable release`
10+
- **REMOVE `interface-instructions` feature** if present (removed in Anchor 1.0). This affects transfer-hook projects.
11+
- Keep all other features as-is (`idl-build`, `init-if-needed`, `cpi`, etc.)
12+
13+
### Anchor.toml
14+
- Remove `[registry]` section if present (no longer used in Anchor 1.0)
15+
- Keep everything else
16+
17+
### package.json
18+
- Replace `"@coral-xyz/anchor": "..."` with `"@anchor-lang/core": "1.0.0-rc.5"`
19+
- Bump `"typescript"` to `"^5.3.3"` if it's on 4.x (required for @solana/web3.js peer dep)
20+
- Keep everything else
21+
22+
### TypeScript files (tests/*.ts, migrations/*.ts)
23+
- Replace `import ... from "@coral-xyz/anchor"``import ... from "@anchor-lang/core"`
24+
- Replace `import ... from '@coral-xyz/anchor'``import ... from '@anchor-lang/core'`
25+
- Replace `require("@coral-xyz/anchor")``require("@anchor-lang/core")` if any
26+
27+
### Rust source code (lib.rs etc.)
28+
- Usually NO changes needed
29+
- If `AccountInfo` is used in an Accounts struct, replace with `UncheckedAccount`
30+
- If duplicate mutable accounts exist, add `#[account(dup)]` constraint
31+
32+
### Build verification
33+
- Run `cargo build-sbf` in the anchor project directory to verify Rust builds
34+
- Run `pnpm install` to verify deps install
35+
- Do NOT run tests (no validator available)
36+
37+
### interface-instructions removal (transfer-hook projects)
38+
For projects that had `features = ["interface-instructions"]`:
39+
- Remove that feature from Cargo.toml
40+
- The `#[interface]` attribute is removed — check if the program source uses it
41+
- If it does, this needs manual intervention to refactor

0 commit comments

Comments
 (0)