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 19, 2022
1 parent 7d682b0 commit cf020b4
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 cf020b4

Please sign in to comment.