Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add put-deploy deprecation warning #224

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/cli/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -52,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)
Expand All @@ -78,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)
Expand All @@ -99,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)
}

Expand All @@ -114,7 +118,9 @@ pub async fn send_deploy_file(
) -> Result<SuccessResponse<PutDeployResult>, 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)
.await
.map_err(CliError::from)
Expand All @@ -132,7 +138,9 @@ pub async fn speculative_send_deploy_file(
) -> Result<SuccessResponse<SpeculativeExecResult>, 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)
Expand Down Expand Up @@ -170,6 +178,7 @@ pub async fn transfer(
payment_params,
false,
)?;
#[allow(deprecated)]
crate::put_deploy(rpc_id, node_address, verbosity, deploy)
.await
.map_err(CliError::from)
Expand Down Expand Up @@ -208,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)
Expand Down Expand Up @@ -245,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)
Expand Down
3 changes: 3 additions & 0 deletions lib/cli/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
6 changes: 6 additions & 0 deletions lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -169,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,
Expand Down Expand Up @@ -210,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()?)?;
Expand All @@ -231,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<P: AsRef<Path>>(deploy_path: P) -> Result<Deploy, Error> {
let input = fs::read(deploy_path.as_ref()).map_err(|error| Error::IoError {
Expand Down Expand Up @@ -264,12 +268,14 @@ pub fn read_transaction_file<P: AsRef<Path>>(transaction_path: P) -> Result<Tran
///
/// The same path can be specified for input and output, and if the operation fails, the original
/// input file will be left unmodified.
#[deprecated(since = "3.0.0", note = "use `sign_transaction_file` instead")]
#[cfg(any(feature = "std-fs-io", test))]
pub fn sign_deploy_file<P: AsRef<Path>>(
input_path: P,
secret_key: &SecretKey,
output: OutputKind,
) -> Result<(), Error> {
#[allow(deprecated)]
let mut deploy = read_deploy_file(input_path)?;

deploy.sign(secret_key);
Expand Down
14 changes: 13 additions & 1 deletion src/deploy/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -32,6 +41,9 @@ impl ClientCommand for MakeDeploy {
}

async fn run(matches: &ArgMatches) -> Result<Success, CliError> {
// 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);
Expand Down
15 changes: 14 additions & 1 deletion src/deploy/put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -27,6 +37,9 @@ impl ClientCommand for PutDeploy {
}

async fn run(matches: &ArgMatches) -> Result<Success, CliError> {
// 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);

Expand Down
14 changes: 13 additions & 1 deletion src/deploy/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -29,6 +38,9 @@ impl ClientCommand for SendDeploy {
}

async fn run(matches: &ArgMatches) -> Result<Success, CliError> {
// 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);
Expand Down
14 changes: 13 additions & 1 deletion src/deploy/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -32,6 +41,9 @@ impl ClientCommand for SignDeploy {
}

async fn run(matches: &ArgMatches) -> Result<Success, CliError> {
// 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();
Expand Down
Loading