From dc7618d7c2c6788cbbc31d11d9a443b46a48dc7e Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Tue, 15 Mar 2022 10:32:07 +0000 Subject: [PATCH] made account principal optional https://github.com/paritytech/substrate/pull/10403 --- parachain/pallets/basic-channel/src/outbound/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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,