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

Print max fee conversion info when using v3 txs #2797

Open
wants to merge 16 commits into
base: franciszekjob/2706-validate-fee-args-greater-than-zero
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 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
7 changes: 7 additions & 0 deletions crates/sncast/src/helpers/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ impl FeeArgs {
})
}
FeeToken::Strk => {
if self.max_fee.is_some() {
ksew1 marked this conversation as resolved.
Show resolved Hide resolved
print_max_fee_conversion_info();
}
let settings = match (self.max_fee, self.max_gas, self.max_gas_unit_price) {
(Some(_), Some(_), Some(_)) => {
bail!("Passing all --max-fee, --max-gas and --max-gas-unit-price is conflicting. Please pass only two of them or less")
Expand Down Expand Up @@ -273,6 +276,10 @@ fn parse_fee_token(s: &str) -> Result<FeeToken, String> {
Ok(parsed_token)
}

fn print_max_fee_conversion_info() {
println!("Specifying '--max-fee' flag while using v3 transactions results in conversion to '--max-gas' and '--max-gas-unit-price' flags\n");
}

fn parse_non_zero_felt(s: &str) -> Result<NonZeroFelt, String> {
let felt: Felt = s.parse().map_err(|_| "Failed to parse value")?;
felt.try_into()
Expand Down
6 changes: 6 additions & 0 deletions crates/sncast/tests/e2e/account/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ pub async fn test_valid_class_hash() {
let snapbox = runner(&args).current_dir(tempdir.path());

snapbox.assert().success().stdout_matches(indoc! {r"
Specifying '--max-fee' flag while using v3 transactions results in conversion to '--max-gas' and '--max-gas-unit-price' flags

command: account deploy
transaction_hash: [..]

Expand Down Expand Up @@ -584,6 +586,8 @@ pub async fn test_happy_case_keystore(account_type: &str) {
let snapbox = runner(&args).current_dir(tempdir.path());

snapbox.assert().stdout_matches(indoc! {r"
Specifying '--max-fee' flag while using v3 transactions results in conversion to '--max-gas' and '--max-gas-unit-price' flags

command: account deploy
transaction_hash: 0x0[..]

Expand Down Expand Up @@ -857,6 +861,8 @@ pub async fn test_deploy_keystore_other_args() {

let snapbox = runner(&args).current_dir(tempdir.path());
snapbox.assert().stdout_matches(indoc! {r"
Specifying '--max-fee' flag while using v3 transactions results in conversion to '--max-gas' and '--max-gas-unit-price' flags

command: account deploy
transaction_hash: 0x0[..]

Expand Down
6 changes: 4 additions & 2 deletions crates/sncast/tests/e2e/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ async fn test_happy_case_strk(class_hash: Felt, account_type: AccountType) {
];

let snapbox = runner(&args).current_dir(tempdir.path());
let output = snapbox.assert().success().get_output().stdout.clone();
let output = snapbox.assert().success();
let stdout = output.get_output().stdout.clone();

let hash = get_transaction_hash(&output);
let hash = get_transaction_hash(&stdout);
let receipt = get_transaction_receipt(hash).await;

assert_stdout_contains(output, "Specifying '--max-fee' flag while using v3 transactions results in conversion to '--max-gas' and '--max-gas-unit-price' flags");
assert!(matches!(receipt, Invoke(_)));
}

Expand Down
Loading