diff --git a/Cargo.toml b/Cargo.toml index 51d95a9a..f2200c1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,52 @@ members = [ "INV4/pallet-inv4", "OCIF/staking", "pallet-checked-inflation", - "pallet-rings" + "pallet-rings", ] + +[workspace.dependencies] + +# crates.io dependencies +codec = { package = "parity-scale-codec", version = "3.6.5", features = [ + "derive", +], default-features = false } +log = { version = "0.4.20", default-features = false } +num-traits = { version = "0.2", default-features = false } +scale-info = { version = "2.10.0", default-features = false, features = [ + "derive", +] } +serde = { version = "1.0.189", features = ["derive"] } +smallvec = { version = "1.6.1" } + +# polkadot-sdk dependencies +frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +pallet-session = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +sp-api = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +sp-arithmetic = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +sp-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } +xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk.git", default-features = false, branch = "release-polkadot-v1.6.0" } + + +# dev dependencies + +orml-asset-registry = { git = "https://github.com/InvArch/open-runtime-module-library.git", default-features = false, branch = "polkadot-v1.6.0" } +orml-tokens2 = { package = "orml-tokens", git = "https://github.com/arrudagates/open-runtime-module-library.git", default-features = false, rev = "bc6b41e8a9539971a2da5d62cf8f550cde985f00" } +orml-traits2 = { package = "orml-traits", git = "https://github.com/arrudagates/open-runtime-module-library.git", default-features = false, rev = "bc6b41e8a9539971a2da5d62cf8f550cde985f00" } + +orml-tokens = { package = "orml-tokens", git = "https://github.com/InvArch/open-runtime-module-library.git", default-features = false, branch = "polkadot-v1.6.0" } +orml-traits = { package = "orml-traits", git = "https://github.com/InvArch/open-runtime-module-library.git", default-features = false, branch = "polkadot-v1.6.0" } + +# orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +# orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } +# orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } diff --git a/INV4/pallet-inv4/Cargo.toml b/INV4/pallet-inv4/Cargo.toml index e8fe555e..20e7ff20 100644 --- a/INV4/pallet-inv4/Cargo.toml +++ b/INV4/pallet-inv4/Cargo.toml @@ -9,60 +9,67 @@ repository = 'https://github.com/InvArch/InvArch-Frames' version = '0.1.0-dev' [dependencies] -serde = { version = "1.0.132", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -smallvec = "1.6.1" +serde = { workspace = true, optional = true } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ + "derive", "max-encoded-len" +] } +sp-runtime = { workspace = true, default-features = false } +sp-arithmetic = { workspace = true, default-features = false } +sp-std = { workspace = true, default-features = false } +frame-support = { workspace = true, default-features = false } +smallvec = { workspace = true } -scale-info = { version = "2.0.0", features = ["derive"], default-features = false } +scale-info = { workspace = true, default-features = false } -log = { version = "0.4.14", default-features = false } +log = { workspace = true, default-features = false } # InvArch dependencies primitives = { package = "invarch-primitives", path = "../../primitives", default-features = false } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +sp-io = { workspace = true, default-features = false } +sp-api = { workspace = true, default-features = false } +sp-core = { workspace = true, default-features = false } -pallet-balances = { git = 'https://github.com/paritytech/substrate.git', default-features = false , branch = "polkadot-v0.9.43" } +pallet-balances = { workspace = true, default-features = false } -frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', default-features = false, optional = true , branch = "polkadot-v0.9.43" } +frame-system = { workspace = true, default-features = false } # frame-benchmarking requires system +frame-benchmarking = { workspace = true, default-features = false, optional = true } -orml-tokens2 = { package = "orml-tokens", git = "https://github.com/arrudagates/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.43" } +xcm = { workspace = true, default-features = false } +orml-tokens2 = { workspace = true, default-features = false } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } -orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -orml-traits2 = { package = "orml-traits", git = "https://github.com/arrudagates/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } + +orml-traits2 = { workspace = true, default-features = false } +orml-tokens = { workspace = true, default-features = false } +orml-traits = { workspace = true, default-features = false } +orml-asset-registry = { workspace = true, default-features = false } + [features] default = ["std"] std = [ - "serde", - "codec/std", - "sp-runtime/std", - "sp-std/std", - "frame-support/std", - "frame-system/std", - "sp-io/std", - "scale-info/std", - "pallet-balances/std", - "frame-benchmarking?/std", - "orml-asset-registry/std", - "orml-tokens/std", + "serde", + "codec/std", + "sp-runtime/std", + "sp-std/std", + "frame-support/std", + "frame-system/std", + "sp-io/std", + "scale-info/std", + "pallet-balances/std", + "frame-benchmarking?/std", + "xcm/std", + "orml-asset-registry/std", + "orml-tokens/std", + "orml-tokens2/std", + "orml-traits/std", + "orml-traits2/std", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/INV4/pallet-inv4/src/account_derivation.rs b/INV4/pallet-inv4/src/account_derivation.rs index e2abd15c..a9a0e4cb 100644 --- a/INV4/pallet-inv4/src/account_derivation.rs +++ b/INV4/pallet-inv4/src/account_derivation.rs @@ -14,7 +14,7 @@ use crate::{Config, Pallet}; use codec::{Compact, Encode}; use frame_support::traits::Get; use sp_io::hashing::blake2_256; -use xcm::latest::{BodyId, BodyPart, Junction, Junctions}; +use xcm::v3::{BodyId, BodyPart, Junction, Junctions}; /// Trait providing the XCM location and the derived account of a core. pub trait CoreAccountDerivation { /// Derives the core's AccountId. diff --git a/INV4/pallet-inv4/src/dispatch.rs b/INV4/pallet-inv4/src/dispatch.rs index ff026c2d..8721faee 100644 --- a/INV4/pallet-inv4/src/dispatch.rs +++ b/INV4/pallet-inv4/src/dispatch.rs @@ -11,10 +11,9 @@ use crate::{ origin::{INV4Origin, MultisigInternalOrigin}, Config, Error, }; -use frame_support::{ - dispatch::{Dispatchable, GetDispatchInfo}, - pallet_prelude::*, -}; +use frame_support::{dispatch::GetDispatchInfo, pallet_prelude::*}; + +use sp_runtime::traits::Dispatchable; /// Dispatch a call executing pre/post dispatch for proper fee handling. pub fn dispatch_call( diff --git a/INV4/pallet-inv4/src/lib.rs b/INV4/pallet-inv4/src/lib.rs index 3f20965f..a67f9704 100644 --- a/INV4/pallet-inv4/src/lib.rs +++ b/INV4/pallet-inv4/src/lib.rs @@ -63,7 +63,7 @@ pub mod pallet { use super::*; use codec::FullCodec; use frame_support::{ - dispatch::{Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo}, + dispatch::{GetDispatchInfo, Pays, PostDispatchInfo}, pallet_prelude::*, traits::{ fungibles, @@ -76,7 +76,7 @@ pub mod pallet { use primitives::CoreInfo; use scale_info::prelude::fmt::Display; use sp_runtime::{ - traits::{AtLeast32BitUnsigned, Member}, + traits::{AtLeast32BitUnsigned, Dispatchable, Member}, Perbill, }; use sp_std::{boxed::Box, convert::TryInto, vec::Vec}; diff --git a/INV4/pallet-inv4/src/origin.rs b/INV4/pallet-inv4/src/origin.rs index 8249a0ef..39a2328b 100644 --- a/INV4/pallet-inv4/src/origin.rs +++ b/INV4/pallet-inv4/src/origin.rs @@ -14,7 +14,7 @@ use crate::{ Config, }; use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::{error::BadOrigin, RuntimeDebug}; +use frame_support::{error::BadOrigin, pallet_prelude::RuntimeDebug}; use scale_info::TypeInfo; /// Origin representing a core by its id. diff --git a/INV4/pallet-inv4/src/tests/mock.rs b/INV4/pallet-inv4/src/tests/mock.rs index fcc29f1c..4af34722 100644 --- a/INV4/pallet-inv4/src/tests/mock.rs +++ b/INV4/pallet-inv4/src/tests/mock.rs @@ -2,10 +2,10 @@ use crate::{fee_handling::*, *}; use codec::{Decode, Encode}; use core::convert::TryFrom; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{ fungibles::Credit, ConstU128, ConstU32, ConstU64, Contains, Currency, EnsureOrigin, - EnsureOriginWithArg, GenesisBuild, + EnsureOriginWithArg, }, }; use frame_system::EnsureRoot; @@ -13,13 +13,11 @@ use orml_asset_registry::AssetMetadata; use pallet_balances::AccountData; use scale_info::TypeInfo; use sp_core::H256; -use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; +use sp_runtime::{AccountId32, BuildStorage}; use sp_std::{convert::TryInto, vec}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Balance = u128; -type BlockNumber = u64; type AccountId = AccountId32; @@ -31,17 +29,14 @@ pub const CHARLIE: AccountId = AccountId::new([2u8; 32]); pub const DAVE: AccountId = AccountId::new([3u8; 32]); frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Event, Config}, - INV4: pallet::{Pallet, Call, Storage, Event, Origin}, - CoreAssets: orml_tokens2::{Pallet, Call, Storage, Event}, - Tokens: orml_tokens::{Pallet, Call, Storage, Event}, - AssetRegistry: orml_asset_registry::{Pallet, Call, Storage, Event, Config}, + System: frame_system, + Balances: pallet_balances, + Tokens: orml_tokens, + AssetRegistry: orml_asset_registry, + CoreAssets: orml_tokens2, + INV4: pallet, } ); @@ -52,16 +47,16 @@ impl Contains for TestBaseCallFilter { } } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = BlockNumber; + type Nonce = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; + type Lookup = sp_runtime::traits::IdentityLookup; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type BlockWeights = (); @@ -79,31 +74,20 @@ impl frame_system::Config for Test { type MaxConsumers = ConstU32<16>; } +#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)] impl pallet_balances::Config for Test { type MaxLocks = ConstU32<50>; - /// The type for recording an account's balance. type Balance = Balance; type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); type ExistentialDeposit = ConstU128; type AccountStore = System; - type WeightInfo = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type MaxHolds = ConstU32<1>; - type FreezeIdentifier = (); - type MaxFreezes = (); - type HoldIdentifier = [u8; 8]; + type MaxFreezes = ConstU32<1>; } const UNIT: u128 = 1000000000000; -orml_traits2::parameter_type_with_key! { - pub CoreExistentialDeposits: |_currency_id: ::CoreId| -> Balance { - 1u128 - }; -} - pub struct CoreDustRemovalWhitelist; impl Contains for CoreDustRemovalWhitelist { fn contains(_: &AccountId) -> bool { @@ -112,15 +96,19 @@ impl Contains for CoreDustRemovalWhitelist { } pub struct DisallowIfFrozen; -impl orml_traits2::currency::OnTransfer::CoreId, Balance> - for DisallowIfFrozen +impl + orml_traits2::currency::OnTransfer< + ::AccountId, + ::CoreId, + Balance, + > for DisallowIfFrozen { fn on_transfer( currency_id: ::CoreId, _from: &AccountId, _to: &AccountId, _amount: Balance, - ) -> sp_runtime::DispatchResult { + ) -> sp_std::result::Result<(), orml_traits::parameters::sp_runtime::DispatchError> { if let Some(true) = INV4::is_asset_frozen(currency_id) { Err(sp_runtime::DispatchError::Token( sp_runtime::TokenError::Frozen, @@ -132,15 +120,23 @@ impl orml_traits2::currency::OnTransfer::Cor } pub struct HandleNewMembers; -impl orml_traits2::Happened<(AccountId, ::CoreId)> for HandleNewMembers { +impl + orml_traits2::Happened<( + ::AccountId, + ::CoreId, + )> for HandleNewMembers +{ fn happened((member, core_id): &(AccountId, ::CoreId)) { INV4::add_member(core_id, member) } } pub struct HandleRemovedMembers; -impl orml_traits2::Happened<(AccountId, ::CoreId)> - for HandleRemovedMembers +impl + orml_traits2::Happened<( + ::AccountId, + ::CoreId, + )> for HandleRemovedMembers { fn happened((member, core_id): &(AccountId, ::CoreId)) { INV4::remove_member(core_id, member) @@ -148,8 +144,12 @@ impl orml_traits2::Happened<(AccountId, ::CoreId)> } pub struct INV4TokenHooks; -impl orml_traits2::currency::MutationHooks::CoreId, Balance> - for INV4TokenHooks +impl + orml_traits2::currency::MutationHooks< + ::AccountId, + ::CoreId, + Balance, + > for INV4TokenHooks { type PreTransfer = DisallowIfFrozen; type OnDust = (); @@ -161,6 +161,12 @@ impl orml_traits2::currency::MutationHooks:: type OnKilledTokenAccount = HandleRemovedMembers; } +orml_traits2::parameter_type_with_key! { + pub CoreExistentialDeposits: |_currency_id: ::CoreId| -> Balance { + CExistentialDeposit::get() + }; +} + impl orml_tokens2::Config for Test { type RuntimeEvent = RuntimeEvent; type Balance = Balance; @@ -197,9 +203,11 @@ parameter_types! { pub const NativeAssetId: AssetId = NATIVE_ASSET_ID; pub const RelayAssetId: AssetId = RELAY_ASSET_ID; pub const ExistentialDeposit: u128 = 100000000000; + pub const CExistentialDeposit: u128 = 1; pub const MaxLocks: u32 = 1; pub const MaxReserves: u32 = 1; pub const MaxCallSize: u32 = 50 * 1024; + pub const StringLimit: u32 = 2125; } pub struct AssetAuthority; @@ -210,7 +218,7 @@ impl EnsureOriginWithArg> for AssetAuthority { origin: RuntimeOrigin, _asset_id: &Option, ) -> Result { - EnsureRoot::try_origin(origin) + as EnsureOrigin>::try_origin(origin) } } @@ -222,6 +230,7 @@ impl orml_asset_registry::Config for Test { type AssetProcessor = orml_asset_registry::SequentialId; type CustomMetadata = (); type WeightInfo = (); + type StringLimit = StringLimit; } pub struct DustRemovalWhitelist; @@ -251,7 +260,7 @@ impl orml_tokens::Config for Test { type WeightInfo = (); type ExistentialDeposits = ExistentialDeposits; type MaxLocks = MaxLocks; - type DustRemovalWhitelist = DustRemovalWhitelist; + type DustRemovalWhitelist = CoreDustRemovalWhitelist; type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; type CurrencyHooks = (); @@ -345,8 +354,8 @@ pub const INITIAL_BALANCE: Balance = 100000000000000000; impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); pallet_balances::GenesisConfig:: { @@ -366,8 +375,8 @@ impl ExtBuilder { 0u32, AssetMetadata { decimals: 12, - name: vec![], - symbol: vec![], + name: sp_core::bounded_vec::BoundedVec::::new(), + symbol: sp_core::bounded_vec::BoundedVec::::new(), existential_deposit: ExistentialDeposit::get(), location: None, additional: (), @@ -378,8 +387,8 @@ impl ExtBuilder { 1u32, AssetMetadata { decimals: 12, - name: vec![], - symbol: vec![], + name: sp_core::bounded_vec::BoundedVec::::new(), + symbol: sp_core::bounded_vec::BoundedVec::::new(), existential_deposit: ExistentialDeposit::get(), location: None, additional: (), diff --git a/INV4/pallet-inv4/src/tests/mod.rs b/INV4/pallet-inv4/src/tests/mod.rs index 22e3451d..35fedb5f 100644 --- a/INV4/pallet-inv4/src/tests/mod.rs +++ b/INV4/pallet-inv4/src/tests/mod.rs @@ -1,3 +1,4 @@ +#[allow(unused_imports)] mod mock; extern crate alloc; diff --git a/INV4/pallet-inv4/src/voting.rs b/INV4/pallet-inv4/src/voting.rs index bd8786f9..23564d26 100644 --- a/INV4/pallet-inv4/src/voting.rs +++ b/INV4/pallet-inv4/src/voting.rs @@ -11,11 +11,11 @@ use crate::{origin::INV4Origin, BalanceOf, Config, CoreStorage, Error, Multisig, use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; use core::marker::PhantomData; use frame_support::{ - pallet_prelude::Member, + pallet_prelude::{Member, RuntimeDebug}, traits::{fungibles::Inspect, PollStatus, VoteTally}, - BoundedBTreeMap, CloneNoBound, EqNoBound, Parameter, PartialEqNoBound, RuntimeDebug, - RuntimeDebugNoBound, + BoundedBTreeMap, CloneNoBound, EqNoBound, Parameter, PartialEqNoBound, RuntimeDebugNoBound, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_runtime::{ traits::{One, Zero}, @@ -171,7 +171,7 @@ pub trait CustomPolling { impl CustomPolling> for Pallet { type Index = T::Hash; type Votes = Votes; - type Moment = T::BlockNumber; + type Moment = BlockNumberFor; type Class = T::CoreId; fn classes() -> Vec { @@ -181,7 +181,7 @@ impl CustomPolling> for Pallet { fn access_poll( class: Self::Class, index: Self::Index, - f: impl FnOnce(PollStatus<&mut Tally, T::BlockNumber, T::CoreId>) -> R, + f: impl FnOnce(PollStatus<&mut Tally, BlockNumberFor, T::CoreId>) -> R, ) -> R { match Multisig::::get(class, index) { Some(mut m) => { @@ -196,7 +196,9 @@ impl CustomPolling> for Pallet { fn try_access_poll( class: Self::Class, index: Self::Index, - f: impl FnOnce(PollStatus<&mut Tally, T::BlockNumber, T::CoreId>) -> Result, + f: impl FnOnce( + PollStatus<&mut Tally, BlockNumberFor, T::CoreId>, + ) -> Result, ) -> Result { match Multisig::::get(class, index) { Some(mut m) => { diff --git a/OCIF/staking/Cargo.toml b/OCIF/staking/Cargo.toml index 2118b001..ea865a42 100644 --- a/OCIF/staking/Cargo.toml +++ b/OCIF/staking/Cargo.toml @@ -12,56 +12,56 @@ version = '0.1.0-dev' targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } -scale-info = { version = "2.1.0", default-features = false, features = ["derive"] } -serde = { version = "1.0.140", features = ["derive"], optional = true } +codec = { workspace = true, default-features = false } +scale-info = { workspace = true, default-features = false } +serde = { workspace = true, optional = true } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -num-traits = { version = "0.2", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.43" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.43" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +frame-support = { workspace = true, default-features = false } +frame-system = { workspace = true, default-features = false } +num-traits = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false, optional = true } +pallet-session = { workspace = true, default-features = false } +pallet-timestamp = { workspace = true, default-features = false, optional = true } +sp-arithmetic = { workspace = true, default-features = false } +sp-core = { workspace = true, default-features = false } +sp-io = { workspace = true, default-features = false } +sp-runtime = { workspace = true, default-features = false } +sp-staking = { workspace = true, default-features = false } +sp-std = { workspace = true, default-features = false } pallet-inv4 = { path = "../../INV4/pallet-inv4", default-features = false } -frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', default-features = false, optional = true , branch = "polkadot-v0.9.43" } +frame-benchmarking = { workspace = true, default-features = false, optional = true } [dev-dependencies] -orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.43" } +orml-traits = { workspace = true, default-features = false } +orml-tokens = { workspace = true, default-features = false } +xcm = { workspace = true, default-features = false } [features] default = ["std"] std = [ - "serde", - "codec/std", - "scale-info/std", - "num-traits/std", - "sp-core/std", - "sp-runtime/std", - "sp-arithmetic/std", - "sp-io/std", - "sp-std/std", - "frame-support/std", - "frame-system/std", - "pallet-balances/std", - "pallet-session/std", - "pallet-timestamp/std", - "sp-staking/std", - "orml-traits/std", - "orml-tokens/std", + "serde", + "codec/std", + "scale-info/std", + "num-traits/std", + "sp-core/std", + "sp-runtime/std", + "sp-arithmetic/std", + "sp-io/std", + "sp-std/std", + "frame-support/std", + "frame-system/std", + "pallet-balances/std", + "pallet-session/std", + "pallet-timestamp/std", + "sp-staking/std", + "orml-traits/std", + "orml-tokens/std", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/OCIF/staking/src/lib.rs b/OCIF/staking/src/lib.rs index 1d471c9c..e6167ad7 100644 --- a/OCIF/staking/src/lib.rs +++ b/OCIF/staking/src/lib.rs @@ -128,7 +128,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency used in staking. - type Currency: LockableCurrency + type Currency: LockableCurrency> + ReservableCurrency; // type CoreId: Parameter @@ -229,7 +229,7 @@ pub mod pallet { /// Stores the block number of when the next era starts. #[pallet::storage] #[pallet::getter(fn next_era_starting_block)] - pub type NextEraStartingBlock = StorageValue<_, T::BlockNumber, ValueQuery>; + pub type NextEraStartingBlock = StorageValue<_, BlockNumberFor, ValueQuery>; /// Simple map where CoreId points to the respective core information. #[pallet::storage] diff --git a/OCIF/staking/src/testing/mock.rs b/OCIF/staking/src/testing/mock.rs index ef2e79a0..b3c2e768 100644 --- a/OCIF/staking/src/testing/mock.rs +++ b/OCIF/staking/src/testing/mock.rs @@ -2,7 +2,7 @@ use crate as pallet_ocif_staking; use codec::{Decode, Encode}; use core::convert::{TryFrom, TryInto}; use frame_support::{ - construct_runtime, parameter_types, + construct_runtime, derive_impl, parameter_types, traits::{ fungibles::Credit, ConstU128, ConstU32, Contains, Currency, OnFinalize, OnInitialize, }, @@ -14,9 +14,8 @@ use scale_info::TypeInfo; use sp_core::H256; use sp_io::TestExternalities; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, - AccountId32, Perbill, + AccountId32, BuildStorage, Perbill, }; pub(crate) type AccountId = AccountId32; @@ -24,7 +23,6 @@ pub(crate) type BlockNumber = u64; pub(crate) type Balance = u128; pub(crate) type EraIndex = u32; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; pub(crate) const EXISTENTIAL_DEPOSIT: Balance = 2; @@ -37,18 +35,13 @@ pub(crate) const BLOCKS_PER_ERA: BlockNumber = 3; pub(crate) const REGISTER_DEPOSIT: Balance = 10; construct_runtime!( - pub struct Test - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub struct Test { System: frame_system, Balances: pallet_balances, Timestamp: pallet_timestamp, OcifStaking: pallet_ocif_staking, - INV4: pallet_inv4, CoreAssets: orml_tokens, + INV4: pallet_inv4, } ); @@ -58,19 +51,18 @@ parameter_types! { frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0)); } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); + type RuntimeTask = RuntimeTask; type RuntimeOrigin = RuntimeOrigin; - type Index = u64; + type Nonce = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = BlockNumber; + type Block = Block; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); @@ -90,6 +82,7 @@ parameter_types! { pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT; } +#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)] impl pallet_balances::Config for Test { type MaxLocks = MaxLocks; type MaxReserves = (); @@ -100,10 +93,8 @@ impl pallet_balances::Config for Test { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); - type MaxHolds = ConstU32<1>; - type FreezeIdentifier = (); + type FreezeIdentifier = [u8; 8]; type MaxFreezes = (); - type HoldIdentifier = [u8; 8]; } parameter_types! { @@ -292,8 +283,8 @@ pub const N: CoreId = 13; impl ExternalityBuilder { pub fn build() -> TestExternalities { - let storage = frame_system::GenesisConfig::default() - .build_storage::() + let storage = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); let mut ext = TestExternalities::from(storage); diff --git a/README.md b/README.md index 0340ac0c..1d21007a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![Telegram](https://img.shields.io/badge/Telegram-gray?logo=telegram)](https://t.me/InvArch) [![Knowledge Hub](https://img.shields.io/badge/🧠_Knwoledge_hub-gray)](https://abstracted.notion.site/Knowledge-Hub-eec0071f36364d6aa8138f0004ac8d85)
-[![Substrate version](https://img.shields.io/badge/Substrate-v3.0.0-E6007A?logo=Parity%20Substrate)](https://github.com/paritytech/substrate/releases/tag/v3.0.0) +[![Polkadot SDK version](https://img.shields.io/badge/Polkadot_SDK-V1.6.0-E6007A?logo=polkadot)](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.6.0) [![Medium](https://img.shields.io/badge/Medium-InvArch-E6007A?logo=medium)](https://invarch.medium.com/) [![License](https://img.shields.io/github/license/InvArch/InvArch?color=E6007A)](https://github.com/InvArch/InvArch/blob/main/LICENSE) [![Library Docs](https://img.shields.io/badge/Library-Docs%2Ers-E6007A?logo=docsdotrs)](https://invarch.github.io/InvArch-Frames/) @@ -22,7 +22,7 @@ ## Intro -This repository should contain the Substrate FRAME Pallets used in the InvArch blockchain, and reviews their relationships and functions. At the current stage, the goal of creating this document and repository is centered around getting feedback while we continue to write the code and develop InvArch. This is a WIP. +This repository should contain the Polkadot SDK FRAME Pallets used in the InvArch blockchain, and reviews their relationships and functions. At the current stage, the goal of creating this document and repository is centered around getting feedback while we continue to write the code and develop InvArch. This is a WIP. Check out the [Knowledge Hub](https://abstracted.notion.site/Knowledge-Hub-eec0071f36364d6aa8138f0004ac8d85), it is the perfect place to dive into all things InvArch diff --git a/pallet-checked-inflation/Cargo.toml b/pallet-checked-inflation/Cargo.toml index 75b6931d..b4eaca0c 100644 --- a/pallet-checked-inflation/Cargo.toml +++ b/pallet-checked-inflation/Cargo.toml @@ -12,25 +12,25 @@ version = '0.1.0-dev' targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } -scale-info = { version = "2.1.0", default-features = false, features = ["derive"] } -serde = { version = "1.0.140", features = ["derive"], optional = true } +codec = {workspace = true, default-features = false} +scale-info = {workspace = true, default-features = false} +serde = {workspace = true, optional = true} -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -num-traits = { version = "0.2", default-features = false } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +frame-support = {workspace = true, default-features = false} +frame-system = {workspace = true, default-features = false} +num-traits = {workspace = true, default-features = false} +pallet-session = {workspace = true, default-features = false} +sp-arithmetic = {workspace = true, default-features = false} +sp-core = {workspace = true, default-features = false} +sp-io = {workspace = true, default-features = false} +sp-runtime = {workspace = true, default-features = false} +sp-staking = {workspace = true, default-features = false} +sp-std = {workspace = true, default-features = false} -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.43" } +frame-benchmarking = {workspace = true, default-features = false, optional = true} [dev-dependencies] -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +pallet-balances = {workspace = true, default-features = false} [features] default = ["std"] diff --git a/pallet-checked-inflation/src/lib.rs b/pallet-checked-inflation/src/lib.rs index 6223148e..e20451e6 100644 --- a/pallet-checked-inflation/src/lib.rs +++ b/pallet-checked-inflation/src/lib.rs @@ -69,9 +69,8 @@ pub mod pallet { pub trait Config: frame_system::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// The currency (token) used in this pallet. - type Currency: LockableCurrency + type Currency: LockableCurrency> + ReservableCurrency + Currency; @@ -102,7 +101,7 @@ pub mod pallet { /// Block that the next era starts at. #[pallet::storage] #[pallet::getter(fn next_era_starting_block)] - pub type NextEraStartingBlock = StorageValue<_, T::BlockNumber, ValueQuery>; + pub type NextEraStartingBlock = StorageValue<_, BlockNumberFor, ValueQuery>; /// Total token supply at the very beginning of the year before any inflation has been minted. #[pallet::storage] diff --git a/pallet-checked-inflation/src/mock.rs b/pallet-checked-inflation/src/mock.rs index 84db2ebd..f0322edc 100644 --- a/pallet-checked-inflation/src/mock.rs +++ b/pallet-checked-inflation/src/mock.rs @@ -2,19 +2,17 @@ use super::*; use crate::inflation::InflationMethod; use core::convert::TryFrom; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{ConstU128, ConstU32, ConstU64, Currency, Hooks, OnUnbalanced}, }; use pallet_balances::AccountData; use sp_core::H256; -use sp_runtime::{testing::Header, traits::IdentityLookup, Perbill}; +use sp_runtime::{traits::IdentityLookup, BuildStorage, Perbill}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Balance = u128; type AccountId = u32; -type BlockNumber = u64; type NegativeImbalance = >::NegativeImbalance; pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000; @@ -23,60 +21,40 @@ pub const INFLATION_RECEIVER: AccountId = 0; pub const ALICE: AccountId = 1; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Event, Config}, - CheckedInflation: pallet::{Pallet, Call, Storage, Event}, + System: frame_system, + Balances: pallet_balances, + CheckedInflation: pallet, } ); +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = BlockNumber; + type Nonce = u64; + type Block = Block; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; - type BlockWeights = (); - type BlockLength = (); - type Version = (); type PalletInfo = PalletInfo; type AccountData = AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type DbWeight = (); - type BaseCallFilter = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); type MaxConsumers = ConstU32<16>; } +#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)] impl pallet_balances::Config for Test { type MaxLocks = ConstU32<50>; - /// The type for recording an account's balance. type Balance = Balance; type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); type ExistentialDeposit = ConstU128; type AccountStore = System; - type WeightInfo = (); type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - - type MaxHolds = ConstU32<1>; - type FreezeIdentifier = (); - type MaxFreezes = (); - type HoldIdentifier = [u8; 8]; } parameter_types! { @@ -115,8 +93,8 @@ pub const GENESIS_ISSUANCE: u128 = 11700000000000000000; impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); pallet_balances::GenesisConfig:: { diff --git a/pallet-rings/Cargo.toml b/pallet-rings/Cargo.toml index 3896c2c2..fe031647 100644 --- a/pallet-rings/Cargo.toml +++ b/pallet-rings/Cargo.toml @@ -12,39 +12,40 @@ version = '0.1.0-dev' targets = ["x86_64-unknown-linux-gnu"] [dependencies] -log = { version = "0.4.14", default-features = false } -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } -scale-info = { version = "2.1.0", default-features = false, features = ["derive"] } -serde = { version = "1.0.140", features = ["derive"], optional = true } +log = {workspace = true, default-features = false} +codec = {workspace = true, default-features = false} +scale-info = {workspace = true, default-features = false} +serde = {workspace = true, optional = true} -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -num-traits = { version = "0.2", default-features = false } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.43" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.43" } +frame-support = {workspace = true, default-features = false} +frame-system = {workspace = true, default-features = false} +num-traits = {workspace = true, default-features = false} +pallet-balances = {workspace = true, default-features = false} +pallet-session = {workspace = true, default-features = false} +pallet-timestamp = { workspace = true, default-features = false, optional = true } +sp-arithmetic = {workspace = true, default-features = false} +sp-core = {workspace = true, default-features = false} +sp-io = {workspace = true, default-features = false} +sp-runtime = {workspace = true} +sp-staking = {workspace = true} +sp-std = {workspace = true} pallet-inv4 = { path = "../INV4/pallet-inv4", default-features = false } -pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" } -xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" } -xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" } +pallet-xcm = {workspace = true, default-features = false} +xcm = {workspace = true, default-features = false} +xcm-executor = {workspace = true, default-features = false} -frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', default-features = false, optional = true, branch = "polkadot-v0.9.43" } +frame-benchmarking = {workspace = true, default-features = false, optional = true} [dev-dependencies] -orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -orml-traits2 = { package = "orml-traits", git = "https://github.com/arrudagates/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -orml-tokens2 = { package = "orml-tokens", git = "https://github.com/arrudagates/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, rev = "7ecebeab7e3dbc2226ed58d32ee159271a8176ae" } -xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.43" } +orml-traits = { workspace = true, default-features = false} +orml-traits2 = { workspace = true, default-features = false} +orml-tokens = { workspace = true, default-features = false} +orml-tokens2 = { workspace = true, default-features = false} +orml-asset-registry = { workspace = true, default-features = false} +xcm-builder = {workspace = true, default-features = false} + [features] default = ["std"] diff --git a/pallet-rings/src/lib.rs b/pallet-rings/src/lib.rs index 30d92e95..055a2c32 100644 --- a/pallet-rings/src/lib.rs +++ b/pallet-rings/src/lib.rs @@ -43,7 +43,7 @@ pub mod pallet { use pallet_inv4::origin::{ensure_multisig, INV4Origin}; use sp_std::{vec, vec::Vec}; use xcm::{ - latest::{prelude::*, MultiAsset, Weight, WildMultiAsset}, + v3::{prelude::*, MultiAsset, Weight, WildMultiAsset}, DoubleEncoded, }; @@ -136,7 +136,7 @@ pub mod pallet { ::CoreId: Into, [u8; 32]: From<::AccountId>, - T::AccountId: From<[u8; 32]>, + ::AccountId: From<[u8; 32]>, { /// Set the maintenance status of a chain. /// diff --git a/pallet-rings/src/tests/mock.rs b/pallet-rings/src/tests/mock.rs index f8c346e1..4e75548c 100644 --- a/pallet-rings/src/tests/mock.rs +++ b/pallet-rings/src/tests/mock.rs @@ -5,10 +5,10 @@ use crate::{ use codec::{Decode, Encode, MaxEncodedLen}; use core::convert::TryFrom; use frame_support::{ - parameter_types, + derive_impl, parameter_types, traits::{ fungibles::Credit, ConstU128, ConstU32, ConstU64, Contains, Currency, EnsureOrigin, - EnsureOriginWithArg, Everything, GenesisBuild, Nothing, + EnsureOriginWithArg, Everything, Nothing, }, }; use frame_system::EnsureRoot; @@ -17,24 +17,22 @@ use pallet_balances::AccountData; use pallet_inv4::fee_handling::*; use scale_info::TypeInfo; use sp_core::H256; -use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; +use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage}; pub use sp_std::{cell::RefCell, fmt::Debug}; use sp_std::{convert::TryInto, vec}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, - FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, + AllowTopLevelPaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, + FungibleAdapter as XcmCurrencyAdapter, IsConcrete, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, }; use xcm_executor::XcmExecutor; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Balance = u128; type AccountId = AccountId32; -type BlockNumber = u64; pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000; @@ -49,19 +47,16 @@ pub const CHARLIE: AccountId = AccountId32::new([ ]); frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Event, Config}, - INV4: pallet_inv4::{Pallet, Call, Storage, Event, Origin}, - CoreAssets: orml_tokens2::{Pallet, Call, Storage, Event}, - Rings: pallet::{Pallet, Call, Storage, Event}, - XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config}, - Tokens: orml_tokens::{Pallet, Call, Storage, Event}, - AssetRegistry: orml_asset_registry::{Pallet, Call, Storage, Event, Config}, + System: frame_system, + Balances: pallet_balances, + Tokens: orml_tokens, + CoreAssets: orml_tokens2, + AssetRegistry: orml_asset_registry, + INV4: pallet_inv4, + Rings: pallet, + XcmPallet: pallet_xcm, } ); @@ -72,16 +67,17 @@ impl Contains for TestBaseCallFilter { } } +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = BlockNumber; + type RuntimeTask = RuntimeTask; + type Nonce = u64; + type Block = Block; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type BlockWeights = (); @@ -99,6 +95,7 @@ impl frame_system::Config for Test { type MaxConsumers = ConstU32<16>; } +#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig as pallet_balances::DefaultConfig)] impl pallet_balances::Config for Test { type MaxLocks = ConstU32<50>; /// The type for recording an account's balance. @@ -111,9 +108,7 @@ impl pallet_balances::Config for Test { type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; type MaxHolds = ConstU32<1>; - type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = [u8; 8]; } thread_local! { @@ -196,6 +191,7 @@ impl xcm_executor::Config for XcmConfig { type SafeCallFilter = Everything; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type Aliasers = (); } pub type LocalOriginToLocation = SignedToAccountId32; @@ -313,7 +309,7 @@ parameter_types! { pub const MaxCallers: u32 = 10000; pub const CoreSeedBalance: Balance = 1000000u128; pub const CoreCreationFee: Balance = UNIT; - + pub const StringLimit: u32 = 2125; pub const RelayCoreCreationFee: Balance = UNIT; } @@ -338,7 +334,7 @@ impl EnsureOriginWithArg> for AssetAuthority { origin: RuntimeOrigin, _asset_id: &Option, ) -> Result { - EnsureRoot::try_origin(origin) + as EnsureOrigin>::try_origin(origin) } } @@ -350,6 +346,7 @@ impl orml_asset_registry::Config for Test { type AssetProcessor = orml_asset_registry::SequentialId; type CustomMetadata = (); type WeightInfo = (); + type StringLimit = StringLimit; } pub struct DustRemovalWhitelist; @@ -568,8 +565,8 @@ pub const INITIAL_BALANCE: Balance = 100000000000000000; impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::default() - .build_storage::() + let mut t = frame_system::GenesisConfig::::default() + .build_storage() .unwrap(); pallet_balances::GenesisConfig:: { @@ -588,8 +585,8 @@ impl ExtBuilder { 0u32, AssetMetadata { decimals: 12, - name: vec![], - symbol: vec![], + name: sp_core::bounded_vec::BoundedVec::::new(), + symbol: sp_core::bounded_vec::BoundedVec::::new(), existential_deposit: ExistentialDeposit::get(), location: None, additional: (), @@ -600,8 +597,8 @@ impl ExtBuilder { 1u32, AssetMetadata { decimals: 12, - name: vec![], - symbol: vec![], + name: sp_core::bounded_vec::BoundedVec::::new(), + symbol: sp_core::bounded_vec::BoundedVec::::new(), existential_deposit: ExistentialDeposit::get(), location: None, additional: (), diff --git a/pallet-rings/src/traits.rs b/pallet-rings/src/traits.rs index fb6d2bc5..1868a9ce 100644 --- a/pallet-rings/src/traits.rs +++ b/pallet-rings/src/traits.rs @@ -14,7 +14,7 @@ use codec::MaxEncodedLen; use frame_support::Parameter; -use xcm::latest::MultiLocation; +use xcm::opaque::v3::MultiLocation; /// A chain [`MultiLocation`] abstraction trait. /// diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 34ed2dc9..6c190c42 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -10,15 +10,15 @@ repository = 'https://github.com/InvArch/InvArch-Pallet-Library/ipt' [dependencies] -serde = { version = "1.0.132", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } -scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } +serde = { workspace = true, optional = true } +codec = { workspace = true, default-features = false } +scale-info = { workspace = true, default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +frame-system = { workspace = true, default-features = false } +sp-core = { workspace = true, default-features = false } +sp-runtime = { workspace = true, default-features = false } +sp-std = { workspace = true, default-features = false } +sp-io = { workspace = true, default-features = false } [features] @@ -30,5 +30,6 @@ std = [ "frame-system/std", "sp-std/std", "scale-info/std", - "sp-io/std" + "sp-io/std", + "sp-runtime/std", ] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 09139ba2..c084c265 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] channel = "nightly-2024-02-06" targets = ["wasm32-unknown-unknown"] -components = [ "rustfmt", "rustc", "rust-std", "cargo", "clippy", "llvm-tools-preview"] +components = [ "rustfmt", "rustc", "rust-std", "cargo", "clippy", "llvm-tools-preview"] \ No newline at end of file