mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 16:37:57 +00:00
Add support for modules to require inherent to be present (#5792)
* Add support for modules to require inherent to be present * Bump node impl version * Allow is_inherent_required itself to return error This handles the case if runtime fails to check the inherent data (if the inherent data is invalid, etc). * typo: &module -> $module * fix: iter
This commit is contained in:
@@ -77,7 +77,7 @@ macro_rules! impl_outer_inherent {
|
||||
let mut result = $crate::inherent::CheckInherentsResult::new();
|
||||
for xt in block.extrinsics() {
|
||||
if $crate::inherent::Extrinsic::is_signed(xt).unwrap_or(false) {
|
||||
break;
|
||||
break
|
||||
}
|
||||
|
||||
$(
|
||||
@@ -88,7 +88,7 @@ macro_rules! impl_outer_inherent {
|
||||
$module::INHERENT_IDENTIFIER, &e
|
||||
).expect("There is only one fatal error; qed");
|
||||
if e.is_fatal_error() {
|
||||
return result;
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,41 @@ macro_rules! impl_outer_inherent {
|
||||
)*
|
||||
}
|
||||
|
||||
$(
|
||||
match $module::is_inherent_required(self) {
|
||||
Ok(Some(e)) => {
|
||||
let found = block.extrinsics().iter().any(|xt| {
|
||||
if $crate::inherent::Extrinsic::is_signed(xt).unwrap_or(false) {
|
||||
return false
|
||||
}
|
||||
|
||||
match xt.function {
|
||||
Call::$call(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
|
||||
if !found {
|
||||
result.put_error(
|
||||
$module::INHERENT_IDENTIFIER, &e
|
||||
).expect("There is only one fatal error; qed");
|
||||
if e.is_fatal_error() {
|
||||
return result
|
||||
}
|
||||
}
|
||||
},
|
||||
Ok(None) => (),
|
||||
Err(e) => {
|
||||
result.put_error(
|
||||
$module::INHERENT_IDENTIFIER, &e
|
||||
).expect("There is only one fatal error; qed");
|
||||
if e.is_fatal_error() {
|
||||
return result
|
||||
}
|
||||
},
|
||||
}
|
||||
)*
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user