From 94e6b11f9431a15fd58132979dc14791e980ce98 Mon Sep 17 00:00:00 2001 From: Mattie Conover Date: Fri, 14 Apr 2023 09:13:38 -0700 Subject: [PATCH] Fix payment enforcement config parsing bug (#2093) ### Description Fixes a bug where we were first parsing the matching list as a string and then trying to convert it which was impacting the expected config type. ### Drive-by changes None ### Related issues - https://discord.com/channels/935678348330434570/1096400530722537513 ### Backward compatibility _Are these changes backward compatible?_ Yes _Are there any infrastructure implications, e.g. changes that would prohibit deploying older commits using this infra tooling?_ None ### Testing _What kind of testing have these changes undergone?_ Unit Tests --- rust/agents/relayer/src/settings/mod.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/rust/agents/relayer/src/settings/mod.rs b/rust/agents/relayer/src/settings/mod.rs index 643e2522f..8702fa7a0 100644 --- a/rust/agents/relayer/src/settings/mod.rs +++ b/rust/agents/relayer/src/settings/mod.rs @@ -101,12 +101,12 @@ pub struct GasPaymentEnforcementConf { } #[derive(Debug, Deserialize)] -#[serde(tag = "type", rename_all = "camelCase")] +#[serde(rename_all = "camelCase")] struct RawGasPaymentEnforcementConf { #[serde(flatten)] policy: Option, #[serde(default)] - matching_list: Option, + matching_list: Option, } impl FromRawConf<'_, RawGasPaymentEnforcementConf> for GasPaymentEnforcementConf { @@ -122,13 +122,7 @@ impl FromRawConf<'_, RawGasPaymentEnforcementConf> for GasPaymentEnforcementConf r.parse_config(cwp).take_config_err(&mut err) }); - let matching_list = raw - .matching_list - .and_then(|v| { - serde_json::from_str::(&v) - .take_err(&mut err, || cwp + "matching_list") - }) - .unwrap_or_default(); + let matching_list = raw.matching_list.unwrap_or_default(); err.into_result()?; Ok(Self { policy: policy.unwrap(),