Skip to content

Commit

Permalink
chore: use rustfmt nightly build to introduce opinionated imports ord…
Browse files Browse the repository at this point in the history
…ering (#141)
  • Loading branch information
cgorenflo authored Jan 14, 2025
1 parent 47d92ee commit e19f588
Show file tree
Hide file tree
Showing 48 changed files with 215 additions and 208 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Rust nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt

- name: Run cargo fmt
run: cargo fmt --all -- --check

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.81.0
components: rustfmt, clippy
components: clippy

- name: Rust Cache
uses: useblacksmith/rust-cache@v3
Expand All @@ -34,9 +43,6 @@ jobs:
with:
crate: cargo-sort

- name: Run cargo fmt
run: cargo fmt --all -- --check

- name: Run cargo sort
run: cargo-sort --workspace --check --check-format

Expand Down
6 changes: 3 additions & 3 deletions contracts/axelar-gas-service/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use axelar_soroban_std::ttl::extend_instance_ttl;
use axelar_soroban_std::types::Token;
use axelar_soroban_std::{ensure, interfaces, Ownable, Upgradable};
use soroban_sdk::{contract, contractimpl, token, Address, Bytes, Env, String};

use crate::error::ContractError;
use crate::event;
use crate::interface::AxelarGasServiceInterface;
use crate::storage_types::DataKey;
use axelar_soroban_std::ttl::extend_instance_ttl;
use axelar_soroban_std::{ensure, interfaces, types::Token};
use axelar_soroban_std::{Ownable, Upgradable};

#[contract]
#[derive(Ownable, Upgradable)]
Expand Down
15 changes: 5 additions & 10 deletions contracts/axelar-gas-service/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ use std::format;

use axelar_gas_service::error::ContractError;
use axelar_gas_service::{AxelarGasService, AxelarGasServiceClient};
use axelar_soroban_std::{
assert_contract_err, assert_invoke_auth_err, assert_last_emitted_event, types::Token,
};
use soroban_sdk::Bytes;
use soroban_sdk::{
bytes,
testutils::Address as _,
token::{StellarAssetClient, TokenClient},
Address, Env, String, Symbol,
};
use axelar_soroban_std::types::Token;
use axelar_soroban_std::{assert_contract_err, assert_invoke_auth_err, assert_last_emitted_event};
use soroban_sdk::testutils::Address as _;
use soroban_sdk::token::{StellarAssetClient, TokenClient};
use soroban_sdk::{bytes, Address, Bytes, Env, String, Symbol};

fn setup_env<'a>() -> (Env, Address, Address, AxelarGasServiceClient<'a>) {
let env = Env::default();
Expand Down
8 changes: 4 additions & 4 deletions contracts/axelar-gateway/src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::error::ContractError;
use crate::types::{ProofSignature, ProofSigner, WeightedSigner};
use axelar_soroban_std::ensure;
use axelar_soroban_std::events::Event;
use soroban_sdk::{crypto::Hash, Bytes, BytesN, Env, Vec};
use soroban_sdk::crypto::Hash;
use soroban_sdk::{Bytes, BytesN, Env, Vec};

use crate::error::ContractError;
use crate::event::SignersRotatedEvent;
use crate::storage_types::DataKey;
use crate::types::{Proof, WeightedSigners};
use crate::types::{Proof, ProofSignature, ProofSigner, WeightedSigner, WeightedSigners};

pub fn initialize_auth(
env: Env,
Expand Down
11 changes: 6 additions & 5 deletions contracts/axelar-gateway/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use axelar_soroban_std::events::Event;
use axelar_soroban_std::ttl::extend_instance_ttl;
use axelar_soroban_std::{ensure, interfaces, Operatable, Ownable, Upgradable};
use soroban_sdk::xdr::ToXdr;
use soroban_sdk::{contract, contractimpl, Address, Bytes, BytesN, Env, String, Vec};

use crate::auth;
use crate::error::ContractError;
use crate::event::{ContractCalledEvent, MessageApprovedEvent, MessageExecutedEvent};
use crate::interface::AxelarGatewayInterface;
use crate::messaging_interface::AxelarGatewayMessagingInterface;
use crate::storage_types::{DataKey, MessageApprovalKey, MessageApprovalValue};
use crate::types::{CommandType, Message, Proof, WeightedSigners};
use axelar_soroban_std::events::Event;
use axelar_soroban_std::ttl::extend_instance_ttl;
use axelar_soroban_std::{ensure, interfaces, Operatable, Ownable, Upgradable};
use soroban_sdk::xdr::ToXdr;
use soroban_sdk::{contract, contractimpl, Address, Bytes, BytesN, Env, String, Vec};

#[contract]
#[derive(Ownable, Upgradable, Operatable)]
Expand Down
4 changes: 2 additions & 2 deletions contracts/axelar-gateway/src/event.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::types::Message;

use core::fmt::Debug;

use axelar_soroban_std::events::Event;
use cfg_if::cfg_if;
use soroban_sdk::{Address, Bytes, BytesN, Env, IntoVal, String, Symbol, Topics, Val, Vec};

use crate::types::Message;

#[derive(Debug, PartialEq, Eq)]
pub struct ContractCalledEvent {
pub caller: Address,
Expand Down
9 changes: 4 additions & 5 deletions contracts/axelar-gateway/src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::{
error::ContractError,
types::{Message, Proof, WeightedSigners},
AxelarGatewayMessagingInterface,
};
use axelar_soroban_std::interfaces::{OperatableInterface, OwnableInterface, UpgradableInterface};
use soroban_sdk::{contractclient, BytesN, Env, Vec};

use crate::error::ContractError;
use crate::types::{Message, Proof, WeightedSigners};
use crate::AxelarGatewayMessagingInterface;

#[contractclient(name = "AxelarGatewayClient")]
pub trait AxelarGatewayInterface:
AxelarGatewayMessagingInterface + UpgradableInterface + OwnableInterface + OperatableInterface
Expand Down
14 changes: 6 additions & 8 deletions contracts/axelar-gateway/src/testutils.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
extern crate std;

use crate::auth::{self, epoch};
use crate::{AxelarGateway, AxelarGatewayClient};
use axelar_soroban_std::traits::IntoVec;
use axelar_soroban_std::{assert_last_emitted_event, assert_ok};
use ed25519_dalek::{Signature, Signer, SigningKey};
use rand::distributions::{Alphanumeric, DistString};
use rand::Rng;
use soroban_sdk::testutils::{Address as _, BytesN as _};
use soroban_sdk::xdr::ToXdr;
use soroban_sdk::{vec, Address, Bytes, BytesN, Env, String, Symbol, Vec};

use soroban_sdk::Symbol;
use soroban_sdk::{testutils::Address as _, Address};
use soroban_sdk::{testutils::BytesN as _, vec, xdr::ToXdr, Bytes, BytesN, Env, String, Vec};

use crate::auth::{self, epoch};
use crate::types::{
CommandType, Message, Proof, ProofSignature, ProofSigner, WeightedSigner, WeightedSigners,
};

use axelar_soroban_std::traits::IntoVec;
use crate::{AxelarGateway, AxelarGatewayClient};

#[derive(Clone, Debug)]
pub struct TestSignerSet {
Expand Down
9 changes: 6 additions & 3 deletions contracts/axelar-gateway/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use soroban_sdk::{contracttype, xdr::ToXdr, Address, BytesN, Env, String, Vec};
use soroban_sdk::xdr::ToXdr;
use soroban_sdk::{contracttype, Address, BytesN, Env, String, Vec};

#[contracttype]
#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -95,9 +96,11 @@ impl Proof {

#[cfg(test)]
mod test {
use crate::types::{CommandType, Message, WeightedSigner, WeightedSigners};
use hex_literal::hex;
use soroban_sdk::{xdr::ToXdr, Address, BytesN, Env, String, Vec};
use soroban_sdk::xdr::ToXdr;
use soroban_sdk::{Address, BytesN, Env, String, Vec};

use crate::types::{CommandType, Message, WeightedSigner, WeightedSigners};

#[test]
fn weighted_signers_hash() {
Expand Down
6 changes: 2 additions & 4 deletions contracts/axelar-gateway/tests/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ use axelar_gateway::testutils::{generate_proof, generate_signers_set, randint};
use axelar_gateway::types::{ProofSignature, ProofSigner, WeightedSigner, WeightedSigners};
use axelar_gateway::AxelarGateway;
use axelar_soroban_std::{assert_contract_err, assert_invoke_auth_ok};
use soroban_sdk::{
testutils::{Address as _, BytesN as _},
Address, BytesN, Env, Vec,
};
use soroban_sdk::testutils::{Address as _, BytesN as _};
use soroban_sdk::{Address, BytesN, Env, Vec};

mod utils;
use utils::setup_env;
Expand Down
7 changes: 2 additions & 5 deletions contracts/axelar-gateway/tests/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ use axelar_gateway::types::Message;
use axelar_soroban_std::{
assert_contract_err, assert_invocation, assert_invoke_auth_err, assert_invoke_auth_ok, events,
};
use soroban_sdk::{
bytes,
testutils::{Address as _, Events},
vec, Address, BytesN, String,
};
use soroban_sdk::testutils::{Address as _, Events};
use soroban_sdk::{bytes, vec, Address, BytesN, String};

mod utils;
use utils::setup_env;
Expand Down
6 changes: 2 additions & 4 deletions contracts/axelar-gateway/tests/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use axelar_gateway::{
testutils::{setup_gateway, TestSignerSet},
AxelarGatewayClient,
};
use axelar_gateway::testutils::{setup_gateway, TestSignerSet};
use axelar_gateway::AxelarGatewayClient;
use soroban_sdk::Env;

pub fn setup_env<'a>(
Expand Down
7 changes: 4 additions & 3 deletions contracts/axelar-operators/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::error::ContractError;
use crate::event;
use crate::storage_types::DataKey;
use axelar_soroban_std::ttl::extend_instance_ttl;
use axelar_soroban_std::{ensure, interfaces, Ownable, Upgradable};
use soroban_sdk::{contract, contractimpl, Address, Env, Symbol, Val, Vec};

use crate::error::ContractError;
use crate::event;
use crate::storage_types::DataKey;

#[contract]
#[derive(Ownable, Upgradable)]
pub struct AxelarOperators;
Expand Down
12 changes: 4 additions & 8 deletions contracts/axelar-operators/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
extern crate std;

use axelar_operators::error::ContractError;
use axelar_soroban_std::{
assert_contract_err, assert_invoke_auth_err, assert_last_emitted_event,
testutils::assert_invocation,
};

use axelar_operators::{AxelarOperators, AxelarOperatorsClient};
use soroban_sdk::{
contract, contractimpl, symbol_short, testutils::Address as _, Address, Env, Symbol, Val, Vec,
};
use axelar_soroban_std::testutils::assert_invocation;
use axelar_soroban_std::{assert_contract_err, assert_invoke_auth_err, assert_last_emitted_event};
use soroban_sdk::testutils::Address as _;
use soroban_sdk::{contract, contractimpl, symbol_short, Address, Env, Symbol, Val, Vec};

#[contract]
pub struct TestTarget;
Expand Down
5 changes: 2 additions & 3 deletions contracts/example/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use crate::event;
use axelar_gas_service::AxelarGasServiceClient;
use axelar_gateway::executable::{AxelarExecutableInterface, NotApprovedError};
use axelar_gateway::{impl_not_approved_error, AxelarGatewayMessagingClient};
use axelar_soroban_std::types::Token;
use soroban_sdk::{contract, contracterror, contractimpl, Address, Bytes, Env, String};

use crate::event;
use crate::storage_types::DataKey;

use axelar_gateway::executable::{AxelarExecutableInterface, NotApprovedError};

#[contract]
pub struct Example;

Expand Down
11 changes: 5 additions & 6 deletions contracts/example/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
extern crate std;

use axelar_gas_service::{AxelarGasService, AxelarGasServiceClient};
use axelar_gateway::{
testutils::{self, generate_proof, get_approve_hash, TestSignerSet},
types::Message,
AxelarGatewayClient,
};
use axelar_soroban_std::{assert_last_emitted_event, auth_invocation, types::Token};
use axelar_gateway::testutils::{self, generate_proof, get_approve_hash, TestSignerSet};
use axelar_gateway::types::Message;
use axelar_gateway::AxelarGatewayClient;
use axelar_soroban_std::types::Token;
use axelar_soroban_std::{assert_last_emitted_event, auth_invocation};
use example::{Example, ExampleClient};
use soroban_sdk::testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation, BytesN as _};
use soroban_sdk::token::StellarAssetClient;
Expand Down
9 changes: 6 additions & 3 deletions contracts/interchain-token-service/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,15 @@ impl From<MessageType> for U256 {

#[cfg(test)]
mod tests {
use super::*;
use alloc::vec;
use axelar_soroban_std::{assert_ok, traits::BytesExt};
use soroban_sdk::{Bytes, BytesN, Env, String};
use std::vec::Vec;

use axelar_soroban_std::assert_ok;
use axelar_soroban_std::traits::BytesExt;
use soroban_sdk::{Bytes, BytesN, Env, String};

use super::*;

#[test]
fn soroban_str_to_std_string() {
let env = Env::default();
Expand Down
28 changes: 15 additions & 13 deletions contracts/interchain-token-service/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
use axelar_gas_service::AxelarGasServiceClient;
use axelar_gateway::executable::AxelarExecutableInterface;
use axelar_gateway::AxelarGatewayMessagingClient;
use axelar_soroban_std::address::AddressExt;
use axelar_soroban_std::events::Event;
use axelar_soroban_std::token::validate_token_metadata;
use axelar_soroban_std::ttl::{extend_instance_ttl, extend_persistent_ttl};
use axelar_soroban_std::types::Token;
use axelar_soroban_std::{ensure, interfaces, Operatable, Ownable, Upgradable};
use interchain_token::InterchainTokenClient;
use soroban_sdk::token::{self, StellarAssetClient};
use soroban_sdk::xdr::{FromXdr, ToXdr};
use soroban_sdk::{contract, contractimpl, Address, Bytes, BytesN, Env, String};
use soroban_token_sdk::metadata::TokenMetadata;

use crate::abi::{get_message_type, MessageType as EncodedMessageType};
use crate::error::ContractError;
use crate::event::{
Expand All @@ -13,19 +28,6 @@ use crate::types::{
DeployInterchainToken, HubMessage, InterchainTransfer, Message, TokenManagerType,
};
use crate::{flow_limit, token_handler};
use axelar_gas_service::AxelarGasServiceClient;
use axelar_gateway::{executable::AxelarExecutableInterface, AxelarGatewayMessagingClient};
use axelar_soroban_std::events::Event;
use axelar_soroban_std::token::validate_token_metadata;
use axelar_soroban_std::ttl::{extend_instance_ttl, extend_persistent_ttl};
use axelar_soroban_std::{
address::AddressExt, ensure, interfaces, types::Token, Operatable, Ownable, Upgradable,
};
use interchain_token::InterchainTokenClient;
use soroban_sdk::token::{self, StellarAssetClient};
use soroban_sdk::xdr::{FromXdr, ToXdr};
use soroban_sdk::{contract, contractimpl, Address, Bytes, BytesN, Env, String};
use soroban_token_sdk::metadata::TokenMetadata;

const ITS_HUB_CHAIN_NAME: &str = "axelar";
const PREFIX_INTERCHAIN_TOKEN_ID: &str = "its-interchain-token-id";
Expand Down
12 changes: 6 additions & 6 deletions contracts/interchain-token-service/src/flow_limit.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use axelar_soroban_std::{ensure, events::Event, ttl::extend_persistent_ttl};
use axelar_soroban_std::ensure;
use axelar_soroban_std::events::Event;
use axelar_soroban_std::ttl::extend_persistent_ttl;
use soroban_sdk::{BytesN, Env};

use crate::{
error::ContractError,
event::FlowLimitSetEvent,
storage_types::{DataKey, FlowKey},
};
use crate::error::ContractError;
use crate::event::FlowLimitSetEvent;
use crate::storage_types::{DataKey, FlowKey};

const EPOCH_TIME: u64 = 6 * 60 * 60; // 6 hours in seconds = 21600

Expand Down
3 changes: 2 additions & 1 deletion contracts/interchain-token-service/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use axelar_soroban_std::types::Token;
use soroban_sdk::{contractclient, Address, Bytes, BytesN, Env, String};
use soroban_token_sdk::metadata::TokenMetadata;

use crate::{error::ContractError, types::TokenManagerType};
use crate::error::ContractError;
use crate::types::TokenManagerType;

#[allow(dead_code)]
#[contractclient(name = "InterchainTokenServiceClient")]
Expand Down
Loading

0 comments on commit e19f588

Please sign in to comment.