diff --git a/crates/configuration/src/parachain.rs b/crates/configuration/src/parachain.rs index 4d7827010a922911fc83d41a201b239e6aa9877c..2eda033dae04e59fd77c01531ed78f66bfc7fa23 100644 --- a/crates/configuration/src/parachain.rs +++ b/crates/configuration/src/parachain.rs @@ -233,24 +233,14 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> { ) } - pub fn with_genesis_wasm_path<T>(self, location: T) -> Self - where - T: TryInto<AssetLocation>, - T::Error: Error + 'static, - { - match location.try_into() { - Ok(location) => Self::transition( - ParachainConfig { - genesis_wasm_path: Some(location), - ..self.config - }, - self.errors, - ), - Err(error) => Self::transition( - self.config, - merge_errors(self.errors, FieldError::GenesisWasmPath(error).into()), - ), - } + pub fn with_genesis_wasm_path(self, location: impl Into<AssetLocation>) -> Self { + Self::transition( + ParachainConfig { + genesis_wasm_path: Some(location.into()), + ..self.config + }, + self.errors, + ) } pub fn with_genesis_wasm_generator<T>(self, command: T) -> Self @@ -273,24 +263,14 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> { } } - pub fn with_genesis_state_path<T>(self, location: T) -> Self - where - T: TryInto<AssetLocation>, - T::Error: Error + 'static, - { - match location.try_into() { - Ok(location) => Self::transition( - ParachainConfig { - genesis_state_path: Some(location), - ..self.config - }, - self.errors, - ), - Err(error) => Self::transition( - self.config, - merge_errors(self.errors, FieldError::GenesisStatePath(error).into()), - ), - } + pub fn with_genesis_state_path(self, location: impl Into<AssetLocation>) -> Self { + Self::transition( + ParachainConfig { + genesis_state_path: Some(location.into()), + ..self.config + }, + self.errors, + ) } pub fn with_genesis_state_generator<T>(self, command: T) -> Self @@ -313,24 +293,14 @@ impl ParachainConfigBuilder<WithAtLeastOneCollator> { } } - pub fn with_chain_spec_path<T>(self, location: T) -> Self - where - T: TryInto<AssetLocation>, - T::Error: Error + 'static, - { - match location.try_into() { - Ok(location) => Self::transition( - ParachainConfig { - chain_spec_path: Some(location), - ..self.config - }, - self.errors, - ), - Err(error) => Self::transition( - self.config, - merge_errors(self.errors, FieldError::ChainSpecPath(error).into()), - ), - } + pub fn with_chain_spec_path(self, location: impl Into<AssetLocation>) -> Self { + Self::transition( + ParachainConfig { + chain_spec_path: Some(location.into()), + ..self.config + }, + self.errors, + ) } pub fn cumulus_based(self, choice: bool) -> Self { diff --git a/crates/configuration/src/relaychain.rs b/crates/configuration/src/relaychain.rs index 979aa1b28dc5b0090d0a8f07e833bacbbe26d5e8..f9e079dd0d2b8a411e670b0b68160894e2b2a2e9 100644 --- a/crates/configuration/src/relaychain.rs +++ b/crates/configuration/src/relaychain.rs @@ -136,44 +136,24 @@ macro_rules! common_builder_methods { } } - pub fn with_default_db_snapshot<T>(self, location: T) -> Self - where - T: TryInto<AssetLocation>, - T::Error: Error + 'static, - { - match location.try_into() { - Ok(location) => Self::transition( - RelaychainConfig { - default_db_snapshot: Some(location), - ..self.config - }, - self.errors, - ), - Err(error) => Self::transition( - self.config, - merge_errors(self.errors, FieldError::DefaultDbSnapshot(error).into()), - ), - } + pub fn with_default_db_snapshot(self, location: impl Into<AssetLocation>) -> Self { + Self::transition( + RelaychainConfig { + default_db_snapshot: Some(location.into()), + ..self.config + }, + self.errors, + ) } - pub fn with_chain_spec_path<T>(self, location: T) -> Self - where - T: TryInto<AssetLocation>, - T::Error: Error + 'static, - { - match location.try_into() { - Ok(location) => Self::transition( - RelaychainConfig { - chain_spec_path: Some(location), - ..self.config - }, - self.errors, - ), - Err(error) => Self::transition( - self.config, - merge_errors(self.errors, FieldError::ChainSpecPath(error).into()), - ), - } + pub fn with_chain_spec_path(self, location: impl Into<AssetLocation>) -> Self { + Self::transition( + RelaychainConfig { + chain_spec_path: Some(location.into()), + ..self.config + }, + self.errors, + ) } pub fn with_default_args(self, args: Vec<Arg>) -> Self { diff --git a/crates/configuration/src/shared/errors.rs b/crates/configuration/src/shared/errors.rs index 0bc07d106121b4f9b906dc39b21e782aefc95426..d9b5a812186471c0b824d1fc721c5f309d7bba89 100644 --- a/crates/configuration/src/shared/errors.rs +++ b/crates/configuration/src/shared/errors.rs @@ -38,27 +38,12 @@ pub enum FieldError<E> { #[error("default_command: {0}")] DefaultCommand(E), - #[error("db_snapshot: {0}")] - DbSnapshot(E), - - #[error("default_db_snapshot: {0}")] - DefaultDbSnapshot(E), - #[error("bootnodes_addresses[{0}]: {1}")] BootnodesAddress(usize, E), - #[error("chain_spec_path: {0}")] - ChainSpecPath(E), - - #[error("genesis_wasm_path: {0}")] - GenesisWasmPath(E), - #[error("genesis_wasm_generator: {0}")] GenesisWasmGenerator(E), - #[error("genesis_state_path: {0}")] - GenesisStatePath(E), - #[error("genesis_state_generator: {0}")] GenesisStateGenerator(E), diff --git a/crates/configuration/src/shared/node.rs b/crates/configuration/src/shared/node.rs index e3d6074ec47c3fbf5e1fcc4583d85ca864cc84a3..148e90fae2cd304127f1fbc5270b8cf3ae69f179 100644 --- a/crates/configuration/src/shared/node.rs +++ b/crates/configuration/src/shared/node.rs @@ -420,24 +420,14 @@ impl NodeConfigBuilder<Buildable> { ) } - pub fn with_db_snapshot<T>(self, location: T) -> Self - where - T: TryInto<AssetLocation>, - T::Error: Error + 'static, - { - match location.try_into() { - Ok(location) => Self::transition( - NodeConfig { - db_snapshot: Some(location), - ..self.config - }, - self.errors, - ), - Err(error) => Self::transition( - self.config, - merge_errors(self.errors, FieldError::DbSnapshot(error).into()), - ), - } + pub fn with_db_snapshot(self, location: impl Into<AssetLocation>) -> Self { + Self::transition( + NodeConfig { + db_snapshot: Some(location.into()), + ..self.config + }, + self.errors, + ) } pub fn build(self) -> Result<NodeConfig, (String, Vec<Box<dyn Error>>)> {