Skip to content

Commit 9dca1ce

Browse files
authored
Add deprecation info of version flag (#2834)
<!-- Reference any GitHub issues resolved by this PR --> Closes #2828 ## Introduced changes <!-- A brief description of the changes --> - ## Checklist <!-- Make sure all of these are complete --> - [x] Linked relevant issue - [x] Updated relevant documentation - [x] Added relevant tests - [x] Performed self-review of the code - [x] Added changes to `CHANGELOG.md`
1 parent a530f45 commit 9dca1ce

File tree

14 files changed

+210
-8
lines changed

14 files changed

+210
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424

2525
- Values passed to the `--max-fee`, `--max-gas`, and `--max-gas-unit-price` flags must be greater than 0
2626

27+
#### Deprecated
28+
29+
- `--version` flag
30+
2731
## [0.35.1] - 2024-12-16
2832

2933
### Forge

crates/sncast/src/helpers/fee.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ impl FromStr for FeeToken {
270270
}
271271

272272
fn parse_fee_token(s: &str) -> Result<FeeToken, String> {
273-
let deprecation_message = "Specifying '--fee-token' flag is deprecated and will be removed in the future. Use '--version' instead";
273+
let deprecation_message =
274+
"Specifying '--fee-token' flag is deprecated and will be removed in the future.";
274275
print_as_warning(&Error::msg(deprecation_message));
275276

276277
let parsed_token: FeeToken = s.parse()?;

crates/sncast/src/helpers/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ pub mod fee;
88
pub mod interactive;
99
pub mod rpc;
1010
pub mod scarb_utils;
11+
pub mod version;

crates/sncast/src/helpers/version.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use anyhow::Error;
2+
use clap::ValueEnum;
3+
use shared::print::print_as_warning;
4+
5+
const DEPRECATION_MESSAGE: &str = "The '--version' flag is deprecated and will be removed in the future. Version 3 will become the only type of transaction available.";
6+
7+
pub fn parse_version<T: ValueEnum>(s: &str) -> Result<T, String> {
8+
print_as_warning(&Error::msg(DEPRECATION_MESSAGE));
9+
T::from_str(s, true)
10+
}

crates/sncast/src/starknet_commands/account/deploy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use sncast::helpers::constants::{BRAAVOS_BASE_ACCOUNT_CLASS_HASH, KEYSTORE_PASSW
88
use sncast::helpers::error::token_not_supported_for_deployment;
99
use sncast::helpers::fee::{FeeArgs, FeeSettings, FeeToken, PayableTransaction};
1010
use sncast::helpers::rpc::RpcArgs;
11+
use sncast::helpers::version::parse_version;
1112
use sncast::response::structs::InvokeResponse;
1213
use sncast::{
1314
apply_optional, chain_id_to_network_name, check_account_file_exists,
@@ -38,7 +39,7 @@ pub struct Deploy {
3839
pub fee_args: FeeArgs,
3940

4041
/// Version of the account deployment (can be inferred from fee token)
41-
#[clap(short, long)]
42+
#[clap(short, long, value_parser = parse_version::<AccountDeployVersion>)]
4243
pub version: Option<AccountDeployVersion>,
4344

4445
#[clap(flatten)]

crates/sncast/src/starknet_commands/declare.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use scarb_api::StarknetContractArtifacts;
66
use sncast::helpers::error::token_not_supported_for_declaration;
77
use sncast::helpers::fee::{FeeArgs, FeeSettings, FeeToken, PayableTransaction};
88
use sncast::helpers::rpc::RpcArgs;
9+
use sncast::helpers::version::parse_version;
910
use sncast::response::errors::StarknetCommandError;
1011
use sncast::response::structs::{
1112
AlreadyDeclaredResponse, DeclareResponse, DeclareTransactionResponse,
@@ -44,7 +45,7 @@ pub struct Declare {
4445
pub package: Option<String>,
4546

4647
/// Version of the declaration (can be inferred from fee token)
47-
#[clap(short, long)]
48+
#[clap(short, long, value_parser = parse_version::<DeclareVersion>)]
4849
pub version: Option<DeclareVersion>,
4950

5051
#[clap(flatten)]

crates/sncast/src/starknet_commands/deploy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use conversions::IntoConv;
44
use sncast::helpers::error::token_not_supported_for_deployment;
55
use sncast::helpers::fee::{FeeArgs, FeeSettings, FeeToken, PayableTransaction};
66
use sncast::helpers::rpc::RpcArgs;
7+
use sncast::helpers::version::parse_version;
78
use sncast::response::errors::StarknetCommandError;
89
use sncast::response::structs::DeployResponse;
910
use sncast::{extract_or_generate_salt, impl_payable_transaction, udc_uniqueness};
@@ -43,7 +44,7 @@ pub struct Deploy {
4344
pub nonce: Option<Felt>,
4445

4546
/// Version of the deployment (can be inferred from fee token)
46-
#[clap(short, long)]
47+
#[clap(short, long, value_parser = parse_version::<DeployVersion>)]
4748
pub version: Option<DeployVersion>,
4849

4950
#[clap(flatten)]

crates/sncast/src/starknet_commands/invoke.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use conversions::IntoConv;
55
use sncast::helpers::error::token_not_supported_for_invoke;
66
use sncast::helpers::fee::{FeeArgs, FeeSettings, FeeToken, PayableTransaction};
77
use sncast::helpers::rpc::RpcArgs;
8+
use sncast::helpers::version::parse_version;
89
use sncast::response::errors::StarknetCommandError;
910
use sncast::response::structs::InvokeResponse;
1011
use sncast::{apply_optional, handle_wait_for_tx, impl_payable_transaction, WaitForTx};
@@ -38,7 +39,7 @@ pub struct Invoke {
3839
pub nonce: Option<Felt>,
3940

4041
/// Version of invoke (can be inferred from fee token)
41-
#[clap(short, long)]
42+
#[clap(short, long, value_parser = parse_version::<InvokeVersion>)]
4243
pub version: Option<InvokeVersion>,
4344

4445
#[clap(flatten)]

crates/sncast/src/starknet_commands/multicall/run.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use sncast::helpers::constants::UDC_ADDRESS;
88
use sncast::helpers::error::token_not_supported_for_invoke;
99
use sncast::helpers::fee::{FeeArgs, FeeToken, PayableTransaction};
1010
use sncast::helpers::rpc::RpcArgs;
11+
use sncast::helpers::version::parse_version;
1112
use sncast::response::errors::handle_starknet_command_error;
1213
use sncast::response::structs::InvokeResponse;
1314
use sncast::{extract_or_generate_salt, impl_payable_transaction, udc_uniqueness, WaitForTx};
@@ -31,7 +32,7 @@ pub struct Run {
3132
pub fee_args: FeeArgs,
3233

3334
/// Version of invoke (can be inferred from fee token)
34-
#[clap(short, long)]
35+
#[clap(short, long, value_parser = parse_version::<InvokeVersion>)]
3536
pub version: Option<InvokeVersion>,
3637

3738
#[clap(flatten)]

crates/sncast/tests/e2e/account/deploy.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ async fn test_fee_token_deprecation_warning_eth() {
399399
let snapbox = runner(&args).current_dir(tempdir.path());
400400

401401
snapbox.assert().success().stdout_matches(indoc! {r"
402-
[WARNING] Specifying '--fee-token' flag is deprecated and will be removed in the future. Use '--version' instead
402+
[WARNING] Specifying '--fee-token' flag is deprecated and will be removed in the future.
403403
[WARNING] Eth transactions will stop being supported in the future due to 'SNIP-16'
404404
Transaction hash: [..]
405405
command: account deploy
@@ -432,7 +432,39 @@ async fn test_fee_token_deprecation_warning_strk() {
432432
let snapbox = runner(&args).current_dir(tempdir.path());
433433

434434
snapbox.assert().success().stdout_matches(indoc! {r"
435-
[WARNING] Specifying '--fee-token' flag is deprecated and will be removed in the future. Use '--version' instead
435+
[WARNING] Specifying '--fee-token' flag is deprecated and will be removed in the future.
436+
Transaction hash: [..]
437+
command: account deploy
438+
transaction_hash: [..]
439+
440+
To see invocation details, visit:
441+
transaction: [..]
442+
"});
443+
}
444+
445+
#[tokio::test]
446+
async fn test_version_deprecation_warning() {
447+
let tempdir = create_account(false, &OZ_CLASS_HASH.into_hex_string(), "oz").await;
448+
let accounts_file = "accounts.json";
449+
450+
let args = vec![
451+
"--accounts-file",
452+
accounts_file,
453+
"--wait",
454+
"account",
455+
"deploy",
456+
"--url",
457+
URL,
458+
"--name",
459+
"my_account",
460+
"--version",
461+
"v3",
462+
];
463+
464+
let snapbox = runner(&args).current_dir(tempdir.path());
465+
466+
snapbox.assert().success().stdout_matches(indoc! {r"
467+
[WARNING] The '--version' flag is deprecated and will be removed in the future. Version 3 will become the only type of transaction available.
436468
Transaction hash: [..]
437469
command: account deploy
438470
transaction_hash: [..]

0 commit comments

Comments
 (0)