Skip to content

Commit

Permalink
fix: tx submission error details not displayed
Browse files Browse the repository at this point in the history
Error details are correctly printed when calling functions or estimating
fees. However, only the error type is printed when an error happens on
transaction submission. This is happening rather frequently recently
due to the increase of class declaration fees, as many users do not have
sufficient funds to cover the `max_fee` setting, causing validation
errors on transaction submission.
  • Loading branch information
xJonathanLEI committed Mar 19, 2024
1 parent 1fe0590 commit 9b313db
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/subcommands/account/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ impl Deploy {
}

// TODO: add option to check ETH balance before sending out tx
let account_deployment_tx = account_deployment.send().await?.transaction_hash;
let account_deployment_tx = account_deployment
.send()
.await
.map_err(account_factory_error_mapper)?
.transaction_hash;
eprintln!(
"Account deployment transaction: {}",
format!("{:#064x}", account_deployment_tx).bright_yellow()
Expand Down
18 changes: 16 additions & 2 deletions src/subcommands/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,14 @@ impl Declare {
return Ok(());
}

(class_hash, declaration.send().await?.transaction_hash)
(
class_hash,
declaration
.send()
.await
.map_err(account_error_mapper)?
.transaction_hash,
)
} else if let Ok(_) =
serde_json::from_reader::<_, CompiledClass>(std::fs::File::open(&self.file)?)
{
Expand Down Expand Up @@ -249,7 +256,14 @@ impl Declare {
return Ok(());
}

(class_hash, declaration.send().await?.transaction_hash)
(
class_hash,
declaration
.send()
.await
.map_err(account_error_mapper)?
.transaction_hash,
)
} else {
anyhow::bail!("failed to parse contract artifact");
};
Expand Down
6 changes: 5 additions & 1 deletion src/subcommands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ impl Deploy {
return Ok(());
}

let deployment_tx = contract_deployment.send().await?.transaction_hash;
let deployment_tx = contract_deployment
.send()
.await
.map_err(account_error_mapper)?
.transaction_hash;
eprintln!(
"Contract deployment transaction: {}",
format!("{:#064x}", deployment_tx).bright_yellow()
Expand Down
6 changes: 5 additions & 1 deletion src/subcommands/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ impl Invoke {
return Ok(());
}

let invoke_tx = execution.send().await?.transaction_hash;
let invoke_tx = execution
.send()
.await
.map_err(account_error_mapper)?
.transaction_hash;
eprintln!(
"Invoke transaction: {}",
format!("{:#064x}", invoke_tx).bright_yellow()
Expand Down

0 comments on commit 9b313db

Please sign in to comment.