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 deprecation info of version flag #2834

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- interactive interface that allows setting created or imported account as the default

#### 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 @@ -248,7 +248,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()?;
kkawula marked this conversation as resolved.
Show resolved Hide resolved
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
kkawula marked this conversation as resolved.
Show resolved Hide resolved
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)
}
4 changes: 3 additions & 1 deletion crates/sncast/src/starknet_commands/account/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ 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,
get_account_data_from_accounts_file, get_account_data_from_keystore, get_keystore_password,
Expand Down Expand Up @@ -38,7 +40,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
kkawula marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -452,3 +452,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: [..]
"});
}
Loading