Skip to content

Commit

Permalink
refactor(configuration): simplify from env namespacing
Browse files Browse the repository at this point in the history
  • Loading branch information
luketchang committed May 3, 2022
1 parent 806027f commit 6f27e66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
8 changes: 4 additions & 4 deletions configuration/src/chains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl Default for ChainConf {
impl FromEnv for ChainConf {
fn from_env(network: &str) -> Option<Self> {
println!("Getting chainconf info");
let rpc_style = std::env::var(&format!("RPCS_{}_RPCSTYLE", network)).ok()?;
let rpc_url = std::env::var(&format!("RPCS_{}_CONNECTION_URL", network)).ok()?;
let rpc_style = std::env::var(&format!("{}_RPCSTYLE", network)).ok()?;
let rpc_url = std::env::var(&format!("{}_CONNECTION_URL", network)).ok()?;
println!("GOT chainconf info");

let json = json!({
Expand All @@ -51,11 +51,11 @@ pub enum TxSubmitterConf {

impl FromEnv for TxSubmitterConf {
fn from_env(network: &str) -> Option<Self> {
let rpc_style = std::env::var(&format!("TXSUBMITTERS_{}_RPCSTYLE", network)).ok()?;
let rpc_style = std::env::var(&format!("{}_RPCSTYLE", network)).ok()?;

match rpc_style.as_ref() {
"ethereum" => Some(Self::Ethereum(ethereum::TxSubmitterConf::from_env(
&format!("TXSUBMITTERS_{}", network),
network,
)?)),
_ => panic!("Unknown transaction submission rpc style: {}", rpc_style),
}
Expand Down
20 changes: 9 additions & 11 deletions fixtures/env.test
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
RUN_ENV=test
AGENT_HOME=ethereum

RPCS_ETHEREUM_RPCSTYLE=ethereum
RPCS_ETHEREUM_CONNECTION_URL=https://main-light.eth.linkpool.io/
ETHEREUM_RPCSTYLE=ethereum
MOONBEAM_RPCSTYLE=ethereum

RPCS_MOONBEAM_RPCSTYLE=ethereum
RPCS_MOONBEAM_CONNECTION_URL=https://rpc.api.moonbeam.network
ETHEREUM_CONNECTION_URL=https://main-light.eth.linkpool.io/
MOONBEAM_CONNECTION_URL=https://rpc.api.moonbeam.network

TXSUBMITTERS_ETHEREUM_RPCSTYLE=ethereum
TXSUBMITTERS_ETHEREUM_SUBMITTERTYPE=local
TXSUBMITTERS_ETHEREUM_SUBMITTER_KEY=0x1111111111111111111111111111111111111111111111111111111111111111
ETHEREUM_SUBMITTERTYPE=local
ETHEREUM_SUBMITTER_KEY=0x1111111111111111111111111111111111111111111111111111111111111111

TXSUBMITTERS_MOONBEAM_RPCSTYLE=ethereum
TXSUBMITTERS_MOONBEAM_SUBMITTERTYPE=gelato
TXSUBMITTERS_MOONBEAM_SUBMITTER_SPONSOR_KEY=0x1111111111111111111111111111111111111111111111111111111111111111
TXSUBMITTERS_MOONBEAM_SUBMITTER_FEETOKEN=0xabcd
MOONBEAM_SUBMITTERTYPE=gelato
MOONBEAM_SUBMITTER_SPONSOR_KEY=0x1111111111111111111111111111111111111111111111111111111111111111
MOONBEAM_SUBMITTER_FEETOKEN=0xabcd

ATTESTATION_SIGNER_ID=dummy_id
ATTESTATION_SIGNER_REGION=dummy_region

0 comments on commit 6f27e66

Please sign in to comment.