Skip to content

Commit

Permalink
fixed clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 8, 2024
1 parent 0820eed commit e1ddb27
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 33 deletions.
14 changes: 7 additions & 7 deletions contracts/cosmwasm/order/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub mod order {
}

pub mod solution {
use crate::{prelude::*, Block, CowFillResult, DenomPair, SolutionItem};
use crate::{prelude::*, Block, CowFillResult, DenomPair};
use cosmwasm_std::Event;
use sylvia::types::ExecCtx;

Expand All @@ -72,23 +72,23 @@ pub mod solution {
block_added: Block,
) -> Event {
let solution_id = crate::types::solution_id(&(owner.to_string(), ab.clone(), block_added));
let solution_chosen = Event::new("mantis-solution-chosen")

Event::new("mantis-solution-chosen")
.add_attribute("token_a", ab.clone().a)
.add_attribute("token_b", ab.clone().b)
.add_attribute("solver_address", ctx.info.sender.to_string())
.add_attribute("cow_volume", cow_volume.to_string())
.add_attribute("cross_chain_volume", cross_chain_volume.to_string())
.add_attribute("total_transfers", transfers.len().to_string())
.add_attribute("solution_id", hex::encode(solution_id))
.add_attribute("solution_block_added", block_added.to_string());
solution_chosen
.add_attribute("solution_block_added", block_added.to_string())
}

pub fn mantis_solution_upserted(ab: &DenomPair, ctx: &ExecCtx<'_>) -> Event {
let solution_upserted = Event::new("mantis-solution-upserted")

Event::new("mantis-solution-upserted")
.add_attribute("token_a", ab.clone().a)
.add_attribute("token_b", ab.clone().b)
.add_attribute("solver_address", ctx.info.sender.to_string());
solution_upserted
.add_attribute("solver_address", ctx.info.sender.to_string())
}
}
35 changes: 18 additions & 17 deletions contracts/cosmwasm/order/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use types::*;
pub use crate::sv::{ExecMsg, QueryMsg};

use cosmwasm_std::{wasm_execute, Addr, BankMsg, Coin, Event, Order, StdError, Storage};
use cvm_runtime::shared::{CvmInstruction, CvmProgram};
use cvm_runtime::shared::{CvmProgram};
use cw_storage_plus::{Index, IndexList, IndexedMap, Item, Map};
use sylvia::{
contract,
Expand Down Expand Up @@ -117,8 +117,8 @@ impl OrderContract<'_> {
pub fn timeout(
&self,
ctx: ExecCtx,
orders: Vec<OrderId>,
solutions: Vec<Addr>,
_orders: Vec<OrderId>,
_solutions: Vec<Addr>,
) -> StdResult<Response> {
let orders: Result<Vec<(u128, OrderItem)>, _> = self
.orders
Expand Down Expand Up @@ -164,7 +164,7 @@ impl OrderContract<'_> {
&self,
_ctx: ExecCtx,
_orders: Vec<OrderId>,
solution: Option<Addr>,
_solution: Option<Addr>,
) -> StdResult<Response> {
todo!("remove order and send event")
}
Expand Down Expand Up @@ -261,7 +261,7 @@ impl OrderContract<'_> {
let at_least_one = all_orders.first().expect("at least one");

// normalize pair
let mut ab = DenomPair::new(
let ab = DenomPair::new(
at_least_one.given().denom.clone(),
at_least_one.wants().denom.clone(),
);
Expand Down Expand Up @@ -290,7 +290,7 @@ impl OrderContract<'_> {
// get all solution for pair
let all_solutions: Result<Vec<SolutionItem>, _> = self
.solutions
.prefix(ab.clone().into())
.prefix(ab.clone())
.range(ctx.deps.storage, None, None, Order::Ascending)
.map(|r| r.map(|(_, solution)| solution))
.collect();
Expand Down Expand Up @@ -424,16 +424,17 @@ impl OrderContract<'_> {
.add_event(solution_chosen))
}

fn start_solution(&self, mut ctx: ExecCtx<'_>, ab: DenomPair) -> Result<(), StdError> {
fn start_solution(&self, ctx: ExecCtx<'_>, ab: DenomPair) -> Result<(), StdError> {
if self
.pair_to_block
.load(ctx.deps.storage, ab.clone())
.is_err()
{
self.pair_to_block
.save(ctx.deps.storage, ab, &ctx.env.block.height)?;
};
Ok(
if self
.pair_to_block
.load(ctx.deps.storage, ab.clone())
.is_err()
{
self.pair_to_block
.save(ctx.deps.storage, ab, &ctx.env.block.height)?;
},
(),
)
}

Expand Down Expand Up @@ -533,9 +534,9 @@ impl OrderContract<'_> {
/// similar to `fill_local`, but instead of transfers via bank,
/// produced movement of movement funds to tracking,
/// but eventing and cleanup has same behavior
fn pre_fill_remotely<'a>(
fn pre_fill_remotely(
&self,
ctx: ExecCtx<'a>,
ctx: ExecCtx<'_>,
_optimal_price: Ratio,
solver_address: String,
solution_id: SolutionHash,
Expand Down
2 changes: 1 addition & 1 deletion contracts/cosmwasm/order/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use cosmwasm_schema::cw_serde;
pub use cosmwasm_std::{Addr, Coin};
pub use cosmwasm_std::{StdError, Uint128};
pub use cosmwasm_std::{StdError, Uint128, Uint64};
pub use tuples::*;

pub use serde::{Deserialize, Serialize};
Expand Down
4 changes: 2 additions & 2 deletions contracts/cosmwasm/order/src/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use cosmwasm_std::Storage;
use cvm_route::asset::AssetItem;
use cvm_runtime::shared::CvmProgram;
use cvm_runtime::AssetId;


use crate::prelude::*;
use crate::CowFilledOrder;

use crate::CowSolutionCalculation;
use crate::Filling;
use crate::SolvedOrder;
Expand Down
12 changes: 6 additions & 6 deletions contracts/cosmwasm/order/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{ensure, BankMsg, Event, StdResult};
use cvm_runtime::{outpost::ExecuteProgramMsg, shared::CvmProgram, AssetId, ExchangeId, NetworkId};
use cvm_runtime::{outpost::ExecuteProgramMsg, AssetId};
use mantis_cw::{DenomPair, OrderSide};

pub type Ratio = num_rational::Ratio<u64>;
Expand Down Expand Up @@ -95,7 +95,7 @@ pub struct Filling {
#[cfg(test)]
mod test {
use cosmwasm_std::Coin;

use crate::prelude::*;
use crate::types::*;

Expand Down Expand Up @@ -314,8 +314,8 @@ impl SolvedOrder {
pub fn given_cross_chain(&self) -> Amount {
match self.solution.cross_chain_part {
Some(x) => match x {
OrderAmount::All => self.order.given.amount.into(),
OrderAmount::Part(x, _) => x.into(),
OrderAmount::All => self.order.given.amount,
OrderAmount::Part(x, _) => x,
},
None => 0u128.into(),
}
Expand All @@ -324,8 +324,8 @@ impl SolvedOrder {
pub fn wants_cross_chain(&self) -> Amount {
match self.solution.cross_chain_part {
Some(x) => match x {
OrderAmount::All => self.order.msg.wants.amount.into(),
OrderAmount::Part(_, x) => x.into(),
OrderAmount::All => self.order.msg.wants.amount,
OrderAmount::Part(_, x) => x,
},
None => 0u128.into(),
}
Expand Down

0 comments on commit e1ddb27

Please sign in to comment.