Replace system config Index for Nonce (#14290)

* replace Index by Nonce

* replace Index by Nonce

* replace Index by Nonce

* replace Index by Nonce

* replace Index by Nonce

* wip

* remove index in lieu of nonce

* wip

* remove accountnonce in lieu of nonce

* add minor improvement

* rebase and merge conflicts
This commit is contained in:
Juan
2023-07-14 08:56:48 +02:00
committed by GitHub
parent 0fbeb31d50
commit 6a29a70a92
132 changed files with 234 additions and 235 deletions
@@ -22,7 +22,7 @@ impl pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -1,6 +1,6 @@
use frame_support::construct_runtime;
use sp_runtime::{generic, traits::BlakeTwo256};
use sp_core::sr25519;
use sp_runtime::{generic, traits::BlakeTwo256};
#[frame_support::pallet]
mod pallet {
@@ -18,22 +18,22 @@ mod pallet {
#[derive(scale_info::TypeInfo, frame_support::PalletError, codec::Encode, codec::Decode)]
pub enum Nested1 {
Nested2(Nested2)
Nested2(Nested2),
}
#[derive(scale_info::TypeInfo, frame_support::PalletError, codec::Encode, codec::Decode)]
pub enum Nested2 {
Nested3(Nested3)
Nested3(Nested3),
}
#[derive(scale_info::TypeInfo, frame_support::PalletError, codec::Encode, codec::Decode)]
pub enum Nested3 {
Nested4(Nested4)
Nested4(Nested4),
}
#[derive(scale_info::TypeInfo, frame_support::PalletError, codec::Encode, codec::Decode)]
pub enum Nested4 {
Num(u8)
Num(u8),
}
pub type Signature = sr25519::Signature;
@@ -47,7 +47,7 @@ impl pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -1,6 +1,6 @@
use frame_support::construct_runtime;
use sp_runtime::{generic, traits::BlakeTwo256};
use sp_core::sr25519;
use sp_runtime::{generic, traits::BlakeTwo256};
#[frame_support::pallet]
mod pallet {
@@ -22,7 +22,7 @@ impl pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -1,6 +1,6 @@
use frame_support::construct_runtime;
use sp_runtime::{generic, traits::BlakeTwo256};
use sp_core::sr25519;
use sp_runtime::{generic, traits::BlakeTwo256};
#[frame_support::pallet]
mod pallet {
@@ -22,7 +22,7 @@ impl pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -1,6 +1,6 @@
use frame_support::construct_runtime;
use sp_runtime::{generic, traits::BlakeTwo256};
use sp_core::sr25519;
use sp_runtime::{generic, traits::BlakeTwo256};
#[frame_support::pallet]
mod pallet {
@@ -22,7 +22,7 @@ impl pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -1,6 +1,6 @@
use frame_support::construct_runtime;
use sp_runtime::{generic, traits::BlakeTwo256};
use sp_core::sr25519;
use sp_runtime::{generic, traits::BlakeTwo256};
#[frame_support::pallet]
mod pallet {
@@ -22,7 +22,7 @@ impl pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -1,6 +1,6 @@
use frame_support::construct_runtime;
use sp_runtime::{generic, traits::BlakeTwo256};
use sp_core::sr25519;
use sp_runtime::{generic, traits::BlakeTwo256};
#[frame_support::pallet]
mod pallet {
@@ -22,7 +22,7 @@ impl pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -22,7 +22,7 @@ impl pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
+1 -1
View File
@@ -656,7 +656,7 @@ frame_support::parameter_types!(
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -291,7 +291,7 @@ pub mod pallet2 {
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -5,7 +5,7 @@ mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config
where
<Self as frame_system::Config>::Index: From<u128>,
<Self as frame_system::Config>::Nonce: From<u128>,
{
}
@@ -5,7 +5,7 @@ mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config
where
<Self as frame_system::Config>::Index: From<u128>,
<Self as frame_system::Config>::Nonce: From<u128>,
{
}
@@ -5,7 +5,7 @@ mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config
where
<Self as frame_system::Config>::Index: From<u128>,
<Self as frame_system::Config>::Nonce: From<u128>,
{
}
@@ -5,7 +5,7 @@ mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config
where
<Self as frame_system::Config>::Index: From<u128>,
<Self as frame_system::Config>::Nonce: From<u128>,
{
}
@@ -1,10 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
use frame_support::{
traits::{
ConstU32,
},
};
use frame_support::traits::ConstU32;
pub use pallet::*;
@@ -60,7 +56,7 @@ pub mod pallet {
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -96,17 +92,15 @@ frame_support::construct_runtime!(
}
);
impl pallet::Config for Runtime {
}
impl pallet::Config for Runtime {}
fn main() {
use frame_support::{pallet_prelude::*};
use storage::unhashed;
use frame_support::pallet_prelude::*;
use sp_io::{
hashing::{blake2_128, twox_128},
TestExternalities,
};
use storage::unhashed;
fn blake2_128_concat(d: &[u8]) -> Vec<u8> {
let mut v = blake2_128(d).to_vec();
@@ -1,6 +1,6 @@
use frame_support::construct_runtime;
use sp_runtime::{generic, traits::BlakeTwo256};
use sp_core::sr25519;
use sp_runtime::{generic, traits::BlakeTwo256};
pub type Signature = sr25519::Signature;
pub type BlockNumber = u32;
@@ -13,7 +13,7 @@ impl test_pallet::Config for Runtime {}
impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -1,17 +1,24 @@
#[frame_support::pallet]
mod pallet {
#[pallet::config]
pub trait Config: frame_system::Config where <Self as frame_system::Config>::Index: From<u128> {}
pub trait Config: frame_system::Config
where
<Self as frame_system::Config>::Nonce: From<u128>,
{
}
#[pallet::pallet]
pub struct Pallet<T>(core::marker::PhantomData<T>);
#[pallet::call]
impl<T: Config> Pallet<T> where <T as frame_system::Config>::Index: From<u128> {}
impl<T: Config> Pallet<T> where <T as frame_system::Config>::Nonce: From<u128> {}
impl<T: Config> Pallet<T> where <T as frame_system::Config>::Index: From<u128> {
impl<T: Config> Pallet<T>
where
<T as frame_system::Config>::Nonce: From<u128>,
{
fn foo(x: u128) {
let _index = <T as frame_system::Config>::Index::from(x);
let _index = <T as frame_system::Config>::Nonce::from(x);
}
}
}
@@ -25,7 +25,6 @@ use scale_info::{form::MetaForm, meta_type};
use sp_runtime::traits::Block as BlockT;
pub type BlockNumber = u64;
pub type Index = u64;
pub type Header = sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>;
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, RuntimeCall, (), ()>;
@@ -36,7 +35,7 @@ impl frame_system::Config for Runtime {
type DbWeight = ();
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Index = u64;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
@@ -58,7 +58,7 @@ pub mod pallet {
}
pub type BlockNumber = u32;
pub type Index = u64;
pub type Nonce = u64;
pub type AccountId = u64;
pub type Header = sp_runtime::generic::Header<BlockNumber, sp_runtime::traits::BlakeTwo256>;
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, RuntimeCall, (), ()>;
@@ -70,7 +70,7 @@ impl frame_system::Config for Runtime {
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Index = Index;
type Nonce = Nonce;
type Hash = sp_runtime::testing::H256;
type Hashing = sp_runtime::traits::BlakeTwo256;
type AccountId = AccountId;