diff --git a/framework/scripts/src/bin/full_deploy.rs b/framework/scripts/src/bin/full_deploy.rs index 4ebf0fe03f..6efae68a8d 100644 --- a/framework/scripts/src/bin/full_deploy.rs +++ b/framework/scripts/src/bin/full_deploy.rs @@ -6,11 +6,10 @@ use std::{ }; use abstract_core::objects::gov_type::GovernanceDetails; -use abstract_interface::{Abstract, VersionControl}; +use abstract_interface::Abstract; use abstract_interface_scripts::{assert_wallet_balance, DeploymentStatus, SUPPORTED_CHAINS}; use clap::Parser; -use cw_orch::daemon::{ChainKind, NetworkInfo}; use cw_orch::{ deploy::Deploy, prelude::{ @@ -29,16 +28,16 @@ fn full_deploy(mut networks: Vec) -> anyhow::Result<()> { if networks.is_empty() { networks = SUPPORTED_CHAINS.to_vec(); } - // - // let deployment_status = read_deployment()?; - // if deployment_status.success { - // log::info!("Do you want to re-deploy to {:?}?", networks); - // let mut input = String::new(); - // std::io::stdin().read_line(&mut input)?; - // if input.to_lowercase().contains('n') { - // return Ok(()); - // } - // } + + let deployment_status = read_deployment()?; + if deployment_status.success { + log::info!("Do you want to re-deploy to {:?}?", networks); + let mut input = String::new(); + std::io::stdin().read_line(&mut input)?; + if input.to_lowercase().contains('n') { + return Ok(()); + } + } // let deployment_status = deployment_status.clone(); // If some chains need to be deployed, deploy them @@ -141,10 +140,9 @@ fn main() { use dotenv::dotenv; - // let args = Arguments::parse(); + let args = Arguments::parse(); - // let networks = args.network_ids.iter().map(|n| parse_network(n)).collect(); - let networks = vec![NEUTRON_1]; + let networks = args.network_ids.iter().map(|n| parse_network(n)).collect(); if let Err(ref err) = full_deploy(networks) { log::error!("{}", err); diff --git a/modules/contracts/apps/betting/examples/deploy.rs b/modules/contracts/apps/betting/examples/deploy.rs index 6d7a6a5150..e8bb3015e4 100644 --- a/modules/contracts/apps/betting/examples/deploy.rs +++ b/modules/contracts/apps/betting/examples/deploy.rs @@ -6,9 +6,9 @@ use cw_orch::daemon::DaemonBuilder; use cw_orch::daemon::networks::parse_network; use cw_orch::tokio::runtime::Runtime; -use clap::Parser; use betting_app::contract::interface::BetApp; use betting_app::BET_APP_ID; +use clap::Parser; use semver::Version; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/modules/contracts/apps/betting/examples/schema.rs b/modules/contracts/apps/betting/examples/schema.rs index a36bb47ae7..ab3d673be5 100644 --- a/modules/contracts/apps/betting/examples/schema.rs +++ b/modules/contracts/apps/betting/examples/schema.rs @@ -1,5 +1,5 @@ -use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use betting_app::contract::BetApp; +use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use std::env::current_dir; use std::fs::create_dir_all; diff --git a/modules/contracts/apps/betting/src/error.rs b/modules/contracts/apps/betting/src/error.rs index 65b556d7b9..65413b0a89 100644 --- a/modules/contracts/apps/betting/src/error.rs +++ b/modules/contracts/apps/betting/src/error.rs @@ -1,13 +1,13 @@ +use crate::state::RoundId; use abstract_app::AppError; -use abstract_core::AbstractError; -use abstract_core::objects::AccountId; use abstract_core::objects::validation::ValidationError; +use abstract_core::objects::AccountId; +use abstract_core::AbstractError; use abstract_sdk::AbstractSdkError; use cosmwasm_std::{Addr, CheckedFromRatioError, OverflowError, StdError}; use cw_asset::{AssetError, AssetInfo, AssetInfoBase}; use cw_controllers::AdminError; use thiserror::Error; -use crate::state::RoundId; #[derive(Error, Debug, PartialEq)] pub enum BetError { @@ -84,7 +84,10 @@ pub enum BetError { account_id: AccountId, }, #[error("Invalid asset. Expected: {expected}, Actual: {actual}")] - InvalidAsset { expected: AssetInfo, actual: AssetInfoBase }, + InvalidAsset { + expected: AssetInfo, + actual: AssetInfoBase, + }, #[error("Round {0} already closed")] RoundAlreadyClosed(RoundId), diff --git a/modules/contracts/apps/betting/src/handlers/execute.rs b/modules/contracts/apps/betting/src/handlers/execute.rs index 8a3b5da8d9..cea6237195 100644 --- a/modules/contracts/apps/betting/src/handlers/execute.rs +++ b/modules/contracts/apps/betting/src/handlers/execute.rs @@ -1,20 +1,19 @@ -use std::str::FromStr; use abstract_core::objects::{AccountId, AnsAsset, AssetEntry}; -use abstract_sdk::{ - *, - core::objects::fee::Fee, features::AbstractResponse, +use abstract_sdk::{core::objects::fee::Fee, features::AbstractResponse, *}; +use cosmwasm_std::{ + coins, Addr, CosmosMsg, Decimal, DepsMut, Env, MessageInfo, Order, Response, StdError, + StdResult, Storage, Uint128, }; -use cosmwasm_std::{Addr, coins, CosmosMsg, Decimal, DepsMut, Env, MessageInfo, Order, Response, StdError, StdResult, Storage, Uint128}; use cw_storage_plus::Item; +use std::str::FromStr; use crate::contract::{BetApp, BetResult}; use crate::error::BetError; +use crate::handlers::query; use crate::msg::BetExecuteMsg; -use crate::state::*; use crate::state::CONFIG; +use crate::state::*; use abstract_sdk::features::AbstractNameService; -use crate::handlers::query; - pub fn execute_handler( deps: DepsMut, @@ -39,7 +38,11 @@ pub fn execute_handler( // Check asset create_round(deps, info, app, round_info) } - BetExecuteMsg::UpdateAccounts { to_add, to_remove, round_id } => { + BetExecuteMsg::UpdateAccounts { + to_add, + to_remove, + round_id, + } => { // Only admin can register specific accounts app.admin.assert_admin(deps.as_ref(), &info.sender)?; @@ -54,23 +57,14 @@ pub fn execute_handler( update_config(deps, app, rake) } - BetExecuteMsg::PlaceBet { - bet, - round_id - } => { - place_bet(deps, info, app, round_id, bet) - } - BetExecuteMsg::CloseRound { - round_id, winner - } => { + BetExecuteMsg::PlaceBet { bet, round_id } => place_bet(deps, info, app, round_id, bet), + BetExecuteMsg::CloseRound { round_id, winner } => { app.admin.assert_admin(deps.as_ref(), &info.sender)?; let round = Round::new(round_id); close_round(deps, &app, winner, round)? } - BetExecuteMsg::DistributeWinnings { - round_id - } => distribute_winnings(deps, app, round_id), + BetExecuteMsg::DistributeWinnings { round_id } => distribute_winnings(deps, app, round_id), BetExecuteMsg::Register { round_id } => { let round = Round::new(round_id); round.assert_not_closed(deps.storage)?; @@ -80,7 +74,7 @@ pub fn execute_handler( } fn update_config(deps: DepsMut, app: BetApp, rake: Option) -> BetResult { -// TODO: use config constant, not sure why this is not working. + // TODO: use config constant, not sure why this is not working. let mut config: Config = Item::new("config").load(deps.storage)?; let mut attrs = vec![]; @@ -89,26 +83,26 @@ fn update_config(deps: DepsMut, app: BetApp, rake: Option) -> BetResult attrs.push(("rake", rake.to_string())); }; - Ok(app.custom_tag_response( - Response::default(), - "update_config", - attrs, - )) + Ok(app.custom_tag_response(Response::default(), "update_config", attrs)) } fn register_for_round(deps: DepsMut, info: MessageInfo, app: BetApp, round: Round) -> BetResult { - let account_id = app.account_registry(deps.as_ref()).account_id(&info.sender)?; + let account_id = app + .account_registry(deps.as_ref()) + .account_id(&info.sender)?; // default odds let odds = Decimal::one(); - let to_add = vec![AccountOdds { - account_id, - odds, - }]; + let to_add = vec![AccountOdds { account_id, odds }]; let to_remove = vec![]; update_accounts(deps, info, app, round, to_add, to_remove) } -fn close_round(deps: DepsMut, app: &BetApp, winner: Option, round: Round) -> Result, BetError> { +fn close_round( + deps: DepsMut, + app: &BetApp, + winner: Option, + round: Round, +) -> Result, BetError> { let current_status = round.status(deps.storage)?; Ok(match current_status { @@ -119,12 +113,19 @@ fn close_round(deps: DepsMut, app: &BetApp, winner: Option, round: Ro return Err(BetError::AccountNotFound(winner)); } } - round.set_status(deps.storage, RoundStatus::Closed { winning_team: winner })?; + round.set_status( + deps.storage, + RoundStatus::Closed { + winning_team: winner, + }, + )?; Ok(app.custom_tag_response( Response::default(), "update_round_status", - vec![("round_id", round.id().to_string()) /*, ("status", new_status.to_string()) */], + vec![ + ("round_id", round.id().to_string()), /*, ("status", new_status.to_string()) */ + ], )) } _ => Err(BetError::RoundAlreadyClosed(round.id())), @@ -147,7 +148,8 @@ fn distribute_winnings(deps: DepsMut, app: BetApp, round_id: RoundId) -> BetResu let bank = app.bank(deps.as_ref()); let round_info = round.info(deps.storage)?.bet_asset; - let distribution_actions: Result, AbstractSdkError> = bets.into_iter() + let distribution_actions: Result, AbstractSdkError> = bets + .into_iter() .map(|(better_addr, bet_amount)| { let transfer_asset = AnsAsset::new(round_info.clone(), bet_amount); bank.transfer(vec![transfer_asset], &better_addr) @@ -156,7 +158,9 @@ fn distribute_winnings(deps: DepsMut, app: BetApp, round_id: RoundId) -> BetResu distribution_actions.map_err(Into::into) } - RoundStatus::Closed { winning_team: Some(winning_team) } => { + RoundStatus::Closed { + winning_team: Some(winning_team), + } => { // Distribute the winnings to the winning betters let winning_odds = ODDS.load(deps.storage, (round_id, winning_team.clone()))?; let winning_bets = BETS.load(deps.storage, (round_id, winning_team.clone()))?; @@ -164,7 +168,8 @@ fn distribute_winnings(deps: DepsMut, app: BetApp, round_id: RoundId) -> BetResu let bank = app.bank(deps.as_ref()); let round_info = round.info(deps.storage)?.bet_asset; - let distribution_msgs1 = winning_bets.into_iter() + let distribution_msgs1 = winning_bets + .into_iter() .map(|(better_addr, bet_amount)| { let winnings = bet_amount * winning_odds; let transfer_asset = AnsAsset::new(round_info.clone(), winnings); @@ -174,36 +179,39 @@ fn distribute_winnings(deps: DepsMut, app: BetApp, round_id: RoundId) -> BetResu distribution_msgs1.map_err(Into::into) } - _ => Err(BetError::RoundNotClosed(round_id)) + _ => Err(BetError::RoundNotClosed(round_id)), }?; let executor = app.executor(deps.as_ref()); - let distribution_msg = executor.execute(distribution_msgs)?; - Ok(app.tag_response(Response::default().add_message(distribution_msg), "distribute_draw")) - + Ok(app.tag_response( + Response::default().add_message(distribution_msg), + "distribute_draw", + )) } - -fn update_accounts(deps: DepsMut, info: MessageInfo, app: BetApp, round: Round, to_add: Vec, to_remove: Vec) -> BetResult { +fn update_accounts( + deps: DepsMut, + info: MessageInfo, + app: BetApp, + round: Round, + to_add: Vec, + to_remove: Vec, +) -> BetResult { let account_registry = app.account_registry(deps.as_ref()); - for AccountOdds { - account_id, - .. - } in to_add.iter() { + for AccountOdds { account_id, .. } in to_add.iter() { // ensure account exists - account_registry.account_base(&account_id).map_err(|_| BetError::AccountNotFound(account_id.clone()))?; + account_registry + .account_base(&account_id) + .map_err(|_| BetError::AccountNotFound(account_id.clone()))?; } // register account round.update_accounts(deps, to_add, to_remove)?; - Ok(app.tag_response( - Response::default(), - "update_accounts", - )) + Ok(app.tag_response(Response::default(), "update_accounts")) } pub fn create_round( @@ -226,10 +234,20 @@ pub fn create_round( state.next_round_id += 1; Ok(state) })?; - Ok(app.custom_tag_response(Response::default(), "create_round", vec![("round_id", state.next_round_id.to_string())])) + Ok(app.custom_tag_response( + Response::default(), + "create_round", + vec![("round_id", state.next_round_id.to_string())], + )) } -fn place_bet(deps: DepsMut, info: MessageInfo, app: BetApp, round_id: RoundId, bet: Bet) -> BetResult { +fn place_bet( + deps: DepsMut, + info: MessageInfo, + app: BetApp, + round_id: RoundId, + bet: Bet, +) -> BetResult { let mut messages: Vec = vec![]; let bank = app.bank(deps.as_ref()); @@ -244,17 +262,19 @@ fn place_bet(deps: DepsMut, info: MessageInfo, app: BetApp, round_id: RoundId, b let round = Round::new(round_id); // Ensure the account placing the bet exists - bet.validate(deps.as_ref(), &round)?; + bet.validate(deps.as_ref(), &round)?; - // deposit the sent assets - let deposit_msg = bank.deposit(vec![bet.asset.clone()])?; - messages.extend(deposit_msg.into_iter()); + // deposit the sent assets + let deposit_msg = bank.deposit(vec![bet.asset.clone()])?; + messages.extend(deposit_msg.into_iter()); // Record the bet let bet_account = bet.account_id; let key = (round.id(), bet_account.clone()); - let mut bets = BETS.may_load(deps.storage, key.clone())?.unwrap_or_default(); + let mut bets = BETS + .may_load(deps.storage, key.clone())? + .unwrap_or_default(); // Find and update the existing bet if it exists if let Some(index) = bets.iter().position(|(addr, _)| addr == &info.sender) { let (_, amount) = &mut bets[index]; @@ -282,7 +302,13 @@ fn place_bet(deps: DepsMut, info: MessageInfo, app: BetApp, round_id: RoundId, b /// Calculates the new odds for the given round/account pair /// # Returns /// the new odds -fn adjust_odds_for_team(storage: &mut dyn Storage, round_id: RoundId, team_id: AccountId, bet_totals: Uint128, rake: Decimal) -> StdResult<()> { +fn adjust_odds_for_team( + storage: &mut dyn Storage, + round_id: RoundId, + team_id: AccountId, + bet_totals: Uint128, + rake: Decimal, +) -> StdResult<()> { let team_bet_total = query::get_total_bets_for_team(storage, round_id, team_id.clone())?; // No action, odds have not changed if team_bet_total.is_zero() { diff --git a/modules/contracts/apps/betting/src/handlers/instantiate.rs b/modules/contracts/apps/betting/src/handlers/instantiate.rs index f9af2422bd..78efee4942 100644 --- a/modules/contracts/apps/betting/src/handlers/instantiate.rs +++ b/modules/contracts/apps/betting/src/handlers/instantiate.rs @@ -1,11 +1,11 @@ use abstract_core::objects::fee::Fee; -use abstract_sdk::AbstractResponse; use abstract_sdk::features::AbstractNameService; +use abstract_sdk::AbstractResponse; use cosmwasm_std::{Decimal, DepsMut, Env, MessageInfo, Response}; use crate::contract::{BetApp, BetResult}; use crate::msg::BetInstantiateMsg; -use crate::state::{Config, CONFIG, DEFAULT_RAKE_PERCENT, State, STATE}; +use crate::state::{Config, State, CONFIG, DEFAULT_RAKE_PERCENT, STATE}; pub const INSTANTIATE_REPLY_ID: u64 = 1u64; diff --git a/modules/contracts/apps/betting/src/handlers/query.rs b/modules/contracts/apps/betting/src/handlers/query.rs index 93c88c8b18..441aca16d6 100644 --- a/modules/contracts/apps/betting/src/handlers/query.rs +++ b/modules/contracts/apps/betting/src/handlers/query.rs @@ -1,20 +1,19 @@ use crate::contract::{BetApp, BetResult}; -use crate::msg::{BetQueryMsg, BetsResponse, ConfigResponse, ListOddsResponse, OddsResponse, RoundResponse, RoundsResponse}; -use crate::state::{AccountOdds, BETS, CONFIG, Config, ODDS, Round, RoundId, RoundInfo, ROUNDS}; -use cosmwasm_std::{Binary, Decimal, Deps, Env, Order, StdResult, Storage, to_binary, Uint128}; +use crate::error::BetError; +use crate::msg::{ + BetQueryMsg, BetsResponse, ConfigResponse, ListOddsResponse, OddsResponse, RoundResponse, + RoundsResponse, +}; +use crate::state::{AccountOdds, Config, Round, RoundId, RoundInfo, BETS, CONFIG, ODDS, ROUNDS}; use abstract_core::objects::AccountId; +use cosmwasm_std::{to_binary, Binary, Decimal, Deps, Env, Order, StdResult, Storage, Uint128}; use cw_storage_plus::Bound; -use crate::error::BetError; pub fn query_handler(deps: Deps, _env: Env, _etf: &BetApp, msg: BetQueryMsg) -> BetResult { match msg { BetQueryMsg::Config {} => { - let Config { - rake, - } = CONFIG.load(deps.storage)?; - to_binary(&ConfigResponse { - rake: rake.share(), - }) + let Config { rake } = CONFIG.load(deps.storage)?; + to_binary(&ConfigResponse { rake: rake.share() }) } BetQueryMsg::ListRounds { limit, start_after } => { to_binary(&list_rounds(deps, limit, start_after)?) @@ -23,39 +22,35 @@ pub fn query_handler(deps: Deps, _env: Env, _etf: &BetApp, msg: BetQueryMsg) -> let round_res = Round::new(round_id).query(deps)?; to_binary(&round_res) } - BetQueryMsg::Odds { - round_id, - team_id - } => { + BetQueryMsg::Odds { round_id, team_id } => { let odds = ODDS.load(deps.storage, (round_id, team_id))?; - to_binary(&OddsResponse { - round_id, - odds, - }) - } - BetQueryMsg::ListOdds { - round_id - } => { - to_binary(&list_odds(deps, round_id)?) + to_binary(&OddsResponse { round_id, odds }) } + BetQueryMsg::ListOdds { round_id } => to_binary(&list_odds(deps, round_id)?), BetQueryMsg::Bets { round_id } => { let round = Round::new(round_id.clone()); let bets = round.bets(deps.storage)?; - let response = BetsResponse { - round_id, - bets, - }; + let response = BetsResponse { round_id, bets }; to_binary(&response) } } .map_err(Into::into) } -fn list_rounds(deps: Deps, limit: Option, start_after: Option) -> BetResult { +fn list_rounds( + deps: Deps, + limit: Option, + start_after: Option, +) -> BetResult { let limit = limit.unwrap_or(10) as usize; let rounds: Vec<(RoundId, RoundInfo)> = ROUNDS - .range(deps.storage, start_after.map(Bound::exclusive), None, Order::Ascending) + .range( + deps.storage, + start_after.map(Bound::exclusive), + None, + Order::Ascending, + ) .take(limit) .collect::>>()?; @@ -70,26 +65,30 @@ fn list_rounds(deps: Deps, limit: Option, start_after: Option) -> } fn list_odds(deps: Deps, round_id: RoundId) -> BetResult { - let odds = ODDS.prefix(round_id).range(deps.storage, None, None, Order::Ascending).collect::>>()?; - let odds = odds.into_iter().map(|(key, value)| AccountOdds { - account_id: key, - odds: value, - }).collect::>(); - let response = ListOddsResponse { - round_id, - odds, - }; + let odds = ODDS + .prefix(round_id) + .range(deps.storage, None, None, Order::Ascending) + .collect::>>()?; + let odds = odds + .into_iter() + .map(|(key, value)| AccountOdds { + account_id: key, + odds: value, + }) + .collect::>(); + let response = ListOddsResponse { round_id, odds }; Ok(response) } - /// Returns the total bet amount for a specific `AccountId` in a given `RoundId`. pub fn get_total_bets_for_team( storage: &dyn Storage, round_id: RoundId, - account_id: AccountId + account_id: AccountId, ) -> StdResult { - let bets_for_account = BETS.may_load(storage, (round_id, account_id.clone()))?.unwrap_or_default(); + let bets_for_account = BETS + .may_load(storage, (round_id, account_id.clone()))? + .unwrap_or_default(); let total: Uint128 = bets_for_account.iter().map(|(_, amount)| *amount).sum(); Ok(total) @@ -98,9 +97,11 @@ pub fn get_total_bets_for_team( /// Returns the total bet amount across all `AccountId`s for a given `RoundId`. pub fn get_total_bets_for_all_accounts( storage: &dyn Storage, - round_id: RoundId + round_id: RoundId, ) -> StdResult { - let all_keys = BETS.prefix(round_id).keys(storage, None, None, Order::Ascending); + let all_keys = BETS + .prefix(round_id) + .keys(storage, None, None, Order::Ascending); let total = all_keys .into_iter() diff --git a/modules/contracts/apps/betting/src/msg.rs b/modules/contracts/apps/betting/src/msg.rs index 8d009dcbae..08ccdcf664 100644 --- a/modules/contracts/apps/betting/src/msg.rs +++ b/modules/contracts/apps/betting/src/msg.rs @@ -43,9 +43,8 @@ use cosmwasm_std::{Addr, Decimal, Uint128}; use cw_asset::AssetUnchecked; use crate::contract::BetApp; +use crate::state::{AccountOdds, Bet, OddsType, RoundId, RoundInfo, RoundStatus, RoundTeamKey}; use abstract_core::objects::{AccountId, AnsAsset, AssetEntry}; -use crate::state::{RoundInfo, RoundId, RoundTeamKey, Bet, AccountOdds, OddsType, RoundStatus}; - abstract_app::app_msg_types!(BetApp, BetExecuteMsg, BetQueryMsg); @@ -69,9 +68,7 @@ pub enum BetExecuteMsg { }, /// Register as a team for the hackathon /// Uses the account caller to find the account id - Register { - round_id: RoundId, - }, + Register { round_id: RoundId }, /// Register teams manually for the round, with predefined odds set. /// Good for creating games with predefined odds, but payout can exceed account balance. UpdateAccounts { @@ -81,23 +78,16 @@ pub enum BetExecuteMsg { }, /// Place a new bet for a round #[cfg_attr(feature = "interface", payable)] - PlaceBet { - bet: Bet, - round_id: RoundId, - }, + PlaceBet { bet: Bet, round_id: RoundId }, /// Distribute winnings to the winners of the round - DistributeWinnings { - round_id: RoundId, - }, + DistributeWinnings { round_id: RoundId }, /// Admin only CloseRound { round_id: RoundId, winner: Option, }, /// Update the config of the contract - UpdateConfig { - rake: Option, - }, + UpdateConfig { rake: Option }, } /// Query Msg @@ -108,9 +98,7 @@ pub enum BetExecuteMsg { pub enum BetQueryMsg { /// Returns [`RoundResponse`] #[returns(RoundResponse)] - Round { - round_id: RoundId, - }, + Round { round_id: RoundId }, /// Returns [`RoundsResponse`] #[returns(RoundsResponse)] ListRounds { @@ -125,17 +113,13 @@ pub enum BetQueryMsg { }, /// Returns [`ListOddsResponse`] #[returns(ListOddsResponse)] - ListOdds { - round_id: RoundId, - }, + ListOdds { round_id: RoundId }, /// Returns [`ConfigResponse`] #[returns(ConfigResponse)] Config {}, /// Returns [`BetsResponse`] #[returns(BetsResponse)] - Bets { - round_id: RoundId, - } + Bets { round_id: RoundId }, } /// Hook when sending CW20 tokens @@ -181,7 +165,7 @@ pub struct RoundResponse { pub teams: Vec, pub status: RoundStatus, pub bet_count: u128, - pub total_bet: AnsAsset + pub total_bet: AnsAsset, } #[cosmwasm_schema::cw_serde] diff --git a/modules/contracts/apps/betting/src/state.rs b/modules/contracts/apps/betting/src/state.rs index 1ccb53a298..f43ecafd5b 100644 --- a/modules/contracts/apps/betting/src/state.rs +++ b/modules/contracts/apps/betting/src/state.rs @@ -1,19 +1,19 @@ -use std::collections::{HashMap, HashSet}; -use abstract_core::AbstractResult; -use abstract_core::objects::fee::Fee; -use cosmwasm_std::{Addr, Decimal, Deps, DepsMut, Order, StdError, StdResult, Storage, Uint128}; -use cw_storage_plus::{Item, Map, MultiIndex}; -use abstract_core::objects::{AccountId, AnsAsset, AssetEntry}; -use abstract_core::objects::ans_host::AnsHost; -use abstract_core::objects::validation::{validate_description, validate_name}; -use abstract_sdk::{AccountingInterface, Resolve}; -use abstract_sdk::features::AbstractNameService; -use cw_asset::{Asset, AssetInfo}; use crate::contract::{BetApp, BetResult}; use crate::error::BetError; use crate::handlers::query; use crate::handlers::query::get_total_bets_for_team; use crate::msg::RoundResponse; +use abstract_core::objects::ans_host::AnsHost; +use abstract_core::objects::fee::Fee; +use abstract_core::objects::validation::{validate_description, validate_name}; +use abstract_core::objects::{AccountId, AnsAsset, AssetEntry}; +use abstract_core::AbstractResult; +use abstract_sdk::features::AbstractNameService; +use abstract_sdk::{AccountingInterface, Resolve}; +use cosmwasm_std::{Addr, Decimal, Deps, DepsMut, Order, StdError, StdResult, Storage, Uint128}; +use cw_asset::{Asset, AssetInfo}; +use cw_storage_plus::{Item, Map, MultiIndex}; +use std::collections::{HashMap, HashSet}; /// State stores LP token address /// BaseState is initialized in contract @@ -23,14 +23,13 @@ pub struct Config { } impl Config { - pub fn validate(&self,_deps: Deps) -> BetResult<()> { + pub fn validate(&self, _deps: Deps) -> BetResult<()> { Ok(()) } } pub const DEFAULT_RAKE_PERCENT: u64 = 10; - pub type RoundId = u64; #[cosmwasm_schema::cw_serde] @@ -54,7 +53,7 @@ pub enum RoundStatus { #[derive(Default)] #[cosmwasm_schema::cw_serde] pub struct State { - pub next_round_id: RoundId, + pub next_round_id: RoundId, } pub struct Round(pub RoundId); @@ -68,7 +67,9 @@ impl Round { } pub fn info(&self, storage: &dyn Storage) -> BetResult { - let info = ROUNDS.load(storage, self.id()).map_err(|_| BetError::RoundNotFound(self.id()))?; + let info = ROUNDS + .load(storage, self.id()) + .map_err(|_| BetError::RoundNotFound(self.id()))?; Ok(info) } pub fn status(&self, storage: &dyn Storage) -> BetResult { @@ -81,14 +82,24 @@ impl Round { } pub fn bets(&self, storage: &dyn Storage) -> BetResult> { - let all_bets = BETS.prefix(self.id()).range(storage, None, None, Order::Ascending).collect::>>()?; - let bets = all_bets.into_iter().map(|(_, value)| value).flatten().collect::>(); + let all_bets = BETS + .prefix(self.id()) + .range(storage, None, None, Order::Ascending) + .collect::>>()?; + let bets = all_bets + .into_iter() + .map(|(_, value)| value) + .flatten() + .collect::>(); Ok(bets) } fn bet_count(&self, storage: &dyn Storage) -> BetResult { - let all_keys: Vec<_> = BETS.prefix(self.id()).keys(storage, None, None, Order::Ascending).collect(); + let all_keys: Vec<_> = BETS + .prefix(self.id()) + .keys(storage, None, None, Order::Ascending) + .collect(); Ok(all_keys.len() as u128) } @@ -128,26 +139,41 @@ impl Round { total_bet: AnsAsset { name: info.bet_asset, amount: total_bet, - } + }, }) } /// Register accounts to a round and error out if duplicates are found. /// *unchecked* for account existence. - pub fn update_accounts(&self, deps: DepsMut, to_add: Vec, to_remove: Vec) -> BetResult<()> { + pub fn update_accounts( + &self, + deps: DepsMut, + to_add: Vec, + to_remove: Vec, + ) -> BetResult<()> { // Load existing accounts associated with the round - let mut existing_accounts: Vec = ROUNDS_TO_ACCOUNTS.may_load(deps.storage, self.id())?.unwrap_or_default(); + let mut existing_accounts: Vec = ROUNDS_TO_ACCOUNTS + .may_load(deps.storage, self.id())? + .unwrap_or_default(); let rake = CONFIG.load(deps.storage)?.rake.share(); deps.api.debug(&format!("rake: {:?}", rake)); // Add new account IDs after checking for duplicates - for AccountOdds {account_id, odds } in to_add.into_iter() { + for AccountOdds { account_id, odds } in to_add.into_iter() { if existing_accounts.contains(&account_id.clone()) { - return Err(StdError::generic_err(format!("Duplicate Account ID found: {}", account_id)).into()); + return Err(StdError::generic_err(format!( + "Duplicate Account ID found: {}", + account_id + )) + .into()); } existing_accounts.push(account_id.clone()); - deps.api.debug(&format!("odds {:?} / Decimal::one() + rake.clone() {:?}", odds, Decimal::one() + rake.clone())); + deps.api.debug(&format!( + "odds {:?} / Decimal::one() + rake.clone() {:?}", + odds, + Decimal::one() + rake.clone() + )); let mut edged_odds = odds.checked_div(Decimal::one() + rake.clone())?; // Don't allow odds to go below 1 if edged_odds < Decimal::one() { @@ -169,11 +195,8 @@ impl Round { Ok(()) } - } - - impl RoundInfo { pub fn validate(&self, deps: Deps, ans_host: &AnsHost) -> BetResult<()> { validate_name(self.name.as_str())?; @@ -182,15 +205,11 @@ impl RoundInfo { self.bet_asset.resolve(&deps.querier, ans_host)?; Ok(()) } - - } pub type RoundTeamKey = (RoundId, AccountId); -pub type OddsType = Decimal; // Represents odds with two decimal precision - - +pub type OddsType = Decimal; // Represents odds with two decimal precision /// TODO: remove round ID and replace this tuple #[cosmwasm_schema::cw_serde] @@ -199,7 +218,6 @@ pub struct Bet { pub asset: AnsAsset, } - impl Bet { pub fn validate(&self, deps: Deps, round: &Round) -> BetResult<()> { // check that the account being bet on is registered @@ -222,7 +240,7 @@ impl Bet { if !accounts.contains(bet_account_id) { return Err(BetError::AccountNotParticipating { account_id: bet_account_id.clone(), - round_id: round.id() + round_id: round.id(), }); } diff --git a/modules/contracts/apps/betting/tests/integration.rs b/modules/contracts/apps/betting/tests/integration.rs index 505a137097..0c9b3f6374 100644 --- a/modules/contracts/apps/betting/tests/integration.rs +++ b/modules/contracts/apps/betting/tests/integration.rs @@ -1,35 +1,33 @@ -// #[cfg(test)] -// mod test_utils; - use std::str::FromStr; -use abstract_core::{objects::AssetEntry, app::BaseInstantiateMsg, ans_host::ExecuteMsgFns as AnsExecuteMsgFns, objects::gov_type::GovernanceDetails, version_control::ExecuteMsgFns as VersionControlExecuteMsgFns, app}; use abstract_core::app::BaseExecuteMsg; use abstract_core::objects::{AccountId, AnsAsset}; use abstract_core::version_control::AccountBase; -use abstract_interface::{ - Abstract, AbstractAccount, AppDeployer, DeployStrategy, - ManagerQueryFns, +use abstract_core::{ + ans_host::ExecuteMsgFns as AnsExecuteMsgFns, app, app::BaseInstantiateMsg, + objects::gov_type::GovernanceDetails, objects::AssetEntry, + version_control::ExecuteMsgFns as VersionControlExecuteMsgFns, }; +use abstract_interface::{Abstract, AbstractAccount, AppDeployer, DeployStrategy, ManagerQueryFns}; use abstract_sdk::core as abstract_core; use abstract_testing::addresses::TEST_NAMESPACE; use abstract_testing::prelude::TEST_ADMIN; -use cosmwasm_std::{Addr, coins, Decimal, Uint128}; +use cosmwasm_std::{coins, Addr, Decimal, Uint128}; use cw_asset::AssetInfoUnchecked; use cw_orch::deploy::Deploy; use cw_orch::prelude::*; use betting_app::{ - contract::CONTRACT_VERSION, - BET_APP_ID, contract::interface::BetApp, + contract::CONTRACT_VERSION, + msg::BetQueryMsgFns, msg::{BetInstantiateMsg, InstantiateMsg}, - msg::BetQueryMsgFns + BET_APP_ID, }; -use speculoos::prelude::*; use betting_app::msg::{BetExecuteMsg, BetExecuteMsgFns, RoundResponse}; -use betting_app::state::{AccountOdds, DEFAULT_RAKE_PERCENT, Bet, RoundId, RoundInfo, RoundStatus}; +use betting_app::state::{AccountOdds, Bet, RoundId, RoundInfo, RoundStatus, DEFAULT_RAKE_PERCENT}; +use speculoos::prelude::*; type AResult = anyhow::Result; @@ -112,9 +110,7 @@ impl BetEnv { ans_host_address: abstr.ans_host.addr_str()?, version_control_address: abstr.version_control.addr_str()?, }, - module: BetInstantiateMsg { - rake: None, - }, + module: BetInstantiateMsg { rake: None }, }, None, )?; @@ -131,10 +127,13 @@ impl BetEnv { } fn account(&self, seq: u32) -> AResult> { - Ok(AbstractAccount::new(&self.abstr, Some(AccountId::local(seq.into())))) + Ok(AbstractAccount::new( + &self.abstr, + Some(AccountId::local(seq.into())), + )) } - fn admin_account(&self) ->AResult> { + fn admin_account(&self) -> AResult> { self.account(ADMIN_ACCOUNT_SEQ) } @@ -142,12 +141,13 @@ impl BetEnv { Ok(self.admin_account()?.manager.address()?) } - - fn add_team_to_round(&self, round_id: RoundId, account_id: AccountId, odds: Decimal) -> AResult<()> { - self.manual_add_teams_to_round(round_id, vec![AccountOdds { - account_id, - odds, - }])?; + fn add_team_to_round( + &self, + round_id: RoundId, + account_id: AccountId, + odds: Decimal, + ) -> AResult<()> { + self.manual_add_teams_to_round(round_id, vec![AccountOdds { account_id, odds }])?; Ok(()) } @@ -156,9 +156,13 @@ impl BetEnv { let mut ids = vec![]; for i in 0..x { - let account = self.abstr.account_factory.create_default_account(GovernanceDetails::Monarchy { - monarch: self.admin_account_addr().unwrap().into_string(), - }).unwrap(); + let account = self + .abstr + .account_factory + .create_default_account(GovernanceDetails::Monarchy { + monarch: self.admin_account_addr().unwrap().into_string(), + }) + .unwrap(); let account_id = account.id().unwrap(); ids.push(account_id); } @@ -167,16 +171,22 @@ impl BetEnv { } // Add teams to the round with 0 odds to start fn add_x_teams_to_round(&self, round_id: RoundId, x: usize) -> AResult<()> { - let account_ids = (0..x).map(|_| { - let account= self.abstr.account_factory.create_default_account(GovernanceDetails::Monarchy { - monarch: self.admin_account_addr().unwrap().into_string(), - }).unwrap(); - let account_id = account.id().unwrap(); - AccountOdds { - account_id, - odds: Decimal::from_str("1").unwrap(), - } - }).collect::>(); + let account_ids = (0..x) + .map(|_| { + let account = self + .abstr + .account_factory + .create_default_account(GovernanceDetails::Monarchy { + monarch: self.admin_account_addr().unwrap().into_string(), + }) + .unwrap(); + let account_id = account.id().unwrap(); + AccountOdds { + account_id, + odds: Decimal::from_str("1").unwrap(), + } + }) + .collect::>(); self.manual_add_teams_to_round(round_id, account_ids)?; @@ -184,13 +194,19 @@ impl BetEnv { } fn manual_add_teams_to_round(&self, round_id: RoundId, teams: Vec) -> AResult<()> { - self.bet.call_as(&self.admin_account_addr()?).update_accounts(round_id, teams, vec![])?; + self.bet + .call_as(&self.admin_account_addr()?) + .update_accounts(round_id, teams, vec![])?; Ok(()) } fn create_test_round(&self) -> AResult { - self.bet.call_as(&self.admin_account_addr()?).create_round(AssetEntry::new(BET_TOKEN_ANS_ID), "test".to_string(), "test".to_string())?; + self.bet.call_as(&self.admin_account_addr()?).create_round( + AssetEntry::new(BET_TOKEN_ANS_ID), + "test".to_string(), + "test".to_string(), + )?; let rounds = self.bet.list_rounds(None, None)?; @@ -199,8 +215,14 @@ impl BetEnv { Ok(last_round.id) } // admin execute on round - fn execute_as_account_on_round(&self, account: AbstractAccount, msg: BetExecuteMsg) -> AResult<()> { - account.manager.execute_on_module(BET_APP_ID, app::ExecuteMsg::<_, Empty>::Module(msg))?; + fn execute_as_account_on_round( + &self, + account: AbstractAccount, + msg: BetExecuteMsg, + ) -> AResult<()> { + account + .manager + .execute_on_module(BET_APP_ID, app::ExecuteMsg::<_, Empty>::Module(msg))?; Ok(()) } @@ -211,19 +233,25 @@ impl BetEnv { Ok(()) } - fn bet_on_round_as(&self, sender: Addr, round_id: RoundId, account_id: AccountId, amount: u128) -> AResult<()> { + fn bet_on_round_as( + &self, + sender: Addr, + round_id: RoundId, + account_id: AccountId, + amount: u128, + ) -> AResult<()> { let bet = Bet { account_id, asset: AnsAsset::new(BET_TOKEN_ANS_ID, amount), }; - self.bet.call_as(&sender).place_bet(bet, round_id, &coins(amount, BET_TOKEN_DENOM))?; + self.bet + .call_as(&sender) + .place_bet(bet, round_id, &coins(amount, BET_TOKEN_DENOM))?; Ok(()) } } - - #[test] fn test_init_config() -> AResult { let test_env = BetEnv::setup(None)?; @@ -232,7 +260,6 @@ fn test_init_config() -> AResult { assert_that!(config.rake).is_equal_to(Decimal::percent(DEFAULT_RAKE_PERCENT)); - Ok(()) } @@ -247,12 +274,14 @@ fn test_create_round() -> AResult { assert_that!(rounds.rounds).has_length(1); let RoundResponse { - id, name, + id, + name, description, teams, status, - bet_count, total_bet, - } = rounds.rounds[0].clone(); + bet_count, + total_bet, + } = rounds.rounds[0].clone(); assert_that!(id).is_equal_to(0); assert_that!(name).is_equal_to("test".to_string()); @@ -262,17 +291,14 @@ fn test_create_round() -> AResult { assert_that!(total_bet).is_equal_to(AnsAsset::new(BET_TOKEN_ANS_ID.to_string(), 0u128)); assert_that!(bet_count).is_equal_to(0); - Ok(()) } - - #[test] fn test_create_round_with_teams() -> AResult { let env = BetEnv::setup(None)?; - let round_id= env.create_test_round()?; + let round_id = env.create_test_round()?; env.add_x_teams_to_round(round_id, 10)?; @@ -286,7 +312,7 @@ fn test_create_round_with_teams() -> AResult { fn test_create_round_with_mini_bets() -> AResult { let env = BetEnv::setup(None)?; - let round_id= env.create_test_round()?; + let round_id = env.create_test_round()?; env.add_x_teams_to_round(round_id, 2)?; @@ -296,8 +322,8 @@ fn test_create_round_with_mini_bets() -> AResult { let better = Addr::unchecked("account"); let bet_amount = 100; - - env.env.set_balance(&better, coins(bet_amount, BET_TOKEN_DENOM))?; + env.env + .set_balance(&better, coins(bet_amount, BET_TOKEN_DENOM))?; let betting_on = AccountId::local(2); @@ -313,7 +339,7 @@ fn test_create_round_with_mini_bets() -> AResult { fn test_create_round_with_two_teams() -> AResult { let env = BetEnv::setup(None)?; - let round_id= env.create_test_round()?; + let round_id = env.create_test_round()?; // create 2 accounts let mut new_acc_ids = env.create_x_accounts(2)?; @@ -321,7 +347,6 @@ fn test_create_round_with_two_teams() -> AResult { let team_1 = new_acc_ids.swap_remove(0); let team_2 = new_acc_ids.swap_remove(0); - env.add_team_to_round(round_id, team_1.clone(), Decimal::from_str("1").unwrap())?; env.add_team_to_round(round_id, team_2.clone(), Decimal::from_str("1").unwrap())?; @@ -331,8 +356,8 @@ fn test_create_round_with_two_teams() -> AResult { let better = Addr::unchecked("account"); let bet_amount = 100000000; - env.env.set_balance(&better, coins(bet_amount * 5999, BET_TOKEN_DENOM))?; - + env.env + .set_balance(&better, coins(bet_amount * 5999, BET_TOKEN_DENOM))?; env.bet_on_round_as(better.clone(), round_id, team_1, bet_amount)?; println!("odds_list 2: {:?}", odds_list.odds); @@ -345,20 +370,18 @@ fn test_create_round_with_two_teams() -> AResult { Ok(()) } - #[test] fn test_create_round_with_three_teams() -> AResult { let env = BetEnv::setup(None)?; - let round_id= env.create_test_round()?; + let round_id = env.create_test_round()?; // create 3 accounts let mut new_acc_ids = env.create_x_accounts(3)?; let team_1 = new_acc_ids.get(0).unwrap().clone(); - let team_2 = new_acc_ids.get(1).unwrap().clone(); - let team_3 = new_acc_ids.get(2).unwrap().clone(); - + let team_2 = new_acc_ids.get(1).unwrap().clone(); + let team_3 = new_acc_ids.get(2).unwrap().clone(); env.add_team_to_round(round_id, team_1.clone(), Decimal::from_str("1").unwrap())?; env.add_team_to_round(round_id, team_2.clone(), Decimal::from_str("1").unwrap())?; @@ -368,7 +391,8 @@ fn test_create_round_with_three_teams() -> AResult { println!("initial odds: {:?}", odds_list.odds); let better = Addr::unchecked("account"); - env.env.set_balance(&better, coins(5005050 * 5999, BET_TOKEN_DENOM))?; + env.env + .set_balance(&better, coins(5005050 * 5999, BET_TOKEN_DENOM))?; let bet_amount = 125000000; env.bet_on_round_as(better.clone(), round_id, team_1, bet_amount)?; @@ -396,15 +420,14 @@ fn test_create_round_with_three_teams() -> AResult { fn test_create_round_with_three_teams_and_claim() -> AResult { let env = BetEnv::setup(None)?; - let round_id= env.create_test_round()?; + let round_id = env.create_test_round()?; // create 3 accounts let mut new_acc_ids = env.create_x_accounts(3)?; let team_1 = new_acc_ids.get(0).unwrap().clone(); - let team_2 = new_acc_ids.get(1).unwrap().clone(); - let team_3 = new_acc_ids.get(2).unwrap().clone(); - + let team_2 = new_acc_ids.get(1).unwrap().clone(); + let team_3 = new_acc_ids.get(2).unwrap().clone(); env.add_team_to_round(round_id, team_1.clone(), Decimal::from_str("1").unwrap())?; env.add_team_to_round(round_id, team_2.clone(), Decimal::from_str("1").unwrap())?; @@ -415,8 +438,10 @@ fn test_create_round_with_three_teams_and_claim() -> AResult { let loser = Addr::unchecked("loser"); let winner = Addr::unchecked("winner"); - env.env.set_balance(&loser, coins(200000000, BET_TOKEN_DENOM))?; - env.env.set_balance(&winner, coins(200000000, BET_TOKEN_DENOM))?; + env.env + .set_balance(&loser, coins(200000000, BET_TOKEN_DENOM))?; + env.env + .set_balance(&winner, coins(200000000, BET_TOKEN_DENOM))?; let bet_amount = 125000000; env.bet_on_round_as(loser.clone(), round_id, team_1, bet_amount)?; @@ -437,7 +462,9 @@ fn test_create_round_with_three_teams_and_claim() -> AResult { assert_that!(odds_for_potential_winning_team).is_equal_to(Decimal::from_str("1.8").unwrap()); // set the winner - env.bet.call_as(&env.admin_account_addr()?).close_round(round_id, Some(team_2))?; + env.bet + .call_as(&env.admin_account_addr()?) + .close_round(round_id, Some(team_2))?; env.bet.distribute_winnings(round_id)?; let loser_balance = env.env.query_balance(&loser, BET_TOKEN_DENOM)?; @@ -458,15 +485,14 @@ fn test_create_round_with_three_teams_and_claim() -> AResult { fn test_create_round_with_three_teams_and_claim_multiple_winners() -> AResult { let env = BetEnv::setup(None)?; - let round_id= env.create_test_round()?; + let round_id = env.create_test_round()?; // create 3 accounts let mut new_acc_ids = env.create_x_accounts(3)?; let team_1 = new_acc_ids.get(0).unwrap().clone(); - let team_2 = new_acc_ids.get(1).unwrap().clone(); - let team_3 = new_acc_ids.get(2).unwrap().clone(); - + let team_2 = new_acc_ids.get(1).unwrap().clone(); + let team_3 = new_acc_ids.get(2).unwrap().clone(); env.add_team_to_round(round_id, team_1.clone(), Decimal::from_str("1").unwrap())?; env.add_team_to_round(round_id, team_2.clone(), Decimal::from_str("1").unwrap())?; @@ -478,9 +504,12 @@ fn test_create_round_with_three_teams_and_claim_multiple_winners() -> AResult { let loser = Addr::unchecked("loser"); let winner_1 = Addr::unchecked("winner_1"); let winner_2 = Addr::unchecked("winner_2"); - env.env.set_balance(&loser, coins(200000000, BET_TOKEN_DENOM))?; - env.env.set_balance(&winner_1, coins(200000000, BET_TOKEN_DENOM))?; - env.env.set_balance(&winner_2, coins(200000000, BET_TOKEN_DENOM))?; + env.env + .set_balance(&loser, coins(200000000, BET_TOKEN_DENOM))?; + env.env + .set_balance(&winner_1, coins(200000000, BET_TOKEN_DENOM))?; + env.env + .set_balance(&winner_2, coins(200000000, BET_TOKEN_DENOM))?; let bet_amount = 125000000; env.bet_on_round_as(loser.clone(), round_id, team_1, bet_amount)?; @@ -506,12 +535,14 @@ fn test_create_round_with_three_teams_and_claim_multiple_winners() -> AResult { assert_that!(odds_for_potential_winning_team).is_equal_to(Decimal::from_str("1.35").unwrap()); // set the winner - env.bet.call_as(&env.admin_account_addr()?).close_round(round_id, Some(team_2.clone()))?; - + env.bet + .call_as(&env.admin_account_addr()?) + .close_round(round_id, Some(team_2.clone()))?; let round = env.bet.round(round_id)?; - assert_that!(round.status).is_equal_to(RoundStatus::Closed { winning_team: Some(team_2) }); - + assert_that!(round.status).is_equal_to(RoundStatus::Closed { + winning_team: Some(team_2), + }); // distribute the winnings env.bet.distribute_winnings(round_id)?; @@ -527,7 +558,6 @@ fn test_create_round_with_three_teams_and_claim_multiple_winners() -> AResult { let round = env.bet.round(round_id)?; assert_that!(round.status).is_equal_to(RoundStatus::RewardsDistributed {}); - Ok(()) } @@ -535,15 +565,14 @@ fn test_create_round_with_three_teams_and_claim_multiple_winners() -> AResult { fn test_draw() -> AResult { let env = BetEnv::setup(None)?; - let round_id= env.create_test_round()?; + let round_id = env.create_test_round()?; // create 3 accounts let mut new_acc_ids = env.create_x_accounts(3)?; let team_1 = new_acc_ids.get(0).unwrap().clone(); - let team_2 = new_acc_ids.get(1).unwrap().clone(); - let team_3 = new_acc_ids.get(2).unwrap().clone(); - + let team_2 = new_acc_ids.get(1).unwrap().clone(); + let team_3 = new_acc_ids.get(2).unwrap().clone(); env.add_team_to_round(round_id, team_1.clone(), Decimal::from_str("1").unwrap())?; env.add_team_to_round(round_id, team_2.clone(), Decimal::from_str("1").unwrap())?; @@ -554,8 +583,10 @@ fn test_draw() -> AResult { let draw_1 = Addr::unchecked("dd"); let draw_2 = Addr::unchecked("ddd"); - env.env.set_balance(&draw_1, coins(125000000, BET_TOKEN_DENOM))?; - env.env.set_balance(&draw_2, coins(200000000, BET_TOKEN_DENOM))?; + env.env + .set_balance(&draw_1, coins(125000000, BET_TOKEN_DENOM))?; + env.env + .set_balance(&draw_2, coins(200000000, BET_TOKEN_DENOM))?; let bet_amount = 125000000; env.bet_on_round_as(draw_1.clone(), round_id, team_1, bet_amount)?; @@ -564,7 +595,9 @@ fn test_draw() -> AResult { env.bet_on_round_as(draw_2.clone(), round_id, team_2.clone(), bet_amount)?; // set the winner - env.bet.call_as(&env.admin_account_addr()?).close_round(round_id, None)?; + env.bet + .call_as(&env.admin_account_addr()?) + .close_round(round_id, None)?; let draw_1_balance = env.env.query_balance(&draw_1, BET_TOKEN_DENOM)?; assert_that!(draw_1_balance.u128()).is_equal_to(0); @@ -578,7 +611,5 @@ fn test_draw() -> AResult { let draw_2_balance = env.env.query_balance(&draw_2, BET_TOKEN_DENOM)?; assert_that!(draw_2_balance.u128()).is_equal_to(200000000); - Ok(()) } - diff --git a/modules/scripts/src/bin/deploy.rs b/modules/scripts/src/bin/deploy.rs index 42350fa33d..e9e49cfd4a 100644 --- a/modules/scripts/src/bin/deploy.rs +++ b/modules/scripts/src/bin/deploy.rs @@ -10,11 +10,12 @@ use std::net::TcpStream; use clap::Parser; use cw_orch::{ + daemon::{ChainKind, NetworkInfo}, deploy::Deploy, prelude::{ networks::{parse_network, ChainInfo, JUNO_1}, *, - }, daemon::{NetworkInfo, ChainKind}, + }, }; use tokio::runtime::Runtime; @@ -34,7 +35,6 @@ fn full_deploy() -> anyhow::Result<()> { .get_all_deployed_chains(); let networks: Vec = deployment.iter().map(|n| parse_network(n)).collect(); - for network in networks { let chain = DaemonBuilder::default() .handle(rt.handle())