diff --git a/Cargo.lock b/Cargo.lock index d7f8d8d7..6073be3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2637,7 +2637,7 @@ dependencies = [ [[package]] name = "nomad-xyz-configuration" -version = "1.0.0-rc.1" +version = "1.0.0-rc.2" dependencies = [ "affix", "dotenv", diff --git a/configuration/Cargo.toml b/configuration/Cargo.toml index 6355fcda..4673c597 100644 --- a/configuration/Cargo.toml +++ b/configuration/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nomad-xyz-configuration" -version = "1.0.0-rc.1" +version = "1.0.0-rc.2" edition = "2021" authors = ["James Prestwich ", "The Nomad Developers "] description = "Nomad project configuration file utilities" diff --git a/configuration/configs/test.json b/configuration/configs/test.json index 9390b92e..1f7e43bc 100644 --- a/configuration/configs/test.json +++ b/configuration/configs/test.json @@ -15,7 +15,8 @@ "networks": { "ethereum": { "name": "ethereum", - "domain": 6648936, + "rpcStyle": "ethereum", + "domain": 6648936, "connections": ["moonbeam", "evmos"], "specs": { "chainId": 1, @@ -41,7 +42,8 @@ }, "moonbeam": { "name": "moonbeam", - "domain": 1650811245, + "rpcStyle": "ethereum", + "domain": 1650811245, "connections": ["ethereum", "evmos"], "specs": { "chainId": 1284, @@ -71,7 +73,8 @@ }, "evmos": { "name": "evmos", - "domain": 1702260083, + "rpcStyle": "ethereum", + "domain": 1702260083, "connections": ["ethereum", "moonbeam"], "configuration": { "optimisticSeconds": 1800, @@ -272,7 +275,6 @@ }, "agent": { "ethereum": { - "rpcStyle": "ethereum", "db": "db", "metrics": 9090, "logging": { @@ -301,7 +303,6 @@ } }, "moonbeam": { - "rpcStyle": "ethereum", "db": "db", "metrics": 9090, "logging": { @@ -330,7 +331,6 @@ } }, "evmos": { - "rpcStyle": "ethereum", "db": "db", "metrics": 9090, "logging": { diff --git a/configuration/configs/testMultiVm.json b/configuration/configs/testMultiVm.json index 148ce2e8..545fbfd5 100644 --- a/configuration/configs/testMultiVm.json +++ b/configuration/configs/testMultiVm.json @@ -16,7 +16,8 @@ "networks": { "ethereum": { "name": "ethereum", - "domain": 6648936, + "rpcStyle": "ethereum", + "domain": 6648936, "connections": ["moonbeam", "evmos"], "specs": { "chainId": 1, @@ -42,7 +43,8 @@ }, "moonbeam": { "name": "moonbeam", - "domain": 1650811245, + "rpcStyle": "ethereum", + "domain": 1650811245, "connections": ["ethereum", "evmos"], "specs": { "chainId": 1284, @@ -72,7 +74,8 @@ }, "evmos": { "name": "evmos", - "domain": 1702260083, + "rpcStyle": "ethereum", + "domain": 1702260083, "connections": ["ethereum", "moonbeam"], "configuration": { "optimisticSeconds": 1800, @@ -109,7 +112,8 @@ }, "avail": { "name": "avail", - "domain": 1702260083, + "rpcStyle": "substrate", + "domain": 1702260083, "connections": ["ethereum"], "configuration": { "optimisticSeconds": 1800, @@ -311,7 +315,6 @@ }, "agent": { "ethereum": { - "rpcStyle": "ethereum", "db": "db", "metrics": 9090, "logging": { @@ -340,7 +343,6 @@ } }, "moonbeam": { - "rpcStyle": "ethereum", "db": "db", "metrics": 9090, "logging": { @@ -369,7 +371,6 @@ } }, "evmos": { - "rpcStyle": "ethereum", "db": "db", "metrics": 9090, "logging": { diff --git a/configuration/data/definitions.ts b/configuration/data/definitions.ts index aed06e27..ecd1199f 100644 --- a/configuration/data/definitions.ts +++ b/configuration/data/definitions.ts @@ -31,7 +31,6 @@ export type ProcessorConfig = BaseAgentConfig & { }; export interface AgentConfig { - rpcStyle: string; db: string; metrics: number; logging: LogConfig; @@ -130,6 +129,7 @@ export interface BridgeConfiguration { export interface Domain { name: string; domain: number; + rpcStyle: string; connections: Array; configuration: ContractConfig; specs: NetworkSpecs; diff --git a/configuration/src/agent/logging.rs b/configuration/src/agent/logging.rs index 0957a23a..1e24bcc6 100644 --- a/configuration/src/agent/logging.rs +++ b/configuration/src/agent/logging.rs @@ -1,32 +1,5 @@ //! Agent configuration types -/// Rpc Styles -#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, Eq, PartialEq)] -#[serde(rename_all = "lowercase")] -pub enum RpcStyles { - /// Ethereum - Ethereum, - /// Substrate - Substrate, -} - -impl std::fmt::Display for RpcStyles { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let style = match self { - RpcStyles::Ethereum => "ethereum", - RpcStyles::Substrate => "substrate", - }; - - write!(f, "{}", style) - } -} - -impl Default for RpcStyles { - fn default() -> Self { - RpcStyles::Ethereum - } -} - /// Basic tracing configuration #[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, Eq, PartialEq)] #[serde(rename_all = "camelCase")] @@ -96,11 +69,11 @@ impl Default for LogConfig { mod test { use serde_json::json; - use super::RpcStyles; + use crate::RpcStyle; #[test] fn it_deserializes_rpc_styles() { - let serialized = serde_json::to_value(&RpcStyles::Ethereum).unwrap(); + let serialized = serde_json::to_value(&RpcStyle::Ethereum).unwrap(); let val = json! { "ethereum" }; assert_eq!(val, serialized); diff --git a/configuration/src/agent/mod.rs b/configuration/src/agent/mod.rs index 32dd87d7..08b4230c 100644 --- a/configuration/src/agent/mod.rs +++ b/configuration/src/agent/mod.rs @@ -28,8 +28,6 @@ use self::{ #[derive(Default, Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] pub struct AgentConfig { - /// RPC specifier - pub rpc_style: RpcStyles, /// Path to the DB pub db: PathBuf, /// Metrics port diff --git a/configuration/src/chains/mod.rs b/configuration/src/chains/mod.rs index fdde5084..04093650 100644 --- a/configuration/src/chains/mod.rs +++ b/configuration/src/chains/mod.rs @@ -6,11 +6,14 @@ pub mod substrate; use std::str::FromStr; +use serde::{Deserialize, Serialize}; use serde_json::json; /// Rpc style of chain -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Default, Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq)] +#[serde(rename_all = "camelCase")] pub enum RpcStyle { + #[default] /// Ethereum Ethereum, /// Substrate @@ -29,6 +32,17 @@ impl FromStr for RpcStyle { } } +impl std::fmt::Display for RpcStyle { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let style = match self { + RpcStyle::Ethereum => "ethereum", + RpcStyle::Substrate => "substrate", + }; + + write!(f, "{}", style) + } +} + /// Chain connection configuration #[derive(Debug, Clone, PartialEq)] pub enum Connection { diff --git a/configuration/src/network.rs b/configuration/src/network.rs index 95182e72..3b3bca00 100644 --- a/configuration/src/network.rs +++ b/configuration/src/network.rs @@ -1,6 +1,6 @@ //! Core deploy information -use crate::bridge::BridgeConfiguration; +use crate::{bridge::BridgeConfiguration, RpcStyle}; use nomad_types::{ deser_nomad_u32, deser_nomad_u64, deser_nomad_u8, NameOrDomain, NomadIdentifier, NomadLocator, }; @@ -83,6 +83,8 @@ pub struct Domain { /// Network domain identifier #[serde(deserialize_with = "deser_nomad_u32")] pub domain: u32, + /// dwfgkewopgk + pub rpc_style: RpcStyle, /// List of connections to other networks pub connections: HashSet, /// Nomad protocol configuration options diff --git a/configuration/src/wasm/types.rs b/configuration/src/wasm/types.rs index 586dc258..9ce8d55b 100644 --- a/configuration/src/wasm/types.rs +++ b/configuration/src/wasm/types.rs @@ -37,7 +37,6 @@ export type ProcessorConfig = BaseAgentConfig & { }; export interface AgentConfig { - rpcStyle: string; db: string; metrics: number; logging: LogConfig; @@ -136,6 +135,7 @@ export interface BridgeConfiguration { export interface Domain { name: string; domain: number; + rpcStyle: string; connections: Array; configuration: ContractConfig; specs: NetworkSpecs; diff --git a/fixtures/external_config.json b/fixtures/external_config.json index 4cbee898..77cf8d78 100644 --- a/fixtures/external_config.json +++ b/fixtures/external_config.json @@ -14,7 +14,8 @@ "networks": { "ethereum": { "name": "ethereum", - "domain": 6648936, + "rpcStyle": "ethereum", + "domain": 6648936, "connections": ["polygon"], "specs": { "chainId": 1, @@ -45,7 +46,8 @@ }, "polygon": { "name": "polygon", - "domain": 1650811245, + "rpcStyle": "ethereum", + "domain": 1650811245, "connections": ["ethereum"], "specs": { "chainId": 1284, @@ -170,7 +172,6 @@ }, "agent": { "ethereum": { - "rpcStyle": "ethereum", "db": "/usr/share/nomad", "metrics": 9090, "logging": { @@ -195,7 +196,6 @@ } }, "polygon": { - "rpcStyle": "ethereum", "db": "/usr/share/nomad", "metrics": 9090, "logging": { diff --git a/nomad-base/src/bin/secrets_template.rs b/nomad-base/src/bin/secrets_template.rs index b220669a..012c47a4 100644 --- a/nomad-base/src/bin/secrets_template.rs +++ b/nomad-base/src/bin/secrets_template.rs @@ -1,3 +1,4 @@ +use nomad_types::NameOrDomain; use serde_json::json; use std::{fs::OpenOptions, io::Write}; @@ -16,7 +17,12 @@ fn main() { }); for network in config.networks.iter() { - let rpc_style = config.agent().get(network).expect("!agent").rpc_style; + let networks = config.protocol(); + let rpc_style = networks + .networks + .get(network.as_str()) + .expect("!no domain") + .rpc_style; template["rpcs"].as_object_mut().unwrap().insert( network.to_owned(), json!({