Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
trinitys7 committed Aug 5, 2024
1 parent 8e79686 commit c0780ce
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 29 deletions.
49 changes: 28 additions & 21 deletions contracts/consumer/band-price-feed/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
use cosmwasm_std::{
to_json_binary, Binary, Coin, DepsMut, Env, IbcChannel, IbcEndpoint, IbcMsg, IbcTimeout, Response, Uint64
to_json_binary, Binary, Coin, DepsMut, Env, IbcChannel, IbcEndpoint, IbcMsg, IbcTimeout,
Response, Uint64,
};
use cw2::set_contract_version;
use cw_storage_plus::Item;
use cw_utils::nonpayable;
use mesh_apis::price_feed_api::{PriceFeedApi, PriceResponse};

use crate::error::ContractError;
use crate::state::{TradingPair, Config};
use crate::state::{Config, TradingPair};

use sylvia::types::{InstantiateCtx, QueryCtx, SudoCtx};
use sylvia::{contract, schemars};

use cw_band::{Input, OracleRequestPacketData};
use mesh_price_feed::{Action, Scheduler, PriceKeeper};
use mesh_price_feed::{Action, PriceKeeper, Scheduler};
use obi::enc::OBIEncode;

// Version info for migration
Expand Down Expand Up @@ -75,22 +76,25 @@ impl RemotePriceFeedContract {

set_contract_version(ctx.deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
self.trading_pair.save(ctx.deps.storage, &trading_pair)?;

self.config.save(ctx.deps.storage, &Config{
client_id,
connection_id,
endpoint: IbcEndpoint{
port_id,
channel_id,

self.config.save(
ctx.deps.storage,
&Config {
client_id,
connection_id,
endpoint: IbcEndpoint {
port_id,
channel_id,
},
oracle_script_id,
ask_count,
min_count,
fee_limit,
prepare_gas,
execute_gas,
minimum_sources,
},
oracle_script_id,
ask_count,
min_count,
fee_limit,
prepare_gas,
execute_gas,
minimum_sources,
})?;
)?;

Ok(Response::new())
}
Expand Down Expand Up @@ -163,7 +167,10 @@ pub fn try_request(deps: DepsMut, env: &Env) -> Result<Response, ContractError>

#[cfg(test)]
mod tests {
use cosmwasm_std::{testing::{mock_dependencies, mock_env, mock_info}, Uint64, Uint128};
use cosmwasm_std::{
testing::{mock_dependencies, mock_env, mock_info},
Uint128, Uint64,
};

use super::*;

Expand Down Expand Up @@ -194,13 +201,13 @@ mod tests {
Uint64::new(1),
Uint64::new(10),
Uint64::new(50),
vec![Coin {
vec![Coin {
denom: "uband".to_string(),
amount: Uint128::new(1),
}],
Uint64::new(100000),
Uint64::new(200000),
1
1,
)
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/consumer/band-price-feed/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod contract;
pub mod error;
pub mod ibc;
pub mod state;
pub mod ibc;
2 changes: 1 addition & 1 deletion contracts/consumer/band-price-feed/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Coin, Uint64, IbcEndpoint};
use cosmwasm_std::{Coin, IbcEndpoint, Uint64};

#[cw_serde]
pub struct Config {
Expand Down
2 changes: 1 addition & 1 deletion contracts/consumer/osmosis-price-feed/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use mesh_apis::price_feed_api::{self, PriceFeedApi, PriceResponse};
use crate::error::ContractError;
use crate::ibc::{make_ibc_packet, AUTH_ENDPOINT};
use crate::msg::AuthorizedEndpoint;
use mesh_price_feed::{Action, Scheduler, PriceKeeper};
use crate::state::TradingPair;
use mesh_price_feed::{Action, PriceKeeper, Scheduler};

pub const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME");
pub const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down
4 changes: 2 additions & 2 deletions packages/price-feed/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod scheduler;
mod price_keeper;
mod scheduler;

pub use price_keeper::{PriceKeeper, PriceKeeperError};
pub use scheduler::{Action, Scheduler};
pub use price_keeper::{PriceKeeper, PriceKeeperError};
10 changes: 7 additions & 3 deletions packages/price-feed/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ mod tests {

#[test]
fn scheduler_first_epoch_always_fires() {
let scheduler = TestScheduler::new(Box::new(|_, _| Ok(Response::new().set_data(Binary::from(b"foo")))));
let scheduler = TestScheduler::new(Box::new(|_, _| {
Ok(Response::new().set_data(Binary::from(b"foo")))
}));
let mut deps = mock_dependencies();
let env = mock_env();

Expand All @@ -77,7 +79,9 @@ mod tests {

#[test]
fn scheduler() {
let scheduler = TestScheduler::new(Box::new(|_, _| Ok(Response::new().set_data(Binary::from(b"foo")))));
let scheduler = TestScheduler::new(Box::new(|_, _| {
Ok(Response::new().set_data(Binary::from(b"foo")))
}));
let mut deps = mock_dependencies();
let mut env = mock_env();

Expand All @@ -93,7 +97,7 @@ mod tests {
}

#[track_caller]
fn assert_noop<A, E>(s: &Scheduler<A, E>, deps: DepsMut, env: &Env)
fn assert_noop<A, E>(s: &Scheduler<A, E>, deps: DepsMut, env: &Env)
where
A: Action<E>,
E: std::fmt::Debug + From<StdError>,
Expand Down

0 comments on commit c0780ce

Please sign in to comment.