Skip to content

Commit

Permalink
Fix for receipt format from GetTxnBodiesForTxBlock(Ex)
Browse files Browse the repository at this point in the history
- closes #1883
  • Loading branch information
maxconway committed Nov 25, 2024
1 parent b8955be commit 8fcc925
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion zilliqa/src/api/types/zil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ pub struct TransactionBody {
#[serde(rename = "gasPrice")]
pub gas_price: String,
pub nonce: String,
pub receipt: TransactionReceipt,
pub receipt: TransactionReceiptResponse,
#[serde(rename = "senderPubKey")]
pub sender_pub_key: String,
pub signature: String,
Expand Down
12 changes: 9 additions & 3 deletions zilliqa/src/api/zil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ use super::{
self, BlockchainInfo, DSBlock, DSBlockHeaderVerbose, DSBlockListing, DSBlockListingResult,
DSBlockRateResult, DSBlockVerbose, GetCurrentDSCommResult, MinerInfo,
RecentTransactionsResponse, SWInfo, ShardingStructure, SmartContract, StateProofResponse,
TXBlockRateResult, TransactionBody, TransactionStatusResponse, TxBlockListing,
TxBlockListingResult, TxnBodiesForTxBlockExResponse, TxnsForTxBlockExResponse,
TXBlockRateResult, TransactionBody, TransactionReceiptResponse, TransactionStatusResponse,
TxBlockListing, TxBlockListingResult, TxnBodiesForTxBlockExResponse,
TxnsForTxBlockExResponse,
},
};
use crate::{
Expand Down Expand Up @@ -1036,6 +1037,11 @@ fn extract_transaction_bodies(block: &Block, node: &Node) -> Result<Vec<Transact
let receipt = node
.get_transaction_receipt(*hash)?
.ok_or(anyhow!("Transaction receipt missing"))?;
let receipt_response = TransactionReceiptResponse {
cumulative_gas: ScillaGas(receipt.cumulative_gas_used.0).to_string(),
epoch_num: block.number().to_string(),
success: receipt.success,
};
let (version, to_addr, sender_pub_key, signature, _code, _data) = match tx.tx {
SignedTransaction::Zilliqa { tx, sig, key } => (
((tx.chain_id as u32) << 16) | 1,
Expand Down Expand Up @@ -1090,7 +1096,7 @@ fn extract_transaction_bodies(block: &Block, node: &Node) -> Result<Vec<Transact
gas_limit: gas_limit.to_string(),
gas_price: gas_price.to_string(),
nonce: nonce.to_string(),
receipt,
receipt: receipt_response,
sender_pub_key,
signature,
to_addr: to_addr.to_string(),
Expand Down

0 comments on commit 8fcc925

Please sign in to comment.