mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-04 02:17:23 +00:00
Public extrinsic apply doesn't panic (#178)
* Merge remote-tracking branch 'origin/master' into gav-xts-dont-panic * Update wasm. * consensus, session and staking all panic-safe. * Democracy doesn't panic in apply. * Fix tests. * Extra helper macro, council depanicked. * Fix one test. * Fix up all council tests. No panics! * Council voting depanicked. * utilise hygene
This commit is contained in:
@@ -44,3 +44,62 @@ mod hashable;
|
||||
pub use self::storage::{StorageVec, StorageList, StorageValue, StorageMap};
|
||||
pub use self::hashable::Hashable;
|
||||
pub use self::dispatch::{Parameter, Dispatchable, Callable, AuxDispatchable, AuxCallable, IsSubType, IsAuxSubType};
|
||||
pub use runtime_io::print;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! fail {
|
||||
( $y:expr ) => {{
|
||||
$crate::print($y);
|
||||
return;
|
||||
}}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ensure {
|
||||
( $x:expr, $y:expr ) => {{
|
||||
if !$x {
|
||||
fail!($y);
|
||||
}
|
||||
}};
|
||||
($x:expr) => {{
|
||||
if !$x {
|
||||
$crate::print("Bailing! Cannot ensure: ");
|
||||
$crate::print(stringify!($x));
|
||||
return;
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ensure_unwrap {
|
||||
($x:expr, $y: expr) => {
|
||||
if let Some(v) = $x {
|
||||
v
|
||||
} else {
|
||||
fail!{$y}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! ensure_unwrap_err {
|
||||
($x:expr, $y: expr) => {
|
||||
if let Err(v) = $x {
|
||||
v
|
||||
} else {
|
||||
fail!{$y}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
#[cfg(feature = "std")]
|
||||
macro_rules! assert_noop {
|
||||
( $( $x:tt )* ) => {
|
||||
let h = runtime_io::storage_root();
|
||||
{
|
||||
$( $x )*
|
||||
}
|
||||
assert_eq!(h, runtime_io::storage_root());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user