|
1 | 1 | //! `Eth` namespace |
2 | 2 |
|
| 3 | +use headers::HeaderMap; |
| 4 | + |
3 | 5 | use crate::{ |
4 | 6 | api::Namespace, |
5 | 7 | helpers::{self, CallFuture}, |
@@ -37,8 +39,8 @@ impl<T: Transport> Eth<T> { |
37 | 39 | } |
38 | 40 |
|
39 | 41 | /// Get current block number |
40 | | - pub fn block_number(&self) -> CallFuture<U64, T::Out> { |
41 | | - CallFuture::new(self.transport.execute("eth_blockNumber", vec![])) |
| 42 | + pub fn block_number(&self, headers: Option<HeaderMap>) -> CallFuture<U64, T::Out> { |
| 43 | + CallFuture::new(self.transport.execute_with_headers("eth_blockNumber", vec![], headers)) |
42 | 44 | } |
43 | 45 |
|
44 | 46 | /// Call a constant method of contract without changing the state of the blockchain. |
@@ -116,23 +118,28 @@ impl<T: Transport> Eth<T> { |
116 | 118 | } |
117 | 119 |
|
118 | 120 | /// Get all logs matching a given filter object |
119 | | - pub fn logs(&self, filter: Filter) -> CallFuture<Vec<Log>, T::Out> { |
| 121 | + pub fn logs(&self, filter: Filter, headers: Option<HeaderMap>) -> CallFuture<Vec<Log>, T::Out> { |
120 | 122 | let filter = helpers::serialize(&filter); |
121 | | - CallFuture::new(self.transport.execute("eth_getLogs", vec![filter])) |
| 123 | + CallFuture::new( |
| 124 | + self.transport |
| 125 | + .execute_with_headers("eth_getLogs", vec![filter], headers), |
| 126 | + ) |
122 | 127 | } |
123 | 128 |
|
124 | 129 | /// Get block details with transaction hashes. |
125 | | - pub fn block(&self, block: BlockId) -> CallFuture<Option<Block<H256>>, T::Out> { |
| 130 | + pub fn block(&self, block: BlockId, headers: Option<HeaderMap>) -> CallFuture<Option<Block<H256>>, T::Out> { |
126 | 131 | let include_txs = helpers::serialize(&false); |
127 | 132 |
|
128 | 133 | let result = match block { |
129 | 134 | BlockId::Hash(hash) => { |
130 | 135 | let hash = helpers::serialize(&hash); |
131 | | - self.transport.execute("eth_getBlockByHash", vec![hash, include_txs]) |
| 136 | + self.transport |
| 137 | + .execute_with_headers("eth_getBlockByHash", vec![hash, include_txs], headers) |
132 | 138 | } |
133 | 139 | BlockId::Number(num) => { |
134 | 140 | let num = helpers::serialize(&num); |
135 | | - self.transport.execute("eth_getBlockByNumber", vec![num, include_txs]) |
| 141 | + self.transport |
| 142 | + .execute_with_headers("eth_getBlockByNumber", vec![num, include_txs], headers) |
136 | 143 | } |
137 | 144 | }; |
138 | 145 |
|
@@ -558,7 +565,7 @@ mod tests { |
558 | 565 | ); |
559 | 566 |
|
560 | 567 | rpc_test! ( |
561 | | - Eth:block_number => "eth_blockNumber"; |
| 568 | + Eth:block_number, None => "eth_blockNumber", Vec::<String>::new(); |
562 | 569 | Value::String("0x123".into()) => 0x123 |
563 | 570 | ); |
564 | 571 |
|
@@ -653,21 +660,21 @@ mod tests { |
653 | 660 | ); |
654 | 661 |
|
655 | 662 | rpc_test! ( |
656 | | - Eth:logs, FilterBuilder::default().build() => "eth_getLogs", vec!["{}"]; |
| 663 | + Eth:logs, FilterBuilder::default().build(), None => "eth_getLogs", vec!["{}"]; |
657 | 664 | Value::Array(vec![::serde_json::from_str(EXAMPLE_LOG).unwrap()]) |
658 | 665 | => vec![::serde_json::from_str::<Log>(EXAMPLE_LOG).unwrap()] |
659 | 666 | ); |
660 | 667 |
|
661 | 668 | rpc_test! ( |
662 | | - Eth:block:block_by_hash, BlockId::Hash(H256::from_low_u64_be(0x123)) |
| 669 | + Eth:block:block_by_hash, BlockId::Hash(H256::from_low_u64_be(0x123)), None |
663 | 670 | => |
664 | 671 | "eth_getBlockByHash", vec![r#""0x0000000000000000000000000000000000000000000000000000000000000123""#, r#"false"#]; |
665 | 672 | ::serde_json::from_str(EXAMPLE_BLOCK).unwrap() |
666 | 673 | => Some(::serde_json::from_str::<Block<H256>>(EXAMPLE_BLOCK).unwrap()) |
667 | 674 | ); |
668 | 675 |
|
669 | 676 | rpc_test! ( |
670 | | - Eth:block, BlockNumber::Pending |
| 677 | + Eth:block, BlockNumber::Pending, None |
671 | 678 | => |
672 | 679 | "eth_getBlockByNumber", vec![r#""pending""#, r#"false"#]; |
673 | 680 | ::serde_json::from_str(EXAMPLE_PENDING_BLOCK).unwrap() |
|
0 commit comments