|
| 1 | +use cosmwasm_std::{ |
| 2 | + entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, |
| 3 | +}; |
| 4 | +use cw2::set_contract_version; |
| 5 | +use schemars::JsonSchema; |
| 6 | +use serde::{Deserialize, Serialize}; |
| 7 | + |
| 8 | +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] |
| 9 | +pub struct InstantiateMsg {} |
| 10 | + |
| 11 | +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] |
| 12 | +#[serde(rename_all = "snake_case")] |
| 13 | +pub enum ExecuteMsg {} |
| 14 | + |
| 15 | +use neutron_sdk::bindings::marketmap::query::MarketResponse; |
| 16 | +use neutron_sdk::bindings::{ |
| 17 | + marketmap::query::{LastUpdatedResponse, MarketMapQuery, MarketMapResponse, ParamsResponse}, |
| 18 | + msg::NeutronMsg, |
| 19 | + query::NeutronQuery, |
| 20 | +}; |
| 21 | + |
| 22 | +const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); |
| 23 | +const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); |
| 24 | + |
| 25 | +#[entry_point] |
| 26 | +pub fn instantiate( |
| 27 | + deps: DepsMut, |
| 28 | + _env: Env, |
| 29 | + _info: MessageInfo, |
| 30 | + _msg: InstantiateMsg, |
| 31 | +) -> StdResult<Response> { |
| 32 | + deps.api.debug("WASMDEBUG: instantiate"); |
| 33 | + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; |
| 34 | + Ok(Response::default()) |
| 35 | +} |
| 36 | + |
| 37 | +#[entry_point] |
| 38 | +pub fn execute( |
| 39 | + _deps: DepsMut, |
| 40 | + _env: Env, |
| 41 | + _info: MessageInfo, |
| 42 | + _msg: ExecuteMsg, |
| 43 | +) -> StdResult<Response<NeutronMsg>> { |
| 44 | + Ok(Default::default()) |
| 45 | +} |
| 46 | + |
| 47 | +#[entry_point] |
| 48 | +pub fn query(deps: Deps<NeutronQuery>, env: Env, msg: MarketMapQuery) -> StdResult<Binary> { |
| 49 | + query_marketmap(deps, env, msg) |
| 50 | +} |
| 51 | + |
| 52 | +fn query_marketmap(deps: Deps<NeutronQuery>, _env: Env, msg: MarketMapQuery) -> StdResult<Binary> { |
| 53 | + match msg { |
| 54 | + MarketMapQuery::Params { .. } => { |
| 55 | + let query_response: ParamsResponse = deps.querier.query(&msg.into())?; |
| 56 | + to_json_binary(&query_response) |
| 57 | + } |
| 58 | + MarketMapQuery::LastUpdated { .. } => { |
| 59 | + let query_response: LastUpdatedResponse = deps.querier.query(&msg.into())?; |
| 60 | + to_json_binary(&query_response) |
| 61 | + } |
| 62 | + MarketMapQuery::MarketMap { .. } => { |
| 63 | + let query_response: MarketMapResponse = deps.querier.query(&msg.into())?; |
| 64 | + to_json_binary(&query_response) |
| 65 | + } |
| 66 | + MarketMapQuery::Market { .. } => { |
| 67 | + let query_response: MarketResponse = deps.querier.query(&msg.into())?; |
| 68 | + to_json_binary(&query_response) |
| 69 | + } |
| 70 | + } |
| 71 | +} |
0 commit comments