1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use serde::{Deserialize, Serialize};
use web3::transports::Http;
use web3::Web3;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Web3Config {
pub endpoint: String,
}
impl Default for Web3Config {
fn default() -> Self {
Self {
endpoint: "https://mainnet.infura.io/v3/<api_key>".to_string(),
}
}
}
pub struct Web3Component;
impl Web3Component {
pub fn component(config: Web3Config) -> color_eyre::Result<Web3<Http>> {
Ok(Web3::new(Http::new(&config.endpoint)?))
}
}