Skip to content

Commit

Permalink
revert moving queue traits to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Aug 18, 2024
1 parent 35248da commit fbfa663
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 43 deletions.
2 changes: 1 addition & 1 deletion libs/mocks/src/liquidity_pools_gateway.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libs/mocks/src/queue.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
1 change: 0 additions & 1 deletion libs/traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
23 changes: 22 additions & 1 deletion libs/traits/src/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
22 changes: 0 additions & 22 deletions libs/traits/src/queue.rs

This file was deleted.

2 changes: 1 addition & 1 deletion pallets/liquidity-pools-gateway-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion pallets/liquidity-pools-gateway-queue/src/tests.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down
9 changes: 3 additions & 6 deletions pallets/liquidity-pools-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*};
Expand Down
5 changes: 2 additions & 3 deletions pallets/liquidity-pools-gateway/src/message_processing.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
5 changes: 1 addition & 4 deletions pallets/liquidity-pools-gateway/src/tests.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/cases/queue.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/cases/routers.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit fbfa663

Please sign in to comment.