Skip to content

Commit

Permalink
Impl TypeId for Domain
Browse files Browse the repository at this point in the history
  • Loading branch information
NunoAlexandre committed Jul 21, 2022
1 parent 6c83c16 commit cbb6942
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pallets/connectors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ frame-support = { git = "https://github.com/paritytech/substrate", default-featu
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.24" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.24" }

# Substrate crates
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.24" }

# Optional dependencies for benchmarking
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false , optional = true , branch = "polkadot-v0.9.24" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , optional = true, branch = "polkadot-v0.9.24" }
Expand Down
16 changes: 13 additions & 3 deletions pallets/connectors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod pallet {
use crate::weights::WeightInfo;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_core::TypeId;

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
Expand Down Expand Up @@ -97,6 +98,15 @@ pub mod pallet {
Gnosis,
}

#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct DomainLocator<Domain> {
pub domain: Domain,
}

impl<Domain> TypeId for DomainLocator<Domain> {
const TYPE_ID: [u8; 4] = *b"domn";
}

#[derive(Encode, Decode, Default, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct DomainAddress(pub [u8; 32]);
Expand Down Expand Up @@ -129,10 +139,10 @@ pub mod pallet {
#[pallet::weight(<T as Config>::WeightInfo::add_pool())]
pub fn add_pool(
origin: OriginFor<T>,
pool_id: T::PoolId,
domain: Domain,
_pool_id: T::PoolId,
_domain: Domain,
) -> DispatchResult {
let who = ensure_signed(origin.clone())?;
let _who = ensure_signed(origin.clone())?;

//TODO(nuno)

Expand Down
2 changes: 1 addition & 1 deletion pallets/connectors/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl<PoolId> Encode for Message<PoolId> {
fn encode(&self) -> Vec<u8> {
match self {
Message::Invalid => vec![0u8],
Message::AddPool { pool_id } => {
Message::AddPool { pool_id: _ } => {
let mut message: Vec<u8> = vec![0u8];
message.append(&mut vec![1, 2, 3]); //todo(nuno): &mut pool_id.as_bytes().to_vec());
message
Expand Down

0 comments on commit cbb6942

Please sign in to comment.