Skip to content

Commit 6c1eaf1

Browse files
authored
Merge pull request #224 from teonite/put_deploy_deprecation_warning
Add `put-deploy` deprecation warning
2 parents b5127f3 + d9679eb commit 6c1eaf1

File tree

7 files changed

+73
-4
lines changed

7 files changed

+73
-4
lines changed

lib/cli/deploy.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub async fn put_deploy(
3232
let rpc_id = parse::rpc_id(maybe_rpc_id);
3333
let verbosity = parse::verbosity(verbosity_level);
3434
let deploy = with_payment_and_session(deploy_params, payment_params, session_params, false)?;
35+
#[allow(deprecated)]
3536
crate::put_deploy(rpc_id, node_address, verbosity, deploy)
3637
.await
3738
.map_err(CliError::from)
@@ -52,6 +53,7 @@ pub async fn speculative_put_deploy(
5253
let rpc_id = parse::rpc_id(maybe_rpc_id);
5354
let verbosity = parse::verbosity(verbosity_level);
5455
let deploy = with_payment_and_session(deploy_params, payment_params, session_params, false)?;
56+
#[allow(deprecated)]
5557
crate::speculative_exec(rpc_id, node_address, verbosity, deploy)
5658
.await
5759
.map_err(CliError::from)
@@ -78,6 +80,7 @@ pub fn make_deploy(
7880
#[cfg(feature = "std-fs-io")]
7981
{
8082
let output = parse::output_kind(maybe_output_path, force);
83+
#[allow(deprecated)]
8184
crate::output_deploy(output, &deploy).map_err(CliError::from)?;
8285
}
8386
Ok(deploy)
@@ -99,6 +102,7 @@ pub fn sign_deploy_file(
99102
) -> Result<(), CliError> {
100103
let secret_key = parse::secret_key_from_file(secret_key_path)?;
101104
let output = parse::output_kind(maybe_output_path, force);
105+
#[allow(deprecated)]
102106
crate::sign_deploy_file(input_path, &secret_key, output).map_err(CliError::from)
103107
}
104108

@@ -114,7 +118,9 @@ pub async fn send_deploy_file(
114118
) -> Result<SuccessResponse<PutDeployResult>, CliError> {
115119
let rpc_id = parse::rpc_id(maybe_rpc_id);
116120
let verbosity = parse::verbosity(verbosity_level);
121+
#[allow(deprecated)]
117122
let deploy = crate::read_deploy_file(input_path)?;
123+
#[allow(deprecated)]
118124
crate::put_deploy(rpc_id, node_address, verbosity, deploy)
119125
.await
120126
.map_err(CliError::from)
@@ -132,7 +138,9 @@ pub async fn speculative_send_deploy_file(
132138
) -> Result<SuccessResponse<SpeculativeExecResult>, CliError> {
133139
let rpc_id = parse::rpc_id(maybe_rpc_id);
134140
let verbosity = parse::verbosity(verbosity_level);
141+
#[allow(deprecated)]
135142
let deploy = crate::read_deploy_file(input_path)?;
143+
#[allow(deprecated)]
136144
crate::speculative_exec(rpc_id, node_address, verbosity, deploy)
137145
.await
138146
.map_err(CliError::from)
@@ -170,6 +178,7 @@ pub async fn transfer(
170178
payment_params,
171179
false,
172180
)?;
181+
#[allow(deprecated)]
173182
crate::put_deploy(rpc_id, node_address, verbosity, deploy)
174183
.await
175184
.map_err(CliError::from)
@@ -208,6 +217,7 @@ pub async fn speculative_transfer(
208217
payment_params,
209218
false,
210219
)?;
220+
#[allow(deprecated)]
211221
crate::speculative_exec(rpc_id, node_address, verbosity, deploy)
212222
.await
213223
.map_err(CliError::from)
@@ -245,6 +255,7 @@ pub fn make_transfer(
245255
#[cfg(feature = "std-fs-io")]
246256
{
247257
let output = parse::output_kind(maybe_output_path, force);
258+
#[allow(deprecated)]
248259
crate::output_deploy(output, &deploy).map_err(CliError::from)?;
249260
}
250261
Ok(deploy)

lib/cli/tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,13 @@ fn should_sign_deploy() {
208208
let tempdir = tempfile::tempdir().unwrap();
209209
let path = tempdir.path().join("deploy.json");
210210

211+
#[allow(deprecated)]
211212
crate::output_deploy(OutputKind::file(&path, false), &deploy).unwrap();
212213

213214
let secret_key = SecretKey::generate_ed25519().unwrap();
215+
#[allow(deprecated)]
214216
crate::sign_deploy_file(&path, &secret_key, OutputKind::file(&path, true)).unwrap();
217+
#[allow(deprecated)]
215218
let signed_deploy = crate::read_deploy_file(&path).unwrap();
216219

217220
assert_eq!(

lib/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ pub const MAX_SERIALIZED_SIZE_OF_DEPLOY: u32 = 1_024 * 1_024;
134134
/// Sends a JSON-RPC `account_put_deploy` request to the specified node.
135135
///
136136
/// For details of the parameters, see [the module docs](crate#common-parameters).
137+
#[deprecated(since = "3.0.0", note = "use `put_transaction` instead")]
137138
pub async fn put_deploy(
138139
rpc_id: JsonRpcId,
139140
node_address: &str,
@@ -169,6 +170,7 @@ pub async fn put_transaction(
169170
/// Sends a JSON-RPC `speculative_exec` request to the specified node.
170171
///
171172
/// For details of the parameters, see [the module docs](crate#common-parameters).
173+
#[deprecated(since = "3.0.0", note = "use `speculative_exec_txn` instead")]
172174
pub async fn speculative_exec(
173175
rpc_id: JsonRpcId,
174176
node_address: &str,
@@ -210,6 +212,7 @@ pub async fn speculative_exec_txn(
210212
///
211213
/// `output` specifies the output file and corresponding overwrite behaviour, or if
212214
/// `OutputKind::Stdout`, causes the `Deploy` to be printed `stdout`.
215+
#[deprecated(since = "3.0.0", note = "use `output_transaction` instead")]
213216
#[cfg(any(feature = "std-fs-io", test))]
214217
pub fn output_deploy(output: OutputKind, deploy: &Deploy) -> Result<(), Error> {
215218
write_deploy(deploy, output.get()?)?;
@@ -231,6 +234,7 @@ pub fn output_transaction(output: OutputKind, transaction: &Transaction) -> Resu
231234
}
232235

233236
/// Reads a previously-saved [`Deploy`] from a file.
237+
#[deprecated(since = "3.0.0", note = "use `read_transaction_file` instead")]
234238
#[cfg(any(feature = "std-fs-io", test))]
235239
pub fn read_deploy_file<P: AsRef<Path>>(deploy_path: P) -> Result<Deploy, Error> {
236240
let input = fs::read(deploy_path.as_ref()).map_err(|error| Error::IoError {
@@ -264,12 +268,14 @@ pub fn read_transaction_file<P: AsRef<Path>>(transaction_path: P) -> Result<Tran
264268
///
265269
/// The same path can be specified for input and output, and if the operation fails, the original
266270
/// input file will be left unmodified.
271+
#[deprecated(since = "3.0.0", note = "use `sign_transaction_file` instead")]
267272
#[cfg(any(feature = "std-fs-io", test))]
268273
pub fn sign_deploy_file<P: AsRef<Path>>(
269274
input_path: P,
270275
secret_key: &SecretKey,
271276
output: OutputKind,
272277
) -> Result<(), Error> {
278+
#[allow(deprecated)]
273279
let mut deploy = read_deploy_file(input_path)?;
274280

275281
deploy.sign(secret_key);

src/deploy/make.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ use crate::{command::ClientCommand, common, Success};
88

99
pub struct MakeDeploy;
1010

11+
static DEPRECATION_WARNING: &str = r#"
12+
#################################### WARNING ####################################
13+
# #
14+
# make-deploy subcommand is deprecated in favor of make-transaction #
15+
# and will be removed in a future release #
16+
# #
17+
#################################################################################
18+
"#;
19+
1120
#[async_trait]
1221
impl ClientCommand for MakeDeploy {
1322
const NAME: &'static str = "make-deploy";
1423
const ABOUT: &'static str =
15-
"Create a deploy and output it to a file or stdout. As a file, the deploy can subsequently \
24+
"[DEPRECATED: use `make-transaction` instead] Create a deploy and output it to a file or stdout. As a file, the deploy can subsequently \
1625
be signed by other parties using the 'sign-deploy' subcommand and then sent to the network \
1726
for execution using the 'send-deploy' subcommand";
1827

@@ -32,6 +41,9 @@ impl ClientCommand for MakeDeploy {
3241
}
3342

3443
async fn run(matches: &ArgMatches) -> Result<Success, CliError> {
44+
// show deprecation warning for each use of `put-deploy` subcommand
45+
println!("{DEPRECATION_WARNING}");
46+
3547
creation_common::show_simple_arg_examples_and_exit_if_required(matches);
3648
creation_common::show_json_args_examples_and_exit_if_required(matches);
3749
let gas_price = creation_common::gas_price::get(matches);

src/deploy/put.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,20 @@ use crate::{command::ClientCommand, common, Success};
88

99
pub struct PutDeploy;
1010

11+
static DEPRECATION_WARNING: &str = r#"
12+
#################################### WARNING ####################################
13+
# #
14+
# put-deploy subcommand is deprecated in favor of put-transaction #
15+
# and will be removed in a future release #
16+
# #
17+
#################################################################################
18+
"#;
19+
1120
#[async_trait]
1221
impl ClientCommand for PutDeploy {
1322
const NAME: &'static str = "put-deploy";
14-
const ABOUT: &'static str = "Create a deploy and send it to the network for execution";
23+
const ABOUT: &'static str =
24+
"[DEPRECATED: use `put-transaction` instead] Create a deploy and send it to the network for execution";
1525

1626
fn build(display_order: usize) -> Command {
1727
let subcommand = Command::new(Self::NAME)
@@ -27,6 +37,9 @@ impl ClientCommand for PutDeploy {
2737
}
2838

2939
async fn run(matches: &ArgMatches) -> Result<Success, CliError> {
40+
// show deprecation warning for each use of `put-deploy` subcommand
41+
println!("{DEPRECATION_WARNING}");
42+
3043
creation_common::show_simple_arg_examples_and_exit_if_required(matches);
3144
creation_common::show_json_args_examples_and_exit_if_required(matches);
3245

src/deploy/send.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ use crate::{command::ClientCommand, common, Success};
99

1010
pub struct SendDeploy;
1111

12+
static DEPRECATION_WARNING: &str = r#"
13+
#################################### WARNING ####################################
14+
# #
15+
# send-deploy subcommand is deprecated in favor of send-transaction #
16+
# and will be removed in a future release #
17+
# #
18+
#################################################################################
19+
"#;
20+
1221
#[async_trait]
1322
impl ClientCommand for SendDeploy {
1423
const NAME: &'static str = "send-deploy";
1524
const ABOUT: &'static str =
16-
"Read a previously-saved deploy from a file and send it to the network for execution";
25+
"[DEPRECATED: use `send-transaction` instead] Read a previously-saved deploy from a file and send it to the network for execution";
1726

1827
fn build(display_order: usize) -> Command {
1928
Command::new(Self::NAME)
@@ -29,6 +38,9 @@ impl ClientCommand for SendDeploy {
2938
}
3039

3140
async fn run(matches: &ArgMatches) -> Result<Success, CliError> {
41+
// show deprecation warning for each use of `send-deploy` subcommand
42+
println!("{DEPRECATION_WARNING}");
43+
3244
let is_speculative_exec = creation_common::speculative_exec::get(matches);
3345
let maybe_rpc_id = common::rpc_id::get(matches);
3446
let node_address = common::node_address::get(matches);

src/deploy/sign.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ use crate::{command::ClientCommand, common, Success};
88

99
pub struct SignDeploy;
1010

11+
static DEPRECATION_WARNING: &str = r#"
12+
#################################### WARNING ####################################
13+
# #
14+
# sign-deploy subcommand is deprecated in favor of sign-transaction #
15+
# and will be removed in a future release #
16+
# #
17+
#################################################################################
18+
"#;
19+
1120
#[async_trait]
1221
impl ClientCommand for SignDeploy {
1322
const NAME: &'static str = "sign-deploy";
1423
const ABOUT: &'static str =
15-
"Read a previously-saved deploy from a file, cryptographically sign it, and output it to a \
24+
"[DEPRECATED: use `sign-transaction` instead] Read a previously-saved deploy from a file, cryptographically sign it, and output it to a \
1625
file or stdout";
1726

1827
fn build(display_order: usize) -> Command {
@@ -32,6 +41,9 @@ impl ClientCommand for SignDeploy {
3241
}
3342

3443
async fn run(matches: &ArgMatches) -> Result<Success, CliError> {
44+
// show deprecation warning for each use of `sign-deploy` subcommand
45+
println!("{DEPRECATION_WARNING}");
46+
3547
let input_path = creation_common::input::get(matches);
3648
let secret_key = common::secret_key::get(matches).unwrap_or_default();
3749
let maybe_output_path = creation_common::output::get(matches).unwrap_or_default();

0 commit comments

Comments
 (0)