diff --git a/libs/mocks/src/liquidity_pools_gateway.rs b/libs/mocks/src/liquidity_pools_gateway.rs index 1286fac644..56561a7249 100644 --- a/libs/mocks/src/liquidity_pools_gateway.rs +++ b/libs/mocks/src/liquidity_pools_gateway.rs @@ -1,6 +1,6 @@ #[frame_support::pallet(dev_mode)] pub mod pallet { - use cfg_traits::{liquidity_pools::OutboundMessageHandler, queue::MessageProcessor}; + use cfg_traits::liquidity_pools::{MessageProcessor, OutboundMessageHandler}; use frame_support::pallet_prelude::*; use mock_builder::{execute_call, register_call, CallHandler}; use orml_traits::GetByKey; diff --git a/libs/mocks/src/queue.rs b/libs/mocks/src/queue.rs index e2e32476ab..a368399ee6 100644 --- a/libs/mocks/src/queue.rs +++ b/libs/mocks/src/queue.rs @@ -1,6 +1,6 @@ #[frame_support::pallet(dev_mode)] pub mod pallet { - use cfg_traits::queue::MessageQueue; + use cfg_traits::liquidity_pools::MessageQueue; use frame_support::pallet_prelude::*; use mock_builder::{execute_call, register_call, CallHandler}; diff --git a/libs/traits/src/lib.rs b/libs/traits/src/lib.rs index f7ba6f2707..5860bbfb98 100644 --- a/libs/traits/src/lib.rs +++ b/libs/traits/src/lib.rs @@ -38,7 +38,6 @@ pub mod fees; pub mod interest; pub mod investments; pub mod liquidity_pools; -pub mod queue; pub mod rewards; pub mod swaps; diff --git a/libs/traits/src/liquidity_pools.rs b/libs/traits/src/liquidity_pools.rs index 493796030a..9fe1c4f4a7 100644 --- a/libs/traits/src/liquidity_pools.rs +++ b/libs/traits/src/liquidity_pools.rs @@ -11,7 +11,7 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -use frame_support::dispatch::DispatchResult; +use frame_support::{dispatch::DispatchResult, weights::Weight}; use sp_runtime::DispatchError; use sp_std::vec::Vec; @@ -94,6 +94,27 @@ pub trait MessageReceiver { ) -> DispatchResult; } +/// The trait required for queueing messages. +pub trait MessageQueue { + /// The message type. + type Message; + + /// Submit a message to the queue. + fn queue(msg: Self::Message) -> DispatchResult; +} + +/// The trait required for processing dequeued messages. +pub trait MessageProcessor { + /// The message type. + type Message; + + /// Process a message. + fn process(msg: Self::Message) -> (DispatchResult, Weight); + + /// Max weight that processing a message can take + fn max_processing_weight(msg: &Self::Message) -> Weight; +} + /// The trait required for handling outbound LP messages. pub trait OutboundMessageHandler { /// The sender type of the outbound message. diff --git a/libs/traits/src/queue.rs b/libs/traits/src/queue.rs deleted file mode 100644 index f16ca5aa04..0000000000 --- a/libs/traits/src/queue.rs +++ /dev/null @@ -1,22 +0,0 @@ -use frame_support::{dispatch::DispatchResult, weights::Weight}; - -/// The trait required for queueing messages. -pub trait MessageQueue { - /// The message type. - type Message; - - /// Submit a message to the queue. - fn queue(msg: Self::Message) -> DispatchResult; -} - -/// The trait required for processing dequeued messages. -pub trait MessageProcessor { - /// The message type. - type Message; - - /// Process a message. - fn process(msg: Self::Message) -> (DispatchResult, Weight); - - /// Max weight that processing a message can take - fn max_processing_weight(msg: &Self::Message) -> Weight; -} diff --git a/pallets/liquidity-pools-gateway-queue/src/lib.rs b/pallets/liquidity-pools-gateway-queue/src/lib.rs index 775b4504f7..ff3a45b7af 100644 --- a/pallets/liquidity-pools-gateway-queue/src/lib.rs +++ b/pallets/liquidity-pools-gateway-queue/src/lib.rs @@ -14,7 +14,7 @@ use core::fmt::Debug; -use cfg_traits::queue::{MessageProcessor, MessageQueue as MessageQueueT}; +use cfg_traits::liquidity_pools::{MessageProcessor, MessageQueue as MessageQueueT}; use frame_support::{dispatch::PostDispatchInfo, pallet_prelude::*}; use frame_system::pallet_prelude::*; pub use pallet::*; diff --git a/pallets/liquidity-pools-gateway-queue/src/tests.rs b/pallets/liquidity-pools-gateway-queue/src/tests.rs index f93f5b637d..1f89bac710 100644 --- a/pallets/liquidity-pools-gateway-queue/src/tests.rs +++ b/pallets/liquidity-pools-gateway-queue/src/tests.rs @@ -1,4 +1,4 @@ -use cfg_traits::queue::MessageQueue as _; +use cfg_traits::liquidity_pools::MessageQueue as _; use frame_support::{ assert_noop, assert_ok, dispatch::RawOrigin, pallet_prelude::Hooks, weights::Weight, }; diff --git a/pallets/liquidity-pools-gateway/src/lib.rs b/pallets/liquidity-pools-gateway/src/lib.rs index aadbbf1ff6..7a2a85ae8e 100644 --- a/pallets/liquidity-pools-gateway/src/lib.rs +++ b/pallets/liquidity-pools-gateway/src/lib.rs @@ -29,12 +29,9 @@ use core::fmt::Debug; use cfg_primitives::LP_DEFENSIVE_WEIGHT; -use cfg_traits::{ - liquidity_pools::{ - InboundMessageHandler, LPMessage, MessageHash, MessageReceiver, MessageSender, - OutboundMessageHandler, RouterProvider, - }, - queue::{MessageProcessor, MessageQueue}, +use cfg_traits::liquidity_pools::{ + InboundMessageHandler, LPMessage, MessageHash, MessageProcessor, MessageQueue, MessageReceiver, + MessageSender, OutboundMessageHandler, RouterProvider, }; use cfg_types::domain_address::{Domain, DomainAddress}; use frame_support::{dispatch::DispatchResult, pallet_prelude::*}; diff --git a/pallets/liquidity-pools-gateway/src/message_processing.rs b/pallets/liquidity-pools-gateway/src/message_processing.rs index 5dc5e289c8..a01b6bbb94 100644 --- a/pallets/liquidity-pools-gateway/src/message_processing.rs +++ b/pallets/liquidity-pools-gateway/src/message_processing.rs @@ -1,6 +1,5 @@ -use cfg_traits::{ - liquidity_pools::{InboundMessageHandler, LPMessage, MessageHash, RouterProvider}, - queue::MessageQueue, +use cfg_traits::liquidity_pools::{ + InboundMessageHandler, LPMessage, MessageHash, MessageQueue, RouterProvider, }; use cfg_types::domain_address::{Domain, DomainAddress}; use frame_support::{ diff --git a/pallets/liquidity-pools-gateway/src/tests.rs b/pallets/liquidity-pools-gateway/src/tests.rs index 305882ea03..3793d8fd2c 100644 --- a/pallets/liquidity-pools-gateway/src/tests.rs +++ b/pallets/liquidity-pools-gateway/src/tests.rs @@ -1,10 +1,7 @@ use std::collections::HashMap; use cfg_primitives::LP_DEFENSIVE_WEIGHT; -use cfg_traits::{ - liquidity_pools::{LPMessage, OutboundMessageHandler}, - queue::MessageProcessor, -}; +use cfg_traits::liquidity_pools::{LPMessage, MessageProcessor, OutboundMessageHandler}; use cfg_types::domain_address::*; use frame_support::{assert_err, assert_noop, assert_ok}; use itertools::Itertools; diff --git a/runtime/integration-tests/src/cases/queue.rs b/runtime/integration-tests/src/cases/queue.rs index 79b5b38ed2..07762104b9 100644 --- a/runtime/integration-tests/src/cases/queue.rs +++ b/runtime/integration-tests/src/cases/queue.rs @@ -1,4 +1,4 @@ -use cfg_traits::queue::MessageQueue; +use cfg_traits::liquidity_pools::MessageQueue; use cfg_types::domain_address::DomainAddress; use frame_support::{assert_ok, traits::OriginTrait}; use pallet_liquidity_pools::Message; diff --git a/runtime/integration-tests/src/cases/routers.rs b/runtime/integration-tests/src/cases/routers.rs index 09069b2ee5..56d655b59e 100644 --- a/runtime/integration-tests/src/cases/routers.rs +++ b/runtime/integration-tests/src/cases/routers.rs @@ -1,5 +1,5 @@ use cfg_primitives::Balance; -use cfg_traits::{liquidity_pools::LPMessage, queue::MessageProcessor}; +use cfg_traits::liquidity_pools::{LPMessage, MessageProcessor}; use cfg_types::{ domain_address::{Domain, DomainAddress}, EVMChainId,