diff --git a/contracts/core/src/contract.rs b/contracts/core/src/contract.rs index a6b8a271..8f4e75c7 100644 --- a/contracts/core/src/contract.rs +++ b/contracts/core/src/contract.rs @@ -2,7 +2,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{ attr, ensure, ensure_eq, ensure_ne, to_json_binary, Addr, Attribute, BankQuery, Binary, Coin, CosmosMsg, CustomQuery, Decimal, Deps, DepsMut, Env, MessageInfo, Order, QueryRequest, - Response, StdError, StdResult, SubMsg, Uint128, Uint64, WasmMsg, + Response, StdError, StdResult, Uint128, Uint64, WasmMsg, }; use cw_storage_plus::Bound; use drop_helpers::answer::response; @@ -24,9 +24,9 @@ use drop_staking_base::{ core::{ unbond_batches_map, Config, ConfigOptional, ContractState, Pause, UnbondBatch, UnbondBatchStatus, UnbondBatchStatusTimestamps, UnbondBatchesResponse, BOND_HOOKS, - BOND_PROVIDERS, BOND_PROVIDER_REPLY_ID, CONFIG, EXCHANGE_RATE, FAILED_BATCH_ID, FSM, - LAST_ICA_CHANGE_HEIGHT, LAST_IDLE_CALL, LAST_PUPPETEER_RESPONSE, LD_DENOM, - MAX_BOND_PROVIDERS, PAUSE, UNBOND_BATCH_ID, + BOND_PROVIDERS, CONFIG, EXCHANGE_RATE, FAILED_BATCH_ID, FSM, LAST_ICA_CHANGE_HEIGHT, + LAST_IDLE_CALL, LAST_PUPPETEER_RESPONSE, LD_DENOM, MAX_BOND_PROVIDERS, PAUSE, + UNBOND_BATCH_ID, }, validatorset::ValidatorInfo, withdrawal_voucher::{Metadata, Trait}, @@ -567,7 +567,6 @@ fn execute_tick_idle( let mut attrs = vec![attr("action", "tick_idle"), attr("knot", "000")]; let last_idle_call = LAST_IDLE_CALL.load(deps.storage)?; let mut messages = vec![]; - let mut sub_msgs = vec![]; cache_exchange_rate(deps.branch(), env.clone(), config)?; let addrs = drop_helpers::get_contracts!( deps, @@ -588,18 +587,15 @@ fn execute_tick_idle( if can_process_on_idle.unwrap_or(false) { attrs.push(attr("knot", "036")); // provider can process on idle attrs.push(attr("used_bond_provider", provider.to_string())); - let sub_msg = SubMsg::reply_on_error( - CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: provider.to_string(), - msg: to_json_binary( - &drop_staking_base::msg::bond_provider::ExecuteMsg::ProcessOnIdle {}, - )?, - funds: info.funds.clone(), - }), - BOND_PROVIDER_REPLY_ID, - ); + let msg = CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: provider.to_string(), + msg: to_json_binary( + &drop_staking_base::msg::bond_provider::ExecuteMsg::ProcessOnIdle {}, + )?, + funds: info.funds.clone(), + }); - sub_msgs.push(sub_msg); + messages.push(msg); FSM.go_to(deps.storage, ContractState::Peripheral)?; } @@ -782,9 +778,7 @@ fn execute_tick_idle( } } - Ok(response("execute-tick_idle", CONTRACT_NAME, attrs) - .add_messages(messages) - .add_submessages(sub_msgs)) + Ok(response("execute-tick_idle", CONTRACT_NAME, attrs).add_messages(messages)) } fn execute_tick_peripheral( @@ -983,7 +977,6 @@ fn execute_bond( let addrs = drop_helpers::get_contracts!(deps, config.factory_contract, token_contract); let Coin { amount, denom } = bonded_coin.clone(); let mut msgs = vec![]; - let mut sub_msgs = vec![]; let mut attrs = vec![attr("action", "bond")]; let exchange_rate = query_exchange_rate(deps.as_ref(), &config)?; attrs.push(attr("exchange_rate", exchange_rate.to_string())); @@ -1008,18 +1001,13 @@ fn execute_bond( )?; attrs.push(attr("issue_amount", issue_amount.to_string())); - let sub_msg = SubMsg::reply_on_error( - CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: provider.to_string(), - msg: to_json_binary( - &drop_staking_base::msg::bond_provider::ExecuteMsg::Bond {}, - )?, - funds: vec![Coin::new(amount.u128(), denom.clone())], - }), - BOND_PROVIDER_REPLY_ID, - ); + let msg = CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: provider.to_string(), + msg: to_json_binary(&drop_staking_base::msg::bond_provider::ExecuteMsg::Bond {})?, + funds: vec![Coin::new(amount.u128(), denom.clone())], + }); - sub_msgs.push(sub_msg); + msgs.push(msg); let receiver = receiver.clone().map_or( Ok::(info.sender.to_string()), @@ -1074,9 +1062,7 @@ fn execute_bond( } ); - Ok(response("execute-bond", CONTRACT_NAME, attrs) - .add_submessages(sub_msgs) - .add_messages(msgs)) + Ok(response("execute-bond", CONTRACT_NAME, attrs).add_messages(msgs)) } fn execute_update_config( diff --git a/contracts/core/src/tests.rs b/contracts/core/src/tests.rs index 54170259..8ada4502 100644 --- a/contracts/core/src/tests.rs +++ b/contracts/core/src/tests.rs @@ -23,10 +23,9 @@ use drop_staking_base::{ state::{ core::{ unbond_batches_map, Config, ConfigOptional, ContractState, Pause, UnbondBatch, - UnbondBatchStatus, UnbondBatchStatusTimestamps, BOND_HOOKS, BOND_PROVIDERS, - BOND_PROVIDER_REPLY_ID, CONFIG, FAILED_BATCH_ID, FSM, LAST_ICA_CHANGE_HEIGHT, - LAST_IDLE_CALL, LAST_PUPPETEER_RESPONSE, LD_DENOM, MAX_BOND_PROVIDERS, PAUSE, - UNBOND_BATCH_ID, + UnbondBatchStatus, UnbondBatchStatusTimestamps, BOND_HOOKS, BOND_PROVIDERS, CONFIG, + FAILED_BATCH_ID, FSM, LAST_ICA_CHANGE_HEIGHT, LAST_IDLE_CALL, LAST_PUPPETEER_RESPONSE, + LD_DENOM, MAX_BOND_PROVIDERS, PAUSE, UNBOND_BATCH_ID, }, puppeteer::{Delegations, DropDelegation}, }, @@ -445,17 +444,14 @@ fn test_execute_tick_idle_process_bondig_provider() { ] ) ) - .add_submessage(SubMsg::reply_on_error( - CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "lsm_provider_address".to_string(), - msg: to_json_binary( - &drop_staking_base::msg::bond_provider::ExecuteMsg::ProcessOnIdle {} - ) - .unwrap(), - funds: vec![], - }), - BOND_PROVIDER_REPLY_ID - )) + .add_message(CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: "lsm_provider_address".to_string(), + msg: to_json_binary( + &drop_staking_base::msg::bond_provider::ExecuteMsg::ProcessOnIdle {} + ) + .unwrap(), + funds: vec![], + })) ); } @@ -1659,18 +1655,13 @@ fn test_bond_wo_receiver() { .add_attribute("issue_amount", "1000") .add_attribute("receiver", "some") ) - .add_submessage(SubMsg::reply_on_error( - CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "native_provider_address".to_string(), - msg: to_json_binary( - &drop_staking_base::msg::bond_provider::ExecuteMsg::Bond {} - ) + .add_message(CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: "native_provider_address".to_string(), + msg: to_json_binary(&drop_staking_base::msg::bond_provider::ExecuteMsg::Bond {}) .unwrap(), - funds: vec![Coin::new(1000, "base_denom")], - }), - BOND_PROVIDER_REPLY_ID - )) - .add_submessage(SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { + funds: vec![Coin::new(1000, "base_denom")], + })) + .add_message(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "token_contract".to_string(), msg: to_json_binary(&drop_staking_base::msg::token::ExecuteMsg::Mint { amount: Uint128::from(1000u128), @@ -1678,7 +1669,7 @@ fn test_bond_wo_receiver() { }) .unwrap(), funds: vec![], - }))) + })) ); } @@ -1740,18 +1731,13 @@ fn test_bond_with_receiver() { .add_attribute("receiver", "receiver") .add_attribute("ref", "ref") ) - .add_submessage(SubMsg::reply_on_error( - CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: "native_provider_address".to_string(), - msg: to_json_binary( - &drop_staking_base::msg::bond_provider::ExecuteMsg::Bond {} - ) + .add_message(CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: "native_provider_address".to_string(), + msg: to_json_binary(&drop_staking_base::msg::bond_provider::ExecuteMsg::Bond {}) .unwrap(), - funds: vec![Coin::new(1000, "base_denom")], - }), - BOND_PROVIDER_REPLY_ID - )) - .add_submessage(SubMsg::new(CosmosMsg::Wasm(WasmMsg::Execute { + funds: vec![Coin::new(1000, "base_denom")], + })) + .add_message(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: "token_contract".to_string(), msg: to_json_binary(&drop_staking_base::msg::token::ExecuteMsg::Mint { amount: Uint128::from(1000u128), @@ -1759,7 +1745,7 @@ fn test_bond_with_receiver() { }) .unwrap(), funds: vec![], - }))) + })) ); } diff --git a/packages/base/src/state/core.rs b/packages/base/src/state/core.rs index e6f510e3..668d61c6 100644 --- a/packages/base/src/state/core.rs +++ b/packages/base/src/state/core.rs @@ -146,7 +146,6 @@ pub struct Pause { pub unbond: bool, pub tick: bool, } -pub const BOND_PROVIDER_REPLY_ID: u64 = 1; pub const MAX_BOND_PROVIDERS: u64 = 10; pub const FSM: Fsm = Fsm::new("machine_state", TRANSITIONS);