mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 09:17:58 +00:00
20a3989785
* Implement Printable for tuples. * Add debugging function. * Add debug 1. * Implement for everything. * RuntimeDebug derive. * Introduce RuntimeDebug. * Add some dummy logging. * Replace RuntimeDebug with Debug. * Revert "Replace RuntimeDebug with Debug." This reverts commit bc47070a8cb30241b2b590b2fa29fd195088162f. * Working on Debug for all. * Fix bounds. * Add debug utils. * Implement runtime logging. * Add some docs and clean up. * Clean up derives. * Fix custom derive impl. * Bump runtime. * Fix long lines. * Fix doc test. * Use CARGO_CFG_STD. * Revert "Use CARGO_CFG_STD." This reverts commit ea429566de18ed0fa052571b359eb9826a64a9f4. * Use parse_macro_input * Update lockfile. * Apply review suggestions. * Remove stray re-export. * Add no-std impl. * Update lockfile.
65 lines
1.4 KiB
Rust
65 lines
1.4 KiB
Rust
use support::codec::{Encode, Decode, EncodeLike};
|
|
|
|
pub trait Trait: 'static + Eq + Clone {
|
|
type Origin: Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
|
|
+ From<RawOrigin<Self::AccountId>>;
|
|
|
|
type BlockNumber: Decode + Encode + EncodeLike + Clone + Default;
|
|
type Hash;
|
|
type AccountId: Encode + EncodeLike + 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,
|
|
}
|
|
);
|
|
|
|
support::decl_error! {
|
|
pub enum Error {
|
|
/// Test error documentation
|
|
TestError,
|
|
/// Error documentation
|
|
/// with multiple lines
|
|
AnotherError
|
|
}
|
|
}
|
|
|
|
/// Origin for the system module.
|
|
#[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)]
|
|
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")
|
|
}
|