Skip to content

Commit

Permalink
Fix for issue where statuscode 255 was being returned even for succes…
Browse files Browse the repository at this point in the history
…sful transactions

- `receipt.accepted==Some(false)` is no ignored, and if `receipt.success==true` the transaction is reported dispatched
  • Loading branch information
maxconway committed Jan 10, 2025
1 parent b80319b commit 0e91b93
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions zilliqa/src/api/types/zil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,25 +800,26 @@ impl TransactionStatusResponse {
tx.to_addr.is_some().then(|| hex::encode(&tx.payload)),
),
};
let status_code = if receipt.accepted.is_some() && receipt.accepted.unwrap() {
TxnStatusCode::Confirmed
} else if receipt.accepted.is_none() {
TxnStatusCode::Dispatched
} else {
let errors: Vec<ScillaError> =
receipt.errors.into_iter().flat_map(|(_k, v)| v).collect();
if errors.len() == 1 {
match errors[0] {
ScillaError::CallContractFailed => TxnStatusCode::FailScillaLib,
ScillaError::CreateContractFailed => TxnStatusCode::Error,
ScillaError::GasNotSufficient => TxnStatusCode::InsufficientGas,
ScillaError::BalanceTransferFailed => TxnStatusCode::InsufficientBalance,
_ => TxnStatusCode::Error,
}
let status_code =
if receipt.accepted.is_some() && receipt.accepted.unwrap() && receipt.success {
TxnStatusCode::Confirmed
} else if receipt.success {
TxnStatusCode::Dispatched
} else {
TxnStatusCode::Error
}
};
let errors: Vec<ScillaError> =
receipt.errors.into_iter().flat_map(|(_k, v)| v).collect();
if errors.len() == 1 {
match errors[0] {
ScillaError::CallContractFailed => TxnStatusCode::FailScillaLib,
ScillaError::CreateContractFailed => TxnStatusCode::Error,
ScillaError::GasNotSufficient => TxnStatusCode::InsufficientGas,
ScillaError::BalanceTransferFailed => TxnStatusCode::InsufficientBalance,
_ => TxnStatusCode::Error,
}
} else {
TxnStatusCode::Error
}
};
let modification_state = if receipt.accepted.is_none() { 0 } else { 2 };
Ok(Self {
id: tx.hash.to_string(),
Expand Down

0 comments on commit 0e91b93

Please sign in to comment.