From 26354d258de44c66c095eacc89c37b4caeb6f062 Mon Sep 17 00:00:00 2001 From: lemunozm Date: Tue, 13 Aug 2024 10:38:36 +0200 Subject: [PATCH] remove unused mocks --- libs/mocks/src/lib.rs | 2 - .../src/liquidity_pools_gateway_routers.rs | 102 ------------------ pallets/axelar-router/src/lib.rs | 8 +- 3 files changed, 4 insertions(+), 108 deletions(-) delete mode 100644 libs/mocks/src/liquidity_pools_gateway_routers.rs diff --git a/libs/mocks/src/lib.rs b/libs/mocks/src/lib.rs index 7b595532bf..ca9fb241bc 100644 --- a/libs/mocks/src/lib.rs +++ b/libs/mocks/src/lib.rs @@ -11,7 +11,6 @@ pub mod investment; pub mod liquidity_pools; pub mod liquidity_pools_gateway; pub mod liquidity_pools_gateway_queue; -pub mod liquidity_pools_gateway_routers; pub mod pay_fee; pub mod permissions; pub mod pools; @@ -32,7 +31,6 @@ pub use investment::pallet as pallet_mock_investment; pub use liquidity_pools::pallet as pallet_mock_liquidity_pools; pub use liquidity_pools_gateway::pallet as pallet_mock_liquidity_pools_gateway; pub use liquidity_pools_gateway_queue::pallet as pallet_mock_liquidity_pools_gateway_queue; -pub use liquidity_pools_gateway_routers::{pallet as pallet_mock_routers, RouterMock}; pub use pay_fee::pallet as pallet_mock_pay_fee; pub use permissions::pallet as pallet_mock_permissions; pub use pools::pallet as pallet_mock_pools; diff --git a/libs/mocks/src/liquidity_pools_gateway_routers.rs b/libs/mocks/src/liquidity_pools_gateway_routers.rs deleted file mode 100644 index 22bfdf1bb0..0000000000 --- a/libs/mocks/src/liquidity_pools_gateway_routers.rs +++ /dev/null @@ -1,102 +0,0 @@ -use cfg_traits::liquidity_pools::Router; -use frame_support::{dispatch::DispatchResult, pallet_prelude::*}; -use mock_builder::{execute_call, register_call}; -use sp_std::default::Default; - -#[frame_support::pallet(dev_mode)] -pub mod pallet { - use super::*; - - #[pallet::config] - pub trait Config: frame_system::Config {} - - #[pallet::pallet] - pub struct Pallet(_); - - #[pallet::storage] - type CallIds = StorageMap<_, _, String, mock_builder::CallId>; - - impl Pallet { - pub fn mock_init(f: impl Fn() -> DispatchResult + 'static) { - register_call!(move |()| f()); - } - - pub fn mock_send( - f: impl Fn(T::AccountId, Vec) -> DispatchResultWithPostInfo + 'static, - ) { - register_call!(move |(sender, message)| f(sender, message)); - } - } - - impl MockedRouter for Pallet { - type Sender = T::AccountId; - - fn init() -> DispatchResult { - execute_call!(()) - } - - fn send(sender: Self::Sender, message: Vec) -> DispatchResultWithPostInfo { - execute_call!((sender, message)) - } - } -} - -/// This wraps the mocking functionality of the pallet that we build here and is -/// necessary since this will kept in storage, therefore it has to implement the -/// below traits that make that possible. -#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -pub struct RouterMock { - _marker: PhantomData, -} - -impl Default for RouterMock { - fn default() -> Self { - RouterMock:: { - _marker: Default::default(), - } - } -} - -impl RouterMock { - pub fn mock_init(&self, f: impl Fn() -> DispatchResult + 'static) { - pallet::Pallet::::mock_init(f) - } - - pub fn mock_send( - &self, - f: impl Fn(T::AccountId, Vec) -> DispatchResultWithPostInfo + 'static, - ) { - pallet::Pallet::::mock_send(f) - } -} - -/// Here we implement the actual Router trait for the `RouterMock` which in turn -/// calls the `MockedRouter` trait implementation. -impl Router for RouterMock { - type Sender = T::AccountId; - - fn init(&self) -> DispatchResult { - pallet::Pallet::::init() - } - - fn send(&self, sender: Self::Sender, message: Vec) -> DispatchResultWithPostInfo { - pallet::Pallet::::send(sender, message) - } -} - -/// A mocked Router trait that emulates the actual Router trait but without -/// the inclusion of &self in the function parameters. This allows us to have -/// the mocked Routers pallet (defined above) implementing a Router-like trait -/// (and not just like regular pallet functions) when defining the mocked calls, -/// which is implicitly required by mock-builder or else it fails with `Location -/// must have trait info"`. -trait MockedRouter { - /// The sender type of the outbound message. - type Sender; - - /// Initialize the router. - fn init() -> DispatchResult; - - /// Send the message to the router's destination. - fn send(sender: Self::Sender, message: Vec) -> DispatchResultWithPostInfo; -} diff --git a/pallets/axelar-router/src/lib.rs b/pallets/axelar-router/src/lib.rs index 4ae51e65b2..c562fa584e 100644 --- a/pallets/axelar-router/src/lib.rs +++ b/pallets/axelar-router/src/lib.rs @@ -33,7 +33,7 @@ pub use pallet::*; use precompile_utils::prelude::*; use scale_info::prelude::{format, string::String}; use sp_core::{H160, H256, U256}; -use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec}; +use sp_std::{boxed::Box, collections::btree_map::BTreeMap, vec, vec::Vec}; #[cfg(test)] mod mock; @@ -149,7 +149,7 @@ pub mod pallet { pub enum Event { ConfigSet { name: ChainName, - config: AxelarConfig, + config: Box, }, } @@ -178,7 +178,7 @@ pub mod pallet { pub fn set_config( origin: OriginFor, chain_name: ChainName, - config: AxelarConfig, + config: Box, ) -> DispatchResult { T::AdminOrigin::ensure_origin(origin)?; @@ -203,7 +203,7 @@ pub mod pallet { Self::deposit_event(Event::::ConfigSet { name: chain_name, - config: config, + config, }); Ok(())