From 08591508613c1124d612906da2e58376f627778e Mon Sep 17 00:00:00 2001
From: Vlad Frolov
Date: Sat, 3 Feb 2024 22:44:19 +0100
Subject: [PATCH] chore: release v0.6.0 (#130)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## 🤖 New release
* `cargo-near`: 0.5.2 -> 0.6.0 (⚠️ API breaking changes)
### ⚠️ `cargo-near` breaking changes
```
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---
Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.27.0/src/lints/constructible_struct_adds_field.ron
Failed in:
field CliBuildCommand.no_release in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:3
field CliBuildCommand.no_embed_abi in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:3
field CliBuildCommand.no_doc in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:3
field InteractiveClapContextScopeForBuildCommand.no_release in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:3
field InteractiveClapContextScopeForBuildCommand.no_embed_abi in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:3
field InteractiveClapContextScopeForBuildCommand.no_doc in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:3
field BuildCommand.no_release in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:9
field BuildCommand.no_embed_abi in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:15
field BuildCommand.no_doc in /tmp/.tmpsYxSqi/cargo-near/cargo-near/src/commands/build_command/mod.rs:18
--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---
Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.27.0/src/lints/struct_pub_field_missing.ron
Failed in:
field release of struct InteractiveClapContextScopeForBuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:3
field embed_abi of struct InteractiveClapContextScopeForBuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:3
field doc of struct InteractiveClapContextScopeForBuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:3
field release of struct BuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:9
field embed_abi of struct BuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:12
field doc of struct BuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:15
field release of struct CliBuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:3
field embed_abi of struct CliBuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:3
field doc of struct CliBuildCommand, previously in file /tmp/.tmpZefZn7/cargo-near/src/commands/build_command/mod.rs:3
```
Changelog
##
[0.6.0](https://github.com/near/cargo-near/compare/cargo-near-v0.5.2...cargo-near-v0.6.0)
- 2024-02-03
### Added
- Use hello-world contract instead of the status-message contract for
the new project starter
- Enable by default release mode, embedded ABIs with doc strings
---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
---
CHANGELOG.md | 6 +
Cargo.lock | 4 +-
cargo-near/Cargo.toml | 2 +-
cargo-near/src/commands/abi_command/abi.rs | 2 +-
cargo-near/src/commands/abi_command/mod.rs | 4 +-
.../src/commands/build_command/build.rs | 3 +-
integration-tests/src/lib.rs | 8 +-
integration-tests/tests/abi/opts.rs | 6 +-
integration-tests/tests/build/embed.rs | 48 --------
integration-tests/tests/build/mod.rs | 19 +++-
integration-tests/tests/build/opts.rs | 103 +++++-------------
11 files changed, 59 insertions(+), 146 deletions(-)
delete mode 100644 integration-tests/tests/build/embed.rs
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e71fa6bc..4eeb5658 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [0.6.0](https://github.com/near/cargo-near/compare/cargo-near-v0.5.2...cargo-near-v0.6.0) - 2024-02-03
+
+### Added
+- Use hello-world contract instead of the status-message contract for the new project starter
+- Enable by default release mode, embedded ABIs with doc strings
+
## [0.5.2](https://github.com/near/cargo-near/compare/cargo-near-v0.5.1...cargo-near-v0.5.2) - 2024-01-27
### Other
diff --git a/Cargo.lock b/Cargo.lock
index 7c796854..b86b63bd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -770,7 +770,7 @@ dependencies = [
[[package]]
name = "cargo-near"
-version = "0.5.2"
+version = "0.6.0"
dependencies = [
"atty",
"bs58 0.4.0",
@@ -808,7 +808,7 @@ version = "0.1.0"
dependencies = [
"borsh 1.3.1",
"camino",
- "cargo-near 0.5.2",
+ "cargo-near 0.6.0",
"color-eyre",
"const_format",
"function_name",
diff --git a/cargo-near/Cargo.toml b/cargo-near/Cargo.toml
index dd101308..6c10172b 100644
--- a/cargo-near/Cargo.toml
+++ b/cargo-near/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "cargo-near"
-version = "0.5.2"
+version = "0.6.0"
authors = ["Near Inc "]
edition = "2021"
rust-version = "1.72.0"
diff --git a/cargo-near/src/commands/abi_command/abi.rs b/cargo-near/src/commands/abi_command/abi.rs
index f15b44d1..adf723ce 100644
--- a/cargo-near/src/commands/abi_command/abi.rs
+++ b/cargo-near/src/commands/abi_command/abi.rs
@@ -201,7 +201,7 @@ pub fn run(args: super::AbiCommand) -> near_cli_rs::CliResult {
} else {
AbiFormat::Json
};
- let contract_abi = generate_abi(&crate_metadata, args.doc, false, color)?;
+ let contract_abi = generate_abi(&crate_metadata, !args.no_doc, false, color)?;
let AbiResult { path } =
write_to_file(&contract_abi, &crate_metadata, format, AbiCompression::NoOp)?;
diff --git a/cargo-near/src/commands/abi_command/mod.rs b/cargo-near/src/commands/abi_command/mod.rs
index 5e7f18ee..9fa3c39d 100644
--- a/cargo-near/src/commands/abi_command/mod.rs
+++ b/cargo-near/src/commands/abi_command/mod.rs
@@ -6,7 +6,7 @@ pub mod abi;
pub struct AbiCommand {
/// Include rustdocs in the ABI file
#[interactive_clap(long)]
- pub doc: bool,
+ pub no_doc: bool,
/// Generate compact (minified) JSON
#[interactive_clap(long)]
pub compact_abi: bool,
@@ -34,7 +34,7 @@ impl AbiCommandlContext {
scope: &::InteractiveClapContextScope,
) -> color_eyre::eyre::Result {
let args = AbiCommand {
- doc: scope.doc,
+ no_doc: scope.no_doc,
compact_abi: scope.compact_abi,
out_dir: scope.out_dir.clone(),
manifest_path: scope.manifest_path.clone(),
diff --git a/cargo-near/src/commands/build_command/build.rs b/cargo-near/src/commands/build_command/build.rs
index 2bd82ef9..ec45a0ed 100644
--- a/cargo-near/src/commands/build_command/build.rs
+++ b/cargo-near/src/commands/build_command/build.rs
@@ -51,7 +51,8 @@ pub fn run(args: super::BuildCommand) -> color_eyre::eyre::Result {
let args = cargo_near::commands::abi_command::AbiCommand {
- doc: cmd.doc,
+ no_doc: cmd.no_doc,
compact_abi: cmd.compact_abi,
out_dir: cmd.out_dir,
manifest_path: Some(cargo_path.into()),
@@ -73,10 +73,10 @@ macro_rules! invoke_cargo_near {
},
Some(cargo_near::commands::CliNearCommand::Build(cmd)) => {
let args = cargo_near::commands::build_command::BuildCommand {
- release: cmd.release,
- embed_abi: cmd.embed_abi,
- doc: cmd.doc,
+ no_release: cmd.no_release,
no_abi: cmd.no_abi,
+ no_embed_abi: cmd.no_embed_abi,
+ no_doc: cmd.no_doc,
out_dir: cmd.out_dir,
manifest_path: Some(cargo_path.into()),
color: cmd.color,
diff --git a/integration-tests/tests/abi/opts.rs b/integration-tests/tests/abi/opts.rs
index 1828a046..18408002 100644
--- a/integration-tests/tests/abi/opts.rs
+++ b/integration-tests/tests/abi/opts.rs
@@ -4,9 +4,9 @@ use std::fs;
#[test]
#[named]
-fn test_abi_opt_doc() -> cargo_near::CliResult {
+fn test_abi_no_doc() -> cargo_near::CliResult {
let abi_root = generate_abi_fn_with! {
- Opts: "--doc";
+ Opts: "--no-doc";
Code:
/// Adds `a` and `b`.
pub fn add(&self, a: u32, b: u32) -> u32 {
@@ -16,7 +16,7 @@ fn test_abi_opt_doc() -> cargo_near::CliResult {
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[0];
- assert_eq!(function.doc.as_ref().unwrap(), " Adds `a` and `b`.");
+ assert!(function.doc.is_none());
Ok(())
}
diff --git a/integration-tests/tests/build/embed.rs b/integration-tests/tests/build/embed.rs
deleted file mode 100644
index fd4f7bc2..00000000
--- a/integration-tests/tests/build/embed.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-use crate::util;
-use cargo_near_integration_tests::{build_fn, build_fn_with};
-use function_name::named;
-
-#[tokio::test]
-#[named]
-async fn test_build_embed_abi() -> cargo_near::CliResult {
- let build_result = build_fn_with! {
- Opts: "--embed-abi";
- Code:
- pub fn add(&self, a: u32, b: u32) -> u32 {
- a + b
- }
- };
-
- let mut abi_root = build_result.abi_root.unwrap();
- assert_eq!(abi_root.body.functions.len(), 2);
- let function = &abi_root.body.functions[0];
- assert_eq!(function.name, "add");
-
- let (add, actual_abi) = tokio::join!(
- util::test_add(&build_result.wasm),
- util::fetch_contract_abi(&build_result.wasm)
- );
- add?;
- // WASM hash is not included in the embedded ABI
- abi_root.metadata.wasm_hash = None;
- assert_eq!(abi_root, actual_abi?);
-
- Ok(())
-}
-
-#[tokio::test]
-#[named]
-async fn test_build_no_embed_abi() -> cargo_near::CliResult {
- let build_result = build_fn! {
- pub fn add(&self, a: u32, b: u32) -> u32 {
- a + b
- }
- };
-
- let worker = near_workspaces::sandbox().await?;
- let contract = worker.dev_deploy(&build_result.wasm).await?;
- let outcome = contract.call("__contract_abi").view().await;
- outcome.unwrap_err();
-
- Ok(())
-}
diff --git a/integration-tests/tests/build/mod.rs b/integration-tests/tests/build/mod.rs
index 1e6a08f8..02d881fa 100644
--- a/integration-tests/tests/build/mod.rs
+++ b/integration-tests/tests/build/mod.rs
@@ -2,7 +2,6 @@ use crate::util;
use cargo_near_integration_tests::build_fn;
use function_name::named;
-mod embed;
mod opts;
#[tokio::test]
@@ -14,12 +13,20 @@ async fn test_build_simple() -> cargo_near::CliResult {
a + b
}
};
- let functions = build_result.abi_root.unwrap().body.functions;
- assert_eq!(functions.len(), 2);
- assert_eq!(functions[0].name, "add");
- assert_eq!(functions[0].doc, None);
+ let mut abi_root = build_result.abi_root.unwrap();
+ assert_eq!(abi_root.body.functions.len(), 2);
+ let function = &abi_root.body.functions[0];
+ assert_eq!(function.name, "add");
+ assert_eq!(function.doc.as_ref().unwrap(), " Adds `a` and `b`.");
- assert!(build_result.abi_compressed.is_none());
+ // WASM hash is not included in the embedded ABI
+ abi_root.metadata.wasm_hash = None;
+ assert_eq!(
+ util::fetch_contract_abi(&build_result.wasm).await?,
+ abi_root
+ );
+
+ assert!(build_result.abi_compressed.is_some());
util::test_add(&build_result.wasm).await?;
diff --git a/integration-tests/tests/build/opts.rs b/integration-tests/tests/build/opts.rs
index ca7d6010..8b3d93ea 100644
--- a/integration-tests/tests/build/opts.rs
+++ b/integration-tests/tests/build/opts.rs
@@ -19,11 +19,30 @@ fn test_build_no_abi() -> cargo_near::CliResult {
Ok(())
}
+#[tokio::test]
+#[named]
+async fn test_build_no_embed_abi() -> cargo_near::CliResult {
+ let build_result = build_fn_with! {
+ Opts: "--no-embed-abi";
+ Code:
+ pub fn add(&self, a: u32, b: u32) -> u32 {
+ a + b
+ }
+ };
+
+ let worker = near_workspaces::sandbox().await?;
+ let contract = worker.dev_deploy(&build_result.wasm).await?;
+ let outcome = contract.call("__contract_abi").view().await;
+ outcome.unwrap_err();
+
+ Ok(())
+}
+
#[test]
#[named]
-fn test_build_opt_doc() -> cargo_near::CliResult {
+fn test_build_no_doc() -> cargo_near::CliResult {
let build_result = build_fn_with! {
- Opts: "--doc";
+ Opts: "--no-doc";
Code:
/// Adds `a` and `b`.
pub fn add(&self, a: u32, b: u32) -> u32 {
@@ -34,7 +53,7 @@ fn test_build_opt_doc() -> cargo_near::CliResult {
let abi_root = build_result.abi_root.unwrap();
assert_eq!(abi_root.body.functions.len(), 2);
let function = &abi_root.body.functions[0];
- assert_eq!(function.doc.as_ref().unwrap(), " Adds `a` and `b`.");
+ assert!(function.doc.is_none());
Ok(())
}
@@ -66,9 +85,9 @@ fn test_build_opt_out_dir() -> cargo_near::CliResult {
#[tokio::test]
#[named]
-async fn test_build_opt_release() -> cargo_near::CliResult {
+async fn test_build_no_release() -> cargo_near::CliResult {
let build_result = build_fn_with! {
- Opts: "--release";
+ Opts: "--no-release";
Code:
pub fn add(&self, a: u32, b: u32) -> u32 {
a + b
@@ -77,80 +96,8 @@ async fn test_build_opt_release() -> cargo_near::CliResult {
let abi_root = build_result.abi_root.unwrap();
assert_eq!(abi_root.body.functions.len(), 2);
- assert!(build_result.abi_compressed.is_none());
+ assert!(build_result.abi_compressed.is_some());
util::test_add(&build_result.wasm).await?;
Ok(())
}
-
-#[tokio::test]
-#[named]
-async fn test_build_opt_doc_embed() -> cargo_near::CliResult {
- let build_result = build_fn_with! {
- Opts: "--doc --embed-abi";
- Code:
- /// Adds `a` and `b`.
- pub fn add(&self, a: u32, b: u32) -> u32 {
- a + b
- }
- };
-
- let mut abi_root = build_result.abi_root.unwrap();
- assert_eq!(abi_root.body.functions.len(), 2);
- let function = &abi_root.body.functions[0];
- assert_eq!(function.doc.as_ref().unwrap(), " Adds `a` and `b`.");
-
- // WASM hash is not included in the embedded ABI
- abi_root.metadata.wasm_hash = None;
- assert_eq!(
- util::fetch_contract_abi(&build_result.wasm).await?,
- abi_root
- );
-
- Ok(())
-}
-
-#[test]
-#[named]
-fn test_build_opt_no_abi_doc() -> cargo_near::CliResult {
- fn run_test() -> cargo_near::CliResult {
- build_fn_with! {
- Opts: "--no-abi --doc";
- Code:
- /// Adds `a` and `b`.
- pub fn add(&self, a: u32, b: u32) -> u32 {
- a + b
- }
- };
- Ok(())
- }
-
- assert!(run_test()
- .unwrap_err()
- .to_string()
- .contains("error: the argument '--no-abi' cannot be used with '--doc'"));
-
- Ok(())
-}
-
-#[test]
-#[named]
-fn test_build_opt_no_abi_embed() -> cargo_near::CliResult {
- fn run_test() -> cargo_near::CliResult {
- build_fn_with! {
- Opts: "--no-abi --embed-abi";
- Code:
- /// Adds `a` and `b`.
- pub fn add(&self, a: u32, b: u32) -> u32 {
- a + b
- }
- };
- Ok(())
- }
- assert!(run_test()
- .unwrap_err()
- .to_string()
- .contains("error: the argument '--no-abi' cannot be used with '--embed-abi'"));
-
- Ok(())
-}