Skip to content

Commit

Permalink
erc20next: add support for setting geth endpoints via env
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr committed Aug 30, 2023
1 parent d6bb8fe commit 784fe13
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion core/payment-driver/erc20next/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Erc20NextService {
};
log::warn!("Loading config");
let config_str = include_str!("../config-payments.toml");
let config = match config::Config::load("config-payments.toml").await {
let mut config = match config::Config::load("config-payments.toml").await {
Ok(config) => config,
Err(err) => {
log::warn!(
Expand All @@ -61,6 +61,21 @@ impl Erc20NextService {
}
};

let env_overrides = [
("goerli", "GOERLI_GETH_ADDR"),
("polygon", "POLYGON_GETH_ADDR"),
("mumbai", "MUMBAI_GETH_ADDR"),
];

for env_override in env_overrides {
if let Ok(addr) = env::var(env_override.1) {
log::info!("Geth addr override: {addr}");
if let Some(goerli_conf) = config.chain.get_mut(env_override.0) {
goerli_conf.rpc_endpoints = vec![addr];
}
}
}

log::warn!("Starting payment engine: {:#?}", config);
let signer = IdentitySigner::new();

Expand Down

0 comments on commit 784fe13

Please sign in to comment.