diff --git a/apps/mtcs/contracts/cw-tee-mtcs/src/contract.rs b/apps/mtcs/contracts/cw-tee-mtcs/src/contract.rs index c2a26fea..2ff1970c 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/src/contract.rs +++ b/apps/mtcs/contracts/cw-tee-mtcs/src/contract.rs @@ -13,8 +13,8 @@ use crate::{ error::ContractError, msg::{ execute::{ - Cw20Transfer, FaucetMintMsg, SubmitObligationMsg, SubmitObligationsMsg, - SubmitSetoffsMsg, + Cw20Transfer, FaucetMintMsg, SetLiquiditySourcesMsg, SubmitObligationMsg, + SubmitObligationsMsg, SubmitSetoffsMsg, }, ExecuteMsg, InstantiateMsg, QueryMsg, }, @@ -96,7 +96,7 @@ pub fn execute( for o in obligations { execute::submit_obligation(deps.branch(), o.ciphertext, o.digest)?; } - execute::append_liquidity_sources(deps, liquidity_sources)?; + execute::set_liquidity_sources(deps, liquidity_sources)?; Ok(Response::new()) } ExecuteMsg::SubmitSetoffs(attested_msg) => { @@ -107,6 +107,9 @@ pub fn execute( execute::submit_setoffs(deps, env, setoffs_enc) } ExecuteMsg::InitClearing => execute::init_clearing(deps), + ExecuteMsg::SetLiquiditySources(SetLiquiditySourcesMsg { liquidity_sources }) => { + execute::set_liquidity_sources(deps, liquidity_sources) + } } } @@ -172,10 +175,10 @@ pub mod execute { .add_attribute("ciphertext", ciphertext.to_string())) } - pub fn append_liquidity_sources( + pub fn set_liquidity_sources( deps: DepsMut, liquidity_sources: Vec, - ) -> Result<(), ContractError> { + ) -> Result { // validate liquidity sources as public keys liquidity_sources .iter() @@ -184,11 +187,12 @@ pub mod execute { // store the liquidity sources LiquiditySourcesItem::new(¤t_epoch_key(LIQUIDITY_SOURCES_KEY, deps.storage)?) .update(deps.storage, |mut ls| { + ls.clear(); ls.extend(liquidity_sources); Ok::<_, ContractError>(ls) })?; - Ok(()) + Ok(Response::default()) } pub fn submit_setoffs( diff --git a/apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs b/apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs index bac250f7..0be3d6d0 100644 --- a/apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs +++ b/apps/mtcs/contracts/cw-tee-mtcs/src/msg.rs @@ -24,6 +24,7 @@ pub enum ExecuteMsg { SubmitObligations(execute::SubmitObligationsMsg), SubmitSetoffs(AttestedMsg), InitClearing, + SetLiquiditySources(execute::SetLiquiditySourcesMsg), } pub mod execute { @@ -82,6 +83,11 @@ pub mod execute { user_data } } + + #[cw_serde] + pub struct SetLiquiditySourcesMsg { + pub liquidity_sources: Vec, + } } #[cw_serde]