Skip to content

Commit

Permalink
fixing route builder compile
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Mar 25, 2024
1 parent 88b942a commit d85f18e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
17 changes: 10 additions & 7 deletions mantis/node/src/mantis/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ pub enum MantisCommands {
Glt(GltArgs),
}

#[derive(Debug, Subcommand)]
#[derive(Debug, Parser)]
pub struct GltArgs {
#[command(subcommand)]
pub command: GltCommands,
}

GltComands

#[derive(Debug, Subcommand)]
pub enum GltCommands {
// given offchain configuration, validates is
Validate
Validate,
// given offchain configuration and existing chains, plans apply
// outputs offline transaction to chains provided
Plan
Plan,
/// adds specific things to offchain config
Add
Add,
}


#[derive(Debug, Parser)]
Expand Down Expand Up @@ -78,7 +81,7 @@ pub struct SharedArgs {

#[derive(clap::Parser, Debug)]
pub struct SimulateArgs {
#[arg(flatten)]
#[command(flatten)]
pub shared: SharedArgs,

/// CVM contract on Centauri. Optional, only if consider routing via cross chain CVM.
Expand All @@ -98,7 +101,7 @@ pub struct SimulateArgs {

#[derive(clap::Parser, Debug)]
pub struct SolverArgs {
#[arg(flatten)]
#[command(flatten)]
pub shared: SharedArgs,

/// the problem to solve
Expand Down
19 changes: 10 additions & 9 deletions mantis/node/src/mantis/blackbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ impl BankInput {
}

/// given route and CVM stub with amount, build it to the end
fn build_next(current: &mut CvmProgram, next: &mut [NextItem]) -> CvmInstruction {
fn build_next(current: &mut CvmProgram, next: &mut [NextItem]) {
match next.split_first_mut() {
Some((head, rest)) => {
match head {
NextItem::Exchange(exchange) => {
let exchange = new_exchange(exchange);
current.instructions.push(CvmInstruction::Exchange(exchange));
build_next(current, rest)
build_next(current, rest);
},
NextItem::Spawn(spawn) => {
let spawn = new_spawn(spawn);
current.instructions.push(CvmInstruction::Spawn(spawn));
build_next(spawn.program, rest)
build_next(spawn.program, rest);
},
}
}
None => info!("no more routes"),
None => {
log::info!("no more routes");
},
}
}

Expand All @@ -57,7 +59,7 @@ async fn route(
glt: GetConfigResponse,
) -> CvmProgram {
let blackbox: Client = Client::new(server);
let route = blackbox
let mut route = blackbox
.simulator_router_simulator_router_get(
&InAssetAmount::Variant0(input.in_asset_amount.0.try_into().expect("in_asset_amount")),
&InAssetId::Variant1(input.in_asset_id.to_string()),
Expand All @@ -67,10 +69,9 @@ async fn route(
)
.await
.expect("route found")
.into_inner()
.get(0).expect("at least one route");
.into_inner().pop().expect("at least one route");

let mut program = CvmProgram::new();
build_next(&mut current, &mut route.next);
let mut program = CvmProgram::default();
build_next(&mut program, &mut route.next);
return program;
}
6 changes: 3 additions & 3 deletions mantis/node/src/mantis/solve.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmrs::tendermint::block::Height;
use cw_mantis_order::{OrderItem, OrderSolution, OrderSubMsg};
use cw_mantis_order::{CrossChainPart, OrderAmount, OrderItem, OrderSolution, OrderSubMsg};

use crate::{
prelude::*,
Expand Down Expand Up @@ -53,8 +53,8 @@ pub fn do_cows(all_orders: Vec<OrderItem>) -> SolutionsPerPair {
let filled = x.amount_out.to_u128().expect("u128");
OrderSolution {
order_id: x.id,
cow_out_amount: filled.into(),
out_asset_amount: 0u128.into(),
cow_out_amount: filled.into(),
cross_chain_part: Some(OrderAmount::All),
}
})
.collect::<Vec<_>>();
Expand Down

0 comments on commit d85f18e

Please sign in to comment.