Parse the FVM network and set the global value.
(s: &str)
| 87 | |
| 88 | /// Parse the FVM network and set the global value. |
| 89 | pub fn parse_network(s: &str) -> Result<Network, String> { |
| 90 | match s.to_lowercase().as_str() { |
| 91 | "main" | "mainnet" | "f" => Ok(Network::Mainnet), |
| 92 | "test" | "testnet" | "t" => Ok(Network::Testnet), |
| 93 | n => { |
| 94 | let n: u8 = n |
| 95 | .parse() |
| 96 | .map_err(|e| format!("expected 0 or 1 for network: {e}"))?; |
| 97 | |
| 98 | let n = Network::from_u8(n).ok_or_else(|| format!("unexpected network: {s}"))?; |
| 99 | |
| 100 | Ok(n) |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | pub fn parse_eth_address(s: &str) -> Result<Address, String> { |
| 106 | match ipc_types::EthAddress::from_str(s) { |