Skip to content

Commit

Permalink
Move router types to routers.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
NunoAlexandre committed Jul 21, 2022
1 parent a593622 commit 6c83c16
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
35 changes: 3 additions & 32 deletions pallets/connectors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ pub mod weights;
mod message;
pub use message::*;

mod routers;
pub use routers::*;

// Type aliases
type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
type PoolIdOf<T> = <T as pallet::Config>::PoolId;

#[frame_support::pallet]
Expand All @@ -28,8 +30,6 @@ pub mod pallet {
use crate::weights::WeightInfo;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use frame_system::RawOrigin;
use sp_std::collections::btree_map::BTreeMap;

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
Expand Down Expand Up @@ -101,25 +101,6 @@ pub mod pallet {
#[cfg_attr(feature = "std", derive(Debug))]
pub struct DomainAddress(pub [u8; 32]);

#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Router {
Nomad(NomadRouter),
XCM(XCMRouter),
}

#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct NomadRouter {
forwarding_contract: String, // TODO(nuno): make it a MultiLocation
}

#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct XCMRouter {
multilocations: (), // TODO(nuno): make it a Map<Domain, MultiLocation>
}

#[pallet::storage]
pub(crate) type Routers<T: Config> = StorageMap<_, Blake2_128Concat, Domain, Router>;

Expand All @@ -137,16 +118,6 @@ pub mod pallet {
pub(crate) type LinkedAddresses<T: Config> =
StorageDoubleMap<_, Blake2_128Concat, Domain, Blake2_128Concat, DomainAddress, bool>;

#[pallet::storage]
pub(crate) type DomainBalances<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
Domain,
Blake2_128Concat,
T::CurrencyId, // future proof to make it work for non tranche tokens
T::Balance,
>;

#[pallet::error]
pub enum Error<T> {
ToDo,
Expand Down
21 changes: 21 additions & 0 deletions pallets/connectors/src/routers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use codec::{Decode, Encode};
use scale_info::TypeInfo;

#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Router {
Nomad(NomadRouter),
XCM(XCMRouter),
}

#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct NomadRouter {
forwarding_contract: String, // TODO(nuno): make it a MultiLocation
}

#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct XCMRouter {
multilocations: (), // TODO(nuno): make it a Map<Domain, MultiLocation>
}

0 comments on commit 6c83c16

Please sign in to comment.