Skip to content

Commit

Permalink
wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 14, 2024
1 parent 54dde39 commit da77786
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 23 deletions.
4 changes: 1 addition & 3 deletions contracts/cosmwasm/outpost/src/contract/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ pub fn query(deps: Deps, _env: Env, msg: msg::QueryMsg) -> Result<Binary> {
.and_then(|route| Ok(to_json_binary(&msg::GetIbcIcs20RouteResponse { route })?)),
GetExchangeById { exchange_id } => crate::state::exchange::get_by_id(deps, exchange_id)
.and_then(|exchange| Ok(to_json_binary(&msg::GetExchangeResponse { exchange })?)),
GetConfig {} => {
crate::state::get_config(deps).and_then(|config| Ok(to_json_binary(&config)?))
}
GetConfig {} => crate::state::get_config(deps).and_then(|x| Ok(to_json_binary(&x)?)),
GetAllAssetIds {} => crate::state::assets::get_all_assets(deps)
.and_then(|x| Ok(to_json_binary(&x)?))
.map_err(Into::into),
Expand Down
27 changes: 20 additions & 7 deletions contracts/cosmwasm/outpost/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{error::ContractError, prelude::*};

use cosmwasm_std::{StdResult, Storage};

use cvm_route::asset;
use cvm_runtime::outpost::GetConfigResponse;
use cw_storage_plus::Item;

Expand All @@ -23,13 +24,25 @@ pub(crate) fn save(storage: &mut dyn Storage, value: &HereItem) -> StdResult<()>

pub(crate) fn get_config(deps: cosmwasm_std::Deps<'_>) -> Result<GetConfigResponse, ContractError> {
use crate::state::*;
let network_to_networks = network::get_all_network_to_network(deps)?;
deps.api.debug("got networks to networks");
let exchanges = exchange::get_all_exchanges(deps)?;
Ok(GetConfigResponse {
network_to_networks: network::get_all_network_to_network(deps)?,
assets: assets::get_all_assets(deps)?,
deps.api.debug("got exchanges");
let assets = assets::get_all_assets(deps)?;
deps.api.debug("got assets");
let networks = network::get_all_networks(deps)?;
deps.api.debug("got networks");
let network_assets = assets::get_all_network_assets(deps)?;
deps.api.debug("got network assets");
let asset_venue_items = exchange::get_all_exchange_venues(deps)?;
deps.api.debug("got asset venue items");
let get_config_response = GetConfigResponse {
network_to_networks,
assets,
exchanges,
networks: network::get_all_networks(deps)?,
network_assets: assets::get_all_network_assets(deps)?,
asset_venue_items: exchange::get_all_exchange_venues(deps)?,
})
networks,
network_assets,
asset_venue_items,
};
Ok(get_config_response)
}
12 changes: 10 additions & 2 deletions mantis/node/src/bin/mantis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,21 @@ async fn main() {
}
},
},
MantisCommands::Glt(_) => todo!(),
MantisCommands::Glt(x) => match &x.command {
GltCommands::Validate => todo!(),
GltCommands::Plan => todo!(),
GltCommands::Add => todo!(),
GltCommands::Get(args) => {
let mut wasm_read_client = create_wasm_query_client(&args.grpc_centauri).await;
let cvm_glt = get_cvm_glt(&args.cvm_contract, &mut wasm_read_client).await;
println!("{:?}", cvm_glt);
}
},
}
}

async fn solve_orders(solver_args: &SolverArgs) {
let args = &solver_args.shared;
let _wasm_read_client = create_wasm_query_client(&args.grpc_centauri).await;

let signer = mantis_node::mantis::cosmos::signer::from_mnemonic(
args.wallet.as_str(),
Expand Down
15 changes: 12 additions & 3 deletions mantis/node/src/mantis/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub enum GltCommands {
Plan,
/// adds specific things to offchain config
Add,
Get(GltGetArgs),
}

#[derive(Debug, Parser)]
Expand All @@ -57,7 +58,7 @@ pub enum AssetCommands {
}

#[derive(clap::Parser, Debug)]
pub struct SharedArgs {
pub struct SolverSharedArgs {
/// chain id of order contract
#[arg(long)]
pub main_chain_id: String,
Expand All @@ -84,7 +85,7 @@ pub struct SharedArgs {
#[derive(clap::Parser, Debug)]
pub struct SimulateArgs {
#[command(flatten)]
pub shared: SharedArgs,
pub shared: SolverSharedArgs,

/// CVM contract on Centauri. Optional, only if consider routing via cross chain CVM.
#[arg(long)]
Expand All @@ -103,7 +104,7 @@ pub struct SimulateArgs {
#[derive(clap::Parser, Debug)]
pub struct SolverArgs {
#[command(flatten)]
pub shared: SharedArgs,
pub shared: SolverSharedArgs,

/// CVM contract if interchain solving via CVM enabled
#[arg(long)]
Expand All @@ -118,6 +119,14 @@ pub struct SolverArgs {
pub no_cows: bool,
}

#[derive(clap::Parser, Debug)]
pub struct GltGetArgs {
#[arg(long)]
pub cvm_contract: String,

#[arg(long)]
pub grpc_centauri: String,
}
impl MantisArgs {
pub fn parsed() -> Self {
Self::parse()
Expand Down
2 changes: 1 addition & 1 deletion mantis/node/src/mantis/cosmos/cosmwasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub async fn smart_query<T: serde::ser::Serialize, O: serde::de::DeserializeOwne
let result = read
.smart_contract_state(orders_request)
.await
.expect("result obtained")
.expect("why cannot execute?")
.into_inner()
.data;
serde_json_wasm::from_slice(&result).expect("result parsed")
Expand Down
9 changes: 3 additions & 6 deletions mantis/node/src/mantis/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ pub async fn get_active_orders(
tip: &Tip,
) -> Vec<OrderItem> {
let query = cw_mantis_order::QueryMsg::GetAllOrders {};
let all_orders = smart_query::<_, Vec<OrderItem>>(order_contract, query, cosmos_query_client)
smart_query::<_, Vec<OrderItem>>(order_contract, query, cosmos_query_client)
.await
.into_iter()
.filter(|x| x.msg.timeout > tip.block.value())
.collect::<Vec<OrderItem>>();
println!("all_orders: {:?}", all_orders);
all_orders
.collect::<Vec<OrderItem>>()
}

pub async fn get_stale_orders(
Expand All @@ -38,6 +36,5 @@ pub async fn get_cvm_glt(
cosmos_query_client: &mut CosmWasmReadClient,
) -> GetConfigResponse {
let query = cvm_runtime::outpost::QueryMsg::GetConfig {};
let cvm_glt = smart_query::<_, GetConfigResponse>(contract, query, cosmos_query_client).await;
cvm_glt
smart_query::<_, GetConfigResponse>(contract, query, cosmos_query_client).await
}
1 change: 0 additions & 1 deletion mantis/node/tests/cvms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ async fn cvm_devnet_case() {
.wrap()
.query_wasm_smart(cw_cvm_outpost_contract, &query)
.unwrap();
//panic!("{:?}", cvm_glt);
centauri
.execute_contract(
sender.clone(),
Expand Down

0 comments on commit da77786

Please sign in to comment.