From bd1d6c91df9ca1b0215c9df94d6775031be93277 Mon Sep 17 00:00:00 2001 From: "tsilva@figure.com" <74169378+tsilva-figure@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:48:29 -0600 Subject: [PATCH] verify valid capital denom on asset exchange auth --- src/contract.rs | 14 ++++++++++++++ src/msg.rs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/contract.rs b/src/contract.rs index 0c082c1..4225ec8 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -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(); diff --git a/src/msg.rs b/src/msg.rs index 58e659f..ddb4f77 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -61,8 +61,8 @@ pub struct AssetExchange { #[serde(default)] pub commitment_in_shares: Option, #[serde(rename = "cap_d")] - #[serde(default)] #[serde(skip_serializing_if = "Option::is_none")] + #[serde(default)] pub capital_denom: Option, #[serde(rename = "cap")] #[serde(skip_serializing_if = "Option::is_none")]