diff --git a/parachain/pallets/basic-channel/src/outbound/mod.rs b/parachain/pallets/basic-channel/src/outbound/mod.rs index 9a09452de1..ce7c37be5d 100644 --- a/parachain/pallets/basic-channel/src/outbound/mod.rs +++ b/parachain/pallets/basic-channel/src/outbound/mod.rs @@ -103,7 +103,7 @@ pub mod pallet { /// Fee for accepting a message #[pallet::storage] #[pallet::getter(fn principal)] - pub type Principal = StorageValue<_, T::AccountId, ValueQuery>; + pub type Principal = StorageValue<_, Option, ValueQuery>; #[pallet::storage] pub type Nonce = StorageValue<_, u64, ValueQuery>; @@ -111,7 +111,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { pub interval: T::BlockNumber, - pub principal: T::AccountId, + pub principal: Option, } #[cfg(feature = "std")] @@ -153,7 +153,7 @@ pub mod pallet { ) -> DispatchResult { T::SetPrincipalOrigin::ensure_origin(origin)?; let principal = T::Lookup::lookup(principal)?; - >::put(principal); + >::put(Some(principal)); Ok(()) } } @@ -161,7 +161,9 @@ pub mod pallet { impl Pallet { /// Submit message on the outbound channel pub fn submit(who: &T::AccountId, target: H160, payload: &[u8]) -> DispatchResult { - ensure!(*who == Self::principal(), Error::::NotAuthorized,); + let principal = Self::principal(); + ensure!(principal.is_some(), Error::::NotAuthorized,); + ensure!(*who == principal.unwrap(), Error::::NotAuthorized,); ensure!( >::decode_len().unwrap_or(0) < T::MaxMessagesPerCommit::get() as usize,