Skip to content

Commit

Permalink
chore(fmt): enforce unique import sorting in PR checks (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgorenflo authored Jul 19, 2024
1 parent a7f3b99 commit deab56a
Show file tree
Hide file tree
Showing 145 changed files with 769 additions and 911 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install stable toolchain
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.78.0
toolchain: nightly
components: rustfmt
override: true
components: rustfmt, clippy

- name: Install protoc
uses: arduino/setup-protoc@v2
Expand Down Expand Up @@ -128,6 +128,14 @@ jobs:
command: fmt
args: --all -- --check

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.78.0
components: clippy
override: true

- name: Run cargo sort
uses: actions-rs/cargo@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions ampd/src/asyncutil/future.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use futures::{Future, FutureExt};
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::Duration;

use futures::{Future, FutureExt};
use tokio::time;

pub fn with_retry<F, Fut, R, Err>(
Expand Down Expand Up @@ -101,7 +101,8 @@ where

#[cfg(test)]
mod tests {
use std::{future, sync::Mutex};
use std::future;
use std::sync::Mutex;

use tokio::time::Instant;

Expand Down
8 changes: 5 additions & 3 deletions ampd/src/asyncutil/task.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use axelar_wasm_std::error::extend_err;
use error_stack::{Context, Result, ResultExt};
use std::future::Future;
use std::pin::Pin;

use axelar_wasm_std::error::extend_err;
use error_stack::{Context, Result, ResultExt};
use thiserror::Error;
use tokio::task::JoinSet;
use tokio_util::sync::CancellationToken;
Expand Down Expand Up @@ -109,10 +110,11 @@ pub struct TaskError;

#[cfg(test)]
mod test {
use crate::asyncutil::task::{CancellableTask, TaskError, TaskGroup};
use error_stack::report;
use tokio_util::sync::CancellationToken;

use crate::asyncutil::task::{CancellableTask, TaskError, TaskGroup};

#[tokio::test]
async fn running_no_tasks_returns_no_error() {
let tasks: TaskGroup<TaskError> = TaskGroup::new();
Expand Down
19 changes: 7 additions & 12 deletions ampd/src/block_height_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use error_stack::{Result, ResultExt};
use std::time::Duration;

use error_stack::{Result, ResultExt};
use thiserror::Error;
use tokio::{
select,
sync::watch::{self, Receiver, Sender},
time,
};
use tokio::sync::watch::{self, Receiver, Sender};
use tokio::{select, time};
use tokio_util::sync::CancellationToken;
use tracing::info;

Expand Down Expand Up @@ -77,16 +75,13 @@ mod tests {
use std::convert::TryInto;
use std::time::Duration;

use async_trait::async_trait;
use mockall::mock;
use tendermint::block::Height;
use tokio::test;
use tokio::time;
use tokio::{test, time};
use tokio_util::sync::CancellationToken;

use crate::tm_client;

use crate::BlockHeightMonitor;
use async_trait::async_trait;
use crate::{tm_client, BlockHeightMonitor};

#[test]
#[allow(clippy::cast_possible_truncation)]
Expand Down
9 changes: 4 additions & 5 deletions ampd/src/broadcaster/confirm_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ use cosmrs::proto::cosmos::tx::v1beta1::{GetTxRequest, GetTxResponse};
use error_stack::{report, Report, Result};
use futures::{StreamExt, TryFutureExt};
use thiserror::Error;
use tokio::{
sync::{mpsc, Mutex},
time,
};
use tokio::sync::{mpsc, Mutex};
use tokio::time;
use tokio_stream::wrappers::ReceiverStream;
use tonic::Status;
use tracing::error;
Expand Down Expand Up @@ -179,7 +177,8 @@ mod test {

use cosmrs::proto::cosmos::tx::v1beta1::GetTxRequest;
use mockall::predicate;
use tokio::{sync::mpsc, test};
use tokio::sync::mpsc;
use tokio::test;

use super::{Error, TxConfirmer, TxResponse, TxStatus};
use crate::broadcaster::cosmos::MockBroadcastClient;
Expand Down
1 change: 0 additions & 1 deletion ampd/src/broadcaster/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use cosmrs::proto::cosmos::tx::v1beta1::service_client::ServiceClient;
use cosmrs::proto::cosmos::tx::v1beta1::{
BroadcastTxRequest, GetTxRequest, GetTxResponse, SimulateRequest, SimulateResponse,
};

use mockall::automock;
use tonic::transport::Channel;
use tonic::{Response, Status};
Expand Down
6 changes: 4 additions & 2 deletions ampd/src/broadcaster/dec_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ impl Display for Denom {

#[cfg(test)]
mod tests {
use super::DecCoin;
use cosmrs::proto;
use std::convert::TryFrom;

use cosmrs::proto;

use super::DecCoin;

#[test]
fn correct_parse() {
assert!(DecCoin::new(1000.00, "uaxl").is_ok())
Expand Down
13 changes: 7 additions & 6 deletions ampd/src/broadcaster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::ops::Mul;
use std::time::Duration;

use async_trait::async_trait;
use axelar_wasm_std::FnExt;
use cosmrs::proto::cosmos::auth::v1beta1::{
BaseAccount, QueryAccountRequest, QueryAccountResponse,
};
Expand All @@ -14,23 +15,21 @@ use cosmrs::proto::traits::MessageExt;
use cosmrs::tendermint::chain::Id;
use cosmrs::tx::Fee;
use cosmrs::{Amount, Coin, Denom, Gas};
use dec_coin::DecCoin;
use error_stack::{ensure, report, FutureExt, Result, ResultExt};
use futures::TryFutureExt;
use k256::sha2::{Digest, Sha256};
use mockall::automock;
use num_traits::{cast, Zero};
use prost::Message;
use prost_types::Any;
use report::ResultCompatExt;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use tonic::{Code, Status};
use tracing::info;
use typed_builder::TypedBuilder;

use axelar_wasm_std::FnExt;
use dec_coin::DecCoin;
use report::ResultCompatExt;
use tx::Tx;
use typed_builder::TypedBuilder;

use crate::tofnd;
use crate::tofnd::grpc::Multisig;
Expand Down Expand Up @@ -370,14 +369,16 @@ fn remap_account_not_found_error(

#[cfg(test)]
mod tests {
use cosmrs::bank::MsgSend;
use cosmrs::crypto::PublicKey;
use cosmrs::proto::cosmos::auth::v1beta1::{BaseAccount, QueryAccountResponse};
use cosmrs::proto::cosmos::bank::v1beta1::QueryBalanceResponse;
use cosmrs::proto::cosmos::base::abci::v1beta1::{GasInfo, TxResponse};
use cosmrs::proto::cosmos::tx::v1beta1::{GetTxResponse, SimulateResponse};
use cosmrs::proto::traits::MessageExt;
use cosmrs::proto::Any;
use cosmrs::{bank::MsgSend, tx::Msg, AccountId, Coin, Denom};
use cosmrs::tx::Msg;
use cosmrs::{AccountId, Coin, Denom};
use ecdsa::SigningKey;
use k256::Secp256k1;
use rand::rngs::OsRng;
Expand Down
27 changes: 11 additions & 16 deletions ampd/src/broadcaster/tx.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use core::fmt::Debug;
use std::future::Future;

use cosmrs::proto::cosmos::tx::v1beta1::TxRaw;
use cosmrs::tendermint::chain::Id;
use cosmrs::{
proto::cosmos::tx::v1beta1::TxRaw,
tx::{BodyBuilder, Fee, SignDoc, SignerInfo},
Any, Coin,
};
use cosmrs::tx::{BodyBuilder, Fee, SignDoc, SignerInfo};
use cosmrs::{Any, Coin};
use error_stack::{Context, Result, ResultExt};
use report::ResultCompatExt;
use thiserror::Error;
Expand Down Expand Up @@ -98,24 +96,21 @@ where

#[cfg(test)]
mod tests {
use cosmrs::bank::MsgSend;
use cosmrs::bip32::secp256k1::elliptic_curve::rand_core::OsRng;
use cosmrs::crypto::secp256k1::SigningKey;
use cosmrs::proto::cosmos::tx::v1beta1::TxRaw;
use cosmrs::proto::Any;
use cosmrs::{
bank::MsgSend,
bip32::secp256k1::elliptic_curve::rand_core::OsRng,
crypto::secp256k1::SigningKey,
proto::cosmos::tx::v1beta1::TxRaw,
tendermint::chain::Id,
tx::{BodyBuilder, Fee, Msg, SignDoc, SignerInfo},
AccountId, Coin,
};
use cosmrs::tendermint::chain::Id;
use cosmrs::tx::{BodyBuilder, Fee, Msg, SignDoc, SignerInfo};
use cosmrs::{AccountId, Coin};
use error_stack::Result;
use k256::ecdsa;
use k256::sha2::{Digest, Sha256};
use tokio::test;

use crate::types::PublicKey;

use super::{Error, Tx, DUMMY_CHAIN_ID};
use crate::types::PublicKey;

#[test]
async fn sign_with_should_produce_the_correct_tx() {
Expand Down
14 changes: 5 additions & 9 deletions ampd/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
use clap::Subcommand;
use cosmrs::proto::cosmos::auth::v1beta1::query_client::QueryClient as AuthQueryClient;
use cosmrs::proto::cosmos::bank::v1beta1::query_client::QueryClient as BankQueryClient;
use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::proto::cosmos::{
auth::v1beta1::query_client::QueryClient as AuthQueryClient,
bank::v1beta1::query_client::QueryClient as BankQueryClient,
tx::v1beta1::service_client::ServiceClient,
};
use cosmrs::proto::cosmos::tx::v1beta1::service_client::ServiceClient;
use cosmrs::proto::Any;
use cosmrs::AccountId;
use error_stack::Result;
use error_stack::ResultExt;
use error_stack::{Result, ResultExt};
use serde::{Deserialize, Serialize};
use valuable::Valuable;

use crate::broadcaster::Broadcaster;
use crate::config::Config as AmpdConfig;
use crate::tofnd::grpc::{Multisig, MultisigClient};
use crate::types::{PublicKey, TMAddress};
use crate::{broadcaster, Error};
use crate::{tofnd, PREFIX};
use crate::{broadcaster, tofnd, Error, PREFIX};

pub mod bond_verifier;
pub mod daemon;
Expand Down
23 changes: 10 additions & 13 deletions ampd/src/commands/register_public_key.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
use std::convert::{TryFrom, TryInto};

use cosmrs::{cosmwasm::MsgExecuteContract, tx::Msg};
use cosmrs::cosmwasm::MsgExecuteContract;
use cosmrs::tx::Msg;
use error_stack::{Result, ResultExt};
use multisig::{key::PublicKey, msg::ExecuteMsg};
use multisig::key::PublicKey;
use multisig::msg::ExecuteMsg;
use report::ResultCompatExt;
use sha3::{Digest, Keccak256};
use tracing::info;
use valuable::Valuable;

use crate::{
commands::{broadcast_tx, verifier_pub_key},
config::Config,
handlers,
tofnd::{
self,
grpc::{Multisig, MultisigClient},
},
types::TMAddress,
Error, PREFIX,
};
use crate::commands::{broadcast_tx, verifier_pub_key};
use crate::config::Config;
use crate::tofnd::grpc::{Multisig, MultisigClient};
use crate::tofnd::{self};
use crate::types::TMAddress;
use crate::{handlers, Error, PREFIX};

#[derive(clap::ValueEnum, Clone, Debug, Valuable, Copy)]
enum KeyType {
Expand Down
3 changes: 1 addition & 2 deletions ampd/src/commands/verifier_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use report::ResultCompatExt;

use crate::commands::verifier_pub_key;
use crate::tofnd::Config as TofndConfig;
use crate::Error;
use crate::PREFIX;
use crate::{Error, PREFIX};

pub async fn run(config: TofndConfig) -> Result<Option<String>, Error> {
verifier_pub_key(config)
Expand Down
13 changes: 5 additions & 8 deletions ampd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use std::net::{Ipv4Addr, SocketAddrV4};

use serde::{Deserialize, Serialize};

use crate::broadcaster;
use crate::commands::ServiceRegistryConfig;
use crate::event_processor;
use crate::handlers::{self, config::deserialize_handler_configs};
use crate::handlers::config::deserialize_handler_configs;
use crate::handlers::{self};
use crate::tofnd::Config as TofndConfig;
use crate::url::Url;
use crate::{broadcaster, event_processor};

#[derive(Deserialize, Serialize, Debug, PartialEq)]
#[serde(default)]
Expand Down Expand Up @@ -48,17 +48,14 @@ mod tests {
use std::time::Duration;

use cosmrs::AccountId;

use router_api::ChainName;

use super::Config;
use crate::evm::finalizer::Finalization;
use crate::handlers::config::Chain;
use crate::handlers::config::Config as HandlerConfig;
use crate::handlers::config::{Chain, Config as HandlerConfig};
use crate::types::TMAddress;
use crate::url::Url;

use super::Config;

const PREFIX: &str = "axelar";

#[test]
Expand Down
Loading

0 comments on commit deab56a

Please sign in to comment.