Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

fix: incorrect encoding on TransactionReceipt #1661

Merged
merged 3 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Unreleased

- Fix RLP encoding of `TransactionReceipt`
- Add `Unit8` helper type [#1639](https://github.com/gakonst/ethers-rs/pull/1639)
- Add `evm.deployedBytecode.immutableReferences` output selector [#1523](https://github.com/gakonst/ethers-rs/pull/1523)
- Added `get_erc1155_token_transfer_events` function for etherscan client [#1503](https://github.com/gakonst/ethers-rs/pull/1503)
Expand Down
15 changes: 14 additions & 1 deletion ethers-core/src/types/transaction/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ pub struct TransactionReceipt {
impl rlp::Encodable for TransactionReceipt {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(4);
s.append(&self.status);
rlp_opt(s, &self.status);
s.append(&self.cumulative_gas_used);
s.append(&self.logs_bloom);
s.append_list(&self.logs);
Expand Down Expand Up @@ -460,6 +460,8 @@ impl PartialOrd<Self> for TransactionReceipt {
#[cfg(test)]
#[cfg(not(feature = "celo"))]
mod tests {
use rlp::Encodable;

use crate::types::transaction::eip2930::AccessListItem;

use super::*;
Expand Down Expand Up @@ -910,6 +912,17 @@ mod tests {
assert_eq!(v, receipt);
}

#[test]
fn rlp_encode_receipt() {
let receipt = TransactionReceipt { status: Some(1u64.into()), ..Default::default() };
let encoded = receipt.rlp_bytes();

assert_eq!(
encoded,
hex::decode("f901060180b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0").unwrap(),
);
}

#[test]
fn can_sort_receipts() {
let mut a = TransactionReceipt { block_number: Some(0u64.into()), ..Default::default() };
Expand Down