From 6e99e399137d6eed706d431657a152df965086df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Wed, 22 Jan 2025 16:35:23 +0100 Subject: [PATCH 1/3] add deprecation warning for `put-deploy` subcommand --- lib/cli/deploy.rs | 3 +++ lib/lib.rs | 1 + src/deploy/put.rs | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/cli/deploy.rs b/lib/cli/deploy.rs index 9e3c0b6f..0bf445d5 100644 --- a/lib/cli/deploy.rs +++ b/lib/cli/deploy.rs @@ -32,6 +32,7 @@ pub async fn put_deploy( let rpc_id = parse::rpc_id(maybe_rpc_id); let verbosity = parse::verbosity(verbosity_level); let deploy = with_payment_and_session(deploy_params, payment_params, session_params, false)?; + #[allow(deprecated)] crate::put_deploy(rpc_id, node_address, verbosity, deploy) .await .map_err(CliError::from) @@ -115,6 +116,7 @@ pub async fn send_deploy_file( let rpc_id = parse::rpc_id(maybe_rpc_id); let verbosity = parse::verbosity(verbosity_level); let deploy = crate::read_deploy_file(input_path)?; + #[allow(deprecated)] crate::put_deploy(rpc_id, node_address, verbosity, deploy) .await .map_err(CliError::from) @@ -170,6 +172,7 @@ pub async fn transfer( payment_params, false, )?; + #[allow(deprecated)] crate::put_deploy(rpc_id, node_address, verbosity, deploy) .await .map_err(CliError::from) diff --git a/lib/lib.rs b/lib/lib.rs index 3483b083..4be13b43 100644 --- a/lib/lib.rs +++ b/lib/lib.rs @@ -134,6 +134,7 @@ pub const MAX_SERIALIZED_SIZE_OF_DEPLOY: u32 = 1_024 * 1_024; /// Sends a JSON-RPC `account_put_deploy` request to the specified node. /// /// For details of the parameters, see [the module docs](crate#common-parameters). +#[deprecated(since = "3.0.0", note = "use `put_transaction` instead")] pub async fn put_deploy( rpc_id: JsonRpcId, node_address: &str, diff --git a/src/deploy/put.rs b/src/deploy/put.rs index c599b50e..262e8c2b 100644 --- a/src/deploy/put.rs +++ b/src/deploy/put.rs @@ -8,10 +8,20 @@ use crate::{command::ClientCommand, common, Success}; pub struct PutDeploy; +static DEPRECATION_WARNING: &str = r#" +#################################### WARNING #################################### +# # +# put-deploy subcommand is deprecated in favor of put-transaction # +# and will be removed in a future release # +# # +################################################################################# +"#; + #[async_trait] impl ClientCommand for PutDeploy { const NAME: &'static str = "put-deploy"; - const ABOUT: &'static str = "Create a deploy and send it to the network for execution"; + const ABOUT: &'static str = + "[DEPRECATED: use `put-transaction` instead] Create a deploy and send it to the network for execution"; fn build(display_order: usize) -> Command { let subcommand = Command::new(Self::NAME) @@ -27,6 +37,9 @@ impl ClientCommand for PutDeploy { } async fn run(matches: &ArgMatches) -> Result { + // show deprecation warning for each use of `put-deploy` subcommand + println!("{DEPRECATION_WARNING}"); + creation_common::show_simple_arg_examples_and_exit_if_required(matches); creation_common::show_json_args_examples_and_exit_if_required(matches); From 0a9a5f1e2df985d3d63ee76faaf34bb494b44a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Wed, 22 Jan 2025 17:10:05 +0100 Subject: [PATCH 2/3] add depracation warnings for remaining deploy-related subcommands --- src/deploy/make.rs | 14 +++++++++++++- src/deploy/send.rs | 14 +++++++++++++- src/deploy/sign.rs | 14 +++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/deploy/make.rs b/src/deploy/make.rs index 4b40bcb5..b654c0ba 100644 --- a/src/deploy/make.rs +++ b/src/deploy/make.rs @@ -8,11 +8,20 @@ use crate::{command::ClientCommand, common, Success}; pub struct MakeDeploy; +static DEPRECATION_WARNING: &str = r#" +#################################### WARNING #################################### +# # +# make-deploy subcommand is deprecated in favor of make-transaction # +# and will be removed in a future release # +# # +################################################################################# +"#; + #[async_trait] impl ClientCommand for MakeDeploy { const NAME: &'static str = "make-deploy"; const ABOUT: &'static str = - "Create a deploy and output it to a file or stdout. As a file, the deploy can subsequently \ + "[DEPRECATED: use `make-transaction` instead] Create a deploy and output it to a file or stdout. As a file, the deploy can subsequently \ be signed by other parties using the 'sign-deploy' subcommand and then sent to the network \ for execution using the 'send-deploy' subcommand"; @@ -32,6 +41,9 @@ impl ClientCommand for MakeDeploy { } async fn run(matches: &ArgMatches) -> Result { + // show deprecation warning for each use of `put-deploy` subcommand + println!("{DEPRECATION_WARNING}"); + creation_common::show_simple_arg_examples_and_exit_if_required(matches); creation_common::show_json_args_examples_and_exit_if_required(matches); let gas_price = creation_common::gas_price::get(matches); diff --git a/src/deploy/send.rs b/src/deploy/send.rs index ab6626cb..f9989d71 100644 --- a/src/deploy/send.rs +++ b/src/deploy/send.rs @@ -9,11 +9,20 @@ use crate::{command::ClientCommand, common, Success}; pub struct SendDeploy; +static DEPRECATION_WARNING: &str = r#" +#################################### WARNING #################################### +# # +# send-deploy subcommand is deprecated in favor of send-transaction # +# and will be removed in a future release # +# # +################################################################################# +"#; + #[async_trait] impl ClientCommand for SendDeploy { const NAME: &'static str = "send-deploy"; const ABOUT: &'static str = - "Read a previously-saved deploy from a file and send it to the network for execution"; + "[DEPRECATED: use `send-transaction` instead] Read a previously-saved deploy from a file and send it to the network for execution"; fn build(display_order: usize) -> Command { Command::new(Self::NAME) @@ -29,6 +38,9 @@ impl ClientCommand for SendDeploy { } async fn run(matches: &ArgMatches) -> Result { + // show deprecation warning for each use of `send-deploy` subcommand + println!("{DEPRECATION_WARNING}"); + let is_speculative_exec = creation_common::speculative_exec::get(matches); let maybe_rpc_id = common::rpc_id::get(matches); let node_address = common::node_address::get(matches); diff --git a/src/deploy/sign.rs b/src/deploy/sign.rs index d92ce160..ab944654 100644 --- a/src/deploy/sign.rs +++ b/src/deploy/sign.rs @@ -8,11 +8,20 @@ use crate::{command::ClientCommand, common, Success}; pub struct SignDeploy; +static DEPRECATION_WARNING: &str = r#" +#################################### WARNING #################################### +# # +# sign-deploy subcommand is deprecated in favor of sign-transaction # +# and will be removed in a future release # +# # +################################################################################# +"#; + #[async_trait] impl ClientCommand for SignDeploy { const NAME: &'static str = "sign-deploy"; const ABOUT: &'static str = - "Read a previously-saved deploy from a file, cryptographically sign it, and output it to a \ + "[DEPRECATED: use `sign-transaction` instead] Read a previously-saved deploy from a file, cryptographically sign it, and output it to a \ file or stdout"; fn build(display_order: usize) -> Command { @@ -32,6 +41,9 @@ impl ClientCommand for SignDeploy { } async fn run(matches: &ArgMatches) -> Result { + // show deprecation warning for each use of `sign-deploy` subcommand + println!("{DEPRECATION_WARNING}"); + let input_path = creation_common::input::get(matches); let secret_key = common::secret_key::get(matches).unwrap_or_default(); let maybe_output_path = creation_common::output::get(matches).unwrap_or_default(); From d9679eb1cb25e3e4088e849634f6b38b2d42f48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20W=C3=B3jcik?= Date: Wed, 22 Jan 2025 17:21:27 +0100 Subject: [PATCH 3/3] add deprecation warning for public input/output deploy-related functions --- lib/cli/deploy.rs | 8 ++++++++ lib/cli/tests.rs | 3 +++ lib/lib.rs | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/lib/cli/deploy.rs b/lib/cli/deploy.rs index 0bf445d5..f856a194 100644 --- a/lib/cli/deploy.rs +++ b/lib/cli/deploy.rs @@ -53,6 +53,7 @@ pub async fn speculative_put_deploy( let rpc_id = parse::rpc_id(maybe_rpc_id); let verbosity = parse::verbosity(verbosity_level); let deploy = with_payment_and_session(deploy_params, payment_params, session_params, false)?; + #[allow(deprecated)] crate::speculative_exec(rpc_id, node_address, verbosity, deploy) .await .map_err(CliError::from) @@ -79,6 +80,7 @@ pub fn make_deploy( #[cfg(feature = "std-fs-io")] { let output = parse::output_kind(maybe_output_path, force); + #[allow(deprecated)] crate::output_deploy(output, &deploy).map_err(CliError::from)?; } Ok(deploy) @@ -100,6 +102,7 @@ pub fn sign_deploy_file( ) -> Result<(), CliError> { let secret_key = parse::secret_key_from_file(secret_key_path)?; let output = parse::output_kind(maybe_output_path, force); + #[allow(deprecated)] crate::sign_deploy_file(input_path, &secret_key, output).map_err(CliError::from) } @@ -115,6 +118,7 @@ pub async fn send_deploy_file( ) -> Result, CliError> { let rpc_id = parse::rpc_id(maybe_rpc_id); let verbosity = parse::verbosity(verbosity_level); + #[allow(deprecated)] let deploy = crate::read_deploy_file(input_path)?; #[allow(deprecated)] crate::put_deploy(rpc_id, node_address, verbosity, deploy) @@ -134,7 +138,9 @@ pub async fn speculative_send_deploy_file( ) -> Result, CliError> { let rpc_id = parse::rpc_id(maybe_rpc_id); let verbosity = parse::verbosity(verbosity_level); + #[allow(deprecated)] let deploy = crate::read_deploy_file(input_path)?; + #[allow(deprecated)] crate::speculative_exec(rpc_id, node_address, verbosity, deploy) .await .map_err(CliError::from) @@ -211,6 +217,7 @@ pub async fn speculative_transfer( payment_params, false, )?; + #[allow(deprecated)] crate::speculative_exec(rpc_id, node_address, verbosity, deploy) .await .map_err(CliError::from) @@ -248,6 +255,7 @@ pub fn make_transfer( #[cfg(feature = "std-fs-io")] { let output = parse::output_kind(maybe_output_path, force); + #[allow(deprecated)] crate::output_deploy(output, &deploy).map_err(CliError::from)?; } Ok(deploy) diff --git a/lib/cli/tests.rs b/lib/cli/tests.rs index 40f56577..34954e76 100644 --- a/lib/cli/tests.rs +++ b/lib/cli/tests.rs @@ -208,10 +208,13 @@ fn should_sign_deploy() { let tempdir = tempfile::tempdir().unwrap(); let path = tempdir.path().join("deploy.json"); + #[allow(deprecated)] crate::output_deploy(OutputKind::file(&path, false), &deploy).unwrap(); let secret_key = SecretKey::generate_ed25519().unwrap(); + #[allow(deprecated)] crate::sign_deploy_file(&path, &secret_key, OutputKind::file(&path, true)).unwrap(); + #[allow(deprecated)] let signed_deploy = crate::read_deploy_file(&path).unwrap(); assert_eq!( diff --git a/lib/lib.rs b/lib/lib.rs index 4be13b43..39ebcd64 100644 --- a/lib/lib.rs +++ b/lib/lib.rs @@ -170,6 +170,7 @@ pub async fn put_transaction( /// Sends a JSON-RPC `speculative_exec` request to the specified node. /// /// For details of the parameters, see [the module docs](crate#common-parameters). +#[deprecated(since = "3.0.0", note = "use `speculative_exec_txn` instead")] pub async fn speculative_exec( rpc_id: JsonRpcId, node_address: &str, @@ -211,6 +212,7 @@ pub async fn speculative_exec_txn( /// /// `output` specifies the output file and corresponding overwrite behaviour, or if /// `OutputKind::Stdout`, causes the `Deploy` to be printed `stdout`. +#[deprecated(since = "3.0.0", note = "use `output_transaction` instead")] #[cfg(any(feature = "std-fs-io", test))] pub fn output_deploy(output: OutputKind, deploy: &Deploy) -> Result<(), Error> { write_deploy(deploy, output.get()?)?; @@ -232,6 +234,7 @@ pub fn output_transaction(output: OutputKind, transaction: &Transaction) -> Resu } /// Reads a previously-saved [`Deploy`] from a file. +#[deprecated(since = "3.0.0", note = "use `read_transaction_file` instead")] #[cfg(any(feature = "std-fs-io", test))] pub fn read_deploy_file>(deploy_path: P) -> Result { let input = fs::read(deploy_path.as_ref()).map_err(|error| Error::IoError { @@ -265,12 +268,14 @@ pub fn read_transaction_file>(transaction_path: P) -> Result>( input_path: P, secret_key: &SecretKey, output: OutputKind, ) -> Result<(), Error> { + #[allow(deprecated)] let mut deploy = read_deploy_file(input_path)?; deploy.sign(secret_key);