Skip to content

Commit

Permalink
upd sudo msg
Browse files Browse the repository at this point in the history
  • Loading branch information
quasisamurai committed Sep 15, 2023
1 parent 40b016d commit 8832c7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
17 changes: 5 additions & 12 deletions contracts/before-send-hook/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::msg::{
BlockBeforeSendMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg, SudoResResponse,
TrackBeforeSendMsg,
};
use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg, SudoResResponse};
use crate::state::{SUDO_RES_BLOCK, SUDO_RES_TRACK};
use cosmwasm_std::{
entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult,
Expand Down Expand Up @@ -41,12 +38,8 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
#[entry_point]
pub fn sudo(deps: DepsMut, _env: Env, msg: SudoMsg) -> StdResult<Response> {
match msg {
SudoMsg::TrackBeforeSendSudoMsg { track_before_send } => {
sudo_result_track_before(deps, track_before_send)
}
SudoMsg::BlockBeforeSendSudoMsg { block_before_send } => {
sudo_result_block_before(deps, block_before_send)
}
SudoMsg::TrackBeforeSend { .. } => sudo_result_track_before(deps),
SudoMsg::BlockBeforeSend { .. } => sudo_result_block_before(deps),
}
}

Expand All @@ -67,12 +60,12 @@ fn query_sudo_result_track_before(deps: Deps) -> StdResult<SudoResResponse> {
Ok(resp)
}

fn sudo_result_track_before(deps: DepsMut, _: TrackBeforeSendMsg) -> StdResult<Response> {
fn sudo_result_track_before(deps: DepsMut) -> StdResult<Response> {
SUDO_RES_TRACK.save(deps.storage, &true)?;
Ok(Response::new())
}

fn sudo_result_block_before(deps: DepsMut, _: BlockBeforeSendMsg) -> StdResult<Response> {
fn sudo_result_block_before(deps: DepsMut) -> StdResult<Response> {
SUDO_RES_BLOCK.save(deps.storage, &true)?;
Ok(Response::new())
}
12 changes: 8 additions & 4 deletions contracts/before-send-hook/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ pub enum QueryMsg {
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum SudoMsg {
BlockBeforeSendSudoMsg {
block_before_send: BlockBeforeSendMsg,
TrackBeforeSend {
from: String,
to: String,
amount: Coin,
},
TrackBeforeSendSudoMsg {
track_before_send: TrackBeforeSendMsg,
BlockBeforeSend {
from: String,
to: String,
amount: Coin,
},
}

Expand Down

0 comments on commit 8832c7c

Please sign in to comment.