From d85f18e6fcfe93c02a8dfdec97ebb046f1190ee0 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Mon, 25 Mar 2024 17:04:00 +0000 Subject: [PATCH] fixing route builder compile --- mantis/node/src/mantis/args.rs | 17 ++++++++++------- mantis/node/src/mantis/blackbox/mod.rs | 19 ++++++++++--------- mantis/node/src/mantis/solve.rs | 6 +++--- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/mantis/node/src/mantis/args.rs b/mantis/node/src/mantis/args.rs index 50fb4129..ad771d86 100644 --- a/mantis/node/src/mantis/args.rs +++ b/mantis/node/src/mantis/args.rs @@ -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)] @@ -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. @@ -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 diff --git a/mantis/node/src/mantis/blackbox/mod.rs b/mantis/node/src/mantis/blackbox/mod.rs index 46337e3c..14d7911e 100644 --- a/mantis/node/src/mantis/blackbox/mod.rs +++ b/mantis/node/src/mantis/blackbox/mod.rs @@ -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"); + }, } } @@ -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()), @@ -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; } diff --git a/mantis/node/src/mantis/solve.rs b/mantis/node/src/mantis/solve.rs index d02f5ce7..683698d6 100644 --- a/mantis/node/src/mantis/solve.rs +++ b/mantis/node/src/mantis/solve.rs @@ -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::*, @@ -53,8 +53,8 @@ pub fn do_cows(all_orders: Vec) -> 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::>();