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
@@ -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);
}
}
}