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

Commit

Permalink
fix: incorrect encoding on TransactionReceipt (#1661)
Browse files Browse the repository at this point in the history
* fix TransactionReceipt rlp encoding

* add tests

* update changelog
  • Loading branch information
ncitron authored Sep 4, 2022
1 parent de90662 commit 744d5c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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 @@ -425,7 +425,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 @@ -457,6 +457,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 @@ -907,6 +909,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

0 comments on commit 744d5c0

Please sign in to comment.