-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec87d7d
commit 51fc78b
Showing
2 changed files
with
36 additions
and
36 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,40 @@ | ||
#[cfg(not(feature = "library"))] | ||
pub mod contract; | ||
use cosmwasm_std::entry_point; | ||
use cosmwasm_std::{ | ||
to_vec, ContractResult, Deps, DepsMut, Empty, Env, MessageInfo, QueryRequest, QueryResponse, | ||
Response, StdError, StdResult, SystemResult, | ||
}; | ||
|
||
pub const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME"); | ||
pub const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
|
||
#[cfg(not(feature = "library"))] | ||
#[entry_point] | ||
pub fn instantiate( | ||
deps: DepsMut, | ||
_env: Env, | ||
_info: MessageInfo, | ||
_msg: Empty, | ||
) -> StdResult<Response> { | ||
cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; | ||
|
||
Ok(Response::new()) | ||
} | ||
|
||
#[cfg(not(feature = "library"))] | ||
#[entry_point] | ||
pub fn query(deps: Deps, _env: Env, msg: QueryRequest<Empty>) -> StdResult<QueryResponse> { | ||
let req_bin = to_vec(&msg).map_err(|serialize_err| { | ||
StdError::generic_err(format!("Serializing QueryRequest: {serialize_err}")) | ||
})?; | ||
|
||
match deps.querier.raw_query(&req_bin) { | ||
SystemResult::Err(system_err) => Err(StdError::generic_err(format!( | ||
"Querier system error: {system_err}" | ||
))), | ||
SystemResult::Ok(ContractResult::Err(contract_err)) => Err(StdError::generic_err(format!( | ||
"Querier contract error: {contract_err}" | ||
))), | ||
SystemResult::Ok(ContractResult::Ok(value)) => Ok(value), | ||
} | ||
} |