diff --git a/crates/sncast/src/helpers/fee.rs b/crates/sncast/src/helpers/fee.rs index ab0eca29c7..9bb983d1eb 100644 --- a/crates/sncast/src/helpers/fee.rs +++ b/crates/sncast/src/helpers/fee.rs @@ -61,6 +61,7 @@ impl FeeArgs { } } + #[allow(clippy::too_many_lines)] pub async fn try_into_fee_settings( &self, provider: P, @@ -106,6 +107,7 @@ impl FeeArgs { let max_gas = NonZeroFelt::try_from(Felt::from(max_fee).floor_div(&max_gas_unit_price)) .unwrap_or_else(|_| unreachable!("Calculated max gas must be >= 1 because max_fee >= max_gas_unit_price ensures a positive result")); + print_max_fee_conversion_info(max_fee, max_gas, max_gas_unit_price); FeeSettings::Strk { max_gas: Some( NonZeroU64::try_from_(max_gas).map_err(anyhow::Error::msg)?, @@ -123,6 +125,7 @@ impl FeeArgs { let max_gas_unit_price = NonZeroFelt::try_from(Felt::from(max_fee).floor_div(&max_gas)) .unwrap_or_else(|_| unreachable!("Calculated max gas unit price must be >= 1 because max_fee >= max_gas ensures a positive result")); + print_max_fee_conversion_info(max_fee, max_gas, max_gas_unit_price); FeeSettings::Strk { max_gas: Some( NonZeroU64::try_from_(max_gas).map_err(anyhow::Error::msg)?, @@ -144,6 +147,7 @@ impl FeeArgs { // TODO(#2852) let max_gas = NonZeroFelt::try_from(Felt::from(max_fee) .floor_div(&max_gas_unit_price)).context("Calculated max-gas from provided --max-fee and the current network gas price is 0. Please increase --max-fee to obtain a positive gas amount")?; + print_max_fee_conversion_info(max_fee, max_gas, max_gas_unit_price); FeeSettings::Strk { max_gas: Some( NonZeroU64::try_from_(max_gas).map_err(anyhow::Error::msg)?, @@ -285,6 +289,19 @@ fn parse_fee_token(s: &str) -> Result { Ok(parsed_token) } +fn print_max_fee_conversion_info( + max_fee: impl Into, + max_gas: impl Into, + max_gas_unit_price: impl Into, +) { + let max_fee: Felt = max_fee.into(); + let max_gas: Felt = max_gas.into(); + let max_gas_unit_price: Felt = max_gas_unit_price.into(); + println!( + "Specifying '--max-fee' flag while using v3 transactions results in conversion to '--max-gas' and '--max-gas-unit-price' flags\nConverted {max_fee} max fee to {max_gas} max gas and {max_gas_unit_price} max gas unit price\n", + ); +} + fn parse_non_zero_felt(s: &str) -> Result { let felt: Felt = s.parse().map_err(|_| "Failed to parse value")?; felt.try_into() diff --git a/crates/sncast/tests/e2e/account/deploy.rs b/crates/sncast/tests/e2e/account/deploy.rs index 8039265bde..de59901dcc 100644 --- a/crates/sncast/tests/e2e/account/deploy.rs +++ b/crates/sncast/tests/e2e/account/deploy.rs @@ -495,6 +495,9 @@ 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 + Converted [..] max fee to [..] max gas and [..] max gas unit price + command: account deploy transaction_hash: [..] @@ -616,6 +619,9 @@ 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 + Converted [..] max fee to [..] max gas and [..] max gas unit price + command: account deploy transaction_hash: 0x0[..] @@ -889,6 +895,9 @@ 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 + Converted [..] max fee to [..] max gas and [..] max gas unit price + command: account deploy transaction_hash: 0x0[..] diff --git a/crates/sncast/tests/e2e/invoke.rs b/crates/sncast/tests/e2e/invoke.rs index 2853d99705..c2e64bd55e 100644 --- a/crates/sncast/tests/e2e/invoke.rs +++ b/crates/sncast/tests/e2e/invoke.rs @@ -128,11 +128,19 @@ 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, + indoc! { + "Specifying '--max-fee' flag while using v3 transactions results in conversion to '--max-gas' and '--max-gas-unit-price' flags + Converted [..] max fee to [..] max gas and [..] max gas unit price" + }, + ); assert!(matches!(receipt, Invoke(_))); }