Skip to content

Commit

Permalink
feat: move queries to the messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ratik committed Dec 14, 2023
1 parent ac15cc0 commit 2514fbc
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 39 deletions.
5 changes: 1 addition & 4 deletions contracts/core/src/bin/lido-core-schema.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use cosmwasm_schema::write_api;
use lido_staking_base::{
msg::core::{ExecuteMsg, InstantiateMsg, MigrateMsg},
state::core::QueryMsg,
};
use lido_staking_base::msg::core::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use cosmwasm_std::{
DepsMut, Env, MessageInfo, Response, StdResult, Uint128, WasmMsg,
};
use cw2::set_contract_version;
use lido_staking_base::msg::core::{ExecuteMsg, InstantiateMsg};
use lido_staking_base::msg::core::{ExecuteMsg, InstantiateMsg, QueryMsg};
use lido_staking_base::msg::token::ExecuteMsg as TokenExecuteMsg;
use lido_staking_base::state::core::{QueryMsg, CONFIG};
use lido_staking_base::state::core::CONFIG;
use neutron_sdk::{
bindings::{msg::NeutronMsg, query::NeutronQuery},
NeutronResult,
Expand Down
5 changes: 1 addition & 4 deletions contracts/token/src/bin/lido-token-schema.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use cosmwasm_schema::write_api;

use lido_staking_base::{
msg::token::{ExecuteMsg, InstantiateMsg, MigrateMsg},
state::token::QueryMsg,
};
use lido_staking_base::msg::token::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use cosmwasm_std::{
};

use lido_staking_base::{
msg::token::{ExecuteMsg, InstantiateMsg, MigrateMsg},
state::token::{ConfigResponse, QueryMsg, CORE_ADDRESS, DENOM},
msg::token::{ConfigResponse, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg},
state::token::{CORE_ADDRESS, DENOM},
};
use neutron_sdk::{
bindings::{msg::NeutronMsg, query::NeutronQuery},
Expand Down
13 changes: 11 additions & 2 deletions packages/base/src/msg/core.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Uint128;
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Decimal256, Uint128};

use crate::state::core::Config;

Expand All @@ -11,6 +11,15 @@ pub struct InstantiateMsg {
pub owner: String,
}

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
#[returns(Config)]
Config {},
#[returns(Decimal256)]
ExchangeRate {},
}

#[cw_serde]
pub enum ExecuteMsg {
Bond {},
Expand Down
15 changes: 14 additions & 1 deletion packages/base/src/msg/token.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::Uint128;

#[cosmwasm_schema::cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
#[returns(ConfigResponse)]
Config {},
}

#[cosmwasm_schema::cw_serde]
pub struct ConfigResponse {
pub core_address: String,
pub denom: String,
}

#[cw_serde]
pub enum ExecuteMsg {
Mint { amount: Uint128, receiver: String },
Expand Down
12 changes: 1 addition & 11 deletions packages/base/src/state/core.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::Decimal256;
use cosmwasm_schema::cw_serde;
use cw_storage_plus::Item;

#[cw_serde]
Expand All @@ -10,13 +9,4 @@ pub struct Config {
pub owner: String,
}

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
#[returns(Config)]
Config {},
#[returns(Decimal256)]
ExchangeRate {},
}

pub const CONFIG: Item<Config> = Item::new("config");
13 changes: 0 additions & 13 deletions packages/base/src/state/token.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
use cosmwasm_std::Addr;
use cw_storage_plus::Item;

#[cosmwasm_schema::cw_serde]
#[derive(cosmwasm_schema::QueryResponses)]
pub enum QueryMsg {
#[returns(ConfigResponse)]
Config {},
}

#[cosmwasm_schema::cw_serde]
pub struct ConfigResponse {
pub core_address: String,
pub denom: String,
}

pub const CORE_ADDRESS: Item<Addr> = Item::new("core");
pub const DENOM: Item<String> = Item::new("denom");

0 comments on commit 2514fbc

Please sign in to comment.