Skip to content

Commit

Permalink
feat: incentives module status query
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Nov 7, 2023
1 parent 0e81237 commit 9def096
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/neutron_incentives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ serde = { version = "1.0.180", default-features = false, features = ["derive"] }
serde-json-wasm = { version = "0.5.1" }
cw-storage-plus = { version = "1.1.0", features = ["iterator"]}
cosmos-sdk-proto = { version = "0.16.0", default-features = false }
neutron-sdk = { package = "neutron-sdk",git = "https://github.com/neutron-org/neutron-sdk.git", rev = "3c1861118cdc3899bb3a6d81e7eb00163eb28b84" }
neutron-sdk = { package = "neutron-sdk",git = "https://github.com/neutron-org/neutron-sdk.git", rev = "b5207f78a2cdc9ed5a191e9026d8ccadc729550d" }

base64 = "0.21.2"
protobuf = { version = "3.2.0", features = ["with-bytes"] }
Expand Down
56 changes: 37 additions & 19 deletions contracts/neutron_incentives/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult};
use cosmwasm_std::{
to_binary, Binary, Coin, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult,
};
use cw2::set_contract_version;

use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use neutron_sdk::bindings::msg::NeutronMsg;
use neutron_sdk::bindings::query::NeutronQuery;
use neutron_sdk::bindings::msg::{NeutronMsg, Unstake, UnstakeDescriptor};
use neutron_sdk::bindings::query::{IncentivesQuery, ModuleStatusResponse, NeutronQuery};
use neutron_sdk::NeutronResult;

const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME"));
Expand All @@ -46,7 +48,9 @@ pub fn execute(
deps.api
.debug(format!("WASMDEBUG: execute: received msg: {:?}", msg).as_str());
match msg {
ExecuteMsg::AddToGauge { gauge_id, rewards } => execute_add_to_gauge(deps, env, gauge_id, rewards),
ExecuteMsg::AddToGauge { gauge_id, rewards } => {
execute_add_to_gauge(deps, env, gauge_id, rewards)
}
ExecuteMsg::Stake { coins } => execute_stake(deps, env, coins),
ExecuteMsg::Unstake { unstakes } => execute_unstake(deps, env, unstakes),
}
Expand All @@ -55,38 +59,39 @@ pub fn execute(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps<NeutronQuery>, env: Env, msg: QueryMsg) -> NeutronResult<Binary> {
match msg {
QueryMsg::ModuleState {} => query_module_state(deps, env),
QueryMsg::ModuleStatus {} => query_module_status(deps, env),
QueryMsg::GaugeByID { id } => query_gauge_by_id(deps, env, id),
QueryMsg::Gauges { status, denom } => query_gauges(deps, env, status, denom),
QueryMsg::StakeByID { stake_id } => query_stake_by_id(deps, env, stake_id),
QueryMsg::Stakes { owner } => query_stakes(deps, env),
QueryMsg::Stakes { owner } => query_stakes(deps, env, owner),
}
}

fn query_module_state(deps: Deps<NeutronQuery>, env: Env) -> NeutronResult<Binary> {
todo!()
fn query_module_status(deps: Deps<NeutronQuery>, env: Env) -> NeutronResult<Binary> {
let query = NeutronQuery::Incentives(IncentivesQuery::ModuleStatus {});

let res: ModuleStatusResponse = deps.querier.query(&query.into())?;
Ok(to_binary(&res)?)
}

fn query_gauge_by_id(deps: Deps<NeutronQuery>, env: Env, gauge_id: u64) -> NeutronResult<Binary> {
todo!()
}

fn query_gauges(deps: Deps<NeutronQuery>, env: Env, status: String, denom: String) -> NeutronResult<Binary> {
fn query_gauges(
deps: Deps<NeutronQuery>,
env: Env,
status: String,
denom: String,
) -> NeutronResult<Binary> {
todo!()
}

fn query_stake_by_id(deps: Deps<NeutronQuery>, env: Env, stake_id: u64) -> NeutronResult<Binary> {
todo!()
}

pub fn query_stakes(_deps: Deps<NeutronQuery>, _env: Env) -> NeutronResult<Binary> {
// let query = NeutronQuery::InterchainAccountAddress {
// owner_address: env.contract.address.to_string(),
// interchain_account_id,
// connection_id,
// };

// Ok(to_binary(&res)?)
pub fn query_stakes(_deps: Deps<NeutronQuery>, _env: Env, owner: String) -> NeutronResult<Binary> {
todo!()
}

Expand All @@ -96,10 +101,23 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult<Response
Ok(Response::default())
}

fn execute_add_to_gauge(_deps: DepsMut, _env: Env, gauge_id: u64, rewards: Vec<Coin>) -> StdResult<Response<NeutronMsg>> {
fn execute_add_to_gauge(
_deps: DepsMut,
_env: Env,
gauge_id: u64,
rewards: Vec<Coin>,
) -> StdResult<Response<NeutronMsg>> {
todo!()
}
fn execute_add_to_stake(_deps: DepsMut, _env: Env) -> StdResult<Response<NeutronMsg>> {
fn execute_stake(_deps: DepsMut, _env: Env, coins: Vec<Coin>) -> StdResult<Response<NeutronMsg>> {
todo!()
}

fn execute_unstake(
_deps: DepsMut,
_env: Env,
unstakes: Vec<UnstakeDescriptor>,
) -> StdResult<Response<NeutronMsg>> {
todo!()
}

Expand Down
15 changes: 4 additions & 11 deletions contracts/neutron_incentives/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,15 @@ pub struct InstantiateMsg {}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
AddToGauge {
gauge_id: u64,
rewards: Vec<Coin>,
},
Stake {
coins: Vec<Coin>,
},
Unstake {
unstakes: Vec<UnstakeDescriptor>
},
AddToGauge { gauge_id: u64, rewards: Vec<Coin> },
Stake { coins: Vec<Coin> },
Unstake { unstakes: Vec<UnstakeDescriptor> },
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
ModuleState {},
ModuleStatus {},
GaugeByID { id: u64 },
Gauges { status: String, denom: String },
StakeByID { stake_id: u64 },
Expand Down

0 comments on commit 9def096

Please sign in to comment.