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

Fix for receipt format from GetTxnBodiesForTxBlock(Ex) #1896

Merged
Merged
4 changes: 2 additions & 2 deletions zilliqa/src/api/types/zil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl GetTxResponse {
amount,
signature,
receipt: GetTxResponseReceipt {
cumulative_gas: ScillaGas(receipt.cumulative_gas_used.0),
cumulative_gas: receipt.cumulative_gas_used.into(),
epoch_num: block_number,
transitions: receipt
.transitions
Expand Down Expand Up @@ -659,7 +659,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/zilliqa.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 @@ -1068,6 +1069,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::from(receipt.cumulative_gas_used).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 @@ -1122,7 +1128,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
Loading