diff --git a/src/contract.rs b/src/contract.rs index 05fcfc0..1254c94 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -23,7 +23,6 @@ pub fn instantiate( ) -> Result { let state = State { route: msg.route.clone(), - chain_key: msg.chain_key, tokens: BTreeMap::default(), handled_tickets: BTreeSet::default(), handled_directives: BTreeSet::default(), @@ -36,7 +35,7 @@ pub fn instantiate( Ok(Response::new() .add_attribute("method", "instantiate") - .add_attribute("owner", msg.route)) + .add_attribute("route", msg.route)) } #[cfg_attr(not(feature = "library"), entry_point)] @@ -48,11 +47,9 @@ pub fn execute( ) -> Result { let contract = env.contract.address.clone(); let response = match msg { - ExecuteMsg::ExecDirective { - seq, - directive, - signature, - } => execute::exec_directive(deps, env, info, seq, directive, signature), + ExecuteMsg::ExecDirective { seq, directive } => { + execute::exec_directive(deps, env, info, seq, directive) + } ExecuteMsg::PrivilegeMintToken { ticket_id, token_id, @@ -87,9 +84,13 @@ pub mod execute { info: MessageInfo, seq: u64, directive: Directive, - _sig: Vec, ) -> Result { let mut response = Response::new(); + + if read_state(deps.storage, |s| s.route != info.sender) { + return Err(ContractError::Unauthorized); + } + if read_state(deps.storage, |state| { state.handled_directives.contains(&seq) }) { @@ -101,9 +102,6 @@ pub mod execute { token_id, name, } => { - if read_state(deps.storage, |s| s.route != info.sender) { - return Err(ContractError::Unauthorized); - } if read_state(deps.storage, |s| s.tokens.contains_key(&token_id)) { return Err(ContractError::TokenAleardyExist); } diff --git a/src/integration_tests.rs b/src/integration_tests.rs index 9667c85..a0d28a4 100644 --- a/src/integration_tests.rs +++ b/src/integration_tests.rs @@ -47,7 +47,6 @@ mod tests { let msg = InstantiateMsg { route: Addr::unchecked("wasm1rptjktp9md9u2jcjsxe4ehg3pmz5hfxquklwvt"), - chain_key: vec![], }; let cw_template_contract_addr = app .instantiate_contract( @@ -80,7 +79,6 @@ mod tests { settlement_chain: "Bitcoin".into(), name: "HOPE•YOU•GET•RICH".into(), }, - signature: vec![], }; let cosmos_msg = cw_template_contract.call(msg).unwrap(); app.execute(Addr::unchecked(USER), cosmos_msg).unwrap(); diff --git a/src/msg.rs b/src/msg.rs index 3118f27..ccbfd65 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -8,7 +8,6 @@ use crate::state::Token; #[cw_serde] pub struct InstantiateMsg { pub route: Addr, - pub chain_key: Vec, } #[cw_serde] @@ -16,7 +15,6 @@ pub enum ExecuteMsg { ExecDirective { seq: u64, directive: Directive, - signature: Vec, }, PrivilegeMintToken { ticket_id: String, diff --git a/src/state.rs b/src/state.rs index ec88607..1832b5b 100644 --- a/src/state.rs +++ b/src/state.rs @@ -9,7 +9,6 @@ use cw_storage_plus::Item; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct State { pub route: Addr, - pub chain_key: Vec, pub tokens: BTreeMap, pub handled_tickets: BTreeSet, pub handled_directives: BTreeSet,