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
pull/2095/head
Mattie Conover 2 years ago committed by GitHub
parent 91837d8a20
commit 94e6b11f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      rust/agents/relayer/src/settings/mod.rs

@ -101,12 +101,12 @@ pub struct GasPaymentEnforcementConf {
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(tag = "type", rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct RawGasPaymentEnforcementConf { struct RawGasPaymentEnforcementConf {
#[serde(flatten)] #[serde(flatten)]
policy: Option<RawGasPaymentEnforcementPolicy>, policy: Option<RawGasPaymentEnforcementPolicy>,
#[serde(default)] #[serde(default)]
matching_list: Option<String>, matching_list: Option<MatchingList>,
} }
impl FromRawConf<'_, RawGasPaymentEnforcementConf> for GasPaymentEnforcementConf { impl FromRawConf<'_, RawGasPaymentEnforcementConf> for GasPaymentEnforcementConf {
@ -122,13 +122,7 @@ impl FromRawConf<'_, RawGasPaymentEnforcementConf> for GasPaymentEnforcementConf
r.parse_config(cwp).take_config_err(&mut err) r.parse_config(cwp).take_config_err(&mut err)
}); });
let matching_list = raw let matching_list = raw.matching_list.unwrap_or_default();
.matching_list
.and_then(|v| {
serde_json::from_str::<MatchingList>(&v)
.take_err(&mut err, || cwp + "matching_list")
})
.unwrap_or_default();
err.into_result()?; err.into_result()?;
Ok(Self { Ok(Self {
policy: policy.unwrap(), policy: policy.unwrap(),

Loading…
Cancel
Save