diff --git a/CHANGELOG.md b/CHANGELOG.md index c254d1ff7e..669acde2d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Values passed to the `--max-fee`, `--max-gas`, and `--max-gas-unit-price` flags must be greater than 0 +#### Deprecated + +- `--version` flag + ## [0.35.1] - 2024-12-16 ### Forge diff --git a/crates/sncast/src/helpers/fee.rs b/crates/sncast/src/helpers/fee.rs index 55160ffc06..ab0eca29c7 100644 --- a/crates/sncast/src/helpers/fee.rs +++ b/crates/sncast/src/helpers/fee.rs @@ -270,7 +270,8 @@ impl FromStr for FeeToken { } fn parse_fee_token(s: &str) -> Result { - let deprecation_message = "Specifying '--fee-token' flag is deprecated and will be removed in the future. Use '--version' instead"; + let deprecation_message = + "Specifying '--fee-token' flag is deprecated and will be removed in the future."; print_as_warning(&Error::msg(deprecation_message)); let parsed_token: FeeToken = s.parse()?; diff --git a/crates/sncast/src/helpers/mod.rs b/crates/sncast/src/helpers/mod.rs index 4dd3519e36..369c5019f5 100644 --- a/crates/sncast/src/helpers/mod.rs +++ b/crates/sncast/src/helpers/mod.rs @@ -8,3 +8,4 @@ pub mod fee; pub mod interactive; pub mod rpc; pub mod scarb_utils; +pub mod version; diff --git a/crates/sncast/src/helpers/version.rs b/crates/sncast/src/helpers/version.rs new file mode 100644 index 0000000000..954770db49 --- /dev/null +++ b/crates/sncast/src/helpers/version.rs @@ -0,0 +1,10 @@ +use anyhow::Error; +use clap::ValueEnum; +use shared::print::print_as_warning; + +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."; + +pub fn parse_version(s: &str) -> Result { + print_as_warning(&Error::msg(DEPRECATION_MESSAGE)); + T::from_str(s, true) +} diff --git a/crates/sncast/src/starknet_commands/account/deploy.rs b/crates/sncast/src/starknet_commands/account/deploy.rs index e8c8bfed96..682bcf22b3 100644 --- a/crates/sncast/src/starknet_commands/account/deploy.rs +++ b/crates/sncast/src/starknet_commands/account/deploy.rs @@ -8,6 +8,7 @@ use sncast::helpers::constants::{BRAAVOS_BASE_ACCOUNT_CLASS_HASH, KEYSTORE_PASSW use sncast::helpers::error::token_not_supported_for_deployment; use sncast::helpers::fee::{FeeArgs, FeeSettings, FeeToken, PayableTransaction}; use sncast::helpers::rpc::RpcArgs; +use sncast::helpers::version::parse_version; use sncast::response::structs::InvokeResponse; use sncast::{ apply_optional, chain_id_to_network_name, check_account_file_exists, @@ -38,7 +39,7 @@ pub struct Deploy { pub fee_args: FeeArgs, /// Version of the account deployment (can be inferred from fee token) - #[clap(short, long)] + #[clap(short, long, value_parser = parse_version::)] pub version: Option, #[clap(flatten)] diff --git a/crates/sncast/src/starknet_commands/declare.rs b/crates/sncast/src/starknet_commands/declare.rs index 1fe283adfb..3efbd061a8 100644 --- a/crates/sncast/src/starknet_commands/declare.rs +++ b/crates/sncast/src/starknet_commands/declare.rs @@ -6,6 +6,7 @@ use scarb_api::StarknetContractArtifacts; use sncast::helpers::error::token_not_supported_for_declaration; use sncast::helpers::fee::{FeeArgs, FeeSettings, FeeToken, PayableTransaction}; use sncast::helpers::rpc::RpcArgs; +use sncast::helpers::version::parse_version; use sncast::response::errors::StarknetCommandError; use sncast::response::structs::{ AlreadyDeclaredResponse, DeclareResponse, DeclareTransactionResponse, @@ -44,7 +45,7 @@ pub struct Declare { pub package: Option, /// Version of the declaration (can be inferred from fee token) - #[clap(short, long)] + #[clap(short, long, value_parser = parse_version::)] pub version: Option, #[clap(flatten)] diff --git a/crates/sncast/src/starknet_commands/deploy.rs b/crates/sncast/src/starknet_commands/deploy.rs index fb713c6259..7990d0dfef 100644 --- a/crates/sncast/src/starknet_commands/deploy.rs +++ b/crates/sncast/src/starknet_commands/deploy.rs @@ -4,6 +4,7 @@ use conversions::IntoConv; use sncast::helpers::error::token_not_supported_for_deployment; use sncast::helpers::fee::{FeeArgs, FeeSettings, FeeToken, PayableTransaction}; use sncast::helpers::rpc::RpcArgs; +use sncast::helpers::version::parse_version; use sncast::response::errors::StarknetCommandError; use sncast::response::structs::DeployResponse; use sncast::{extract_or_generate_salt, impl_payable_transaction, udc_uniqueness}; @@ -43,7 +44,7 @@ pub struct Deploy { pub nonce: Option, /// Version of the deployment (can be inferred from fee token) - #[clap(short, long)] + #[clap(short, long, value_parser = parse_version::)] pub version: Option, #[clap(flatten)] diff --git a/crates/sncast/src/starknet_commands/invoke.rs b/crates/sncast/src/starknet_commands/invoke.rs index d469cfd2d6..215967d0e5 100644 --- a/crates/sncast/src/starknet_commands/invoke.rs +++ b/crates/sncast/src/starknet_commands/invoke.rs @@ -5,6 +5,7 @@ use conversions::IntoConv; use sncast::helpers::error::token_not_supported_for_invoke; use sncast::helpers::fee::{FeeArgs, FeeSettings, FeeToken, PayableTransaction}; use sncast::helpers::rpc::RpcArgs; +use sncast::helpers::version::parse_version; use sncast::response::errors::StarknetCommandError; use sncast::response::structs::InvokeResponse; use sncast::{apply_optional, handle_wait_for_tx, impl_payable_transaction, WaitForTx}; @@ -38,7 +39,7 @@ pub struct Invoke { pub nonce: Option, /// Version of invoke (can be inferred from fee token) - #[clap(short, long)] + #[clap(short, long, value_parser = parse_version::)] pub version: Option, #[clap(flatten)] diff --git a/crates/sncast/src/starknet_commands/multicall/run.rs b/crates/sncast/src/starknet_commands/multicall/run.rs index 647ee55bc3..ce313e986a 100644 --- a/crates/sncast/src/starknet_commands/multicall/run.rs +++ b/crates/sncast/src/starknet_commands/multicall/run.rs @@ -8,6 +8,7 @@ use sncast::helpers::constants::UDC_ADDRESS; use sncast::helpers::error::token_not_supported_for_invoke; use sncast::helpers::fee::{FeeArgs, FeeToken, PayableTransaction}; use sncast::helpers::rpc::RpcArgs; +use sncast::helpers::version::parse_version; use sncast::response::errors::handle_starknet_command_error; use sncast::response::structs::InvokeResponse; use sncast::{extract_or_generate_salt, impl_payable_transaction, udc_uniqueness, WaitForTx}; @@ -31,7 +32,7 @@ pub struct Run { pub fee_args: FeeArgs, /// Version of invoke (can be inferred from fee token) - #[clap(short, long)] + #[clap(short, long, value_parser = parse_version::)] pub version: Option, #[clap(flatten)] diff --git a/crates/sncast/tests/e2e/account/deploy.rs b/crates/sncast/tests/e2e/account/deploy.rs index 4ea89bb962..8039265bde 100644 --- a/crates/sncast/tests/e2e/account/deploy.rs +++ b/crates/sncast/tests/e2e/account/deploy.rs @@ -399,7 +399,7 @@ async fn test_fee_token_deprecation_warning_eth() { let snapbox = runner(&args).current_dir(tempdir.path()); snapbox.assert().success().stdout_matches(indoc! {r" - [WARNING] Specifying '--fee-token' flag is deprecated and will be removed in the future. Use '--version' instead + [WARNING] Specifying '--fee-token' flag is deprecated and will be removed in the future. [WARNING] Eth transactions will stop being supported in the future due to 'SNIP-16' Transaction hash: [..] command: account deploy @@ -432,7 +432,39 @@ async fn test_fee_token_deprecation_warning_strk() { let snapbox = runner(&args).current_dir(tempdir.path()); snapbox.assert().success().stdout_matches(indoc! {r" - [WARNING] Specifying '--fee-token' flag is deprecated and will be removed in the future. Use '--version' instead + [WARNING] Specifying '--fee-token' flag is deprecated and will be removed in the future. + Transaction hash: [..] + command: account deploy + transaction_hash: [..] + + To see invocation details, visit: + transaction: [..] + "}); +} + +#[tokio::test] +async fn test_version_deprecation_warning() { + let tempdir = create_account(false, &OZ_CLASS_HASH.into_hex_string(), "oz").await; + let accounts_file = "accounts.json"; + + let args = vec![ + "--accounts-file", + accounts_file, + "--wait", + "account", + "deploy", + "--url", + URL, + "--name", + "my_account", + "--version", + "v3", + ]; + + let snapbox = runner(&args).current_dir(tempdir.path()); + + snapbox.assert().success().stdout_matches(indoc! {r" + [WARNING] The '--version' flag is deprecated and will be removed in the future. Version 3 will become the only type of transaction available. Transaction hash: [..] command: account deploy transaction_hash: [..] diff --git a/crates/sncast/tests/e2e/declare.rs b/crates/sncast/tests/e2e/declare.rs index f423075c82..50ce7f917d 100644 --- a/crates/sncast/tests/e2e/declare.rs +++ b/crates/sncast/tests/e2e/declare.rs @@ -729,3 +729,40 @@ async fn test_no_scarb_profile() { "}, ); } + +#[tokio::test] +async fn test_version_deprecation_warning() { + let contract_path = duplicate_contract_directory_with_salt( + CONTRACTS_DIR.to_string() + "/map", + "put", + "human_readable", + ); + let tempdir = create_and_deploy_oz_account().await; + join_tempdirs(&contract_path, &tempdir); + + let args = vec![ + "--accounts-file", + "accounts.json", + "--account", + "my_account", + "declare", + "--url", + URL, + "--contract-name", + "Map", + "--max-fee", + "99999999999999999", + "--version", + "v3", + ]; + + let snapbox = runner(&args).current_dir(tempdir.path()); + let output = snapbox.assert().success(); + + assert_stdout_contains( + output, + indoc! {r" + [WARNING] The '--version' flag is deprecated and will be removed in the future. Version 3 will become the only type of transaction available. + " }, + ); +} diff --git a/crates/sncast/tests/e2e/deploy.rs b/crates/sncast/tests/e2e/deploy.rs index 3de61512d4..eeb8191f00 100644 --- a/crates/sncast/tests/e2e/deploy.rs +++ b/crates/sncast/tests/e2e/deploy.rs @@ -463,3 +463,46 @@ async fn test_happy_case_shell() { .arg(CONSTRUCTOR_WITH_PARAMS_CONTRACT_CLASS_HASH_SEPOLIA); snapbox.assert().success(); } + +#[tokio::test] +async fn test_version_deprecation_warning() { + let tempdir = create_and_deploy_account(OZ_CLASS_HASH, AccountType::OpenZeppelin).await; + + let args = vec![ + "--accounts-file", + "accounts.json", + "--account", + "my_account", + "deploy", + "--url", + URL, + "--class-hash", + MAP_CONTRACT_CLASS_HASH_SEPOLIA, + "--salt", + "0x2", + "--unique", + "--max-fee", + "99999999999999999", + "--version", + "v3", + ]; + + let snapbox = runner(&args).current_dir(tempdir.path()); + let output = snapbox.assert().success(); + + assert_stdout_contains( + output, + indoc! { + " + [WARNING] The '--version' flag is deprecated and will be removed in the future. Version 3 will become the only type of transaction available. + command: deploy + contract_address: 0x0[..] + transaction_hash: 0x0[..] + + To see deployment details, visit: + contract: [..] + transaction: [..] + " + }, + ); +} diff --git a/crates/sncast/tests/e2e/invoke.rs b/crates/sncast/tests/e2e/invoke.rs index 17cb37357b..2853d99705 100644 --- a/crates/sncast/tests/e2e/invoke.rs +++ b/crates/sncast/tests/e2e/invoke.rs @@ -524,3 +524,36 @@ async fn test_happy_case_shell() { .arg(DATA_TRANSFORMER_CONTRACT_ADDRESS_SEPOLIA); snapbox.assert().success(); } + +#[test] +fn test_version_deprecation_warning() { + let args = vec![ + "--accounts-file", + ACCOUNT_FILE_PATH, + "--account", + "oz", + "invoke", + "--url", + URL, + "--contract-address", + MAP_CONTRACT_ADDRESS_SEPOLIA, + "--function", + "put", + "--calldata", + "0x1 0x2", + "--max-fee", + "99999999999999999", + "--version", + "v3", + ]; + + let snapbox = runner(&args); + let output = snapbox.assert().success(); + + assert_stdout_contains( + output, + indoc! {" + [WARNING] The '--version' flag is deprecated and will be removed in the future. Version 3 will become the only type of transaction available. + "}, + ); +} diff --git a/crates/sncast/tests/e2e/multicall/run.rs b/crates/sncast/tests/e2e/multicall/run.rs index 557bed9c2f..338faa7264 100644 --- a/crates/sncast/tests/e2e/multicall/run.rs +++ b/crates/sncast/tests/e2e/multicall/run.rs @@ -317,3 +317,39 @@ async fn test_numeric_overflow() { "}, ); } + +#[tokio::test] +async fn test_version_deprecation_warning() { + let path = project_root::get_project_root().expect("failed to get project root path"); + let path = Path::new(&path) + .join(MULTICALL_CONFIGS_DIR) + .join("deploy_invoke.toml"); + let path = path.to_str().expect("failed converting path to str"); + + let args = vec![ + "--accounts-file", + ACCOUNT_FILE_PATH, + "--account", + "oz", + "multicall", + "run", + "--url", + URL, + "--path", + path, + "--version", + "v3", + ]; + + let snapbox = runner(&args); + let output = snapbox.assert(); + + output.stdout_matches(indoc! {r" + [WARNING] The '--version' flag is deprecated and will be removed in the future. Version 3 will become the only type of transaction available. + command: multicall run + transaction_hash: 0x0[..] + + To see invocation details, visit: + transaction: [..] + "}); +}