|
| 1 | +use std::sync::Arc; |
| 2 | + |
1 | 3 | use crate::prelude::alloy::primitives::{Address as AlloyAddress, B256};
|
2 |
| -use crate::prelude::alloy::rpc::types::Log as AlloyLog; |
| 4 | +use crate::prelude::alloy::rpc::types::{ |
| 5 | + Block as AlloyBlock, Log as AlloyLog, TransactionReceipt as AlloyTransactionReceipt, |
| 6 | +}; |
3 | 7 | /// Type conversion utilities between web3 and alloy types
|
4 |
| -use crate::prelude::web3::types::{Address as Web3Address, Log as Web3Log, H160, H256, U256, U64}; |
| 8 | +use crate::prelude::web3::types::{ |
| 9 | + Address as Web3Address, Block as Web3Block, Log as Web3Log, Transaction as Web3Transaction, |
| 10 | + TransactionReceipt as Web3TransactionReceipt, H160, H256, U256, U64, |
| 11 | +}; |
5 | 12 |
|
6 |
| -/// Converts web3 H256 to alloy B256 |
| 13 | +/// Converts H256 to alloy B256 |
7 | 14 | pub fn h256_to_b256(h: H256) -> B256 {
|
8 | 15 | B256::from_slice(h.as_bytes())
|
9 | 16 | }
|
10 | 17 |
|
11 |
| -/// Converts alloy B256 to web3 H256 |
| 18 | +/// Converts alloy B256 to H256 |
12 | 19 | pub fn b256_to_h256(b: B256) -> H256 {
|
13 | 20 | H256::from_slice(b.as_slice())
|
14 | 21 | }
|
@@ -50,6 +57,26 @@ pub fn alloy_log_to_web3_log(log: AlloyLog) -> Web3Log {
|
50 | 57 | }
|
51 | 58 | }
|
52 | 59 |
|
| 60 | +pub fn alloy_transaction_receipt_to_web3_transaction_receipt( |
| 61 | + _receipt: Arc<AlloyTransactionReceipt>, |
| 62 | +) -> Arc<Web3TransactionReceipt> { |
| 63 | + unimplemented!("TransactionReceipt conversion not yet implemented - will be done when needed") |
| 64 | +} |
| 65 | + |
| 66 | +/// Converts alloy Block to web3 Block |
| 67 | +pub fn alloy_block_to_web3_block(_block: AlloyBlock) -> Web3Block<Web3Transaction> { |
| 68 | + unimplemented!( |
| 69 | + "Block conversion from alloy to web3 not yet implemented - will be done when needed" |
| 70 | + ) |
| 71 | +} |
| 72 | + |
| 73 | +/// Converts web3 Block to alloy Block |
| 74 | +pub fn web3_block_to_alloy_block(_block: Web3Block<Web3Transaction>) -> AlloyBlock { |
| 75 | + unimplemented!( |
| 76 | + "Block conversion from web3 to alloy not yet implemented - will be done when needed" |
| 77 | + ) |
| 78 | +} |
| 79 | + |
53 | 80 | #[cfg(test)]
|
54 | 81 | mod tests {
|
55 | 82 | use super::*;
|
|
0 commit comments