From 49139d421bf3b96b1720fdfde6665ece9253893b Mon Sep 17 00:00:00 2001 From: Roznovjak Date: Wed, 13 Nov 2024 18:13:07 +0100 Subject: [PATCH] formatting --- pallets/liquidation/src/benchmarks.rs | 5 +- pallets/liquidation/src/lib.rs | 17 ++--- pallets/liquidation/src/tests/liquidation.rs | 4 +- runtime/hydradx/src/lib.rs | 12 +++- runtime/hydradx/src/migration.rs | 76 ++++++++++---------- 5 files changed, 54 insertions(+), 60 deletions(-) diff --git a/pallets/liquidation/src/benchmarks.rs b/pallets/liquidation/src/benchmarks.rs index bb8b58909..615037541 100644 --- a/pallets/liquidation/src/benchmarks.rs +++ b/pallets/liquidation/src/benchmarks.rs @@ -62,10 +62,7 @@ where AssetId: From<::AssetId>, ::AssetId: From, { - use frame_support::{ - storage::with_transaction, - sp_runtime::TransactionOutcome, - }; + use frame_support::{sp_runtime::TransactionOutcome, storage::with_transaction}; // Register new asset in asset registry let name = b"DOT".to_vec().try_into().map_err(|_| "BoundedConvertionFailed")?; diff --git a/pallets/liquidation/src/lib.rs b/pallets/liquidation/src/lib.rs index 9f4800d86..53d5fefac 100644 --- a/pallets/liquidation/src/lib.rs +++ b/pallets/liquidation/src/lib.rs @@ -26,28 +26,25 @@ #![cfg_attr(not(feature = "std"), no_std)] +use ethabi::ethereum_types::BigEndianHash; +use evm::{ExitReason, ExitSucceed}; use frame_support::{ pallet_prelude::*, + sp_runtime::traits::{AccountIdConversion, CheckedConversion}, traits::fungibles::{Inspect, Mutate}, traits::tokens::{Fortitude, Precision, Preservation}, PalletId, - sp_runtime::traits::{AccountIdConversion, CheckedConversion}, }; use frame_system::{ensure_signed, pallet_prelude::OriginFor, RawOrigin}; use hydradx_traits::{ evm::{CallContext, Erc20Mapping, EvmAddress, InspectEvmAccounts, EVM}, router::{AmmTradeWeights, AmountInAndOut, AssetPair, RouteProvider, RouterT, Trade}, }; -use sp_arithmetic::ArithmeticError; -use sp_core::{ - H256, U256, - crypto::AccountId32, -}; -use sp_std::{vec, vec::Vec}; -use ethabi::ethereum_types::BigEndianHash; use num_enum::{IntoPrimitive, TryFromPrimitive}; -use evm::{ExitReason, ExitSucceed}; use pallet_evm::GasWeightMapping; +use sp_arithmetic::ArithmeticError; +use sp_core::{crypto::AccountId32, H256, U256}; +use sp_std::{vec, vec::Vec}; #[cfg(test)] mod tests; @@ -145,7 +142,7 @@ pub mod pallet { /// Provided route doesn't match the existing route InvalidRoute, /// Liquidation was not profitable enough to repay flash loan - NotProfitable + NotProfitable, } #[pallet::call] diff --git a/pallets/liquidation/src/tests/liquidation.rs b/pallets/liquidation/src/tests/liquidation.rs index 7b289dc8a..374d0ecbb 100644 --- a/pallets/liquidation/src/tests/liquidation.rs +++ b/pallets/liquidation/src/tests/liquidation.rs @@ -4,9 +4,7 @@ pub use crate::tests::mock::*; use crate::{Error, Event}; -use frame_support::{ - assert_noop, assert_ok, -}; +use frame_support::{assert_noop, assert_ok}; use hydradx_traits::{ evm::InspectEvmAccounts, router::{AssetPair, RouteProvider}, diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index 837d3058e..29b12222a 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -29,8 +29,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); mod tests; mod benchmarking; -pub mod weights; mod migration; +pub mod weights; mod assets; pub mod evm; @@ -265,8 +265,14 @@ pub type UncheckedExtrinsic = fp_self_contained::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = - frame_executive::Executive, Runtime, AllPalletsWithSystem, migration::OnRuntimeUpgradeMigration>; +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, + migration::OnRuntimeUpgradeMigration, +>; impl frame_system::offchain::SendTransactionTypes for Runtime where diff --git a/runtime/hydradx/src/migration.rs b/runtime/hydradx/src/migration.rs index 747111e37..8ebc6e5c6 100644 --- a/runtime/hydradx/src/migration.rs +++ b/runtime/hydradx/src/migration.rs @@ -15,50 +15,46 @@ use super::*; use frame_support::{ - traits::OnRuntimeUpgrade, - weights::Weight, - dispatch::{GetDispatchInfo, RawOrigin}, + dispatch::{GetDispatchInfo, RawOrigin}, + traits::OnRuntimeUpgrade, + weights::Weight, }; pub struct OnRuntimeUpgradeMigration; use super::Runtime; -pub fn bind_pallet_account() -> Weight -{ - match EVMAccounts::bind_evm_address(RawOrigin::Signed(Liquidation::account_id()).into()) { - Ok(_) => { - log::info!( - target: "runtime::pallet_liquidation", - "Migration to v1 for Liquidation pallet" - ); - }, - Err(error) => { - log::info!( - target: "runtime::pallet_liquidation", - "Migration to v1 for Liquidation pallet failed: {:?}", error - ); - } - } - - let call = pallet_evm_accounts::Call::::bind_evm_address { - }; - - call.get_dispatch_info().weight +pub fn bind_pallet_account() -> Weight { + match EVMAccounts::bind_evm_address(RawOrigin::Signed(Liquidation::account_id()).into()) { + Ok(_) => { + log::info!( + target: "runtime::pallet_liquidation", + "Migration to v1 for Liquidation pallet" + ); + } + Err(error) => { + log::info!( + target: "runtime::pallet_liquidation", + "Migration to v1 for Liquidation pallet failed: {:?}", error + ); + } + } + + let call = pallet_evm_accounts::Call::::bind_evm_address {}; + + call.get_dispatch_info().weight } - impl OnRuntimeUpgrade for OnRuntimeUpgradeMigration { - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { - Ok(vec![]) - } - - fn on_runtime_upgrade() -> Weight - { - bind_pallet_account() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), &'static str> { - Ok(()) - } - } \ No newline at end of file + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + Ok(vec![]) + } + + fn on_runtime_upgrade() -> Weight { + bind_pallet_account() + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_state: Vec) -> Result<(), &'static str> { + Ok(()) + } +}