Skip to content

Commit

Permalink
Interpolate env vars into config (#350)
Browse files Browse the repository at this point in the history
* Interpolate env vars into config

* Add better env var validation

* Load .dotenv on demand

* Store used env vars hash in the persisted state

* Fix env hash

* Fix tests

* Improve config hashing

* Don't store ecosystem on human_config

* Add support for default values

* Update codegenerator/cli/src/config_parsing/system_config.rs

Co-authored-by: Jono Prest <[email protected]>

* Update codegenerator/cli/src/config_parsing/system_config.rs

Co-authored-by: Jono Prest <[email protected]>

* Fix tests

---------

Co-authored-by: Jono Prest <[email protected]>
  • Loading branch information
DZakh and JonoPrest authored Nov 28, 2024
1 parent 8bfc4b0 commit 84f9fdc
Show file tree
Hide file tree
Showing 11 changed files with 1,290 additions and 671 deletions.
1,022 changes: 640 additions & 382 deletions codegenerator/Cargo.lock

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions codegenerator/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ edition = "2021"
[dependencies]
clap = { version = "4.2.2", features = ["derive", "env"] }
clap-markdown = { version = "0.1.0" }
dialoguer = "0.8"
ethers = "2.0.14"
graphql-parser = "0.4.0"
handlebars = "6.0.0"
Expand Down Expand Up @@ -44,9 +43,7 @@ thiserror = "1.0.50"
fuel-abi-types = "0.7.0"
schemars = { version = "1.0.0-alpha.2", features = ["preserve_order"] }
convert_case = "0.6.0"
# TODO: replace ethers with alloy and foundry-block-explorers since these are actively maintained
# foundry-block-explorers = "0.5.1"
# alloy-chains = "0.1.23"
dotenvy = { git = "https://github.com/enviodev/dotenvy", rev = "e2da110668572cf2d67178f192eb1fc285224040" }

[dev-dependencies]
tempdir = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions codegenerator/cli/src/config_parsing/chain_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum Network {
#[subenum(HypersyncNetwork, GraphNetwork, NetworkWithExplorer)]
Avalanche = 43114,

#[subenum(HypersyncNetwork, NetworkWithExplorer)]
#[subenum(NetworkWithExplorer)]
B2Testnet = 1123,

#[subenum(HypersyncNetwork, NetworkWithExplorer, GraphNetwork)]
Expand Down Expand Up @@ -513,7 +513,7 @@ impl HypersyncNetwork {
}

SophonTestnet | MorphTestnet | GaladrielDevnet | CitreaTestnet | Goerli
| BscTestnet | B2Testnet | UnichainSepolia => Experimental,
| BscTestnet | UnichainSepolia => Experimental,
}
}

Expand Down
21 changes: 20 additions & 1 deletion codegenerator/cli/src/config_parsing/human_config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::utils::normalized_list::{NormalizedList, SingleOrList};
use schemars::{json_schema, JsonSchema, Schema, SchemaGenerator};
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::{borrow::Cow, fmt::Display};

impl<T: Clone + JsonSchema> JsonSchema for SingleOrList<T> {
fn schema_name() -> Cow<'static, str> {
Expand Down Expand Up @@ -93,6 +93,25 @@ pub struct ConfigDiscriminant {
pub ecosystem: Option<String>,
}

#[derive(Debug)]
pub enum HumanConfig {
Evm(evm::HumanConfig),
Fuel(fuel::HumanConfig),
}

impl Display for HumanConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
HumanConfig::Evm(config) => config.to_string(),
HumanConfig::Fuel(config) => config.to_string(),
}
)
}
}

pub mod evm {
use super::{GlobalContract, NetworkContract, NetworkId};
use crate::utils::normalized_list::SingleOrList;
Expand Down
Loading

0 comments on commit 84f9fdc

Please sign in to comment.