Просмотр исходного кода

feat(cli): Add MSRV (#3873)

* Add MSRV

* Make Clippy Happy

* Do Not Pin Rust Version in Program Crate

* Bump MSRV

* Bump to 1.89.0

* Update CHANGELOG.md with MSRV PR
Evan 1 неделя назад
Родитель
Сommit
152d4318a8
2 измененных файлов с 22 добавлено и 1 удалено
  1. 2 0
      CHANGELOG.md
  2. 20 1
      cli/src/rust_template.rs

+ 2 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 ### Features
 
 - lang: Add `#[error]` attribute to `declare_program!` ([#3757](https://github.com/coral-xyz/anchor/pull/3757)).
+- cli: Replace `anchor verify` to use `solana-verify` under the hood, adding automatic installation via AVM, local path support, and future-proof argument passing ([#3768](https://github.com/solana-foundation/anchor/pull/3768)).
 - lang: Replace `solana-program` crate with smaller crates ([#3819](https://github.com/solana-foundation/anchor/pull/3819)).
 - cli: Make `anchor deploy` to upload the IDL to the cluster by default unless `--no-idl` is passed ([#3863](https://github.com/solana-foundation/anchor/pull/3863)).
 - lang: Use `solana-invoke` instead of `solana_cpi::invoke` ([#3900](https://github.com/solana-foundation/anchor/pull/3900)).
@@ -23,6 +24,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 - ts: Add support for Bun as a package manager ([#3586](https://github.com/solana-foundation/anchor/pull/3586)).
 - lang: Add support for tuple types in space calculation ([#3744](https://github.com/solana-foundation/anchor/pull/3744)).
 - lang: Add missing pubkey const generation ([#3677](https://github.com/solana-foundation/anchor/pull/3677)).
+- cli: Add the Minimum Supported Rust Version (MSRV) to the Rust template, since an arbitrary compiler version isn't supported ([#3873](https://github.com/solana-foundation/anchor/pull/3873)).
 
 ### Fixes
 

+ 20 - 1
cli/src/rust_template.rs

@@ -18,6 +18,8 @@ use std::{
     process::Stdio,
 };
 
+const ANCHOR_MSRV: &str = "1.89.0";
+
 /// Program initialization template
 #[derive(Clone, Debug, Default, Eq, PartialEq, Parser, ValueEnum)]
 pub enum ProgramTemplate {
@@ -33,6 +35,7 @@ pub fn create_program(name: &str, template: ProgramTemplate, with_mollusk: bool)
     let program_path = Path::new("programs").join(name);
     let common_files = vec![
         ("Cargo.toml".into(), workspace_manifest().into()),
+        ("rust-toolchain.toml".into(), rust_toolchain_toml()),
         (
             program_path.join("Cargo.toml"),
             cargo_toml(name, with_mollusk),
@@ -48,6 +51,18 @@ pub fn create_program(name: &str, template: ProgramTemplate, with_mollusk: bool)
     create_files(&[common_files, template_files].concat())
 }
 
+/// Helper to create a rust-toolchain.toml at the workspace root
+fn rust_toolchain_toml() -> String {
+    format!(
+        r#"[toolchain]
+channel = "{msrv}"
+components = ["rustfmt","clippy"]
+profile = "minimal"
+"#,
+        msrv = ANCHOR_MSRV
+    )
+}
+
 /// Create a program with a single `lib.rs` file.
 fn create_program_template_single(name: &str, program_path: &Path) -> Files {
     vec![(
@@ -732,11 +747,15 @@ name = "tests"
 version = "0.1.0"
 description = "Created with Anchor"
 edition = "2021"
+rust-version = "{msrv}"
 
 [dependencies]
-anchor-client = "{VERSION}"
+anchor-client = "{version}"
 {name} = {{ version = "0.1.0", path = "../programs/{name}" }}
 "#,
+        msrv = ANCHOR_MSRV,
+        version = VERSION,
+        name = name,
     )
 }