Skip to content

Commit 0d4e786

Browse files
Use fully qualify syntax for try-runtime usage
1 parent 97189ba commit 0d4e786

File tree

6 files changed

+30
-40
lines changed

6 files changed

+30
-40
lines changed

crates/humanode-runtime/src/storage_version_initializer.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
use core::marker::PhantomData;
22

3-
#[cfg(feature = "try-runtime")]
4-
use frame_support::{ensure, sp_runtime::TryRuntimeError};
53
use frame_support::{
64
log::info,
75
traits::{Get, GetStorageVersion, OnRuntimeUpgrade, PalletInfoAccess, StorageVersion},
86
weights::Weight,
97
};
10-
#[cfg(feature = "try-runtime")]
11-
use sp_std::vec::Vec;
128

139
/// Pallet storage version initializer.
1410
pub struct StorageVersionInitializer<P, R>(PhantomData<(P, R)>);
@@ -51,14 +47,16 @@ where
5147
}
5248

5349
#[cfg(feature = "try-runtime")]
54-
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
50+
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, frame_support::sp_runtime::TryRuntimeError> {
5551
// Do nothing.
56-
Ok(Vec::new())
52+
Ok(sp_std::vec::Vec::new())
5753
}
5854

5955
#[cfg(feature = "try-runtime")]
60-
fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError> {
61-
ensure!(
56+
fn post_upgrade(
57+
_state: sp_std::vec::Vec<u8>,
58+
) -> Result<(), frame_support::sp_runtime::TryRuntimeError> {
59+
frame_support::ensure!(
6260
P::on_chain_storage_version() == P::current_storage_version(),
6361
"the current storage version and onchain storage version should be the same"
6462
);

crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ use frame_support::{
1414
};
1515
pub use pallet::*;
1616
use sp_std::cmp::Ordering;
17-
#[cfg(feature = "try-runtime")]
18-
use sp_std::vec::Vec;
1917
pub use weights::*;
2018

2119
pub mod weights;
@@ -47,8 +45,6 @@ pub const CURRENT_BRIDGES_INITIALIZER_VERSION: u16 = 1;
4745
#[allow(clippy::missing_docs_in_private_items)]
4846
#[frame_support::pallet]
4947
pub mod pallet {
50-
#[cfg(feature = "try-runtime")]
51-
use frame_support::sp_runtime::TryRuntimeError;
5248
use frame_support::{pallet_prelude::*, sp_runtime::traits::MaybeDisplay};
5349
use frame_system::pallet_prelude::*;
5450
use sp_std::fmt::Debug;
@@ -149,12 +145,15 @@ pub mod pallet {
149145
}
150146

151147
#[cfg(feature = "try-runtime")]
152-
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
148+
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, frame_support::sp_runtime::TryRuntimeError>
149+
{
153150
upgrade_init::pre_upgrade()
154151
}
155152

156153
#[cfg(feature = "try-runtime")]
157-
fn post_upgrade(state: Vec<u8>) -> Result<(), TryRuntimeError> {
154+
fn post_upgrade(
155+
state: sp_std::vec::Vec<u8>,
156+
) -> Result<(), frame_support::sp_runtime::TryRuntimeError> {
158157
upgrade_init::post_upgrade::<T>(state)
159158
}
160159
}

crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
//! Initialization of the bridge pot accounts on runtime upgrade.
22
3-
#[cfg(feature = "try-runtime")]
4-
use frame_support::sp_runtime::TryRuntimeError;
53
use frame_support::{log, pallet_prelude::*};
6-
#[cfg(feature = "try-runtime")]
7-
use sp_std::vec::Vec;
84

95
use crate::{
106
Config, LastForceRebalanceAskCounter, LastInitializerVersion, Pallet,
@@ -40,22 +36,26 @@ pub fn on_runtime_upgrade<T: Config>() -> Weight {
4036
///
4137
/// Panics if anything goes wrong.
4238
#[cfg(feature = "try-runtime")]
43-
pub fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
39+
pub fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, frame_support::sp_runtime::TryRuntimeError> {
4440
// Do nothing.
45-
Ok(Vec::new())
41+
Ok(sp_std::vec::Vec::new())
4642
}
4743

4844
/// Check the state after the bridges initialization.
4945
///
5046
/// Panics if anything goes wrong.
5147
#[cfg(feature = "try-runtime")]
52-
pub fn post_upgrade<T: Config>(_state: Vec<u8>) -> Result<(), TryRuntimeError> {
48+
pub fn post_upgrade<T: Config>(
49+
_state: sp_std::vec::Vec<u8>,
50+
) -> Result<(), frame_support::sp_runtime::TryRuntimeError> {
5351
use frame_support::{storage_root, StateVersion};
5452

5553
let storage_root_before = storage_root(StateVersion::V1);
5654

5755
if !Pallet::<T>::is_balanced()? {
58-
return Err(TryRuntimeError::Other("currencies are not balanced"));
56+
return Err(frame_support::sp_runtime::TryRuntimeError::Other(
57+
"currencies are not balanced",
58+
));
5959
}
6060

6161
ensure!(

crates/pallet-dummy-precompiles-code/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ pub const DUMMY_CODE: &[u8] = &[0x5F, 0x5F, 0xFD];
3232
#[allow(clippy::missing_docs_in_private_items)]
3333
#[frame_support::pallet]
3434
pub mod pallet {
35-
#[cfg(feature = "try-runtime")]
36-
use frame_support::sp_runtime::TryRuntimeError;
3735
use frame_support::{pallet_prelude::*, sp_std::vec::Vec};
3836
use frame_system::pallet_prelude::*;
3937

@@ -103,15 +101,13 @@ pub mod pallet {
103101
}
104102

105103
#[cfg(feature = "try-runtime")]
106-
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
104+
fn pre_upgrade() -> Result<Vec<u8>, frame_support::sp_runtime::TryRuntimeError> {
107105
// Do nothing.
108106
Ok(Vec::new())
109107
}
110108

111109
#[cfg(feature = "try-runtime")]
112-
fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError> {
113-
use sp_std::vec::Vec;
114-
110+
fn post_upgrade(_state: Vec<u8>) -> Result<(), frame_support::sp_runtime::TryRuntimeError> {
115111
let mut not_created_precompiles = Vec::new();
116112

117113
for precompile_address in &T::PrecompilesAddresses::get() {
@@ -122,7 +118,7 @@ pub mod pallet {
122118
}
123119

124120
if !not_created_precompiles.is_empty() {
125-
return Err(TryRuntimeError::Other(
121+
return Err(frame_support::sp_runtime::TryRuntimeError::Other(
126122
"precompiles not created properly: {:not_created_precompiles}",
127123
));
128124
}

crates/pallet-erc20-support/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ type BalanceOf<T, I> = <<T as Config<I>>::Currency as Currency<AccountIdOf<T, I>
4646
pub mod pallet {
4747

4848
use frame_support::{pallet_prelude::*, sp_runtime::traits::MaybeDisplay, sp_std::fmt::Debug};
49-
#[cfg(feature = "try-runtime")]
50-
use frame_support::{
51-
sp_runtime::TryRuntimeError,
52-
sp_std::{vec, vec::Vec},
53-
};
5449
use frame_system::pallet_prelude::*;
5550

5651
use super::*;
@@ -123,12 +118,16 @@ pub mod pallet {
123118
}
124119

125120
#[cfg(feature = "try-runtime")]
126-
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
121+
fn pre_upgrade(
122+
) -> Result<frame_support::sp_std::vec::Vec<u8>, frame_support::sp_runtime::TryRuntimeError>
123+
{
127124
Ok(vec![])
128125
}
129126

130127
#[cfg(feature = "try-runtime")]
131-
fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError> {
128+
fn post_upgrade(
129+
_state: frame_support::sp_std::vec::Vec<u8>,
130+
) -> Result<(), frame_support::sp_runtime::TryRuntimeError> {
132131
ensure!(
133132
<Pallet<T, I>>::on_chain_storage_version()
134133
== <Pallet<T, I>>::current_storage_version(),

crates/pallet-humanode-session/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ pub mod pallet {
3434
use frame_support::pallet_prelude::*;
3535
use frame_system::pallet_prelude::*;
3636
use sp_runtime::BoundedBTreeSet;
37-
#[cfg(feature = "try-runtime")]
38-
use sp_runtime::TryRuntimeError;
3937

4038
use super::*;
4139

@@ -170,12 +168,12 @@ pub mod pallet {
170168
}
171169

172170
#[cfg(feature = "try-runtime")]
173-
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
171+
fn pre_upgrade() -> Result<Vec<u8>, frame_support::sp_runtime::TryRuntimeError> {
174172
Ok(migrations::v1::pre_migrate::<T>())
175173
}
176174

177175
#[cfg(feature = "try-runtime")]
178-
fn post_upgrade(state: Vec<u8>) -> Result<(), TryRuntimeError> {
176+
fn post_upgrade(state: Vec<u8>) -> Result<(), frame_support::sp_runtime::TryRuntimeError> {
179177
migrations::v1::post_migrate::<T>(state);
180178
Ok(())
181179
}

0 commit comments

Comments
 (0)