-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from mickvandijke/local_as_runtime_opt
Local as runtime opt
- Loading branch information
Showing
8 changed files
with
55 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use autonomi::{get_evm_network_from_env, local_evm_network_from_csv, Network}; | ||
use color_eyre::eyre::Result; | ||
|
||
use std::sync::OnceLock; | ||
|
||
static EVM_NETWORK: OnceLock<Network> = OnceLock::new(); | ||
|
||
pub(crate) fn get_evm_network(local: bool) -> Result<Network> { | ||
if let Some(network) = EVM_NETWORK.get() { | ||
return Ok(network.clone()); | ||
} | ||
|
||
let res = match get_evm_network_from_env() { | ||
Ok(evm_network) => Ok(evm_network), | ||
Err(_) if local => Ok(local_evm_network_from_csv()?), | ||
Err(_) => Ok(Default::default()), | ||
}; | ||
|
||
if let Ok(network) = res.as_ref() { | ||
let _ = EVM_NETWORK.set(network.clone()); | ||
} | ||
|
||
res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters