Skip to content

Commit

Permalink
remove chain_key and signature for auth execute msg
Browse files Browse the repository at this point in the history
  • Loading branch information
shenao78 committed Jul 22, 2024
1 parent 9669498 commit b8e5ad5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
20 changes: 9 additions & 11 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub fn instantiate(
) -> Result<Response, ContractError> {
let state = State {
route: msg.route.clone(),
chain_key: msg.chain_key,
tokens: BTreeMap::default(),
handled_tickets: BTreeSet::default(),
handled_directives: BTreeSet::default(),
Expand All @@ -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)]
Expand All @@ -48,11 +47,9 @@ pub fn execute(
) -> Result<Response, ContractError> {
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,
Expand Down Expand Up @@ -87,9 +84,13 @@ pub mod execute {
info: MessageInfo,
seq: u64,
directive: Directive,
_sig: Vec<u8>,
) -> Result<Response, ContractError> {
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)
}) {
Expand All @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ mod tests {

let msg = InstantiateMsg {
route: Addr::unchecked("wasm1rptjktp9md9u2jcjsxe4ehg3pmz5hfxquklwvt"),
chain_key: vec![],
};
let cw_template_contract_addr = app
.instantiate_contract(
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ use crate::state::Token;
#[cw_serde]
pub struct InstantiateMsg {
pub route: Addr,
pub chain_key: Vec<u8>,
}

#[cw_serde]
pub enum ExecuteMsg {
ExecDirective {
seq: u64,
directive: Directive,
signature: Vec<u8>,
},
PrivilegeMintToken {
ticket_id: String,
Expand Down
1 change: 0 additions & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>,
pub tokens: BTreeMap<String, Token>,
pub handled_tickets: BTreeSet<String>,
pub handled_directives: BTreeSet<u64>,
Expand Down

0 comments on commit b8e5ad5

Please sign in to comment.