Skip to content

Commit

Permalink
Add deprecation info of version flag (#2834)
Browse files Browse the repository at this point in the history
<!-- 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`
  • Loading branch information
kkawula authored Jan 14, 2025
1 parent a530f45 commit 9dca1ce
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion crates/sncast/src/helpers/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ impl FromStr for FeeToken {
}

fn parse_fee_token(s: &str) -> Result<FeeToken, String> {
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()?;
Expand Down
1 change: 1 addition & 0 deletions crates/sncast/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pub mod fee;
pub mod interactive;
pub mod rpc;
pub mod scarb_utils;
pub mod version;
10 changes: 10 additions & 0 deletions crates/sncast/src/helpers/version.rs
Original file line number Diff line number Diff line change
@@ -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<T: ValueEnum>(s: &str) -> Result<T, String> {
print_as_warning(&Error::msg(DEPRECATION_MESSAGE));
T::from_str(s, true)
}
3 changes: 2 additions & 1 deletion crates/sncast/src/starknet_commands/account/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<AccountDeployVersion>)]
pub version: Option<AccountDeployVersion>,

#[clap(flatten)]
Expand Down
3 changes: 2 additions & 1 deletion crates/sncast/src/starknet_commands/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -44,7 +45,7 @@ pub struct Declare {
pub package: Option<String>,

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

#[clap(flatten)]
Expand Down
3 changes: 2 additions & 1 deletion crates/sncast/src/starknet_commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -43,7 +44,7 @@ pub struct Deploy {
pub nonce: Option<Felt>,

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

#[clap(flatten)]
Expand Down
3 changes: 2 additions & 1 deletion crates/sncast/src/starknet_commands/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -38,7 +39,7 @@ pub struct Invoke {
pub nonce: Option<Felt>,

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

#[clap(flatten)]
Expand Down
3 changes: 2 additions & 1 deletion crates/sncast/src/starknet_commands/multicall/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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::<InvokeVersion>)]
pub version: Option<InvokeVersion>,

#[clap(flatten)]
Expand Down
36 changes: 34 additions & 2 deletions crates/sncast/tests/e2e/account/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: [..]
Expand Down
37 changes: 37 additions & 0 deletions crates/sncast/tests/e2e/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
" },
);
}
43 changes: 43 additions & 0 deletions crates/sncast/tests/e2e/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [..]
"
},
);
}
33 changes: 33 additions & 0 deletions crates/sncast/tests/e2e/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"},
);
}
36 changes: 36 additions & 0 deletions crates/sncast/tests/e2e/multicall/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [..]
"});
}

0 comments on commit 9dca1ce

Please sign in to comment.