Skip to content

Commit

Permalink
feat: rlp_decode
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Apr 16, 2024
1 parent 00ca669 commit 356854c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{Error, Field};
use alloy_consensus::{
SignableTransaction, TxEip1559, TxEip2930, TxEip4844, TxEnvelope, TxLegacy, TxType,
};
use alloy_eips::eip2718::Decodable2718;
use alloy_eips::eip2930::AccessList;
use alloy_eips::eip2930::AccessListItem;
use alloy_network::eip2718::Encodable2718;
Expand All @@ -15,6 +16,11 @@ impl ConsensusTx {
pub fn rlp_encode(&self) -> Vec<u8> {
self.0.encoded_2718()
}

pub fn rlp_decode(mut data: &[u8]) -> Result<Self, Error> {
let tx = TxEnvelope::decode_2718(&mut data).map_err(Error::Rlp)?;
Ok(ConsensusTx(tx))
}
}

#[derive(Debug, Clone)]
Expand Down

0 comments on commit 356854c

Please sign in to comment.