mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-29 02:07:25 +00:00
BREAKING - Try-runtime: Use proper error types (#13993)
* Try-state: DispatchResult as return type * try_state for the rest of the pallets * pre_upgrade * post_upgrade * try_runtime_upgrade * fixes * bags-list fix * fix * update test * warning fix * ... * final fixes 🤞 * warning.. * frame-support * warnings * Update frame/staking/src/migrations.rs Co-authored-by: Liam Aharon <liam.aharon@hotmail.com> * fix * fix warning * nit fix * merge fixes * small fix * should be good now * missed these ones * introduce TryRuntimeError and TryRuntimeResult * fixes * fix * removed TryRuntimeResult & made some fixes * fix testsg * tests passing * unnecessary imports * Update frame/assets/src/migration.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> --------- Co-authored-by: Liam Aharon <liam.aharon@hotmail.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
use impl_trait_for_tuples::impl_for_tuples;
|
||||
use sp_arithmetic::traits::AtLeast32BitUnsigned;
|
||||
use sp_runtime::TryRuntimeError;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
/// Which state tests to execute.
|
||||
@@ -129,7 +130,7 @@ impl core::str::FromStr for UpgradeCheckSelect {
|
||||
/// This hook should not alter any storage.
|
||||
pub trait TryState<BlockNumber> {
|
||||
/// Execute the state checks.
|
||||
fn try_state(_: BlockNumber, _: Select) -> Result<(), &'static str>;
|
||||
fn try_state(_: BlockNumber, _: Select) -> Result<(), TryRuntimeError>;
|
||||
}
|
||||
|
||||
#[cfg_attr(all(not(feature = "tuples-96"), not(feature = "tuples-128")), impl_for_tuples(64))]
|
||||
@@ -139,7 +140,7 @@ impl<BlockNumber: Clone + sp_std::fmt::Debug + AtLeast32BitUnsigned> TryState<Bl
|
||||
for Tuple
|
||||
{
|
||||
for_tuples!( where #( Tuple: crate::traits::PalletInfoAccess )* );
|
||||
fn try_state(n: BlockNumber, targets: Select) -> Result<(), &'static str> {
|
||||
fn try_state(n: BlockNumber, targets: Select) -> Result<(), TryRuntimeError> {
|
||||
match targets {
|
||||
Select::None => Ok(()),
|
||||
Select::All => {
|
||||
@@ -148,7 +149,7 @@ impl<BlockNumber: Clone + sp_std::fmt::Debug + AtLeast32BitUnsigned> TryState<Bl
|
||||
result
|
||||
},
|
||||
Select::RoundRobin(len) => {
|
||||
let functions: &[fn(BlockNumber, Select) -> Result<(), &'static str>] =
|
||||
let functions: &[fn(BlockNumber, Select) -> Result<(), TryRuntimeError>] =
|
||||
&[for_tuples!(#( Tuple::try_state ),*)];
|
||||
let skip = n.clone() % (functions.len() as u32).into();
|
||||
let skip: u32 =
|
||||
@@ -163,7 +164,7 @@ impl<BlockNumber: Clone + sp_std::fmt::Debug + AtLeast32BitUnsigned> TryState<Bl
|
||||
Select::Only(ref pallet_names) => {
|
||||
let try_state_fns: &[(
|
||||
&'static str,
|
||||
fn(BlockNumber, Select) -> Result<(), &'static str>,
|
||||
fn(BlockNumber, Select) -> Result<(), TryRuntimeError>,
|
||||
)] = &[for_tuples!(
|
||||
#( (<Tuple as crate::traits::PalletInfoAccess>::name(), Tuple::try_state) ),*
|
||||
)];
|
||||
|
||||
Reference in New Issue
Block a user