mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 22:18:00 +00:00
c284ca2138
* Fix some instances of `runtime-io` * Patch a bunch * More patches for consistancy * more patch * Fix various build issues * Fix tests * Patch `srml-support-*` crates * Fix doc tests * Revert "Fix doc tests" This reverts commit ba2ec61da7acc36821a70e76a31a6a5bf13bbe95. * Revert "Patch `srml-support-*` crates" This reverts commit 9a6070450107dec17784ba34af4b871023f6dc81. * Missed one * Fix doc tests
56 lines
1.3 KiB
Rust
56 lines
1.3 KiB
Rust
use support::codec::{Encode, Decode};
|
|
|
|
pub trait Trait: 'static + Eq + Clone {
|
|
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
|
|
+ From<RawOrigin<Self::AccountId>>;
|
|
|
|
type BlockNumber: Decode + Encode + Clone + Default;
|
|
type Hash;
|
|
type AccountId: Encode + Decode;
|
|
type Event: From<Event>;
|
|
}
|
|
|
|
support::decl_module! {
|
|
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
|
}
|
|
}
|
|
|
|
impl<T: Trait> Module<T> {
|
|
pub fn deposit_event(_event: impl Into<T::Event>) {
|
|
}
|
|
}
|
|
|
|
support::decl_event!(
|
|
pub enum Event {
|
|
ExtrinsicSuccess,
|
|
ExtrinsicFailed,
|
|
}
|
|
);
|
|
|
|
/// Origin for the system module.
|
|
#[derive(PartialEq, Eq, Clone)]
|
|
#[cfg_attr(feature = "std", derive(Debug))]
|
|
pub enum RawOrigin<AccountId> {
|
|
Root,
|
|
Signed(AccountId),
|
|
None,
|
|
}
|
|
|
|
impl<AccountId> From<Option<AccountId>> for RawOrigin<AccountId> {
|
|
fn from(s: Option<AccountId>) -> RawOrigin<AccountId> {
|
|
match s {
|
|
Some(who) => RawOrigin::Signed(who),
|
|
None => RawOrigin::None,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub type Origin<T> = RawOrigin<<T as Trait>::AccountId>;
|
|
|
|
#[allow(dead_code)]
|
|
pub fn ensure_root<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<(), &'static str>
|
|
where OuterOrigin: Into<Result<RawOrigin<AccountId>, OuterOrigin>>
|
|
{
|
|
o.into().map(|_| ()).map_err(|_| "bad origin: expected to be a root origin")
|
|
}
|