Skip to content

Commit 0923657

Browse files
committed
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.
1 parent 2b7da9b commit 0923657

327 files changed

Lines changed: 2819 additions & 3101 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.

.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)