Skip to content

Commit

Permalink
made account principal optional
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Mar 15, 2022
1 parent 2eaac08 commit dc7618d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions parachain/pallets/basic-channel/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ pub mod pallet {
/// Fee for accepting a message
#[pallet::storage]
#[pallet::getter(fn principal)]
pub type Principal<T: Config> = StorageValue<_, T::AccountId, ValueQuery>;
pub type Principal<T: Config> = StorageValue<_, Option<T::AccountId>, ValueQuery>;

#[pallet::storage]
pub type Nonce<T: Config> = StorageValue<_, u64, ValueQuery>;

#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub interval: T::BlockNumber,
pub principal: T::AccountId,
pub principal: Option<T::AccountId>,
}

#[cfg(feature = "std")]
Expand Down Expand Up @@ -153,15 +153,17 @@ pub mod pallet {
) -> DispatchResult {
T::SetPrincipalOrigin::ensure_origin(origin)?;
let principal = T::Lookup::lookup(principal)?;
<Principal<T>>::put(principal);
<Principal<T>>::put(Some(principal));
Ok(())
}
}

impl<T: Config> Pallet<T> {
/// Submit message on the outbound channel
pub fn submit(who: &T::AccountId, target: H160, payload: &[u8]) -> DispatchResult {
ensure!(*who == Self::principal(), Error::<T>::NotAuthorized,);
let principal = Self::principal();
ensure!(principal.is_some(), Error::<T>::NotAuthorized,);
ensure!(*who == principal.unwrap(), Error::<T>::NotAuthorized,);
ensure!(
<MessageQueue<T>>::decode_len().unwrap_or(0)
< T::MaxMessagesPerCommit::get() as usize,
Expand Down

0 comments on commit dc7618d

Please sign in to comment.