Skip to content

Commit

Permalink
add ownership check utility
Browse files Browse the repository at this point in the history
  • Loading branch information
blocksforked committed Mar 20, 2023
1 parent f73c015 commit bcca30a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub fn execute_finish(deps: DepsMut,
if _com!=None{
return Err(ContractError::Completed {});
}
//let transfer_results=handle_swap_transfers(&info.sender,&swap.creator,swap.clone())?;

let transfer_results= match msg.swap_type{
true => handle_swap_transfers(&swap.creator,&info.sender,swap.clone())?,
false=> handle_swap_transfers(&info.sender,&swap.creator,swap.clone())?,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ mod error;
mod integration_test;
pub mod msg;
pub mod state;

pub mod utils;
pub use crate::error::ContractError;
22 changes: 22 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use cosmwasm_std::{
to_binary, Addr, Binary, Deps, DepsMut, Env, QueryRequest, StdError, StdResult, WasmQuery,

Check warning on line 2 in src/utils.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused imports: `Binary`, `Deps`, `Env`, `StdResult`
};
use cw721_base::{Extension, QueryMsg as Cw721QueryMsg};

Check warning on line 4 in src/utils.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `Extension`
use cw721::OwnerOfResponse;

pub fn query_name_owner(
id: &str,
cw721: &Addr,
deps: &DepsMut,
) -> Result<OwnerOfResponse, StdError> {
let query_msg = Cw721QueryMsg::OwnerOf {
token_id: id.to_owned(),
include_expired: None,
};
let req = QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: cw721.to_string(),
msg: to_binary(&query_msg).unwrap(),
});
let res: OwnerOfResponse = deps.querier.query(&req)?;
Ok(res)
}

0 comments on commit bcca30a

Please sign in to comment.