From 9a50f20175523e482de8db8d69e390b1b3127b99 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Mon, 18 Dec 2023 17:34:54 -0800 Subject: [PATCH] Use match statement. --- packages/dao-voting/src/deposit.rs | 46 +++++++++++++++++------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/dao-voting/src/deposit.rs b/packages/dao-voting/src/deposit.rs index 17f23418e..81c02b0f6 100644 --- a/packages/dao-voting/src/deposit.rs +++ b/packages/dao-voting/src/deposit.rs @@ -113,26 +113,32 @@ impl UncheckedDepositInfo { .querier .query_wasm_smart(dao, &dao_interface::msg::QueryMsg::VotingModule {})?; - if token_type == VotingModuleTokenType::Native { - // If the voting module has no native token denom this will - // error. This is desirable. - let denom: DenomResponse = deps - .querier - .query_wasm_smart(voting_module, &dao_interface::voting::Query::Denom {})?; - // Validate that native denom is formatted correctly. - UncheckedDenom::Native(denom.denom).into_checked(deps) - } else { - // If the voting module has no cw20 token this will error. - // This is desirable. - let token_addr: Addr = deps.querier.query_wasm_smart( - voting_module, - &dao_interface::voting::Query::TokenContract {}, - )?; - // We don't assume here that the voting module has - // returned a valid token. Conversion of the unchecked - // denom into a checked one will do a `TokenInfo {}` - // query. - UncheckedDenom::Cw20(token_addr.into_string()).into_checked(deps) + match token_type { + VotingModuleTokenType::Native => { + // If the voting module has no native token denom this + // will error. This is desirable. + let denom: DenomResponse = deps.querier.query_wasm_smart( + voting_module, + &dao_interface::voting::Query::Denom {}, + )?; + + // Validate that native denom is formatted correctly. + UncheckedDenom::Native(denom.denom).into_checked(deps) + } + VotingModuleTokenType::Cw20 => { + // If the voting module has no cw20 token this will + // error. This is desirable. + let token_addr: Addr = deps.querier.query_wasm_smart( + voting_module, + &dao_interface::voting::Query::TokenContract {}, + )?; + + // We don't assume here that the voting module has + // returned a valid token. Conversion of the unchecked + // denom into a checked one will do a `TokenInfo {}` + // query. + UncheckedDenom::Cw20(token_addr.into_string()).into_checked(deps) + } } } }?;