File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ serde_json = { workspace = true }
99
1010serde_with = " 3.0.0"
1111alloy-primitives = " 0.8"
12+ alloy-rlp = " 0.3"
1213alloy-rpc-types-mev = " 0.8"
1314alloy-serde = " 0.8"
1415reth-primitives = { git = " https://github.com/paradigmxyz/reth" , rev = " 1e965caf5fa176f244a31c0d2662ba1b590938db" } # Reth 1.2
16+ eyre = " 0.6.12"
Original file line number Diff line number Diff line change 11//! RPC types that are supported by Beaverbuild
2- use alloy_primitives:: { Address , BlockNumber , TxHash } ;
2+ use alloy_primitives:: { hex, Address , BlockNumber , TxHash } ;
3+ use alloy_rlp:: Decodable ;
4+ use eyre:: eyre;
35use reth_primitives:: TransactionSigned ;
46use serde:: { Deserialize , Serialize } ;
57use serde_with:: { serde_as, skip_serializing_none} ;
@@ -40,6 +42,26 @@ pub struct BeaverBundle {
4042 pub refund_transaction_hashes : Vec < TxHash > ,
4143}
4244
45+ impl BeaverBundle {
46+ pub fn from_rlp_hex ( txs : Vec < String > , block_number : BlockNumber ) -> eyre:: Result < Self > {
47+ Ok ( Self {
48+ transactions : txs
49+ . iter ( )
50+ . map ( |hex_string| {
51+ hex:: decode ( hex_string)
52+ . map_err ( |e| eyre ! ( "Invalid hexadecimal string: {e:?}" ) )
53+ . and_then ( |decoded_bytes| {
54+ TransactionSigned :: decode ( & mut decoded_bytes. as_slice ( ) )
55+ . map_err ( |e| eyre ! ( "Illegal RLP bytes for transaction: {e:?}" ) )
56+ } )
57+ } )
58+ . collect :: < Result < Vec < TransactionSigned > , _ > > ( ) ?,
59+ block_number,
60+ ..Self :: default ( )
61+ } )
62+ }
63+ }
64+
4365#[ cfg( test) ]
4466mod test {
4567 use super :: * ;
You can’t perform that action at this time.
0 commit comments