Skip to content

Commit

Permalink
verify valid capital denom on asset exchange auth
Browse files Browse the repository at this point in the history
  • Loading branch information
tsilva-figure committed Aug 29, 2023
1 parent 701f42e commit bd1d6c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ pub fn execute(
return contract_error("only the lp can authorize asset exchanges");
}

if state.like_capital_denoms.len() > 1 {
for exchange in &exchanges {
if exchange.capital.is_some() {
if let Some(denom_value) = &exchange.capital_denom {
if !state.like_capital_denoms.contains(denom_value) {
return contract_error("unsupported capital denom");
}
} else {
return contract_error("specified capital denom required");
}
}
}
}

let mut authorizations = asset_exchange_authorization_storage(deps.storage)
.may_load()?
.unwrap_or_default();
Expand Down
2 changes: 1 addition & 1 deletion src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ pub struct AssetExchange {
#[serde(default)]
pub commitment_in_shares: Option<i64>,
#[serde(rename = "cap_d")]
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub capital_denom: Option<String>,
#[serde(rename = "cap")]
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down

0 comments on commit bd1d6c9

Please sign in to comment.