Skip to content

Commit b1039bb

Browse files
authored
chore: refactor runtimes code (#797)
WIP. Fixes KILTprotocol/ticket#3672. Built on top of #790. ## Checklist - [x] Review Peregrine code - [x] Ask for review - [x] Apply to Spiritnet code
1 parent 9c326f9 commit b1039bb

File tree

57 files changed

+5235
-4522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+5235
-4522
lines changed

dip-template/pallets/pallet-postit/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub mod pallet {
6565
type OriginCheck: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin, Success = Self::OriginSuccess>;
6666
type OriginSuccess: GetUsername<Username = Self::Username>;
6767
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
68-
type Username: Encode + Decode + TypeInfo + MaxEncodedLen + Clone + PartialEq + Debug + Default;
68+
type Username: Encode + Decode + TypeInfo + MaxEncodedLen + Clone + PartialEq + Debug;
6969
}
7070

7171
#[pallet::storage]

dip-template/runtimes/dip-provider/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
3232

3333
use pallet_did_lookup::linkable_account::LinkableAccountId;
34-
use pallet_web3_names::web3_name::AsciiWeb3Name;
34+
use pallet_web3_names::Web3NameOf;
3535
use parity_scale_codec::{Decode, Encode};
3636
use scale_info::TypeInfo;
3737
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
@@ -437,8 +437,7 @@ impl pallet_did_lookup::Config for Runtime {
437437
type WeightInfo = weights::pallet_did_lookup::WeightInfo<Runtime>;
438438
}
439439

440-
pub type Web3Name = AsciiWeb3Name<Runtime>;
441-
440+
pub type Web3Name = runtime_common::Web3Name<3, 32>;
442441
impl pallet_web3_names::Config for Runtime {
443442
type BalanceMigrationManager = ();
444443
type BanOrigin = EnsureRoot<AccountId>;
@@ -642,7 +641,7 @@ impl_runtime_apis! {
642641
BlockNumber
643642
>
644643
> {
645-
let name: pallet_web3_names::web3_name::AsciiWeb3Name<Runtime> = name.try_into().ok()?;
644+
let name: Web3NameOf<Runtime> = name.try_into().ok()?;
646645
pallet_web3_names::Owner::<Runtime>::get(&name)
647646
.and_then(|owner_info| {
648647
did::Did::<Runtime>::get(&owner_info.owner).map(|details| (owner_info, details))

integration-tests/emulated/src/mock/para_chains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ decl_test_parachains! {
139139
runtime = peregrine_runtime,
140140
core = {
141141
XcmpMessageHandler: peregrine_runtime::XcmpQueue,
142-
LocationToAccountId: peregrine_runtime::xcm_config::LocationToAccountIdConverter,
142+
LocationToAccountId: peregrine_runtime::xcm::LocationToAccountIdConverter,
143143
ParachainInfo: peregrine_runtime::ParachainInfo,
144144
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
145145
},

nodes/parachain/src/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use cumulus_primitives_core::ParaId;
1919
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
2020
use log::info;
21-
use runtime_common::Block;
21+
use runtime_common::opaque::Block;
2222
use sc_cli::SubstrateCli;
2323
use sc_executor::NativeExecutionDispatch;
2424
use sp_runtime::traits::AccountIdConversion;

nodes/parachain/src/rpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use sp_api::ProvideRuntimeApi;
3232
use sp_block_builder::BlockBuilder;
3333
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
3434

35-
use runtime_common::{AccountId, Balance, Block, Nonce};
35+
use runtime_common::{opaque::Block, AccountId, Balance, Nonce};
3636

3737
/// A type representing all RPC extensions.
3838
pub(crate) type RpcExtension = jsonrpsee::RpcModule<()>;

nodes/standalone/src/rpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use sp_api::ProvideRuntimeApi;
3333
use sp_block_builder::BlockBuilder;
3434
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
3535

36-
use runtime_common::{AccountId, Balance, Block, Nonce};
36+
use runtime_common::{opaque::Block, AccountId, Balance, Nonce};
3737

3838
/// Full client dependencies.
3939
pub(crate) struct FullDeps<C, P> {

pallets/pallet-migration/src/benchmarking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,6 @@ benchmarks! {
242242

243243
impl_benchmark_test_suite! {
244244
Pallet,
245-
crate::mock::runtime::ExtBuilder::default().build_with_keystore(),
246-
crate::mock::runtime::Test
245+
crate::mock::ExtBuilder::default().build_with_keystore(),
246+
crate::mock::Test
247247
}

pallets/pallet-migration/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub mod default_weights;
2222

2323
#[cfg(feature = "runtime-benchmarks")]
2424
mod benchmarking;
25-
#[cfg(any(test, feature = "runtime-benchmarks"))]
25+
#[cfg(test)]
2626
mod mock;
2727
#[cfg(test)]
2828
mod test;
@@ -48,6 +48,7 @@ pub mod pallet {
4848
use frame_support::{
4949
pallet_prelude::*,
5050
traits::{fungible::Inspect, Currency, ReservableCurrency},
51+
DefaultNoBound,
5152
};
5253
use frame_system::pallet_prelude::*;
5354
use sp_runtime::{traits::Hash, SaturatedConversion};
@@ -66,15 +67,10 @@ pub mod pallet {
6667

6768
pub type HashOf<T> = <T as frame_system::Config>::Hash;
6869

69-
#[derive(Encode, Decode, TypeInfo, Debug, Clone, PartialEq, Eq)]
70+
#[derive(Encode, Decode, TypeInfo, Debug, Clone, PartialEq, Eq, DefaultNoBound)]
7071
pub struct EntriesToMigrate<T>
7172
where
72-
T: Config
73-
+ did::Config
74-
+ delegation::Config
75-
+ frame_system::Config
76-
+ pallet_web3_names::Config
77-
+ public_credentials::Config,
73+
T: Config + did::Config + delegation::Config + pallet_web3_names::Config + public_credentials::Config,
7874
{
7975
pub attestation: BoundedVec<ClaimHashOf<T>, <T as Config>::MaxMigrationsPerPallet>,
8076
pub delegation: BoundedVec<DelegationNodeIdOf<T>, <T as Config>::MaxMigrationsPerPallet>,

0 commit comments

Comments
 (0)