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
29
30
31
32
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct Web3Provider {
pub name: String,
pub url: String,
}
impl Web3Provider {
pub fn new(name: String, url: String) -> Self {
Self { name, url }
}
pub fn localhost(&mut self, port: Option<u16>) -> &Self {
self.url = format!("http://localhost:{}", port.unwrap_or(8454));
self
}
pub fn from_str(name: &str, url: &str) -> Self {
Self::new(name.to_string(), url.to_string())
}
}