MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / parse_network

Function parse_network

fendermint/app/options/src/parse.rs:89–103  ·  view source on GitHub ↗

Parse the FVM network and set the global value.

(s: &str)

Source from the content-addressed store, hash-verified

87
88/// Parse the FVM network and set the global value.
89pub 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
105pub fn parse_eth_address(s: &str) -> Result<Address, String> {
106 match ipc_types::EthAddress::from_str(s) {

Callers

nothing calls this directly

Calls 2

as_strMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected