From 2486259732a7300f310b73f5c9a6f7e6999e921c Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 01:12:10 +0800 Subject: [PATCH 01/45] Cleanup Base pallet Config and Event types. --- Cargo.lock | 2 +- pallets/base/Cargo.toml | 2 -- pallets/base/src/lib.rs | 20 +++++++++++++++++++- pallets/common/Cargo.toml | 4 ++++ pallets/common/src/lib.rs | 2 +- pallets/common/src/traits/identity.rs | 2 +- pallets/common/src/traits/mod.rs | 24 ------------------------ pallets/common/src/traits/nft.rs | 4 ++-- pallets/common/src/traits/portfolio.rs | 4 ++-- 9 files changed, 30 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f40cbac089..7cb57349d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4838,7 +4838,6 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -6270,6 +6269,7 @@ dependencies = [ "frame-support", "frame-system", "lazy_static", + "pallet-base", "pallet-timestamp", "parity-scale-codec 3.6.9", "polymesh-primitives", diff --git a/pallets/base/Cargo.toml b/pallets/base/Cargo.toml index dee5419dbf..2e7a783c20 100644 --- a/pallets/base/Cargo.toml +++ b/pallets/base/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] polymesh-primitives = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } # Others serde = { version = "1.0.104", default-features = false } @@ -34,5 +33,4 @@ std = [ "frame-system/std", "sp-std/std", "polymesh-primitives/std", - "polymesh-common-utilities/std", ] diff --git a/pallets/base/src/lib.rs b/pallets/base/src/lib.rs index af77081b87..4693394737 100644 --- a/pallets/base/src/lib.rs +++ b/pallets/base/src/lib.rs @@ -26,13 +26,24 @@ #![cfg_attr(not(feature = "std"), no_std)] use core::mem; +use frame_support::decl_event; use frame_support::dispatch::{DispatchError, DispatchResult}; use frame_support::traits::{Get, StorageInfo, StorageInfoTrait}; use frame_support::{decl_error, decl_module, ensure}; -pub use polymesh_common_utilities::traits::base::{Config, Event}; use polymesh_primitives::checked_inc::CheckedInc; use sp_std::{vec, vec::Vec}; +pub trait Config: frame_system::Config { + /// The overarching event type. + type RuntimeEvent: From + Into<::RuntimeEvent>; + + /// The maximum length governing `TooLong`. + /// + /// How lengths are computed to compare against this value is situation based. + /// For example, you could halve it, double it, compute a sum for some tree of strings, etc. + type MaxLen: Get; +} + decl_module! { pub struct Module for enum Call where origin: T::RuntimeOrigin { type Error = Error; @@ -46,6 +57,13 @@ pub fn emit_unexpected_error(error: Option) { Module::::deposit_event(Event::UnexpectedError(error)); } +decl_event! { + pub enum Event { + /// An unexpected error happened that should be investigated. + UnexpectedError(Option), + } +} + decl_error! { pub enum Error for Module { /// Exceeded a generic length limit. diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index 4033e32f0c..f28b97d796 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -8,6 +8,9 @@ edition = "2021" polymesh-primitives = { path = "../../primitives", default-features = false } polymesh-primitives-derive = { path = "../../primitives_derive", default-features = false } +# Our Pallets +pallet-base = { workspace = true, default-features = false } + # Other serde = { version = "1.0.112", default-features = false } serde_derive = { version = "1.0.112", optional = true, default-features = false} @@ -50,6 +53,7 @@ std = [ "frame-support/std", "frame-system/std", "pallet-timestamp/std", + "pallet-base/std", "polymesh-primitives/std", "serde/std", "serde_derive", diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 485a438792..1a9f12921f 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -19,7 +19,7 @@ pub mod constants; pub mod traits; pub use traits::{ - asset, balances, base, compliance_manager, governance_group, group, identity, multisig, nft, + asset, balances, compliance_manager, governance_group, group, identity, multisig, nft, portfolio, transaction_payment, CommonConfig, }; pub mod context; diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index 095c75ca75..24cf259037 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -167,7 +167,7 @@ pub trait WeightInfo { } /// The module's configuration trait. -pub trait Config: CommonConfig + pallet_timestamp::Config + crate::traits::base::Config { +pub trait Config: CommonConfig + pallet_timestamp::Config + pallet_base::Config { /// The overarching event type. type RuntimeEvent: From> + Into<::RuntimeEvent>; /// An extrinsic call. diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index f99a9069e5..d79dd49334 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -40,27 +40,3 @@ pub use permissions::{AccountCallPermissionsData, CheckAccountCallPermissions}; pub mod relayer; pub mod settlement; pub mod statistics; - -pub mod base { - use frame_support::decl_event; - use frame_support::dispatch::DispatchError; - use frame_support::traits::Get; - - decl_event! { - pub enum Event { - /// An unexpected error happened that should be investigated. - UnexpectedError(Option), - } - } - - pub trait Config: frame_system::Config { - /// The overarching event type. - type RuntimeEvent: From + Into<::RuntimeEvent>; - - /// The maximum length governing `TooLong`. - /// - /// How lengths are computed to compare against this value is situation based. - /// For example, you could halve it, double it, compute a sum for some tree of strings, etc. - type MaxLen: Get; - } -} diff --git a/pallets/common/src/traits/nft.rs b/pallets/common/src/traits/nft.rs index 9294c796eb..adeb0f3ded 100644 --- a/pallets/common/src/traits/nft.rs +++ b/pallets/common/src/traits/nft.rs @@ -14,10 +14,10 @@ use polymesh_primitives::nft::{NFTCollectionId, NFTs}; use polymesh_primitives::{IdentityId, NFTId, PortfolioId, PortfolioUpdateReason}; use crate::compliance_manager::ComplianceFnConfig; -use crate::{asset, base, identity, portfolio}; +use crate::{asset, identity, portfolio}; pub trait Config: - frame_system::Config + base::Config + asset::Config + identity::Config + portfolio::Config + frame_system::Config + asset::Config + identity::Config + portfolio::Config { type RuntimeEvent: From + Into<::RuntimeEvent>; diff --git a/pallets/common/src/traits/portfolio.rs b/pallets/common/src/traits/portfolio.rs index 5bc5b88f45..08b5195789 100644 --- a/pallets/common/src/traits/portfolio.rs +++ b/pallets/common/src/traits/portfolio.rs @@ -17,7 +17,7 @@ //! //! The interface allows to accept portfolio custody -use crate::{asset::AssetFnTrait, base, identity, nft::NFTTrait, CommonConfig}; +use crate::{asset::AssetFnTrait, identity, nft::NFTTrait, CommonConfig}; use frame_support::decl_event; use frame_support::dispatch::DispatchResult; use frame_support::pallet_prelude::Get; @@ -117,7 +117,7 @@ pub trait WeightInfo { fn create_custody_portfolio() -> Weight; } -pub trait Config: CommonConfig + identity::Config + base::Config { +pub trait Config: CommonConfig + identity::Config { type RuntimeEvent: From + Into<::RuntimeEvent>; type WeightInfo: WeightInfo; /// Asset module. From 79669ca666d0b5f74b31ecde2516896ac8142e55 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 01:28:50 +0800 Subject: [PATCH 02/45] Move with_transaction method to our primitives crate. --- pallets/common/src/lib.rs | 27 ++------------------------- primitives/src/lib.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 1a9f12921f..5b38c19bbe 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -39,7 +39,8 @@ use polymesh_primitives::IdentityId; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use sp_runtime::{DispatchError, DispatchResult}; + +pub use polymesh_primitives::with_transaction; /// Use `GetExtra` as the trait bounds for pallet `Config` parameters /// that will be used for bounded collections. @@ -143,30 +144,6 @@ pub const GC_DID: IdentityId = SystematicIssuers::Committee.as_id(); pub const TECHNICAL_DID: IdentityId = IdentityId(*constants::did::TECHNICAL_COMMITTEE_DID); pub const UPGRADE_DID: IdentityId = IdentityId(*constants::did::UPGRADE_COMMITTEE_DID); -/// Execute the supplied function in a new storage transaction, -/// committing on `Ok(_)` and rolling back on `Err(_)`, returning the result. -/// -/// Transactions can be arbitrarily nested with commits happening to the parent. -pub fn with_transaction>( - tx: impl FnOnce() -> Result, -) -> Result { - use frame_support::storage::{with_transaction, TransactionOutcome}; - with_transaction(|| match tx() { - r @ Ok(_) => TransactionOutcome::Commit(r), - r @ Err(_) => TransactionOutcome::Rollback(r), - }) -} - -/// In one transaction, execute the supplied function `tx` on each element in `iter`. -/// -/// See `with_transaction` for details. -pub fn with_each_transaction( - iter: impl IntoIterator, - tx: impl FnMut(A) -> DispatchResult, -) -> DispatchResult { - with_transaction(|| iter.into_iter().try_for_each(tx)) -} - /// Either a block number, or nothing. #[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, TypeInfo, Debug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 02c9dd1388..6dd3b72c7f 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -296,6 +296,20 @@ impl ExtrinsicName { } } +/// Execute the supplied function in a new storage transaction, +/// committing on `Ok(_)` and rolling back on `Err(_)`, returning the result. +/// +/// Transactions can be arbitrarily nested with commits happening to the parent. +pub fn with_transaction>( + tx: impl FnOnce() -> Result, +) -> Result { + use frame_support::storage::{with_transaction, TransactionOutcome}; + with_transaction(|| match tx() { + r @ Ok(_) => TransactionOutcome::Commit(r), + r @ Err(_) => TransactionOutcome::Rollback(r), + }) +} + /// Compile time assert. #[macro_export] macro_rules! const_assert { From 6cc2af1acb144c5872c3810b55ce853c0d2e10f0 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 01:37:57 +0800 Subject: [PATCH 03/45] Move permissions traits into it's pallet. --- Cargo.lock | 2 +- pallets/common/Cargo.toml | 3 ++ pallets/common/src/traits/mod.rs | 4 +- pallets/common/src/traits/permissions.rs | 49 ----------------------- pallets/identity/src/keys.rs | 2 +- pallets/permissions/Cargo.toml | 3 -- pallets/permissions/src/lib.rs | 36 +++++++++++++++-- pallets/runtime/common/src/runtime.rs | 2 +- pallets/runtime/tests/src/staking/mock.rs | 2 +- 9 files changed, 41 insertions(+), 62 deletions(-) delete mode 100644 pallets/common/src/traits/permissions.rs diff --git a/Cargo.lock b/Cargo.lock index 7cb57349d5..ac2d21506f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5296,7 +5296,6 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -6270,6 +6269,7 @@ dependencies = [ "frame-system", "lazy_static", "pallet-base", + "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", "polymesh-primitives", diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index f28b97d796..103cccbb4f 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -10,6 +10,7 @@ polymesh-primitives-derive = { path = "../../primitives_derive", default-feature # Our Pallets pallet-base = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } # Other serde = { version = "1.0.112", default-features = false } @@ -54,6 +55,7 @@ std = [ "frame-system/std", "pallet-timestamp/std", "pallet-base/std", + "pallet-permissions/std", "polymesh-primitives/std", "serde/std", "serde_derive", @@ -66,5 +68,6 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking", + "pallet-permissions/runtime-benchmarks", "schnorrkel", ] diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index d79dd49334..f9f4e44713 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -15,7 +15,7 @@ use polymesh_primitives::traits::BlockRewardsReserveCurrency; -pub trait CommonConfig: frame_system::Config + permissions::Config { +pub trait CommonConfig: frame_system::Config + pallet_permissions::Config { type BlockRewardsReserve: BlockRewardsReserveCurrency>; } @@ -35,8 +35,6 @@ pub mod nft; pub mod portfolio; pub mod transaction_payment; pub use transaction_payment::{CddAndFeeDetails, ChargeTxFee}; -pub mod permissions; -pub use permissions::{AccountCallPermissionsData, CheckAccountCallPermissions}; pub mod relayer; pub mod settlement; pub mod statistics; diff --git a/pallets/common/src/traits/permissions.rs b/pallets/common/src/traits/permissions.rs deleted file mode 100644 index 97d3dd88ec..0000000000 --- a/pallets/common/src/traits/permissions.rs +++ /dev/null @@ -1,49 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use polymesh_primitives::{ExtrinsicName, IdentityId, PalletName, SecondaryKey}; - -/// Permissions module configuration trait. -pub trait Config: frame_system::Config { - /// The type that implements the permission check function. - type Checker: CheckAccountCallPermissions; -} - -/// Result of `CheckAccountCallPermissions::check_account_call_permissions`. -pub struct AccountCallPermissionsData { - /// The primary identity of the call. - pub primary_did: IdentityId, - /// The secondary key of the call, if it is defined. - pub secondary_key: Option>, -} - -/// A permission checker for calls from accounts to extrinsics. -pub trait CheckAccountCallPermissions { - /// Checks whether `who` can call the current extrinsic represented by `pallet_name` and - /// `function_name`. - /// - /// Returns: - /// - /// - `Some(data)` where `data` contains the primary identity ID on behalf of which the caller - /// is allowed to make this call and the secondary key of the caller if the caller is a - /// secondary key of the primary identity. - /// - /// - `None` if the call is not allowed. - fn check_account_call_permissions( - who: &AccountId, - pallet_name: impl FnOnce() -> PalletName, - function_name: impl FnOnce() -> ExtrinsicName, - ) -> Option>; -} diff --git a/pallets/identity/src/keys.rs b/pallets/identity/src/keys.rs index 4678ffa512..cb435275a6 100644 --- a/pallets/identity/src/keys.rs +++ b/pallets/identity/src/keys.rs @@ -27,13 +27,13 @@ use frame_support::{ }; use frame_system::ensure_signed; use pallet_base::{ensure_custom_length_ok, ensure_custom_string_limited}; +use pallet_permissions::{AccountCallPermissionsData, CheckAccountCallPermissions}; use polymesh_common_utilities::constants::did::USER; use polymesh_common_utilities::group::GroupTrait; use polymesh_common_utilities::identity::{ CreateChildIdentityWithAuth, SecondaryKeyWithAuth, TargetIdAuthorization, }; use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee as _, ProtocolOp}; -use polymesh_common_utilities::traits::{AccountCallPermissionsData, CheckAccountCallPermissions}; use polymesh_common_utilities::SystematicIssuers; use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, diff --git a/pallets/permissions/Cargo.toml b/pallets/permissions/Cargo.toml index da8004adf8..566bd34d13 100644 --- a/pallets/permissions/Cargo.toml +++ b/pallets/permissions/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] # Common -polymesh-common-utilities = { path = "../common", default-features = false } polymesh-primitives = { path = "../../primitives", default-features = false } # Other @@ -31,7 +30,6 @@ only-staking = [] std = [ "codec/std", "frame-support/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "serde/std", "sp-runtime/std", @@ -39,5 +37,4 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks", ] diff --git a/pallets/permissions/src/lib.rs b/pallets/permissions/src/lib.rs index 4acb818be8..15b1d38988 100644 --- a/pallets/permissions/src/lib.rs +++ b/pallets/permissions/src/lib.rs @@ -32,8 +32,7 @@ use frame_support::{ dispatch::{DispatchError, DispatchResult}, traits::{CallMetadata, GetCallMetadata}, }; -use polymesh_common_utilities::traits::{AccountCallPermissionsData, CheckAccountCallPermissions}; -use polymesh_primitives::{ExtrinsicName, PalletName}; +use polymesh_primitives::{ExtrinsicName, IdentityId, PalletName, SecondaryKey}; use scale_info::TypeInfo; use sp_runtime::{ traits::{DispatchInfoOf, PostDispatchInfoOf, SignedExtension}, @@ -41,7 +40,38 @@ use sp_runtime::{ }; use sp_std::{fmt, marker::PhantomData, result::Result, vec}; -pub use polymesh_common_utilities::traits::permissions::Config; +/// Permissions module configuration trait. +pub trait Config: frame_system::Config { + /// The type that implements the permission check function. + type Checker: CheckAccountCallPermissions; +} + +/// Result of `CheckAccountCallPermissions::check_account_call_permissions`. +pub struct AccountCallPermissionsData { + /// The primary identity of the call. + pub primary_did: IdentityId, + /// The secondary key of the call, if it is defined. + pub secondary_key: Option>, +} + +/// A permission checker for calls from accounts to extrinsics. +pub trait CheckAccountCallPermissions { + /// Checks whether `who` can call the current extrinsic represented by `pallet_name` and + /// `function_name`. + /// + /// Returns: + /// + /// - `Some(data)` where `data` contains the primary identity ID on behalf of which the caller + /// is allowed to make this call and the secondary key of the caller if the caller is a + /// secondary key of the primary identity. + /// + /// - `None` if the call is not allowed. + fn check_account_call_permissions( + who: &AccountId, + pallet_name: impl FnOnce() -> PalletName, + function_name: impl FnOnce() -> ExtrinsicName, + ) -> Option>; +} decl_storage! { trait Store for Module as Permissions { diff --git a/pallets/runtime/common/src/runtime.rs b/pallets/runtime/common/src/runtime.rs index 34423cb0b3..0a98e1bb1b 100644 --- a/pallets/runtime/common/src/runtime.rs +++ b/pallets/runtime/common/src/runtime.rs @@ -549,7 +549,7 @@ macro_rules! misc_pallet_impls { type WeightInfo = polymesh_weights::pallet_sto::SubstrateWeight; } - impl polymesh_common_utilities::traits::permissions::Config for Runtime { + impl pallet_permissions::Config for Runtime { type Checker = Identity; } diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index 116b5d3b6a..e88a5eab7e 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -486,7 +486,7 @@ impl CheckCdd for Test { } } -impl polymesh_common_utilities::traits::permissions::Config for Test { +impl pallet_permissions::Config for Test { type Checker = Identity; } From a662d1f90c99d741ad87b6b8f2276efcc404c11e Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 01:41:52 +0800 Subject: [PATCH 04/45] Remove dead code. --- pallets/common/src/traits/exemption.rs | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 pallets/common/src/traits/exemption.rs diff --git a/pallets/common/src/traits/exemption.rs b/pallets/common/src/traits/exemption.rs deleted file mode 100644 index 3a16a1a91d..0000000000 --- a/pallets/common/src/traits/exemption.rs +++ /dev/null @@ -1,20 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use polymesh_primitives::{IdentityId, Ticker}; - -pub trait Trait { - fn is_exempted(ticker: &Ticker, tm: u16, did: IdentityId) -> bool; -} From 9f7e82ff7a1705b0dd2aa179aee52a9144537d2b Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 01:51:12 +0800 Subject: [PATCH 05/45] Move ChargeProtocolFee types to primitives. --- Cargo.lock | 5 ++--- pallets/asset/src/checkpoint/mod.rs | 6 ++---- pallets/asset/src/lib.rs | 2 +- pallets/common/src/lib.rs | 3 --- pallets/common/src/traits/identity.rs | 5 ++--- pallets/compliance-manager/src/lib.rs | 2 +- pallets/corporate-actions/src/ballot/mod.rs | 2 +- .../corporate-actions/src/distribution/mod.rs | 6 ++---- pallets/identity/src/claims.rs | 4 ++-- pallets/identity/src/keys.rs | 2 +- pallets/identity/src/lib.rs | 2 +- pallets/pips/src/lib.rs | 2 +- pallets/protocol-fee/Cargo.toml | 2 -- pallets/protocol-fee/rpc/Cargo.toml | 2 +- pallets/protocol-fee/rpc/runtime-api/Cargo.toml | 4 ++-- pallets/protocol-fee/rpc/runtime-api/src/lib.rs | 2 +- pallets/protocol-fee/rpc/src/lib.rs | 2 +- pallets/protocol-fee/src/benchmarking.rs | 2 +- pallets/protocol-fee/src/lib.rs | 10 +++++----- pallets/runtime/develop/src/runtime.rs | 2 +- pallets/runtime/mainnet/src/runtime.rs | 2 +- pallets/runtime/testnet/src/runtime.rs | 2 +- pallets/runtime/tests/src/storage.rs | 2 +- primitives/src/lib.rs | 3 +++ .../common => primitives}/src/protocol_fee.rs | 16 ++++++++++++++++ src/chain_spec.rs | 2 +- 26 files changed, 51 insertions(+), 43 deletions(-) rename {pallets/common => primitives}/src/protocol_fee.rs (73%) diff --git a/Cargo.lock b/Cargo.lock index ac2d21506f..a77aba51dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5383,7 +5383,6 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "pallet-identity", "parity-scale-codec 3.6.9", "polymesh-common-utilities", "polymesh-primitives", @@ -5405,7 +5404,7 @@ dependencies = [ "node-rpc", "pallet-protocol-fee-rpc-runtime-api", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", + "polymesh-primitives", "serde", "sp-api", "sp-blockchain", @@ -5420,7 +5419,7 @@ name = "pallet-protocol-fee-rpc-runtime-api" version = "0.1.0" dependencies = [ "parity-scale-codec 3.6.9", - "polymesh-common-utilities", + "polymesh-primitives", "serde", "sp-api", "sp-runtime", diff --git a/pallets/asset/src/checkpoint/mod.rs b/pallets/asset/src/checkpoint/mod.rs index f211deb7d9..a17c448e84 100644 --- a/pallets/asset/src/checkpoint/mod.rs +++ b/pallets/asset/src/checkpoint/mod.rs @@ -60,11 +60,9 @@ pub use polymesh_common_utilities::traits::checkpoint::{Event, WeightInfo}; use polymesh_common_utilities::traits::checkpoint::{ NextCheckpoints, ScheduleCheckpoints, ScheduleId, }; -use polymesh_common_utilities::{ - protocol_fee::{ChargeProtocolFee, ProtocolOp}, - GC_DID, -}; +use polymesh_common_utilities::GC_DID; use polymesh_primitives::asset::AssetId; +use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{asset::CheckpointId, storage_migration_ver, IdentityId, Moment}; use crate::Config; diff --git a/pallets/asset/src/lib.rs b/pallets/asset/src/lib.rs index d13ac2562d..b26d07cf77 100644 --- a/pallets/asset/src/lib.rs +++ b/pallets/asset/src/lib.rs @@ -106,7 +106,6 @@ use pallet_portfolio::{Error as PortfolioError, PortfolioAssetBalances}; use polymesh_common_utilities::asset::AssetFnTrait; use polymesh_common_utilities::compliance_manager::ComplianceFnConfig; use polymesh_common_utilities::constants::*; -use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp}; pub use polymesh_common_utilities::traits::asset::{Config, Event, RawEvent, WeightInfo}; use polymesh_common_utilities::traits::nft::NFTTrait; use polymesh_primitives::agent::AgentGroup; @@ -117,6 +116,7 @@ use polymesh_primitives::asset_metadata::{ AssetMetadataGlobalKey, AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataName, AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, }; +use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::settlement::InstructionId; use polymesh_primitives::{ extract_auth, storage_migrate_on, storage_migration_ver, AssetIdentifier, Balance, Document, diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 5b38c19bbe..36b3b10f6b 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -25,9 +25,6 @@ pub use traits::{ pub mod context; pub use context::Context; -pub mod protocol_fee; -pub use protocol_fee::ChargeProtocolFee; - #[cfg(feature = "runtime-benchmarks")] pub mod benchs; diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index 24cf259037..ef2f95e9b0 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -26,8 +26,8 @@ use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; use polymesh_primitives::{ - secondary_key::SecondaryKey, AuthorizationData, Balance, CustomClaimTypeId, IdentityClaim, - IdentityId, Permissions, Ticker, + protocol_fee::ChargeProtocolFee, secondary_key::SecondaryKey, AuthorizationData, Balance, + CustomClaimTypeId, IdentityClaim, IdentityId, Permissions, Ticker, }; use crate::traits::group::GroupTrait; @@ -35,7 +35,6 @@ use crate::traits::multisig::MultiSigSubTrait; use crate::traits::portfolio::PortfolioSubTrait; use crate::traits::transaction_payment::{CddAndFeeDetails, ChargeTxFee}; use crate::traits::CommonConfig; -use crate::ChargeProtocolFee; pub type AuthorizationNonce = u64; diff --git a/pallets/compliance-manager/src/lib.rs b/pallets/compliance-manager/src/lib.rs index 249e6b4e98..604a82f2ef 100644 --- a/pallets/compliance-manager/src/lib.rs +++ b/pallets/compliance-manager/src/lib.rs @@ -84,7 +84,6 @@ use frame_support::{decl_error, decl_module, decl_storage, ensure}; use sp_std::{convert::From, prelude::*}; use pallet_base::ensure_length_ok; -use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp}; pub use polymesh_common_utilities::traits::compliance_manager::{ ComplianceFnConfig, Config, Event, WeightInfo, }; @@ -93,6 +92,7 @@ use polymesh_primitives::compliance_manager::{ AssetCompliance, AssetComplianceResult, ComplianceReport, ComplianceRequirement, ConditionReport, ConditionResult, RequirementReport, }; +use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{ proposition, storage_migration_ver, Claim, Condition, ConditionType, Context, IdentityId, TargetIdentity, TrustedFor, TrustedIssuer, WeightMeter, diff --git a/pallets/corporate-actions/src/ballot/mod.rs b/pallets/corporate-actions/src/ballot/mod.rs index 12d4718828..a0bb8acca3 100644 --- a/pallets/corporate-actions/src/ballot/mod.rs +++ b/pallets/corporate-actions/src/ballot/mod.rs @@ -92,7 +92,7 @@ use frame_support::{ use pallet_asset::checkpoint; use pallet_base::ensure_string_limited; use pallet_identity as identity; -use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp}; +use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{storage_migration_ver, Balance, EventDid, IdentityId, Moment}; use polymesh_primitives_derive::VecU8StrongTyped; use scale_info::TypeInfo; diff --git a/pallets/corporate-actions/src/distribution/mod.rs b/pallets/corporate-actions/src/distribution/mod.rs index 3d50d2f8ff..3cb4c97941 100644 --- a/pallets/corporate-actions/src/distribution/mod.rs +++ b/pallets/corporate-actions/src/distribution/mod.rs @@ -77,13 +77,11 @@ use frame_support::{ use pallet_asset::{self as asset, checkpoint}; use pallet_identity::{self as identity, PermissionedCallOriginData}; use polymesh_common_utilities::{ - constants::currency::ONE_UNIT, - portfolio::PortfolioSubTrait, - protocol_fee::{ChargeProtocolFee, ProtocolOp}, - with_transaction, + constants::currency::ONE_UNIT, portfolio::PortfolioSubTrait, with_transaction, }; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ + protocol_fee::{ChargeProtocolFee, ProtocolOp}, storage_migration_ver, Balance, EventDid, IdentityId, Moment, PortfolioId, PortfolioNumber, SecondaryKey, WeightMeter, }; diff --git a/pallets/identity/src/claims.rs b/pallets/identity/src/claims.rs index 46b93a844d..db213c7586 100644 --- a/pallets/identity/src/claims.rs +++ b/pallets/identity/src/claims.rs @@ -25,7 +25,6 @@ use frame_system::ensure_root; use pallet_base::{ensure_string_limited, try_next_pre}; use polymesh_common_utilities::{ - protocol_fee::ProtocolOp, traits::{ group::{GroupTrait, InactiveMember}, identity::{Config, RawEvent}, @@ -34,7 +33,8 @@ use polymesh_common_utilities::{ }; use polymesh_primitives::identity_claim::CustomClaimTypeId; use polymesh_primitives::{ - CddId, Claim, ClaimType, IdentityClaim, IdentityId, Scope, SecondaryKey, + protocol_fee::ProtocolOp, CddId, Claim, ClaimType, IdentityClaim, IdentityId, Scope, + SecondaryKey, }; use sp_runtime::traits::{CheckedAdd, SaturatedConversion, Zero}; use sp_std::prelude::*; diff --git a/pallets/identity/src/keys.rs b/pallets/identity/src/keys.rs index cb435275a6..f64c9d4955 100644 --- a/pallets/identity/src/keys.rs +++ b/pallets/identity/src/keys.rs @@ -33,11 +33,11 @@ use polymesh_common_utilities::group::GroupTrait; use polymesh_common_utilities::identity::{ CreateChildIdentityWithAuth, SecondaryKeyWithAuth, TargetIdAuthorization, }; -use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee as _, ProtocolOp}; use polymesh_common_utilities::SystematicIssuers; use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; +use polymesh_primitives::protocol_fee::{ChargeProtocolFee as _, ProtocolOp}; use polymesh_primitives::{ extract_auth, AuthorizationData, CddId, DidRecord, ExtrinsicName, ExtrinsicPermissions, IdentityId, KeyRecord, PalletName, Permissions, SecondaryKey, Signatory, diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index d5878b7010..b15b11295f 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -99,12 +99,12 @@ use frame_support::dispatch::DispatchClass::{Normal, Operational}; use frame_support::dispatch::{DispatchError, DispatchResult, Pays, Weight}; use frame_support::traits::{ChangeMembers, Currency, EnsureOrigin, Get, InitializeMembers}; use frame_support::{decl_error, decl_module, decl_storage}; -use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_common_utilities::traits::identity::{ AuthorizationNonce, Config, CreateChildIdentityWithAuth, IdentityFnTrait, RawEvent, SecondaryKeyWithAuth, }; use polymesh_common_utilities::{SystematicIssuers, GC_DID}; +use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{ storage_migration_ver, AssetPermissions, Authorization, AuthorizationData, AuthorizationType, CddId, Claim, ClaimType, CustomClaimTypeId, DidRecord, ExtrinsicPermissions, IdentityClaim, diff --git a/pallets/pips/src/lib.rs b/pallets/pips/src/lib.rs index 056675b592..20edcaf33e 100644 --- a/pallets/pips/src/lib.rs +++ b/pallets/pips/src/lib.rs @@ -109,13 +109,13 @@ use sp_version::RuntimeVersion; use pallet_base::{ensure_opt_string_limited, try_next_post}; use pallet_identity::PermissionedCallOriginData; use polymesh_common_utilities::constants::PIP_MAX_REPORTING_SIZE; -use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_common_utilities::traits::balances::LockableCurrencyExt; use polymesh_common_utilities::traits::governance_group::GovernanceGroupTrait; use polymesh_common_utilities::traits::group::GroupTrait; use polymesh_common_utilities::traits::identity::Config as IdentityConfig; use polymesh_common_utilities::{with_transaction, CommonConfig, MaybeBlock}; use polymesh_common_utilities::{GC_DID, TECHNICAL_DID, UPGRADE_DID}; +use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::storage_migration_ver; use polymesh_primitives::{Balance, IdentityId, Url}; use polymesh_runtime_common::PipsEnactSnapshotMaximumWeight; diff --git a/pallets/protocol-fee/Cargo.toml b/pallets/protocol-fee/Cargo.toml index 945ac675fc..13a78c3324 100644 --- a/pallets/protocol-fee/Cargo.toml +++ b/pallets/protocol-fee/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" [dependencies] polymesh-primitives = { path = "../../primitives", default-features = false } polymesh-common-utilities = { path = "../common", default-features = false } -pallet-identity = { path = "../identity", default-features = false } # General serde = { version = "1.0.104", default-features = false } @@ -33,7 +32,6 @@ std = [ "frame-benchmarking/std", "frame-support/std", "frame-system/std", - "pallet-identity/std", "polymesh-common-utilities/std", "polymesh-primitives/std", "serde/std", diff --git a/pallets/protocol-fee/rpc/Cargo.toml b/pallets/protocol-fee/rpc/Cargo.toml index 88ea0a676c..c47df1ca84 100644 --- a/pallets/protocol-fee/rpc/Cargo.toml +++ b/pallets/protocol-fee/rpc/Cargo.toml @@ -20,7 +20,7 @@ frame-support = { version = "4.0.0-dev", default-features = false } frame-system = { version = "4.0.0-dev", default-features = false } node-rpc = { path = "../../../rpc" } -polymesh-common-utilities = { path = "../../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } pallet-protocol-fee-rpc-runtime-api = { path = "./runtime-api" } # General diff --git a/pallets/protocol-fee/rpc/runtime-api/Cargo.toml b/pallets/protocol-fee/rpc/runtime-api/Cargo.toml index 6fdc3b7419..22cbb59152 100644 --- a/pallets/protocol-fee/rpc/runtime-api/Cargo.toml +++ b/pallets/protocol-fee/rpc/runtime-api/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -polymesh-common-utilities = { path = "../../../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } # General serde = { version = "1.0.104", optional = true, features = ["derive"] } @@ -25,5 +25,5 @@ std = [ "sp-api/std", "codec/std", "sp-runtime/std", - "polymesh-common-utilities/std" + "polymesh-primitives/std", ] diff --git a/pallets/protocol-fee/rpc/runtime-api/src/lib.rs b/pallets/protocol-fee/rpc/runtime-api/src/lib.rs index 894ee16ecd..14d95736d7 100644 --- a/pallets/protocol-fee/rpc/runtime-api/src/lib.rs +++ b/pallets/protocol-fee/rpc/runtime-api/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode}; -use polymesh_common_utilities::protocol_fee::ProtocolOp; +use polymesh_primitives::protocol_fee::ProtocolOp; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::traits::{SaturatedConversion, UniqueSaturatedInto}; diff --git a/pallets/protocol-fee/rpc/src/lib.rs b/pallets/protocol-fee/rpc/src/lib.rs index 7c7cbac17c..8897e12e71 100644 --- a/pallets/protocol-fee/rpc/src/lib.rs +++ b/pallets/protocol-fee/rpc/src/lib.rs @@ -20,7 +20,7 @@ use jsonrpsee::{ }; use node_rpc::Error; pub use pallet_protocol_fee_rpc_runtime_api::{CappedFee, ProtocolFeeApi as ProtocolFeeRuntimeApi}; -use polymesh_common_utilities::protocol_fee::ProtocolOp; +use polymesh_primitives::protocol_fee::ProtocolOp; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::traits::Block as BlockT; diff --git a/pallets/protocol-fee/src/benchmarking.rs b/pallets/protocol-fee/src/benchmarking.rs index 8ba97ddd22..1cc326efcd 100644 --- a/pallets/protocol-fee/src/benchmarking.rs +++ b/pallets/protocol-fee/src/benchmarking.rs @@ -16,7 +16,7 @@ use crate::*; use frame_benchmarking::benchmarks; use frame_system::RawOrigin; -use polymesh_common_utilities::protocol_fee::ProtocolOp; +use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::PosRatio; benchmarks! { diff --git a/pallets/protocol-fee/src/lib.rs b/pallets/protocol-fee/src/lib.rs index 4be67284e6..acc798580a 100644 --- a/pallets/protocol-fee/src/lib.rs +++ b/pallets/protocol-fee/src/lib.rs @@ -46,13 +46,13 @@ use frame_support::{ }; use frame_system::ensure_root; use polymesh_common_utilities::{ - identity::Config as IdentityConfig, + identity::Config as IdentityConfig, traits::relayer::SubsidiserTrait, + transaction_payment::CddAndFeeDetails, GC_DID, +}; +use polymesh_primitives::{ protocol_fee::{ChargeProtocolFee, ProtocolOp}, - traits::relayer::SubsidiserTrait, - transaction_payment::CddAndFeeDetails, - GC_DID, + Balance, IdentityId, PosRatio, }; -use polymesh_primitives::{Balance, IdentityId, PosRatio}; use sp_runtime::{traits::Zero, Perbill}; use sp_std::vec; diff --git a/pallets/runtime/develop/src/runtime.rs b/pallets/runtime/develop/src/runtime.rs index ac822a1c38..ed1bdbba38 100644 --- a/pallets/runtime/develop/src/runtime.rs +++ b/pallets/runtime/develop/src/runtime.rs @@ -28,7 +28,7 @@ use pallet_session::historical as pallet_session_historical; pub use pallet_transaction_payment::{Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment}; use polymesh_common_utilities::constants::currency::*; use polymesh_common_utilities::constants::ENSURED_MAX_LEN; -use polymesh_common_utilities::protocol_fee::ProtocolOp; +use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{Balance, BlockNumber, Moment}; use polymesh_runtime_common::impls::Author; diff --git a/pallets/runtime/mainnet/src/runtime.rs b/pallets/runtime/mainnet/src/runtime.rs index 1cb76e4664..8a84113631 100644 --- a/pallets/runtime/mainnet/src/runtime.rs +++ b/pallets/runtime/mainnet/src/runtime.rs @@ -32,7 +32,7 @@ pub use pallet_timestamp::Call as TimestampCall; pub use pallet_transaction_payment::{Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment}; use polymesh_common_utilities::constants::currency::*; use polymesh_common_utilities::constants::ENSURED_MAX_LEN; -use polymesh_common_utilities::protocol_fee::ProtocolOp; +use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{Balance, BlockNumber, Moment}; use polymesh_runtime_common::impls::Author; diff --git a/pallets/runtime/testnet/src/runtime.rs b/pallets/runtime/testnet/src/runtime.rs index 5edabb26f4..b27d9ecede 100644 --- a/pallets/runtime/testnet/src/runtime.rs +++ b/pallets/runtime/testnet/src/runtime.rs @@ -34,7 +34,7 @@ pub use pallet_timestamp::Call as TimestampCall; pub use pallet_transaction_payment::{Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment}; use polymesh_common_utilities::constants::currency::*; use polymesh_common_utilities::constants::ENSURED_MAX_LEN; -use polymesh_common_utilities::protocol_fee::ProtocolOp; +use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{Balance, BlockNumber, Moment}; use polymesh_runtime_common::impls::Author; diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index c3aab72f23..9ab866e71e 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -51,10 +51,10 @@ use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::RuntimeDispatchInfo; use pallet_utility; use polymesh_common_utilities::constants::currency::{DOLLARS, POLY}; -use polymesh_common_utilities::protocol_fee::ProtocolOp; use polymesh_common_utilities::traits::group::GroupTrait; use polymesh_common_utilities::traits::transaction_payment::{CddAndFeeDetails, ChargeTxFee}; use polymesh_common_utilities::Context; +use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{ AccountId, Authorization, AuthorizationData, BlockNumber, Claim, Moment, diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 6dd3b72c7f..1071bb7460 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -145,6 +145,9 @@ pub use identity_claim::{Claim, ClaimType, CustomClaimTypeId, IdentityClaim, Sco pub mod jurisdiction; pub use jurisdiction::CountryCode; +/// Protocol fees +pub mod protocol_fee; + /// Utilities for storage migration. pub mod migrate; diff --git a/pallets/common/src/protocol_fee.rs b/primitives/src/protocol_fee.rs similarity index 73% rename from pallets/common/src/protocol_fee.rs rename to primitives/src/protocol_fee.rs index f69153156c..db59c3b8c0 100644 --- a/pallets/common/src/protocol_fee.rs +++ b/primitives/src/protocol_fee.rs @@ -24,21 +24,37 @@ use sp_runtime::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum ProtocolOp { + /// Fee charged when registering a new ticker. AssetRegisterTicker, + /// Fee charged when issuing assets. AssetIssue, + /// Fee charged when adding documents to an asset. AssetAddDocuments, + /// Fee charged when creating a new asset. AssetCreateAsset, + /// Fee charged when creating a checkpoint schedule. CheckpointCreateSchedule, + /// Fee charged when adding compliance requirements. ComplianceManagerAddComplianceRequirement, + /// Fee charged when registering a DID through CDD. IdentityCddRegisterDid, + /// Fee charged when adding a claim to an identity. IdentityAddClaim, + /// Fee charged when adding secondary keys with authorization. IdentityAddSecondaryKeysWithAuthorization, + /// Fee charged when making a proposal in PIPs. PipsPropose, + /// Fee charged when uploading contract code. ContractsPutCode, + /// Fee charged when attaching a ballot to corporate actions. CorporateBallotAttachBallot, + /// Fee charged when distributing capital. CapitalDistributionDistribute, + /// Fee charged when creating an NFT collection. NFTCreateCollection, + /// Fee charged when minting NFTs. NFTMint, + /// Fee charged when creating a child identity. IdentityCreateChildIdentity, } diff --git a/src/chain_spec.rs b/src/chain_spec.rs index 37ddb55f50..bf0b9ff4ce 100644 --- a/src/chain_spec.rs +++ b/src/chain_spec.rs @@ -5,12 +5,12 @@ use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_staking::StakerStatus; use polymesh_common_utilities::{ constants::{currency::ONE_POLY, TREASURY_PALLET_ID}, - protocol_fee::ProtocolOp, MaybeBlock, SystematicIssuers, }; use polymesh_primitives::{ asset_metadata::{AssetMetadataName, AssetMetadataSpec}, identity_id::GenesisIdentityRecord, + protocol_fee::ProtocolOp, AccountId, IdentityId, Moment, PosRatio, SecondaryKey, Signature, Ticker, }; use sc_chain_spec::{ChainSpecExtension, ChainType}; From 457b132f629752c40be25929487e485d3dd4c146 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 02:47:37 +0800 Subject: [PATCH 06/45] Move constants from polymesh-common-utilities to primitives. --- pallets/asset/src/benchmarking.rs | 2 +- pallets/asset/src/checkpoint/mod.rs | 2 +- pallets/asset/src/lib.rs | 4 +- pallets/balances/src/lib.rs | 13 +- pallets/committee/src/lib.rs | 4 +- pallets/common/src/benchs/asset.rs | 2 +- pallets/common/src/constants.rs | 82 --------- pallets/common/src/lib.rs | 90 ---------- pallets/contracts/src/benchmarking.rs | 2 +- .../corporate-actions/src/distribution/mod.rs | 9 +- pallets/corporate-actions/src/lib.rs | 6 +- pallets/external-agents/src/lib.rs | 5 +- pallets/group/src/lib.rs | 4 +- pallets/identity/src/claims.rs | 11 +- pallets/identity/src/keys.rs | 4 +- pallets/identity/src/lib.rs | 4 +- pallets/nft/src/benchmarking.rs | 3 +- pallets/pips/src/benchmarking.rs | 3 +- pallets/pips/src/lib.rs | 8 +- pallets/portfolio/src/benchmarking.rs | 2 +- pallets/protocol-fee/src/lib.rs | 4 +- pallets/runtime/common/src/lib.rs | 2 +- .../develop/src/benchmarks/pallet_session.rs | 2 +- pallets/runtime/develop/src/runtime.rs | 4 +- pallets/runtime/mainnet/src/runtime.rs | 4 +- pallets/runtime/testnet/src/runtime.rs | 4 +- pallets/runtime/tests/src/asset_test.rs | 2 +- pallets/runtime/tests/src/contracts_test.rs | 4 +- .../tests/src/corporate_actions_test.rs | 11 +- pallets/runtime/tests/src/ext_builder.rs | 2 +- pallets/runtime/tests/src/identity_test.rs | 25 ++- pallets/runtime/tests/src/multisig.rs | 2 +- pallets/runtime/tests/src/nft.rs | 5 +- pallets/runtime/tests/src/pips_test.rs | 4 +- pallets/runtime/tests/src/protocol_fee.rs | 5 +- pallets/runtime/tests/src/relayer_test.rs | 8 +- .../settlement_pallet/execute_instruction.rs | 2 +- pallets/runtime/tests/src/settlement_test.rs | 2 +- pallets/runtime/tests/src/staking/mock.rs | 2 +- pallets/runtime/tests/src/storage.rs | 2 +- pallets/settlement/src/benchmarking.rs | 4 +- pallets/settlement/src/lib.rs | 6 +- pallets/staking/src/pallet/impls.rs | 2 +- pallets/staking/src/pallet/mod.rs | 4 +- pallets/statistics/src/benchmarking.rs | 2 +- pallets/sto/src/lib.rs | 4 +- pallets/treasury/src/lib.rs | 6 +- primitives/src/constants.rs | 167 +++++++++++++++++- primitives/src/lib.rs | 1 + src/chain_spec.rs | 8 +- 50 files changed, 266 insertions(+), 294 deletions(-) delete mode 100644 pallets/common/src/constants.rs diff --git a/pallets/asset/src/benchmarking.rs b/pallets/asset/src/benchmarking.rs index dbd9101598..8d08281be3 100644 --- a/pallets/asset/src/benchmarking.rs +++ b/pallets/asset/src/benchmarking.rs @@ -22,7 +22,6 @@ use sp_std::{convert::TryInto, iter, prelude::*}; use pallet_statistics::benchmarking::setup_transfer_restrictions; use polymesh_common_utilities::benchs::{reg_unique_ticker, user, User, UserBuilder}; -use polymesh_common_utilities::constants::currency::{ONE_UNIT, POLY}; use polymesh_common_utilities::traits::compliance_manager::ComplianceFnConfig; use polymesh_common_utilities::traits::nft::NFTTrait; use polymesh_primitives::agent::AgentGroup; @@ -31,6 +30,7 @@ use polymesh_primitives::asset_metadata::{ AssetMetadataDescription, AssetMetadataKey, AssetMetadataName, AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, }; +use polymesh_primitives::constants::currency::{ONE_UNIT, POLY}; use polymesh_primitives::ticker::TICKER_LEN; use polymesh_primitives::{ AuthorizationData, Fund, FundDescription, IdentityId, NFTCollectionKeys, PortfolioKind, diff --git a/pallets/asset/src/checkpoint/mod.rs b/pallets/asset/src/checkpoint/mod.rs index a17c448e84..d1cb75a5ef 100644 --- a/pallets/asset/src/checkpoint/mod.rs +++ b/pallets/asset/src/checkpoint/mod.rs @@ -60,9 +60,9 @@ pub use polymesh_common_utilities::traits::checkpoint::{Event, WeightInfo}; use polymesh_common_utilities::traits::checkpoint::{ NextCheckpoints, ScheduleCheckpoints, ScheduleId, }; -use polymesh_common_utilities::GC_DID; use polymesh_primitives::asset::AssetId; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; +use polymesh_primitives::GC_DID; use polymesh_primitives::{asset::CheckpointId, storage_migration_ver, IdentityId, Moment}; use crate::Config; diff --git a/pallets/asset/src/lib.rs b/pallets/asset/src/lib.rs index b26d07cf77..e1adf71af2 100644 --- a/pallets/asset/src/lib.rs +++ b/pallets/asset/src/lib.rs @@ -105,7 +105,6 @@ use pallet_identity::PermissionedCallOriginData; use pallet_portfolio::{Error as PortfolioError, PortfolioAssetBalances}; use polymesh_common_utilities::asset::AssetFnTrait; use polymesh_common_utilities::compliance_manager::ComplianceFnConfig; -use polymesh_common_utilities::constants::*; pub use polymesh_common_utilities::traits::asset::{Config, Event, RawEvent, WeightInfo}; use polymesh_common_utilities::traits::nft::NFTTrait; use polymesh_primitives::agent::AgentGroup; @@ -116,6 +115,7 @@ use polymesh_primitives::asset_metadata::{ AssetMetadataGlobalKey, AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataName, AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, }; +use polymesh_primitives::constants::*; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::settlement::InstructionId; use polymesh_primitives::{ @@ -255,7 +255,7 @@ decl_storage! { build(|config: &GenesisConfig| { // Reserving country currency logic let fiat_tickers_reservation_did = - polymesh_common_utilities::SystematicIssuers::FiatTickersReservation.as_id(); + polymesh_primitives::SystematicIssuers::FiatTickersReservation.as_id(); for currency_ticker in &config.reserved_country_currency_codes { let _ = >::unverified_register_ticker( *currency_ticker, diff --git a/pallets/balances/src/lib.rs b/pallets/balances/src/lib.rs index a1008c7153..96ac308182 100644 --- a/pallets/balances/src/lib.rs +++ b/pallets/balances/src/lib.rs @@ -177,16 +177,13 @@ use frame_support::{ }; use frame_system::{self as system, ensure_root, ensure_signed}; pub use polymesh_common_utilities::traits::balances::WeightInfo; -use polymesh_common_utilities::{ - traits::{ - balances::{AccountData, BalancesTrait, CheckCdd, RawEvent, Reasons}, - identity::IdentityFnTrait, - NegativeImbalance, PositiveImbalance, - }, - SystematicIssuers, GC_DID, +use polymesh_common_utilities::traits::{ + balances::{AccountData, BalancesTrait, CheckCdd, RawEvent, Reasons}, + identity::IdentityFnTrait, + NegativeImbalance, PositiveImbalance, }; use polymesh_primitives::traits::BlockRewardsReserveCurrency; -use polymesh_primitives::{Balance, Memo}; +use polymesh_primitives::{Balance, Memo, SystematicIssuers, GC_DID}; use scale_info::TypeInfo; use sp_runtime::{ traits::{AccountIdConversion, StaticLookup, Zero}, diff --git a/pallets/committee/src/lib.rs b/pallets/committee/src/lib.rs index 47dc0ffc99..51a47945a4 100644 --- a/pallets/committee/src/lib.rs +++ b/pallets/committee/src/lib.rs @@ -75,9 +75,9 @@ use polymesh_common_utilities::{ governance_group::GovernanceGroupTrait, group::{GroupTrait, InactiveMember, MemberCount}, identity::Config as IdentityConfig, - MaybeBlock, SystematicIssuers, GC_DID, + MaybeBlock, }; -use polymesh_primitives::{storage_migration_ver, IdentityId}; +use polymesh_primitives::{storage_migration_ver, IdentityId, SystematicIssuers, GC_DID}; use scale_info::TypeInfo; use sp_runtime::traits::Hash; use sp_std::{prelude::*, vec}; diff --git a/pallets/common/src/benchs/asset.rs b/pallets/common/src/benchs/asset.rs index 22ff8a2ca2..06b0afd9a3 100644 --- a/pallets/common/src/benchs/asset.rs +++ b/pallets/common/src/benchs/asset.rs @@ -1,10 +1,10 @@ use sp_std::vec; use polymesh_primitives::asset::{AssetId, AssetName, AssetType}; +use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::{PortfolioKind, Ticker}; use crate::benchs::User; -use crate::constants::currency::POLY; use crate::traits::asset::{AssetFnTrait, Config}; pub type ResultTicker = Result; diff --git a/pallets/common/src/constants.rs b/pallets/common/src/constants.rs deleted file mode 100644 index 3106aa5d18..0000000000 --- a/pallets/common/src/constants.rs +++ /dev/null @@ -1,82 +0,0 @@ -use frame_support::PalletId; - -/// Money matters. -pub mod currency { - use polymesh_primitives::Balance; - pub const POLY: Balance = 1_000_000; - pub const ONE_POLY: Balance = POLY; - pub const DOLLARS: Balance = POLY; - pub const CENTS: Balance = DOLLARS / 100; - pub const MILLICENTS: Balance = CENTS / 1_000; - pub const ONE_UNIT: Balance = 1_000_000; - pub const MAX_SUPPLY: Balance = ONE_UNIT * 1_000_000_000_000; -} - -/// DID-related. -pub mod did { - /// prefix for user dids - pub const USER: &[u8; 5] = b"USER:"; - /// prefix for security token dids - pub const SECURITY_TOKEN: &[u8; 15] = b"SECURITY_TOKEN:"; - - /// Governance Committee DID. It is used in systematic CDD claim for Governance Committee members. - pub const GOVERNANCE_COMMITTEE_DID: &[u8; 32] = b"system:governance_committee\0\0\0\0\0"; - /// CDD Providers DID. It is used in systematic CDD claim for CDD Providers. - pub const CDD_PROVIDERS_DID: &[u8; 32] = b"system:customer_due_diligence\0\0\0"; - /// Treasury module DID. It is used in systematic CDD claim for the Treasury module. - pub const TREASURY_DID: &[u8; 32] = b"system:treasury_module_did\0\0\0\0\0\0"; - /// Block Reward Reserve DID. - pub const BLOCK_REWARD_RESERVE_DID: &[u8; 32] = b"system:block_reward_reserve_did\0"; - /// Settlement module DID - pub const SETTLEMENT_MODULE_DID: &[u8; 32] = b"system:settlement_module_did\0\0\0\0"; - /// Polymath Classic / Ethereum migration DID. - pub const CLASSIC_MIGRATION_DID: &[u8; 32] = b"system:polymath_classic_mig\0\0\0\0\0"; - /// Fiat Currency Reservation DID - pub const FIAT_TICKERS_RESERVATION_DID: &[u8; 32] = b"system:fiat_tickers_reservation\0"; - /// Technical Committee DID. - pub const TECHNICAL_COMMITTEE_DID: &[u8; 32] = b"system:technical_committee\0\0\0\0\0\0"; - /// Upgrade Committee DID. - pub const UPGRADE_COMMITTEE_DID: &[u8; 32] = b"system:upgrade_committee\0\0\0\0\0\0\0\0"; -} - -/// Priorities for the task that get scheduled. -pub mod queue_priority { - use frame_support::traits::schedule::Priority; - - /// Queue priority for the settlement instruction execution. - pub const SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY: Priority = 100; -} - -// ERC1400 transfer status codes -pub const ERC1400_TRANSFER_FAILURE: u8 = 0x50; -pub const ERC1400_INSUFFICIENT_BALANCE: u8 = 0x52; -pub const ERC1400_INSUFFICIENT_ALLOWANCE: u8 = 0x53; -pub const ERC1400_FUNDS_LOCKED: u8 = 0x55; -pub const ERC1400_INVALID_SENDER: u8 = 0x56; -pub const ERC1400_INVALID_RECEIVER: u8 = 0x57; -pub const ERC1400_INVALID_OPERATOR: u8 = 0x58; - -// Application-specific status codes -pub const INVALID_SENDER_DID: u8 = 0xa0; -pub const INVALID_RECEIVER_DID: u8 = 0xa1; -pub const INVALID_GRANULARITY: u8 = 0xa4; -pub const APP_TX_VOLUME_LIMIT_REACHED: u8 = 0xa5; -pub const APP_BLOCKED_TX: u8 = 0xa6; -pub const APP_FUNDS_LOCKED: u8 = 0xa7; -pub const APP_FUNDS_LIMIT_REACHED: u8 = 0xa8; -pub const CUSTODIAN_ERROR: u8 = 0xaa; - -// PIP pallet constants. -pub const PIP_MAX_REPORTING_SIZE: usize = 1024; - -/// Module ids, used for deriving sovereign account IDs for modules. -pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"pm/trsry"); -pub const BRR_PALLET_ID: PalletId = PalletId(*b"pm/blrwr"); -pub const GC_PALLET_ID: PalletId = PalletId(*b"pm/govcm"); -pub const CDD_PALLET_ID: PalletId = PalletId(*b"pm/cusdd"); -pub const SETTLEMENT_PALLET_ID: PalletId = PalletId(*b"pm/setmn"); -pub const CLASSIC_MIGRATION_PALLET_ID: PalletId = PalletId(*b"pm/ehmig"); -pub const FIAT_TICKERS_RESERVATION_PALLET_ID: PalletId = PalletId(*b"pm/ftres"); - -/// Base module constants -pub const ENSURED_MAX_LEN: u32 = 2048; diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 36b3b10f6b..06cc56e421 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -15,8 +15,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -pub mod constants; - pub mod traits; pub use traits::{ asset, balances, compliance_manager, governance_group, group, identity, multisig, nft, @@ -31,14 +29,10 @@ pub mod benchs; use core::ops::Add; use frame_support::codec::{Decode, Encode}; use frame_support::traits::Get; -use frame_support::PalletId; -use polymesh_primitives::IdentityId; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -pub use polymesh_primitives::with_transaction; - /// Use `GetExtra` as the trait bounds for pallet `Config` parameters /// that will be used for bounded collections. pub trait GetExtra: Get + Clone + core::fmt::Debug + Default + PartialEq + Eq {} @@ -57,90 +51,6 @@ impl Get for ConstSize { impl GetExtra for ConstSize {} -/// SystematicIssuers (poorly named - should be SystematicIdentities) are identities created and maintained by the chain itself. -/// These identities are associated with a primary key derived from their name, and for which there is -/// no possible known private key. -/// Some of these identities are considered CDD providers: -/// - Committee: Issues CDD claims to members of committees (i.e. technical, GC) and is used for GC initiated CDD claims. -/// - CDDProvider: Issues CDD claims to other identities that need to transact POLYX (treasury, brr, rewards) as well as CDD Providers themselves -/// Committee members have a systematic CDD claim to ensure they can operate independently of permissioned CDD providers if needed. -/// CDD Providers have a systematic CDD claim to avoid a circular root of trust -#[derive(Debug, Clone, Copy)] -pub enum SystematicIssuers { - Committee, - CDDProvider, - Treasury, - BlockRewardReserve, - Settlement, - ClassicMigration, - FiatTickersReservation, -} - -impl core::fmt::Display for SystematicIssuers { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let value = match self { - SystematicIssuers::Committee => "Committee", - SystematicIssuers::CDDProvider => "CDD Trusted Providers", - SystematicIssuers::Treasury => "Treasury", - SystematicIssuers::BlockRewardReserve => "Block Reward Reserve", - SystematicIssuers::Settlement => "Settlement module", - SystematicIssuers::ClassicMigration => "Polymath Classic Imports and Reservations", - SystematicIssuers::FiatTickersReservation => "Fiat Ticker Reservation", - }; - - write!(f, "'{}'", value) - } -} - -pub const SYSTEMATIC_ISSUERS: &[SystematicIssuers] = &[ - SystematicIssuers::Treasury, - SystematicIssuers::Committee, - SystematicIssuers::CDDProvider, - SystematicIssuers::BlockRewardReserve, - SystematicIssuers::Settlement, - SystematicIssuers::ClassicMigration, - SystematicIssuers::FiatTickersReservation, -]; - -impl SystematicIssuers { - /// Returns the representation of this issuer as a raw public key. - pub const fn as_bytes(self) -> &'static [u8; 32] { - use constants::did; - match self { - SystematicIssuers::Committee => did::GOVERNANCE_COMMITTEE_DID, - SystematicIssuers::CDDProvider => did::CDD_PROVIDERS_DID, - SystematicIssuers::Treasury => did::TREASURY_DID, - SystematicIssuers::BlockRewardReserve => did::BLOCK_REWARD_RESERVE_DID, - SystematicIssuers::Settlement => did::SETTLEMENT_MODULE_DID, - SystematicIssuers::ClassicMigration => did::CLASSIC_MIGRATION_DID, - SystematicIssuers::FiatTickersReservation => did::FIAT_TICKERS_RESERVATION_DID, - } - } - - /// It returns the Identity Identifier of this issuer. - pub const fn as_id(self) -> IdentityId { - IdentityId(*self.as_bytes()) - } - - pub const fn as_pallet_id(self) -> PalletId { - match self { - SystematicIssuers::Committee => constants::GC_PALLET_ID, - SystematicIssuers::CDDProvider => constants::CDD_PALLET_ID, - SystematicIssuers::Treasury => constants::TREASURY_PALLET_ID, - SystematicIssuers::BlockRewardReserve => constants::BRR_PALLET_ID, - SystematicIssuers::Settlement => constants::SETTLEMENT_PALLET_ID, - SystematicIssuers::ClassicMigration => constants::CLASSIC_MIGRATION_PALLET_ID, - SystematicIssuers::FiatTickersReservation => { - constants::FIAT_TICKERS_RESERVATION_PALLET_ID - } - } - } -} - -pub const GC_DID: IdentityId = SystematicIssuers::Committee.as_id(); -pub const TECHNICAL_DID: IdentityId = IdentityId(*constants::did::TECHNICAL_COMMITTEE_DID); -pub const UPGRADE_DID: IdentityId = IdentityId(*constants::did::UPGRADE_COMMITTEE_DID); - /// Either a block number, or nothing. #[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, TypeInfo, Debug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] diff --git a/pallets/contracts/src/benchmarking.rs b/pallets/contracts/src/benchmarking.rs index 7afe689bc2..480a4218ea 100644 --- a/pallets/contracts/src/benchmarking.rs +++ b/pallets/contracts/src/benchmarking.rs @@ -30,9 +30,9 @@ use wasm_instrument::parity_wasm::elements::{Instruction, ValueType}; use pallet_identity::ParentDid; use polymesh_common_utilities::benchs::{cdd_provider, user, User, UserBuilder}; -use polymesh_common_utilities::constants::currency::POLY; use polymesh_common_utilities::group::GroupTrait; use polymesh_primitives::asset::AssetId; +use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; diff --git a/pallets/corporate-actions/src/distribution/mod.rs b/pallets/corporate-actions/src/distribution/mod.rs index 3cb4c97941..6d87066115 100644 --- a/pallets/corporate-actions/src/distribution/mod.rs +++ b/pallets/corporate-actions/src/distribution/mod.rs @@ -76,14 +76,13 @@ use frame_support::{ }; use pallet_asset::{self as asset, checkpoint}; use pallet_identity::{self as identity, PermissionedCallOriginData}; -use polymesh_common_utilities::{ - constants::currency::ONE_UNIT, portfolio::PortfolioSubTrait, with_transaction, -}; +use polymesh_common_utilities::portfolio::PortfolioSubTrait; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ + constants::currency::ONE_UNIT, protocol_fee::{ChargeProtocolFee, ProtocolOp}, - storage_migration_ver, Balance, EventDid, IdentityId, Moment, PortfolioId, PortfolioNumber, - SecondaryKey, WeightMeter, + storage_migration_ver, with_transaction, Balance, EventDid, IdentityId, Moment, PortfolioId, + PortfolioNumber, SecondaryKey, WeightMeter, }; use scale_info::TypeInfo; use sp_runtime::traits::Zero; diff --git a/pallets/corporate-actions/src/lib.rs b/pallets/corporate-actions/src/lib.rs index cf9bd4acbe..882af74cbe 100644 --- a/pallets/corporate-actions/src/lib.rs +++ b/pallets/corporate-actions/src/lib.rs @@ -106,12 +106,12 @@ use pallet_base::try_next_post; use pallet_identity::PermissionedCallOriginData; use polymesh_common_utilities::{ balances::Config as BalancesConfig, identity::Config as IdentityConfig, traits::asset, - traits::checkpoint::ScheduleId, with_transaction, GC_DID, + traits::checkpoint::ScheduleId, }; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - asset::CheckpointId, impl_checked_inc, storage_migration_ver, Balance, DocumentId, EventDid, - IdentityId, Moment, PortfolioNumber, + asset::CheckpointId, impl_checked_inc, storage_migration_ver, with_transaction, Balance, + DocumentId, EventDid, IdentityId, Moment, PortfolioNumber, GC_DID, }; use polymesh_primitives_derive::VecU8StrongTyped; use scale_info::TypeInfo; diff --git a/pallets/external-agents/src/lib.rs b/pallets/external-agents/src/lib.rs index bac0b6be46..82b681cf21 100644 --- a/pallets/external-agents/src/lib.rs +++ b/pallets/external-agents/src/lib.rs @@ -62,12 +62,11 @@ use frame_support::{ use pallet_base::{try_next_post, try_next_pre}; use pallet_identity::PermissionedCallOriginData; pub use polymesh_common_utilities::traits::external_agents::{Config, Event, WeightInfo}; -use polymesh_common_utilities::with_transaction; use polymesh_primitives::agent::{AGId, AgentGroup}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - extract_auth, storage_migration_ver, AuthorizationData, EventDid, ExtrinsicPermissions, - IdentityId, PalletPermissions, Signatory, SubsetRestriction, + extract_auth, storage_migration_ver, with_transaction, AuthorizationData, EventDid, + ExtrinsicPermissions, IdentityId, PalletPermissions, Signatory, SubsetRestriction, }; use sp_std::prelude::*; diff --git a/pallets/group/src/lib.rs b/pallets/group/src/lib.rs index 2505212cb9..8a8e87eaee 100644 --- a/pallets/group/src/lib.rs +++ b/pallets/group/src/lib.rs @@ -80,9 +80,9 @@ pub mod benchmarking; use pallet_identity as identity; pub use polymesh_common_utilities::{ group::{Config, GroupTrait, InactiveMember, MemberCount, RawEvent, WeightInfo}, - Context, GC_DID, + Context, }; -use polymesh_primitives::{committee::COMMITTEE_MEMBERS_MAX, IdentityId}; +use polymesh_primitives::{committee::COMMITTEE_MEMBERS_MAX, IdentityId, GC_DID}; use frame_support::{ decl_error, decl_module, decl_storage, diff --git a/pallets/identity/src/claims.rs b/pallets/identity/src/claims.rs index db213c7586..e04c1c8f79 100644 --- a/pallets/identity/src/claims.rs +++ b/pallets/identity/src/claims.rs @@ -24,17 +24,14 @@ use frame_support::{ use frame_system::ensure_root; use pallet_base::{ensure_string_limited, try_next_pre}; -use polymesh_common_utilities::{ - traits::{ - group::{GroupTrait, InactiveMember}, - identity::{Config, RawEvent}, - }, - SystematicIssuers, +use polymesh_common_utilities::traits::{ + group::{GroupTrait, InactiveMember}, + identity::{Config, RawEvent}, }; use polymesh_primitives::identity_claim::CustomClaimTypeId; use polymesh_primitives::{ protocol_fee::ProtocolOp, CddId, Claim, ClaimType, IdentityClaim, IdentityId, Scope, - SecondaryKey, + SecondaryKey, SystematicIssuers, }; use sp_runtime::traits::{CheckedAdd, SaturatedConversion, Zero}; use sp_std::prelude::*; diff --git a/pallets/identity/src/keys.rs b/pallets/identity/src/keys.rs index f64c9d4955..1581aa0ae1 100644 --- a/pallets/identity/src/keys.rs +++ b/pallets/identity/src/keys.rs @@ -28,16 +28,16 @@ use frame_support::{ use frame_system::ensure_signed; use pallet_base::{ensure_custom_length_ok, ensure_custom_string_limited}; use pallet_permissions::{AccountCallPermissionsData, CheckAccountCallPermissions}; -use polymesh_common_utilities::constants::did::USER; use polymesh_common_utilities::group::GroupTrait; use polymesh_common_utilities::identity::{ CreateChildIdentityWithAuth, SecondaryKeyWithAuth, TargetIdAuthorization, }; -use polymesh_common_utilities::SystematicIssuers; +use polymesh_primitives::constants::did::USER; use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; use polymesh_primitives::protocol_fee::{ChargeProtocolFee as _, ProtocolOp}; +use polymesh_primitives::SystematicIssuers; use polymesh_primitives::{ extract_auth, AuthorizationData, CddId, DidRecord, ExtrinsicName, ExtrinsicPermissions, IdentityId, KeyRecord, PalletName, Permissions, SecondaryKey, Signatory, diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index b15b11295f..c455fbcf1c 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -103,13 +103,13 @@ use polymesh_common_utilities::traits::identity::{ AuthorizationNonce, Config, CreateChildIdentityWithAuth, IdentityFnTrait, RawEvent, SecondaryKeyWithAuth, }; -use polymesh_common_utilities::{SystematicIssuers, GC_DID}; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{ storage_migration_ver, AssetPermissions, Authorization, AuthorizationData, AuthorizationType, CddId, Claim, ClaimType, CustomClaimTypeId, DidRecord, ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, Permissions, PortfolioPermissions, Scope, SecondaryKey, Signatory, }; +use polymesh_primitives::{SystematicIssuers, GC_DID}; pub type Event = polymesh_common_utilities::traits::identity::Event; @@ -213,7 +213,7 @@ decl_storage! { // Secondary keys of identities at genesis. `identities` have to be initialised. config(secondary_keys): Vec<(T::AccountId, IdentityId)>; build(|config: &GenesisConfig| { - polymesh_common_utilities::SYSTEMATIC_ISSUERS + polymesh_primitives::SYSTEMATIC_ISSUERS .iter() .copied() .for_each(>::register_systematic_id); diff --git a/pallets/nft/src/benchmarking.rs b/pallets/nft/src/benchmarking.rs index 1bae93fe1a..1134d0dca1 100644 --- a/pallets/nft/src/benchmarking.rs +++ b/pallets/nft/src/benchmarking.rs @@ -8,13 +8,12 @@ use pallet_asset::benchmarking::create_portfolio; use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, user, User, UserBuilder}; use polymesh_common_utilities::traits::asset::AssetFnTrait; use polymesh_common_utilities::traits::compliance_manager::ComplianceFnConfig; -use polymesh_common_utilities::with_transaction; use polymesh_primitives::asset::{AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{ AssetMetadataGlobalKey, AssetMetadataKey, AssetMetadataSpec, AssetMetadataValue, }; use polymesh_primitives::nft::{NFTCollectionId, NFTCollectionKeys, NFTId}; -use polymesh_primitives::{IdentityId, PortfolioKind, WeightMeter}; +use polymesh_primitives::{with_transaction, IdentityId, PortfolioKind, WeightMeter}; use crate::*; diff --git a/pallets/pips/src/benchmarking.rs b/pallets/pips/src/benchmarking.rs index 7c58a4a379..8526bf56c7 100644 --- a/pallets/pips/src/benchmarking.rs +++ b/pallets/pips/src/benchmarking.rs @@ -23,8 +23,9 @@ use frame_support::{ use frame_system::RawOrigin; use polymesh_common_utilities::{ benchs::{user, User}, - MaybeBlock, SystematicIssuers, GC_DID, + MaybeBlock, }; +use polymesh_primitives::{SystematicIssuers, GC_DID}; use rand::{seq::SliceRandom, SeedableRng}; use rand_chacha::ChaCha20Rng; use sp_std::{ diff --git a/pallets/pips/src/lib.rs b/pallets/pips/src/lib.rs index 20edcaf33e..1d0874a118 100644 --- a/pallets/pips/src/lib.rs +++ b/pallets/pips/src/lib.rs @@ -108,16 +108,16 @@ use sp_version::RuntimeVersion; use pallet_base::{ensure_opt_string_limited, try_next_post}; use pallet_identity::PermissionedCallOriginData; -use polymesh_common_utilities::constants::PIP_MAX_REPORTING_SIZE; use polymesh_common_utilities::traits::balances::LockableCurrencyExt; use polymesh_common_utilities::traits::governance_group::GovernanceGroupTrait; use polymesh_common_utilities::traits::group::GroupTrait; use polymesh_common_utilities::traits::identity::Config as IdentityConfig; -use polymesh_common_utilities::{with_transaction, CommonConfig, MaybeBlock}; -use polymesh_common_utilities::{GC_DID, TECHNICAL_DID, UPGRADE_DID}; +use polymesh_common_utilities::{CommonConfig, MaybeBlock}; +use polymesh_primitives::constants::PIP_MAX_REPORTING_SIZE; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; -use polymesh_primitives::storage_migration_ver; +use polymesh_primitives::{storage_migration_ver, with_transaction}; use polymesh_primitives::{Balance, IdentityId, Url}; +use polymesh_primitives::{GC_DID, TECHNICAL_DID, UPGRADE_DID}; use polymesh_runtime_common::PipsEnactSnapshotMaximumWeight; use crate::types::{compare_spip, ProposalData, MAX_NORMAL_PRIORITY, PIPS_LOCK_ID}; diff --git a/pallets/portfolio/src/benchmarking.rs b/pallets/portfolio/src/benchmarking.rs index 20ce1389af..e277261812 100644 --- a/pallets/portfolio/src/benchmarking.rs +++ b/pallets/portfolio/src/benchmarking.rs @@ -21,7 +21,7 @@ use sp_std::prelude::*; use polymesh_common_utilities::asset::Config as AssetConfig; use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, user, User, UserBuilder}; -use polymesh_common_utilities::constants::currency::ONE_UNIT; +use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::{AuthorizationData, NFTs, PortfolioName, Signatory}; use crate::*; diff --git a/pallets/protocol-fee/src/lib.rs b/pallets/protocol-fee/src/lib.rs index acc798580a..06f8708964 100644 --- a/pallets/protocol-fee/src/lib.rs +++ b/pallets/protocol-fee/src/lib.rs @@ -47,11 +47,11 @@ use frame_support::{ use frame_system::ensure_root; use polymesh_common_utilities::{ identity::Config as IdentityConfig, traits::relayer::SubsidiserTrait, - transaction_payment::CddAndFeeDetails, GC_DID, + transaction_payment::CddAndFeeDetails, }; use polymesh_primitives::{ protocol_fee::{ChargeProtocolFee, ProtocolOp}, - Balance, IdentityId, PosRatio, + Balance, IdentityId, PosRatio, GC_DID, }; use sp_runtime::{traits::Zero, Perbill}; use sp_std::vec; diff --git a/pallets/runtime/common/src/lib.rs b/pallets/runtime/common/src/lib.rs index e3ec539d73..41b25975f1 100644 --- a/pallets/runtime/common/src/lib.rs +++ b/pallets/runtime/common/src/lib.rs @@ -40,7 +40,7 @@ pub use sp_runtime::transaction_validity::TransactionPriority; pub use sp_runtime::{Perbill, Permill}; use pallet_balances as balances; -use polymesh_common_utilities::constants::currency::*; +use polymesh_primitives::constants::currency::*; use polymesh_primitives::{Balance, BlockNumber, IdentityId, Moment}; pub use cdd_check::CddChecker; diff --git a/pallets/runtime/develop/src/benchmarks/pallet_session.rs b/pallets/runtime/develop/src/benchmarks/pallet_session.rs index b71a34463d..7a4cfa13b5 100644 --- a/pallets/runtime/develop/src/benchmarks/pallet_session.rs +++ b/pallets/runtime/develop/src/benchmarks/pallet_session.rs @@ -33,7 +33,7 @@ use sp_runtime::traits::TrailingZeroInput; use sp_std::prelude::*; use sp_std::vec; -use polymesh_common_utilities::constants::currency::POLY; +use polymesh_primitives::constants::currency::POLY; pub struct Pallet(Session); pub trait Config: diff --git a/pallets/runtime/develop/src/runtime.rs b/pallets/runtime/develop/src/runtime.rs index ed1bdbba38..f7c89c96f5 100644 --- a/pallets/runtime/develop/src/runtime.rs +++ b/pallets/runtime/develop/src/runtime.rs @@ -26,8 +26,8 @@ use pallet_corporate_actions::ballot as pallet_corporate_ballot; use pallet_corporate_actions::distribution as pallet_capital_distribution; use pallet_session::historical as pallet_session_historical; pub use pallet_transaction_payment::{Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment}; -use polymesh_common_utilities::constants::currency::*; -use polymesh_common_utilities::constants::ENSURED_MAX_LEN; +use polymesh_primitives::constants::currency::*; +use polymesh_primitives::constants::ENSURED_MAX_LEN; use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{Balance, BlockNumber, Moment}; diff --git a/pallets/runtime/mainnet/src/runtime.rs b/pallets/runtime/mainnet/src/runtime.rs index 8a84113631..ec3db3cc3e 100644 --- a/pallets/runtime/mainnet/src/runtime.rs +++ b/pallets/runtime/mainnet/src/runtime.rs @@ -30,8 +30,8 @@ use pallet_session::historical as pallet_session_historical; pub use pallet_staking::StakerStatus; pub use pallet_timestamp::Call as TimestampCall; pub use pallet_transaction_payment::{Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment}; -use polymesh_common_utilities::constants::currency::*; -use polymesh_common_utilities::constants::ENSURED_MAX_LEN; +use polymesh_primitives::constants::currency::*; +use polymesh_primitives::constants::ENSURED_MAX_LEN; use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{Balance, BlockNumber, Moment}; diff --git a/pallets/runtime/testnet/src/runtime.rs b/pallets/runtime/testnet/src/runtime.rs index b27d9ecede..f48796dd14 100644 --- a/pallets/runtime/testnet/src/runtime.rs +++ b/pallets/runtime/testnet/src/runtime.rs @@ -32,8 +32,8 @@ use pallet_session::historical as pallet_session_historical; pub use pallet_staking::StakerStatus; pub use pallet_timestamp::Call as TimestampCall; pub use pallet_transaction_payment::{Multiplier, RuntimeDispatchInfo, TargetedFeeAdjustment}; -use polymesh_common_utilities::constants::currency::*; -use polymesh_common_utilities::constants::ENSURED_MAX_LEN; +use polymesh_primitives::constants::currency::*; +use polymesh_primitives::constants::ENSURED_MAX_LEN; use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{Balance, BlockNumber, Moment}; diff --git a/pallets/runtime/tests/src/asset_test.rs b/pallets/runtime/tests/src/asset_test.rs index ac6f9fe97f..a399953e4f 100644 --- a/pallets/runtime/tests/src/asset_test.rs +++ b/pallets/runtime/tests/src/asset_test.rs @@ -23,7 +23,6 @@ use pallet_portfolio::{ }; use pallet_statistics::AssetStats; use polymesh_common_utilities::asset::AssetFnTrait; -use polymesh_common_utilities::constants::currency::ONE_UNIT; use polymesh_common_utilities::traits::checkpoint::{ NextCheckpoints, ScheduleCheckpoints, ScheduleId, }; @@ -37,6 +36,7 @@ use polymesh_primitives::asset_metadata::{ AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, }; use polymesh_primitives::calendar::{CalendarPeriod, CalendarUnit, FixedOrVariableCalendarUnit}; +use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::settlement::{ InstructionId, Leg, SettlementType, VenueDetails, VenueId, VenueType, }; diff --git a/pallets/runtime/tests/src/contracts_test.rs b/pallets/runtime/tests/src/contracts_test.rs index d08249e62d..fdd1d1f80c 100644 --- a/pallets/runtime/tests/src/contracts_test.rs +++ b/pallets/runtime/tests/src/contracts_test.rs @@ -12,9 +12,9 @@ use sp_runtime::traits::Hash; use pallet_asset::TickersOwnedByUser; use pallet_identity::ParentDid; -use polymesh_common_utilities::constants::currency::POLY; use polymesh_primitives::{ - ExtrinsicPermissions, Gas, Permissions, PortfolioPermissions, SubsetRestriction, Ticker, + constants::currency::POLY, ExtrinsicPermissions, Gas, Permissions, PortfolioPermissions, + SubsetRestriction, Ticker, }; use polymesh_runtime_common::Currency; diff --git a/pallets/runtime/tests/src/corporate_actions_test.rs b/pallets/runtime/tests/src/corporate_actions_test.rs index 7dc0e988c5..9382524360 100644 --- a/pallets/runtime/tests/src/corporate_actions_test.rs +++ b/pallets/runtime/tests/src/corporate_actions_test.rs @@ -20,15 +20,12 @@ use pallet_corporate_actions::{ TargetTreatment::{Exclude, Include}, Tax, }; -use polymesh_common_utilities::{ - constants::currency::ONE_UNIT, - traits::checkpoint::{ScheduleCheckpoints, ScheduleId}, -}; +use polymesh_common_utilities::traits::checkpoint::{ScheduleCheckpoints, ScheduleId}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - agent::AgentGroup, asset::CheckpointId, AuthorizationData, Claim, ClaimType, Condition, - ConditionType, CountryCode, Document, DocumentId, IdentityId, Moment, PortfolioId, - PortfolioNumber, Scope, Signatory, TrustedFor, TrustedIssuer, + agent::AgentGroup, asset::CheckpointId, constants::currency::ONE_UNIT, AuthorizationData, + Claim, ClaimType, Condition, ConditionType, CountryCode, Document, DocumentId, IdentityId, + Moment, PortfolioId, PortfolioNumber, Scope, Signatory, TrustedFor, TrustedIssuer, }; use sp_arithmetic::Permill; use sp_keyring::AccountKeyring; diff --git a/pallets/runtime/tests/src/ext_builder.rs b/pallets/runtime/tests/src/ext_builder.rs index 360a63acf4..9d4bdba366 100644 --- a/pallets/runtime/tests/src/ext_builder.rs +++ b/pallets/runtime/tests/src/ext_builder.rs @@ -7,7 +7,7 @@ use pallet_committee as committee; use pallet_group as group; use pallet_identity as identity; use pallet_pips as pips; -use polymesh_common_utilities::{ +use polymesh_primitives::{ constants::currency::POLY, protocol_fee::ProtocolOp, SystematicIssuers, GC_DID, }; use polymesh_primitives::{ diff --git a/pallets/runtime/tests/src/identity_test.rs b/pallets/runtime/tests/src/identity_test.rs index e6426148b2..9b8278113e 100644 --- a/pallets/runtime/tests/src/identity_test.rs +++ b/pallets/runtime/tests/src/identity_test.rs @@ -19,24 +19,21 @@ use frame_support::{ }; use pallet_balances as balances; use pallet_identity::{ChildDid, CustomClaimIdSequence, CustomClaims, CustomClaimsInverse}; -use polymesh_common_utilities::{ - constants::currency::POLY, - traits::{ - group::GroupTrait, - identity::{ - Config as IdentityConfig, CreateChildIdentityWithAuth, RawEvent, SecondaryKeyWithAuth, - TargetIdAuthorization, - }, - transaction_payment::CddAndFeeDetails, +use polymesh_common_utilities::traits::{ + group::GroupTrait, + identity::{ + Config as IdentityConfig, CreateChildIdentityWithAuth, RawEvent, SecondaryKeyWithAuth, + TargetIdAuthorization, }, - SystematicIssuers, GC_DID, + transaction_payment::CddAndFeeDetails, }; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - AccountId, AssetPermissions, AuthorizationData, AuthorizationType, Claim, ClaimType, - CustomClaimTypeId, ExtrinsicName, ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, - PalletName, PalletPermissions, Permissions, PortfolioId, PortfolioNumber, Scope, SecondaryKey, - Signatory, SubsetRestriction, Ticker, TransactionError, + constants::currency::POLY, AccountId, AssetPermissions, AuthorizationData, AuthorizationType, + Claim, ClaimType, CustomClaimTypeId, ExtrinsicName, ExtrinsicPermissions, IdentityClaim, + IdentityId, KeyRecord, PalletName, PalletPermissions, Permissions, PortfolioId, + PortfolioNumber, Scope, SecondaryKey, Signatory, SubsetRestriction, SystematicIssuers, Ticker, + TransactionError, GC_DID, }; use polymesh_runtime_develop::runtime::{CddHandler, RuntimeCall}; use sp_core::H512; diff --git a/pallets/runtime/tests/src/multisig.rs b/pallets/runtime/tests/src/multisig.rs index a9bd77af66..e58235d109 100644 --- a/pallets/runtime/tests/src/multisig.rs +++ b/pallets/runtime/tests/src/multisig.rs @@ -6,7 +6,7 @@ use frame_support::{ use pallet_multisig::{ self as multisig, AdminDid, LastInvalidProposal, ProposalStates, ProposalVoteCounts, Votes, }; -use polymesh_common_utilities::constants::currency::POLY; +use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::multisig::ProposalState; use polymesh_primitives::{AccountId, AuthorizationData, Permissions, SecondaryKey, Signatory}; use sp_keyring::AccountKeyring; diff --git a/pallets/runtime/tests/src/nft.rs b/pallets/runtime/tests/src/nft.rs index be96ee3c93..5e8afb9cb5 100644 --- a/pallets/runtime/tests/src/nft.rs +++ b/pallets/runtime/tests/src/nft.rs @@ -8,7 +8,6 @@ use pallet_nft::{ }; use pallet_portfolio::PortfolioNFT; use polymesh_common_utilities::traits::nft::Event; -use polymesh_common_utilities::with_transaction; use polymesh_primitives::asset::{AssetId, AssetName, AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{ AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataName, AssetMetadataSpec, @@ -16,8 +15,8 @@ use polymesh_primitives::asset_metadata::{ }; use polymesh_primitives::settlement::{InstructionId, Leg, SettlementType}; use polymesh_primitives::{ - AuthorizationData, Claim, ClaimType, Condition, ConditionType, CountryCode, IdentityId, - NFTCollectionId, NFTCollectionKeys, NFTId, NFTMetadataAttribute, NFTs, PortfolioId, + with_transaction, AuthorizationData, Claim, ClaimType, Condition, ConditionType, CountryCode, + IdentityId, NFTCollectionId, NFTCollectionKeys, NFTId, NFTMetadataAttribute, NFTs, PortfolioId, PortfolioKind, PortfolioNumber, PortfolioUpdateReason, Scope, Signatory, TrustedFor, TrustedIssuer, WeightMeter, }; diff --git a/pallets/runtime/tests/src/pips_test.rs b/pallets/runtime/tests/src/pips_test.rs index 544d988eba..553d64cabb 100644 --- a/pallets/runtime/tests/src/pips_test.rs +++ b/pallets/runtime/tests/src/pips_test.rs @@ -19,8 +19,8 @@ use pallet_pips::{ VotingResult, }; use pallet_treasury as treasury; -use polymesh_common_utilities::{MaybeBlock, GC_DID}; -use polymesh_primitives::{AccountId, BlockNumber, Url}; +use polymesh_common_utilities::MaybeBlock; +use polymesh_primitives::{AccountId, BlockNumber, Url, GC_DID}; use sp_keyring::AccountKeyring; use std::ops::Deref; diff --git a/pallets/runtime/tests/src/protocol_fee.rs b/pallets/runtime/tests/src/protocol_fee.rs index b51e713ab9..dcf6d7e292 100644 --- a/pallets/runtime/tests/src/protocol_fee.rs +++ b/pallets/runtime/tests/src/protocol_fee.rs @@ -4,9 +4,8 @@ use super::{ ExtBuilder, }; use frame_support::{assert_noop, assert_ok}; -use polymesh_common_utilities::{ - protocol_fee::ProtocolOp, traits::transaction_payment::CddAndFeeDetails, -}; +use polymesh_common_utilities::traits::transaction_payment::CddAndFeeDetails; +use polymesh_primitives::protocol_fee::ProtocolOp; use sp_keyring::AccountKeyring; type Error = pallet_protocol_fee::Error; diff --git a/pallets/runtime/tests/src/relayer_test.rs b/pallets/runtime/tests/src/relayer_test.rs index 47407bcebb..3ea47be7ad 100644 --- a/pallets/runtime/tests/src/relayer_test.rs +++ b/pallets/runtime/tests/src/relayer_test.rs @@ -9,11 +9,11 @@ use frame_support::{ }; use frame_system; use pallet_relayer::Subsidy; -use polymesh_common_utilities::{ - constants::currency::POLY, protocol_fee::ProtocolOp, - traits::transaction_payment::CddAndFeeDetails, +use polymesh_common_utilities::traits::transaction_payment::CddAndFeeDetails; +use polymesh_primitives::{ + constants::currency::POLY, protocol_fee::ProtocolOp, AccountId, Balance, Signatory, Ticker, + TransactionError, }; -use polymesh_primitives::{AccountId, Balance, Signatory, Ticker, TransactionError}; use polymesh_runtime_develop::runtime::{CddHandler, RuntimeCall as DevRuntimeCall}; use sp_keyring::AccountKeyring; use sp_runtime::{ diff --git a/pallets/runtime/tests/src/settlement_pallet/execute_instruction.rs b/pallets/runtime/tests/src/settlement_pallet/execute_instruction.rs index 25ee0d5250..1873ab1a45 100644 --- a/pallets/runtime/tests/src/settlement_pallet/execute_instruction.rs +++ b/pallets/runtime/tests/src/settlement_pallet/execute_instruction.rs @@ -8,11 +8,11 @@ use pallet_settlement::{ InstructionLegs, InstructionMediatorsAffirmations, InstructionStatuses, OffChainAffirmations, RawEvent, UserAffirmations, VenueInstructions, }; -use polymesh_common_utilities::SystematicIssuers::Settlement as SettlementDID; use polymesh_primitives::settlement::{ AffirmationStatus, Instruction, InstructionId, InstructionStatus, Leg, LegId, SettlementType, }; use polymesh_primitives::PortfolioId; +use polymesh_primitives::SystematicIssuers::Settlement as SettlementDID; use super::setup::create_and_issue_sample_asset_with_venue; use crate::asset_pallet::setup::create_and_issue_sample_asset; diff --git a/pallets/runtime/tests/src/settlement_test.rs b/pallets/runtime/tests/src/settlement_test.rs index 9547507458..98491b9d21 100644 --- a/pallets/runtime/tests/src/settlement_test.rs +++ b/pallets/runtime/tests/src/settlement_test.rs @@ -21,12 +21,12 @@ use pallet_settlement::{ InstructionMemos, NumberOfVenueSigners, OffChainAffirmations, RawEvent, UserAffirmations, UserVenues, VenueInstructions, }; -use polymesh_common_utilities::constants::currency::ONE_UNIT; use polymesh_primitives::asset::{AssetId, AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{ AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataValue, }; use polymesh_primitives::checked_inc::CheckedInc; +use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::settlement::{ AffirmationCount, AffirmationStatus, AssetCount, Instruction, InstructionId, InstructionStatus, Leg, LegId, LegStatus, MediatorAffirmationStatus, Receipt, ReceiptDetails, SettlementType, diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index e88a5eab7e..cfefcf3720 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -41,7 +41,6 @@ use sp_staking::{EraIndex, SessionIndex}; use pallet_staking::types::SlashingSwitch; use pallet_staking::{self as pallet_staking, *}; -use polymesh_common_utilities::constants::currency::POLY; use polymesh_common_utilities::traits::balances::{AccountData, CheckCdd}; use polymesh_common_utilities::traits::group::{GroupTrait, InactiveMember}; use polymesh_common_utilities::traits::multisig::MultiSigSubTrait; @@ -50,6 +49,7 @@ use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_common_utilities::traits::CommonConfig; use polymesh_common_utilities::transaction_payment::ChargeTxFee; use polymesh_primitives::asset::AssetId; +use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::identity_id::GenesisIdentityRecord; use polymesh_primitives::{ Authorization, AuthorizationData, Claim, IdentityId, Moment, NFTId, Permissions, PortfolioId, diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index 9ab866e71e..91373265ce 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -50,10 +50,10 @@ use pallet_protocol_fee as protocol_fee; use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::RuntimeDispatchInfo; use pallet_utility; -use polymesh_common_utilities::constants::currency::{DOLLARS, POLY}; use polymesh_common_utilities::traits::group::GroupTrait; use polymesh_common_utilities::traits::transaction_payment::{CddAndFeeDetails, ChargeTxFee}; use polymesh_common_utilities::Context; +use polymesh_primitives::constants::currency::{DOLLARS, POLY}; use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{ diff --git a/pallets/settlement/src/benchmarking.rs b/pallets/settlement/src/benchmarking.rs index 8462c0e034..d2cc61b6f3 100644 --- a/pallets/settlement/src/benchmarking.rs +++ b/pallets/settlement/src/benchmarking.rs @@ -24,9 +24,9 @@ use sp_std::prelude::*; use pallet_asset::benchmarking::setup_asset_transfer; use pallet_nft::benchmarking::setup_nft_transfer; use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, User, UserBuilder}; -use polymesh_common_utilities::constants::currency::ONE_UNIT; -use polymesh_common_utilities::constants::ENSURED_MAX_LEN; use polymesh_primitives::checked_inc::CheckedInc; +use polymesh_primitives::constants::currency::ONE_UNIT; +use polymesh_primitives::constants::ENSURED_MAX_LEN; use polymesh_primitives::settlement::ReceiptMetadata; use polymesh_primitives::{IdentityId, Memo, NFTId, NFTs, PortfolioId, Ticker}; diff --git a/pallets/settlement/src/lib.rs b/pallets/settlement/src/lib.rs index 3b489237c1..c4a03cbb49 100644 --- a/pallets/settlement/src/lib.rs +++ b/pallets/settlement/src/lib.rs @@ -69,19 +69,19 @@ use sp_std::vec; use pallet_asset::MandatoryMediators; use pallet_base::{ensure_string_limited, try_next_post}; -use polymesh_common_utilities::constants::queue_priority::SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY; use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; pub use polymesh_common_utilities::traits::settlement::{Event, RawEvent, WeightInfo}; use polymesh_common_utilities::traits::{asset, compliance_manager, identity, nft, CommonConfig}; -use polymesh_common_utilities::with_transaction; -use polymesh_common_utilities::SystematicIssuers::Settlement as SettlementDID; use polymesh_primitives::asset::AssetId; +use polymesh_primitives::constants::queue_priority::SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY; use polymesh_primitives::settlement::{ AffirmationCount, AffirmationStatus, AssetCount, ExecuteInstructionInfo, FilteredLegs, Instruction, InstructionId, InstructionInfo, InstructionStatus, Leg, LegId, LegStatus, MediatorAffirmationStatus, Receipt, ReceiptDetails, SettlementType, Venue, VenueDetails, VenueId, VenueType, }; +use polymesh_primitives::with_transaction; +use polymesh_primitives::SystematicIssuers::Settlement as SettlementDID; use polymesh_primitives::{ storage_migration_ver, Balance, IdentityId, Memo, NFTs, PortfolioId, SecondaryKey, WeightMeter, }; diff --git a/pallets/staking/src/pallet/impls.rs b/pallets/staking/src/pallet/impls.rs index e80343a126..4395c0652f 100644 --- a/pallets/staking/src/pallet/impls.rs +++ b/pallets/staking/src/pallet/impls.rs @@ -58,8 +58,8 @@ use frame_support::traits::schedule::{DispatchTime, HIGHEST_PRIORITY}; use frame_support::traits::DefensiveSaturating; use polymesh_common_utilities::identity::IdentityFnTrait; -use polymesh_common_utilities::GC_DID; use polymesh_primitives::IdentityId; +use polymesh_primitives::GC_DID; use crate::pallet::SlashingSwitch; use crate::UnlockChunk; diff --git a/pallets/staking/src/pallet/mod.rs b/pallets/staking/src/pallet/mod.rs index d0f6740eae..1355daeea8 100644 --- a/pallets/staking/src/pallet/mod.rs +++ b/pallets/staking/src/pallet/mod.rs @@ -56,9 +56,9 @@ use frame_system::offchain::SendTransactionTypes; use sp_runtime::traits::{AccountIdConversion, Dispatchable}; use sp_runtime::Permill; -use polymesh_common_utilities::constants::GC_PALLET_ID; use polymesh_common_utilities::identity::{Config as IdentityConfig, IdentityFnTrait}; -use polymesh_common_utilities::GC_DID; +use polymesh_primitives::constants::GC_PALLET_ID; +use polymesh_primitives::GC_DID; use polymesh_primitives::{storage_migration_ver, IdentityId}; use crate::types::{PermissionedIdentityPrefs, SlashingSwitch}; diff --git a/pallets/statistics/src/benchmarking.rs b/pallets/statistics/src/benchmarking.rs index b562ed3ab5..38f86f3090 100644 --- a/pallets/statistics/src/benchmarking.rs +++ b/pallets/statistics/src/benchmarking.rs @@ -4,8 +4,8 @@ use sp_std::collections::btree_set::BTreeSet; use sp_std::prelude::*; use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, User, UserBuilder}; -use polymesh_common_utilities::constants::currency::{ONE_UNIT, POLY}; use polymesh_common_utilities::traits::asset::Config as Asset; +use polymesh_primitives::constants::currency::{ONE_UNIT, POLY}; use polymesh_primitives::{jurisdiction::*, statistics::*, Claim, ClaimType, Scope}; use crate::*; diff --git a/pallets/sto/src/lib.rs b/pallets/sto/src/lib.rs index cde12e4362..1ec3a14c87 100644 --- a/pallets/sto/src/lib.rs +++ b/pallets/sto/src/lib.rs @@ -40,12 +40,12 @@ use pallet_identity::PermissionedCallOriginData; use pallet_settlement::VenueInfo; use polymesh_common_utilities::portfolio::PortfolioSubTrait; use polymesh_common_utilities::traits::{identity, portfolio}; -use polymesh_common_utilities::with_transaction; use polymesh_primitives::asset::AssetId; use polymesh_primitives::impl_checked_inc; use polymesh_primitives::settlement::{Leg, ReceiptDetails, SettlementType, VenueId, VenueType}; use polymesh_primitives::{ - storage_migration_ver, Balance, EventDid, IdentityId, PortfolioId, WeightMeter, + storage_migration_ver, with_transaction, Balance, EventDid, IdentityId, PortfolioId, + WeightMeter, }; use polymesh_primitives_derive::VecU8StrongTyped; diff --git a/pallets/treasury/src/lib.rs b/pallets/treasury/src/lib.rs index f03145ecf2..187fab69db 100644 --- a/pallets/treasury/src/lib.rs +++ b/pallets/treasury/src/lib.rs @@ -46,10 +46,8 @@ use frame_support::{ }; use frame_system::ensure_root; use pallet_identity as identity; -use polymesh_common_utilities::{ - constants::TREASURY_PALLET_ID, traits::balances::Config as BalancesConfig, GC_DID, -}; -use polymesh_primitives::{Beneficiary, IdentityId}; +use polymesh_common_utilities::traits::balances::Config as BalancesConfig; +use polymesh_primitives::{constants::TREASURY_PALLET_ID, Beneficiary, IdentityId, GC_DID}; use sp_runtime::traits::{AccountIdConversion, Saturating}; use sp_std::prelude::*; diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index 6051645b68..9bf3cbed4e 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -13,10 +13,173 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! Shareable types. - #![allow(missing_docs)] +use crate::IdentityId; +use frame_support::PalletId; + +/// Money matters. +pub mod currency { + use crate::Balance; + pub const POLY: Balance = 1_000_000; + pub const ONE_POLY: Balance = POLY; + pub const DOLLARS: Balance = POLY; + pub const CENTS: Balance = DOLLARS / 100; + pub const MILLICENTS: Balance = CENTS / 1_000; + pub const ONE_UNIT: Balance = 1_000_000; + pub const MAX_SUPPLY: Balance = ONE_UNIT * 1_000_000_000_000; +} + +/// DID-related. +pub mod did { + /// prefix for user dids + pub const USER: &[u8; 5] = b"USER:"; + /// prefix for security token dids + pub const SECURITY_TOKEN: &[u8; 15] = b"SECURITY_TOKEN:"; + + /// Governance Committee DID. It is used in systematic CDD claim for Governance Committee members. + pub const GOVERNANCE_COMMITTEE_DID: &[u8; 32] = b"system:governance_committee\0\0\0\0\0"; + /// CDD Providers DID. It is used in systematic CDD claim for CDD Providers. + pub const CDD_PROVIDERS_DID: &[u8; 32] = b"system:customer_due_diligence\0\0\0"; + /// Treasury module DID. It is used in systematic CDD claim for the Treasury module. + pub const TREASURY_DID: &[u8; 32] = b"system:treasury_module_did\0\0\0\0\0\0"; + /// Block Reward Reserve DID. + pub const BLOCK_REWARD_RESERVE_DID: &[u8; 32] = b"system:block_reward_reserve_did\0"; + /// Settlement module DID + pub const SETTLEMENT_MODULE_DID: &[u8; 32] = b"system:settlement_module_did\0\0\0\0"; + /// Polymath Classic / Ethereum migration DID. + pub const CLASSIC_MIGRATION_DID: &[u8; 32] = b"system:polymath_classic_mig\0\0\0\0\0"; + /// Fiat Currency Reservation DID + pub const FIAT_TICKERS_RESERVATION_DID: &[u8; 32] = b"system:fiat_tickers_reservation\0"; + /// Technical Committee DID. + pub const TECHNICAL_COMMITTEE_DID: &[u8; 32] = b"system:technical_committee\0\0\0\0\0\0"; + /// Upgrade Committee DID. + pub const UPGRADE_COMMITTEE_DID: &[u8; 32] = b"system:upgrade_committee\0\0\0\0\0\0\0\0"; +} + +/// Priorities for the task that get scheduled. +pub mod queue_priority { + use frame_support::traits::schedule::Priority; + + /// Queue priority for the settlement instruction execution. + pub const SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY: Priority = 100; +} + +// ERC1400 transfer status codes +pub const ERC1400_TRANSFER_FAILURE: u8 = 0x50; +pub const ERC1400_INSUFFICIENT_BALANCE: u8 = 0x52; +pub const ERC1400_INSUFFICIENT_ALLOWANCE: u8 = 0x53; +pub const ERC1400_FUNDS_LOCKED: u8 = 0x55; +pub const ERC1400_INVALID_SENDER: u8 = 0x56; +pub const ERC1400_INVALID_RECEIVER: u8 = 0x57; +pub const ERC1400_INVALID_OPERATOR: u8 = 0x58; + +// Application-specific status codes +pub const INVALID_SENDER_DID: u8 = 0xa0; +pub const INVALID_RECEIVER_DID: u8 = 0xa1; +pub const INVALID_GRANULARITY: u8 = 0xa4; +pub const APP_TX_VOLUME_LIMIT_REACHED: u8 = 0xa5; +pub const APP_BLOCKED_TX: u8 = 0xa6; +pub const APP_FUNDS_LOCKED: u8 = 0xa7; +pub const APP_FUNDS_LIMIT_REACHED: u8 = 0xa8; +pub const CUSTODIAN_ERROR: u8 = 0xaa; + +// PIP pallet constants. +pub const PIP_MAX_REPORTING_SIZE: usize = 1024; + +/// Module ids, used for deriving sovereign account IDs for modules. +pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"pm/trsry"); +pub const BRR_PALLET_ID: PalletId = PalletId(*b"pm/blrwr"); +pub const GC_PALLET_ID: PalletId = PalletId(*b"pm/govcm"); +pub const CDD_PALLET_ID: PalletId = PalletId(*b"pm/cusdd"); +pub const SETTLEMENT_PALLET_ID: PalletId = PalletId(*b"pm/setmn"); +pub const CLASSIC_MIGRATION_PALLET_ID: PalletId = PalletId(*b"pm/ehmig"); +pub const FIAT_TICKERS_RESERVATION_PALLET_ID: PalletId = PalletId(*b"pm/ftres"); + +/// Base module constants +pub const ENSURED_MAX_LEN: u32 = 2048; + +/// SystematicIssuers (poorly named - should be SystematicIdentities) are identities created and maintained by the chain itself. +/// These identities are associated with a primary key derived from their name, and for which there is +/// no possible known private key. +/// Some of these identities are considered CDD providers: +/// - Committee: Issues CDD claims to members of committees (i.e. technical, GC) and is used for GC initiated CDD claims. +/// - CDDProvider: Issues CDD claims to other identities that need to transact POLYX (treasury, brr, rewards) as well as CDD Providers themselves +/// Committee members have a systematic CDD claim to ensure they can operate independently of permissioned CDD providers if needed. +/// CDD Providers have a systematic CDD claim to avoid a circular root of trust +#[derive(Debug, Clone, Copy)] +pub enum SystematicIssuers { + Committee, + CDDProvider, + Treasury, + BlockRewardReserve, + Settlement, + ClassicMigration, + FiatTickersReservation, +} + +impl core::fmt::Display for SystematicIssuers { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let value = match self { + SystematicIssuers::Committee => "Committee", + SystematicIssuers::CDDProvider => "CDD Trusted Providers", + SystematicIssuers::Treasury => "Treasury", + SystematicIssuers::BlockRewardReserve => "Block Reward Reserve", + SystematicIssuers::Settlement => "Settlement module", + SystematicIssuers::ClassicMigration => "Polymath Classic Imports and Reservations", + SystematicIssuers::FiatTickersReservation => "Fiat Ticker Reservation", + }; + + write!(f, "'{}'", value) + } +} + +pub const SYSTEMATIC_ISSUERS: &[SystematicIssuers] = &[ + SystematicIssuers::Treasury, + SystematicIssuers::Committee, + SystematicIssuers::CDDProvider, + SystematicIssuers::BlockRewardReserve, + SystematicIssuers::Settlement, + SystematicIssuers::ClassicMigration, + SystematicIssuers::FiatTickersReservation, +]; + +impl SystematicIssuers { + /// Returns the representation of this issuer as a raw public key. + pub const fn as_bytes(self) -> &'static [u8; 32] { + match self { + SystematicIssuers::Committee => did::GOVERNANCE_COMMITTEE_DID, + SystematicIssuers::CDDProvider => did::CDD_PROVIDERS_DID, + SystematicIssuers::Treasury => did::TREASURY_DID, + SystematicIssuers::BlockRewardReserve => did::BLOCK_REWARD_RESERVE_DID, + SystematicIssuers::Settlement => did::SETTLEMENT_MODULE_DID, + SystematicIssuers::ClassicMigration => did::CLASSIC_MIGRATION_DID, + SystematicIssuers::FiatTickersReservation => did::FIAT_TICKERS_RESERVATION_DID, + } + } + + /// It returns the Identity Identifier of this issuer. + pub const fn as_id(self) -> IdentityId { + IdentityId(*self.as_bytes()) + } + + pub const fn as_pallet_id(self) -> PalletId { + match self { + SystematicIssuers::Committee => GC_PALLET_ID, + SystematicIssuers::CDDProvider => CDD_PALLET_ID, + SystematicIssuers::Treasury => TREASURY_PALLET_ID, + SystematicIssuers::BlockRewardReserve => BRR_PALLET_ID, + SystematicIssuers::Settlement => SETTLEMENT_PALLET_ID, + SystematicIssuers::ClassicMigration => CLASSIC_MIGRATION_PALLET_ID, + SystematicIssuers::FiatTickersReservation => FIAT_TICKERS_RESERVATION_PALLET_ID, + } + } +} + +pub const GC_DID: IdentityId = SystematicIssuers::Committee.as_id(); +pub const TECHNICAL_DID: IdentityId = IdentityId(*did::TECHNICAL_COMMITTEE_DID); +pub const UPGRADE_DID: IdentityId = IdentityId(*did::UPGRADE_COMMITTEE_DID); + /// Prefixes for scheduled actions pub const SETTLEMENT_INSTRUCTION_EXECUTION: [u8; 27] = *b"SETTLEMENT_INSTRUCTION_EXEC"; pub const PIP_EXECUTION: [u8; 8] = *b"PIP_EXEC"; diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 1071bb7460..b25a516018 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -234,6 +234,7 @@ pub mod settlement; /// Constants definitions. pub mod constants; +pub use constants::{SystematicIssuers, GC_DID, SYSTEMATIC_ISSUERS, TECHNICAL_DID, UPGRADE_DID}; /// Multisig type definitions. pub mod multisig; diff --git a/src/chain_spec.rs b/src/chain_spec.rs index bf0b9ff4ce..1a550d926c 100644 --- a/src/chain_spec.rs +++ b/src/chain_spec.rs @@ -3,15 +3,13 @@ use grandpa::AuthorityId as GrandpaId; use pallet_asset::TickerRegistrationConfig; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_staking::StakerStatus; -use polymesh_common_utilities::{ - constants::{currency::ONE_POLY, TREASURY_PALLET_ID}, - MaybeBlock, SystematicIssuers, -}; +use polymesh_common_utilities::MaybeBlock; use polymesh_primitives::{ asset_metadata::{AssetMetadataName, AssetMetadataSpec}, + constants::{currency::ONE_POLY, TREASURY_PALLET_ID}, identity_id::GenesisIdentityRecord, protocol_fee::ProtocolOp, - AccountId, IdentityId, Moment, PosRatio, SecondaryKey, Signature, Ticker, + AccountId, IdentityId, Moment, PosRatio, SecondaryKey, Signature, SystematicIssuers, Ticker, }; use sc_chain_spec::{ChainSpecExtension, ChainType}; use sc_service::Properties; From 28ba8e176ec1b4974f0c0e0c721e8ec48b797770 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 03:01:34 +0800 Subject: [PATCH 07/45] Move MaybeBlock, ConstSize, GetExtra types to primitives. --- pallets/committee/src/benchmarking.rs | 6 +-- pallets/committee/src/lib.rs | 5 ++- pallets/common/src/lib.rs | 49 --------------------- pallets/pips/src/benchmarking.rs | 7 +-- pallets/pips/src/lib.rs | 4 +- pallets/pips/src/types.rs | 3 +- pallets/runtime/tests/src/committee_test.rs | 3 +- pallets/runtime/tests/src/pips_test.rs | 3 +- primitives/src/lib.rs | 46 +++++++++++++++++++ src/chain_spec.rs | 4 +- 10 files changed, 60 insertions(+), 70 deletions(-) diff --git a/pallets/committee/src/benchmarking.rs b/pallets/committee/src/benchmarking.rs index 63d571a968..116cb049f3 100644 --- a/pallets/committee/src/benchmarking.rs +++ b/pallets/committee/src/benchmarking.rs @@ -21,11 +21,9 @@ use frame_support::{ StorageValue, }; use frame_system::RawOrigin as SystemOrigin; -use polymesh_common_utilities::{ - benchs::{user, User}, - MaybeBlock, -}; +use polymesh_common_utilities::benchs::{user, User}; use polymesh_primitives::committee::COMMITTEE_MEMBERS_MAX; +use polymesh_primitives::MaybeBlock; use sp_std::prelude::*; const PROPOSAL_PADDING_WORDS: usize = 1_000; diff --git a/pallets/committee/src/lib.rs b/pallets/committee/src/lib.rs index 51a47945a4..18884eeba1 100644 --- a/pallets/committee/src/lib.rs +++ b/pallets/committee/src/lib.rs @@ -75,9 +75,10 @@ use polymesh_common_utilities::{ governance_group::GovernanceGroupTrait, group::{GroupTrait, InactiveMember, MemberCount}, identity::Config as IdentityConfig, - MaybeBlock, }; -use polymesh_primitives::{storage_migration_ver, IdentityId, SystematicIssuers, GC_DID}; +use polymesh_primitives::{ + storage_migration_ver, IdentityId, MaybeBlock, SystematicIssuers, GC_DID, +}; use scale_info::TypeInfo; use sp_runtime::traits::Hash; use sp_std::{prelude::*, vec}; diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 06cc56e421..7c561148ba 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -25,52 +25,3 @@ pub use context::Context; #[cfg(feature = "runtime-benchmarks")] pub mod benchs; - -use core::ops::Add; -use frame_support::codec::{Decode, Encode}; -use frame_support::traits::Get; -use scale_info::TypeInfo; -#[cfg(feature = "std")] -use serde::{Deserialize, Serialize}; - -/// Use `GetExtra` as the trait bounds for pallet `Config` parameters -/// that will be used for bounded collections. -pub trait GetExtra: Get + Clone + core::fmt::Debug + Default + PartialEq + Eq {} - -/// ConstSize type wrapper. -/// -/// This allows the use of Bounded collections in extrinsic parameters. -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] -pub struct ConstSize; - -impl Get for ConstSize { - fn get() -> u32 { - T - } -} - -impl GetExtra for ConstSize {} - -/// Either a block number, or nothing. -#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, TypeInfo, Debug)] -#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -pub enum MaybeBlock { - Some(BlockNumber), - None, -} - -impl Default for MaybeBlock { - fn default() -> Self { - Self::None - } -} - -impl> Add for MaybeBlock { - type Output = Self; - fn add(self, rhs: T) -> Self::Output { - match self { - MaybeBlock::Some(lhs) => MaybeBlock::Some(lhs + rhs), - MaybeBlock::None => MaybeBlock::None, - } - } -} diff --git a/pallets/pips/src/benchmarking.rs b/pallets/pips/src/benchmarking.rs index 8526bf56c7..5e90d153b6 100644 --- a/pallets/pips/src/benchmarking.rs +++ b/pallets/pips/src/benchmarking.rs @@ -21,11 +21,8 @@ use frame_support::{ traits::UnfilteredDispatchable, }; use frame_system::RawOrigin; -use polymesh_common_utilities::{ - benchs::{user, User}, - MaybeBlock, -}; -use polymesh_primitives::{SystematicIssuers, GC_DID}; +use polymesh_common_utilities::benchs::{user, User}; +use polymesh_primitives::{MaybeBlock, SystematicIssuers, GC_DID}; use rand::{seq::SliceRandom, SeedableRng}; use rand_chacha::ChaCha20Rng; use sp_std::{ diff --git a/pallets/pips/src/lib.rs b/pallets/pips/src/lib.rs index 1d0874a118..19a720d090 100644 --- a/pallets/pips/src/lib.rs +++ b/pallets/pips/src/lib.rs @@ -112,11 +112,11 @@ use polymesh_common_utilities::traits::balances::LockableCurrencyExt; use polymesh_common_utilities::traits::governance_group::GovernanceGroupTrait; use polymesh_common_utilities::traits::group::GroupTrait; use polymesh_common_utilities::traits::identity::Config as IdentityConfig; -use polymesh_common_utilities::{CommonConfig, MaybeBlock}; +use polymesh_common_utilities::CommonConfig; use polymesh_primitives::constants::PIP_MAX_REPORTING_SIZE; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{storage_migration_ver, with_transaction}; -use polymesh_primitives::{Balance, IdentityId, Url}; +use polymesh_primitives::{Balance, IdentityId, MaybeBlock, Url}; use polymesh_primitives::{GC_DID, TECHNICAL_DID, UPGRADE_DID}; use polymesh_runtime_common::PipsEnactSnapshotMaximumWeight; diff --git a/pallets/pips/src/types.rs b/pallets/pips/src/types.rs index 8b0fcb0a23..0275dc1ac3 100644 --- a/pallets/pips/src/types.rs +++ b/pallets/pips/src/types.rs @@ -25,9 +25,8 @@ use sp_core::H256; use sp_std::convert::From; use sp_std::vec::Vec; -use polymesh_common_utilities::MaybeBlock; use polymesh_primitives::constants::{PIP_EXECUTION, PIP_EXPIRY}; -use polymesh_primitives::{impl_checked_inc, Balance, Url}; +use polymesh_primitives::{impl_checked_inc, Balance, MaybeBlock, Url}; use polymesh_primitives_derive::VecU8StrongTyped; /// The highest priorities, from `HIGHEST_PRIORITY`(=0) to `HARD_DEADLINE`(=63), enforce the execution of diff --git a/pallets/runtime/tests/src/committee_test.rs b/pallets/runtime/tests/src/committee_test.rs index 5b32604b82..ce27b63b6a 100644 --- a/pallets/runtime/tests/src/committee_test.rs +++ b/pallets/runtime/tests/src/committee_test.rs @@ -14,8 +14,7 @@ use pallet_committee::{self as committee, PolymeshVotes, RawEvent as CommitteeRa use pallet_group as group; use pallet_identity as identity; use pallet_pips::{PipId, ProposalState, SnapshotResult}; -use polymesh_common_utilities::MaybeBlock; -use polymesh_primitives::IdentityId; +use polymesh_primitives::{IdentityId, MaybeBlock}; use sp_core::H256; use sp_keyring::AccountKeyring; use sp_runtime::traits::Hash; diff --git a/pallets/runtime/tests/src/pips_test.rs b/pallets/runtime/tests/src/pips_test.rs index 553d64cabb..200dfd61b0 100644 --- a/pallets/runtime/tests/src/pips_test.rs +++ b/pallets/runtime/tests/src/pips_test.rs @@ -19,8 +19,7 @@ use pallet_pips::{ VotingResult, }; use pallet_treasury as treasury; -use polymesh_common_utilities::MaybeBlock; -use polymesh_primitives::{AccountId, BlockNumber, Url, GC_DID}; +use polymesh_primitives::{AccountId, BlockNumber, MaybeBlock, Url, GC_DID}; use sp_keyring::AccountKeyring; use std::ops::Deref; diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index b25a516018..cc4c83dbce 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -26,6 +26,8 @@ use alloc::{ string::{String, ToString}, }; use codec::{Decode, Encode}; +use core::ops::Add; +use frame_support::traits::Get; use frame_support::weights::Weight; use polymesh_primitives_derive::{SliceU8StrongTyped, StringStrongTyped, VecU8StrongTyped}; use scale_info::TypeInfo; @@ -63,6 +65,50 @@ pub type Index = u32; /// Alias for Gas. pub type Gas = Weight; +/// Use `GetExtra` as the trait bounds for pallet `Config` parameters +/// that will be used for bounded collections. +pub trait GetExtra: Get + Clone + core::fmt::Debug + Default + PartialEq + Eq {} + +/// ConstSize type wrapper. +/// +/// This allows the use of Bounded collections in extrinsic parameters. +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] +pub struct ConstSize; + +impl Get for ConstSize { + fn get() -> u32 { + T + } +} + +impl GetExtra for ConstSize {} + +/// Either a block number, or nothing. +#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, TypeInfo, Debug)] +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +pub enum MaybeBlock { + /// Has a block number. + Some(BlockNumber), + /// No block number. + None, +} + +impl Default for MaybeBlock { + fn default() -> Self { + Self::None + } +} + +impl> Add for MaybeBlock { + type Output = Self; + fn add(self, rhs: T) -> Self::Output { + match self { + MaybeBlock::Some(lhs) => MaybeBlock::Some(lhs + rhs), + MaybeBlock::None => MaybeBlock::None, + } + } +} + /// A positive coefficient: a pair of a numerator and a denominator. Defaults to `(1, 1)`. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[derive(Encode, Decode, TypeInfo)] diff --git a/src/chain_spec.rs b/src/chain_spec.rs index 1a550d926c..b9b4e495c9 100644 --- a/src/chain_spec.rs +++ b/src/chain_spec.rs @@ -3,13 +3,13 @@ use grandpa::AuthorityId as GrandpaId; use pallet_asset::TickerRegistrationConfig; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_staking::StakerStatus; -use polymesh_common_utilities::MaybeBlock; use polymesh_primitives::{ asset_metadata::{AssetMetadataName, AssetMetadataSpec}, constants::{currency::ONE_POLY, TREASURY_PALLET_ID}, identity_id::GenesisIdentityRecord, protocol_fee::ProtocolOp, - AccountId, IdentityId, Moment, PosRatio, SecondaryKey, Signature, SystematicIssuers, Ticker, + AccountId, IdentityId, MaybeBlock, Moment, PosRatio, SecondaryKey, Signature, + SystematicIssuers, Ticker, }; use sc_chain_spec::{ChainSpecExtension, ChainType}; use sc_service::Properties; From 4335d63c7ba43e32c25a276b0559d9aecab1b61a Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 03:17:59 +0800 Subject: [PATCH 08/45] Remove dead code. --- pallets/common/src/benchs/asset.rs | 2 -- pallets/common/src/benchs/mod.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pallets/common/src/benchs/asset.rs b/pallets/common/src/benchs/asset.rs index 06b0afd9a3..8ab8a5e872 100644 --- a/pallets/common/src/benchs/asset.rs +++ b/pallets/common/src/benchs/asset.rs @@ -7,8 +7,6 @@ use polymesh_primitives::{PortfolioKind, Ticker}; use crate::benchs::User; use crate::traits::asset::{AssetFnTrait, Config}; -pub type ResultTicker = Result; - /// Registers a unique ticker named `ticker_name` for `ticker_owner`. pub fn reg_unique_ticker( ticker_owner: T::RuntimeOrigin, diff --git a/pallets/common/src/benchs/mod.rs b/pallets/common/src/benchs/mod.rs index 7b894793a9..da10c71402 100644 --- a/pallets/common/src/benchs/mod.rs +++ b/pallets/common/src/benchs/mod.rs @@ -14,7 +14,7 @@ // along with this program. If not, see . mod asset; -pub use asset::{create_and_issue_sample_asset, reg_unique_ticker, ResultTicker}; +pub use asset::{create_and_issue_sample_asset, reg_unique_ticker}; mod user; pub use user::{PublicKey, SecretKey, User}; From 9769f219af250ac338b6b0ae979c18d16a9bef85 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 03:43:01 +0800 Subject: [PATCH 09/45] Remove unused MultiSigSubTrait. --- pallets/common/src/traits/identity.rs | 3 --- pallets/common/src/traits/multisig.rs | 6 ------ pallets/multisig/src/lib.rs | 4 +--- pallets/runtime/develop/src/runtime.rs | 1 - pallets/runtime/mainnet/src/runtime.rs | 1 - pallets/runtime/testnet/src/runtime.rs | 1 - pallets/runtime/tests/src/staking/mock.rs | 8 -------- pallets/runtime/tests/src/storage.rs | 2 -- 8 files changed, 1 insertion(+), 25 deletions(-) diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index ef2f95e9b0..026da8bcb9 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -31,7 +31,6 @@ use polymesh_primitives::{ }; use crate::traits::group::GroupTrait; -use crate::traits::multisig::MultiSigSubTrait; use crate::traits::portfolio::PortfolioSubTrait; use crate::traits::transaction_payment::{CddAndFeeDetails, ChargeTxFee}; use crate::traits::CommonConfig; @@ -177,8 +176,6 @@ pub trait Config: CommonConfig + pallet_timestamp::Config + pallet_base::Config > + GetCallMetadata + GetDispatchInfo + From>; - /// MultiSig module - type MultiSig: MultiSigSubTrait; /// Portfolio module. Required to accept portfolio custody transfers. type Portfolio: PortfolioSubTrait; /// Group module diff --git a/pallets/common/src/traits/multisig.rs b/pallets/common/src/traits/multisig.rs index eff0801190..1ca7ee0369 100644 --- a/pallets/common/src/traits/multisig.rs +++ b/pallets/common/src/traits/multisig.rs @@ -55,9 +55,3 @@ pub trait WeightInfo { .saturating_add(Self::default_max_weight(max_weight)) } } - -/// This trait is used to add a signer to a multisig and enable unlinking multisig from an identity -pub trait MultiSigSubTrait { - /// Returns `true` if the given `account_id` is a multisign account, otherwise returns `false`. - fn is_multisig(account_id: &AccountId) -> bool; -} diff --git a/pallets/multisig/src/lib.rs b/pallets/multisig/src/lib.rs index 790b3c72ef..2a2f570c5c 100644 --- a/pallets/multisig/src/lib.rs +++ b/pallets/multisig/src/lib.rs @@ -85,7 +85,7 @@ use sp_std::prelude::*; use pallet_identity::PermissionedCallOriginData; use pallet_permissions::with_call_metadata; -pub use polymesh_common_utilities::multisig::{MultiSigSubTrait, WeightInfo}; +pub use polymesh_common_utilities::multisig::WeightInfo; use polymesh_common_utilities::traits::identity::Config as IdentityConfig; use polymesh_primitives::multisig::{ProposalState, ProposalVoteCount}; use polymesh_primitives::{ @@ -1354,9 +1354,7 @@ impl Pallet { LastInvalidProposal::::insert(multisig, next_proposal_id.saturating_sub(1)); } -} -impl MultiSigSubTrait for Pallet { fn is_multisig(account_id: &T::AccountId) -> bool { MultiSigSignsRequired::::contains_key(account_id) } diff --git a/pallets/runtime/develop/src/runtime.rs b/pallets/runtime/develop/src/runtime.rs index f7c89c96f5..2b222f1023 100644 --- a/pallets/runtime/develop/src/runtime.rs +++ b/pallets/runtime/develop/src/runtime.rs @@ -197,7 +197,6 @@ pub type CddHandler = polymesh_runtime_common::fee_details::CddHandler; impl polymesh_common_utilities::traits::identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type MultiSig = MultiSig; type Portfolio = Portfolio; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; diff --git a/pallets/runtime/mainnet/src/runtime.rs b/pallets/runtime/mainnet/src/runtime.rs index ec3db3cc3e..289cf2cc40 100644 --- a/pallets/runtime/mainnet/src/runtime.rs +++ b/pallets/runtime/mainnet/src/runtime.rs @@ -196,7 +196,6 @@ type CddHandler = polymesh_runtime_common::fee_details::CddHandler; impl polymesh_common_utilities::traits::identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type MultiSig = MultiSig; type Portfolio = Portfolio; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; diff --git a/pallets/runtime/testnet/src/runtime.rs b/pallets/runtime/testnet/src/runtime.rs index f48796dd14..94aacc729c 100644 --- a/pallets/runtime/testnet/src/runtime.rs +++ b/pallets/runtime/testnet/src/runtime.rs @@ -199,7 +199,6 @@ type CddHandler = polymesh_runtime_common::fee_details::CddHandler; impl polymesh_common_utilities::traits::identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type MultiSig = MultiSig; type Portfolio = Portfolio; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index cfefcf3720..303c7356fd 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -43,7 +43,6 @@ use pallet_staking::types::SlashingSwitch; use pallet_staking::{self as pallet_staking, *}; use polymesh_common_utilities::traits::balances::{AccountData, CheckCdd}; use polymesh_common_utilities::traits::group::{GroupTrait, InactiveMember}; -use polymesh_common_utilities::traits::multisig::MultiSigSubTrait; use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_common_utilities::traits::CommonConfig; @@ -295,7 +294,6 @@ impl pallet_protocol_fee::Config for Test { impl polymesh_common_utilities::traits::identity::Config for Test { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type MultiSig = Test; type Portfolio = Test; type CddServiceProviders = pallet_group::Module; type Balances = Balances; @@ -433,12 +431,6 @@ impl GroupTrait for Test { } } -impl MultiSigSubTrait for Test { - fn is_multisig(_account: &AccountId) -> bool { - false - } -} - impl PortfolioSubTrait for Test { fn ensure_portfolio_custody(_: PortfolioId, _: IdentityId) -> DispatchResult { unimplemented!() diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index 91373265ce..c629cd2401 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -43,7 +43,6 @@ use pallet_corporate_actions::ballot as corporate_ballots; use pallet_corporate_actions::distribution as capital_distributions; use pallet_group as group; use pallet_identity as identity; -use pallet_multisig as multisig; use pallet_pips as pips; use pallet_portfolio as portfolio; use pallet_protocol_fee as protocol_fee; @@ -621,7 +620,6 @@ impl committee::Config for TestStorage { impl polymesh_common_utilities::traits::identity::Config for TestStorage { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type MultiSig = multisig::Pallet; type Portfolio = portfolio::Module; type CddServiceProviders = CddServiceProvider; type Balances = balances::Module; From 37e4c8bcce7822c7c7c005ba7192fb7d463b81a7 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 03:45:48 +0800 Subject: [PATCH 10/45] The identity pallet doesn't use the PortfolioSubTrait. --- pallets/common/src/traits/identity.rs | 3 --- pallets/runtime/common/src/runtime.rs | 1 + pallets/runtime/develop/src/runtime.rs | 1 - pallets/runtime/mainnet/src/runtime.rs | 1 - pallets/runtime/testnet/src/runtime.rs | 1 - pallets/runtime/tests/src/staking/mock.rs | 1 - pallets/runtime/tests/src/storage.rs | 2 -- pallets/settlement/src/lib.rs | 3 +++ 8 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index 026da8bcb9..0ba859690b 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -31,7 +31,6 @@ use polymesh_primitives::{ }; use crate::traits::group::GroupTrait; -use crate::traits::portfolio::PortfolioSubTrait; use crate::traits::transaction_payment::{CddAndFeeDetails, ChargeTxFee}; use crate::traits::CommonConfig; @@ -176,8 +175,6 @@ pub trait Config: CommonConfig + pallet_timestamp::Config + pallet_base::Config > + GetCallMetadata + GetDispatchInfo + From>; - /// Portfolio module. Required to accept portfolio custody transfers. - type Portfolio: PortfolioSubTrait; /// Group module type CddServiceProviders: GroupTrait; /// Balances module diff --git a/pallets/runtime/common/src/runtime.rs b/pallets/runtime/common/src/runtime.rs index 0a98e1bb1b..908d830c12 100644 --- a/pallets/runtime/common/src/runtime.rs +++ b/pallets/runtime/common/src/runtime.rs @@ -535,6 +535,7 @@ macro_rules! misc_pallet_impls { type Proposal = RuntimeCall; type Scheduler = Scheduler; type WeightInfo = polymesh_weights::pallet_settlement::SubstrateWeight; + type Portfolio = Portfolio; type MaxNumberOfFungibleAssets = MaxNumberOfFungibleAssets; type MaxNumberOfNFTsPerLeg = MaxNumberOfNFTsPerLeg; type MaxNumberOfNFTs = MaxNumberOfNFTs; diff --git a/pallets/runtime/develop/src/runtime.rs b/pallets/runtime/develop/src/runtime.rs index 2b222f1023..4dfe56d3c9 100644 --- a/pallets/runtime/develop/src/runtime.rs +++ b/pallets/runtime/develop/src/runtime.rs @@ -197,7 +197,6 @@ pub type CddHandler = polymesh_runtime_common::fee_details::CddHandler; impl polymesh_common_utilities::traits::identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type Portfolio = Portfolio; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; type ChargeTxFeeTarget = TransactionPayment; diff --git a/pallets/runtime/mainnet/src/runtime.rs b/pallets/runtime/mainnet/src/runtime.rs index 289cf2cc40..756346f8e0 100644 --- a/pallets/runtime/mainnet/src/runtime.rs +++ b/pallets/runtime/mainnet/src/runtime.rs @@ -196,7 +196,6 @@ type CddHandler = polymesh_runtime_common::fee_details::CddHandler; impl polymesh_common_utilities::traits::identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type Portfolio = Portfolio; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; type ChargeTxFeeTarget = TransactionPayment; diff --git a/pallets/runtime/testnet/src/runtime.rs b/pallets/runtime/testnet/src/runtime.rs index 94aacc729c..7e4477483e 100644 --- a/pallets/runtime/testnet/src/runtime.rs +++ b/pallets/runtime/testnet/src/runtime.rs @@ -199,7 +199,6 @@ type CddHandler = polymesh_runtime_common::fee_details::CddHandler; impl polymesh_common_utilities::traits::identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type Portfolio = Portfolio; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; type ChargeTxFeeTarget = TransactionPayment; diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index 303c7356fd..5bc0a7278d 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -294,7 +294,6 @@ impl pallet_protocol_fee::Config for Test { impl polymesh_common_utilities::traits::identity::Config for Test { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type Portfolio = Test; type CddServiceProviders = pallet_group::Module; type Balances = Balances; type ChargeTxFeeTarget = Test; diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index c629cd2401..f195091d98 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -44,7 +44,6 @@ use pallet_corporate_actions::distribution as capital_distributions; use pallet_group as group; use pallet_identity as identity; use pallet_pips as pips; -use pallet_portfolio as portfolio; use pallet_protocol_fee as protocol_fee; use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::RuntimeDispatchInfo; @@ -620,7 +619,6 @@ impl committee::Config for TestStorage { impl polymesh_common_utilities::traits::identity::Config for TestStorage { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; - type Portfolio = portfolio::Module; type CddServiceProviders = CddServiceProvider; type Balances = balances::Module; type ChargeTxFeeTarget = TestStorage; diff --git a/pallets/settlement/src/lib.rs b/pallets/settlement/src/lib.rs index c4a03cbb49..925657fee1 100644 --- a/pallets/settlement/src/lib.rs +++ b/pallets/settlement/src/lib.rs @@ -118,6 +118,9 @@ pub trait Config: /// Scheduler of settlement instructions. type Scheduler: Named::Proposal, Self::SchedulerOrigin>; + /// Portfolio module. + type Portfolio: PortfolioSubTrait; + /// Maximum number of fungible assets that can be in a single instruction. type MaxNumberOfFungibleAssets: Get; From 4e07f450775bad0fa93a0238d6dcb6fc028b805c Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 04:06:01 +0800 Subject: [PATCH 11/45] Remove unused ChargeTxFee trait. --- pallets/common/src/traits/balances.rs | 4 ++-- .../common/src/traits/compliance_manager.rs | 3 ++- pallets/common/src/traits/group.rs | 3 ++- pallets/common/src/traits/identity.rs | 9 ++++---- pallets/common/src/traits/mod.rs | 2 +- .../common/src/traits/transaction_payment.rs | 8 +------ pallets/runtime/develop/src/runtime.rs | 1 - pallets/runtime/mainnet/src/runtime.rs | 1 - pallets/runtime/testnet/src/runtime.rs | 1 - pallets/runtime/tests/src/staking/mock.rs | 12 ++-------- pallets/runtime/tests/src/storage.rs | 15 +++---------- pallets/transaction-payment/src/lib.rs | 22 ++----------------- 12 files changed, 19 insertions(+), 62 deletions(-) diff --git a/pallets/common/src/traits/balances.rs b/pallets/common/src/traits/balances.rs index 363706e83d..71ab61cf00 100644 --- a/pallets/common/src/traits/balances.rs +++ b/pallets/common/src/traits/balances.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::traits::{identity::Config as IdentityConfig, NegativeImbalance}; +use crate::traits::{identity::Config as IdentityConfig, CommonConfig, NegativeImbalance}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ decl_event, @@ -151,7 +151,7 @@ pub trait WeightInfo { fn burn_account_balance() -> Weight; } -pub trait Config: IdentityConfig { +pub trait Config: CommonConfig + IdentityConfig { /// The means of storing the balances of an account. type AccountStore: StoredMap; diff --git a/pallets/common/src/traits/compliance_manager.rs b/pallets/common/src/traits/compliance_manager.rs index 71cc44ef32..613d20ef93 100644 --- a/pallets/common/src/traits/compliance_manager.rs +++ b/pallets/common/src/traits/compliance_manager.rs @@ -29,10 +29,11 @@ use crate::asset::AssetFnTrait; use crate::balances::Config as BalancesConfig; use crate::identity::Config as IdentityConfig; use crate::traits::external_agents::Config as EAConfig; +use crate::traits::CommonConfig; /// The module's configuration trait. pub trait Config: - pallet_timestamp::Config + frame_system::Config + BalancesConfig + IdentityConfig + EAConfig + pallet_timestamp::Config + CommonConfig + BalancesConfig + IdentityConfig + EAConfig { /// The overarching event type. type RuntimeEvent: From + Into<::RuntimeEvent>; diff --git a/pallets/common/src/traits/group.rs b/pallets/common/src/traits/group.rs index b7891971c2..7646b9442f 100644 --- a/pallets/common/src/traits/group.rs +++ b/pallets/common/src/traits/group.rs @@ -14,6 +14,7 @@ // along with this program. If not, see . use crate::identity::Config as IdentityConfig; +use crate::traits::CommonConfig; use polymesh_primitives::IdentityId; @@ -91,7 +92,7 @@ pub trait WeightInfo { fn abdicate_membership() -> Weight; } -pub trait Config: frame_system::Config + pallet_timestamp::Config + IdentityConfig { +pub trait Config: CommonConfig + pallet_timestamp::Config + IdentityConfig { /// The overarching event type. type RuntimeEvent: From> + Into<::RuntimeEvent>; diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index 0ba859690b..8710a5b30a 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -31,8 +31,7 @@ use polymesh_primitives::{ }; use crate::traits::group::GroupTrait; -use crate::traits::transaction_payment::{CddAndFeeDetails, ChargeTxFee}; -use crate::traits::CommonConfig; +use crate::traits::transaction_payment::CddAndFeeDetails; pub type AuthorizationNonce = u64; @@ -164,7 +163,9 @@ pub trait WeightInfo { } /// The module's configuration trait. -pub trait Config: CommonConfig + pallet_timestamp::Config + pallet_base::Config { +pub trait Config: + frame_system::Config + pallet_timestamp::Config + pallet_base::Config + pallet_permissions::Config +{ /// The overarching event type. type RuntimeEvent: From> + Into<::RuntimeEvent>; /// An extrinsic call. @@ -179,8 +180,6 @@ pub trait Config: CommonConfig + pallet_timestamp::Config + pallet_base::Config type CddServiceProviders: GroupTrait; /// Balances module type Balances: Currency; - /// Charges fee for forwarded call - type ChargeTxFeeTarget: ChargeTxFee; /// Used to check and update CDD type CddHandler: CddAndFeeDetails::RuntimeCall>; diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index f9f4e44713..a6247fb2dd 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -34,7 +34,7 @@ pub mod multisig; pub mod nft; pub mod portfolio; pub mod transaction_payment; -pub use transaction_payment::{CddAndFeeDetails, ChargeTxFee}; +pub use transaction_payment::CddAndFeeDetails; pub mod relayer; pub mod settlement; pub mod statistics; diff --git a/pallets/common/src/traits/transaction_payment.rs b/pallets/common/src/traits/transaction_payment.rs index e844c6cb2c..ba142bab10 100644 --- a/pallets/common/src/traits/transaction_payment.rs +++ b/pallets/common/src/traits/transaction_payment.rs @@ -1,5 +1,4 @@ -use frame_support::dispatch::DispatchInfo; -use sp_runtime::transaction_validity::{InvalidTransaction, TransactionValidity}; +use sp_runtime::transaction_validity::InvalidTransaction; // Polymesh note: This was specifically added for Polymesh pub trait CddAndFeeDetails { @@ -11,8 +10,3 @@ pub trait CddAndFeeDetails { fn set_payer_context(payer: Option); fn get_payer_from_context() -> Option; } - -// Polymesh note: This was specifically added for Polymesh -pub trait ChargeTxFee { - fn charge_fee(len: u32, info: DispatchInfo) -> TransactionValidity; -} diff --git a/pallets/runtime/develop/src/runtime.rs b/pallets/runtime/develop/src/runtime.rs index 4dfe56d3c9..54e993a3c3 100644 --- a/pallets/runtime/develop/src/runtime.rs +++ b/pallets/runtime/develop/src/runtime.rs @@ -199,7 +199,6 @@ impl polymesh_common_utilities::traits::identity::Config for Runtime { type Proposal = RuntimeCall; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; - type ChargeTxFeeTarget = TransactionPayment; type CddHandler = CddHandler; type Public = ::Signer; type OffChainSignature = MultiSignature; diff --git a/pallets/runtime/mainnet/src/runtime.rs b/pallets/runtime/mainnet/src/runtime.rs index 756346f8e0..624c51d800 100644 --- a/pallets/runtime/mainnet/src/runtime.rs +++ b/pallets/runtime/mainnet/src/runtime.rs @@ -198,7 +198,6 @@ impl polymesh_common_utilities::traits::identity::Config for Runtime { type Proposal = RuntimeCall; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; - type ChargeTxFeeTarget = TransactionPayment; type CddHandler = CddHandler; type Public = ::Signer; type OffChainSignature = MultiSignature; diff --git a/pallets/runtime/testnet/src/runtime.rs b/pallets/runtime/testnet/src/runtime.rs index 7e4477483e..717f2cfb11 100644 --- a/pallets/runtime/testnet/src/runtime.rs +++ b/pallets/runtime/testnet/src/runtime.rs @@ -201,7 +201,6 @@ impl polymesh_common_utilities::traits::identity::Config for Runtime { type Proposal = RuntimeCall; type CddServiceProviders = CddServiceProviders; type Balances = pallet_balances::Module; - type ChargeTxFeeTarget = TransactionPayment; type CddHandler = CddHandler; type Public = ::Signer; type OffChainSignature = MultiSignature; diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index 5bc0a7278d..f963af49a2 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -20,7 +20,7 @@ use std::collections::BTreeMap; use frame_election_provider_support::{onchain, SequentialPhragmen}; -use frame_support::dispatch::{DispatchInfo, DispatchResult, Weight}; +use frame_support::dispatch::{DispatchResult, Weight}; use frame_support::traits::{ ConstU32, Currency, EitherOfDiverse, FindAuthor, GenesisBuild, Get, Hooks, Imbalance, KeyOwnerProofSystem, OnUnbalanced, OneSessionHandler, @@ -34,7 +34,7 @@ use sp_core::H256; use sp_runtime::curve::PiecewiseLinear; use sp_runtime::testing::{Header, TestXt, UintAuthorityId}; use sp_runtime::traits::{IdentityLookup, Zero}; -use sp_runtime::transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction}; +use sp_runtime::transaction_validity::InvalidTransaction; use sp_runtime::{KeyTypeId, Perbill}; use sp_staking::offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}; use sp_staking::{EraIndex, SessionIndex}; @@ -46,7 +46,6 @@ use polymesh_common_utilities::traits::group::{GroupTrait, InactiveMember}; use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_common_utilities::traits::CommonConfig; -use polymesh_common_utilities::transaction_payment::ChargeTxFee; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::identity_id::GenesisIdentityRecord; @@ -296,7 +295,6 @@ impl polymesh_common_utilities::traits::identity::Config for Test { type Proposal = RuntimeCall; type CddServiceProviders = pallet_group::Module; type Balances = Balances; - type ChargeTxFeeTarget = Test; type CddHandler = Test; type Public = UintAuthorityId; type OffChainSignature = sp_runtime::testing::TestSignature; @@ -371,12 +369,6 @@ impl SubsidiserTrait for Test { } } -impl ChargeTxFee for Test { - fn charge_fee(_len: u32, _info: DispatchInfo) -> TransactionValidity { - Ok(ValidTransaction::default()) - } -} - impl GroupTrait for Test { fn get_members() -> Vec { return Group::active_members(); diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index f195091d98..568b1d1fa4 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -5,7 +5,7 @@ use std::cell::RefCell; use std::convert::From; use codec::Encode; -use frame_support::dispatch::{DispatchInfo, DispatchResult, Weight}; +use frame_support::dispatch::{DispatchResult, Weight}; use frame_support::traits::{ Currency, Imbalance, KeyOwnerProofSystem, OnInitialize, OnUnbalanced, TryCollect, }; @@ -26,9 +26,7 @@ use sp_runtime::traits::{ BlakeTwo256, Block as BlockT, Extrinsic, IdentityLookup, NumberFor, OpaqueKeys, StaticLookup, Verify, }; -use sp_runtime::transaction_validity::{ - InvalidTransaction, TransactionPriority, TransactionValidity, ValidTransaction, -}; +use sp_runtime::transaction_validity::{InvalidTransaction, TransactionPriority}; use sp_runtime::{create_runtime_str, AnySignature, KeyTypeId, Perbill, Permill}; use sp_staking::{EraIndex, SessionIndex}; use sp_version::RuntimeVersion; @@ -49,7 +47,7 @@ use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::RuntimeDispatchInfo; use pallet_utility; use polymesh_common_utilities::traits::group::GroupTrait; -use polymesh_common_utilities::traits::transaction_payment::{CddAndFeeDetails, ChargeTxFee}; +use polymesh_common_utilities::traits::transaction_payment::CddAndFeeDetails; use polymesh_common_utilities::Context; use polymesh_primitives::constants::currency::{DOLLARS, POLY}; use polymesh_primitives::protocol_fee::ProtocolOp; @@ -498,12 +496,6 @@ thread_local! { pub type NegativeImbalance = as Currency<::AccountId>>::NegativeImbalance; -impl ChargeTxFee for TestStorage { - fn charge_fee(_len: u32, _info: DispatchInfo) -> TransactionValidity { - Ok(ValidTransaction::default()) - } -} - type CddHandler = TestStorage; impl CddAndFeeDetails for TestStorage { fn get_valid_payer( @@ -621,7 +613,6 @@ impl polymesh_common_utilities::traits::identity::Config for TestStorage { type Proposal = RuntimeCall; type CddServiceProviders = CddServiceProvider; type Balances = balances::Module; - type ChargeTxFeeTarget = TestStorage; type CddHandler = TestStorage; type Public = ::Signer; type OffChainSignature = MultiSignature; diff --git a/pallets/transaction-payment/src/lib.rs b/pallets/transaction-payment/src/lib.rs index 7cfd2eaef8..e303ee2405 100644 --- a/pallets/transaction-payment/src/lib.rs +++ b/pallets/transaction-payment/src/lib.rs @@ -16,7 +16,6 @@ // Modified by Polymesh Association - 13rd March 2020 // - Charge fee from the identity in the signed extension -// - Introduce `ChargeTxFee` trait to compute and charge transaction fee for Multisig. // - Tips have been removed. //! # Transaction Payment Module @@ -63,10 +62,8 @@ use frame_support::{ }; use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; use polymesh_common_utilities::traits::{ - group::GroupTrait, - identity::IdentityFnTrait, - relayer::SubsidiserTrait, - transaction_payment::{CddAndFeeDetails, ChargeTxFee}, + group::GroupTrait, identity::IdentityFnTrait, relayer::SubsidiserTrait, + transaction_payment::CddAndFeeDetails, }; use polymesh_primitives::TransactionError; use scale_info::TypeInfo; @@ -940,18 +937,3 @@ where Ok(()) } } - -// Polymesh note: This was specifically added for Polymesh -impl ChargeTxFee for Pallet -where - BalanceOf: FixedPointOperand, - T::RuntimeCall: Dispatchable, -{ - fn charge_fee(len: u32, info: DispatchInfoOf) -> TransactionValidity { - let fee = Self::compute_fee(len, &info, 0u32.into()); - if let Some(payer) = T::CddHandler::get_payer_from_context() { - T::OnChargeTransaction::charge_fee(&payer, fee)?; - } - Ok(ValidTransaction::default()) - } -} From 7f2d823d914705326e4fceca51d0e07a4e632720 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 04:23:06 +0800 Subject: [PATCH 12/45] Move CddAndFeeDetails trait to primitives. --- pallets/common/src/lib.rs | 2 +- pallets/common/src/traits/identity.rs | 5 ++--- pallets/common/src/traits/mod.rs | 2 -- pallets/common/src/traits/transaction_payment.rs | 12 ------------ pallets/protocol-fee/src/lib.rs | 2 +- pallets/runtime/common/src/fee_details.rs | 6 ++++-- pallets/runtime/tests/src/fee_details.rs | 3 +-- pallets/runtime/tests/src/identity_test.rs | 11 +++++------ pallets/runtime/tests/src/protocol_fee.rs | 2 +- pallets/runtime/tests/src/relayer_test.rs | 5 ++--- pallets/runtime/tests/src/staking/mock.rs | 2 +- pallets/runtime/tests/src/storage.rs | 5 ++--- pallets/runtime/tests/src/utility_test.rs | 5 ++--- pallets/transaction-payment/src/lib.rs | 3 +-- primitives/src/traits.rs | 12 ++++++++++++ 15 files changed, 35 insertions(+), 42 deletions(-) delete mode 100644 pallets/common/src/traits/transaction_payment.rs diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 7c561148ba..db70a72e4e 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -18,7 +18,7 @@ pub mod traits; pub use traits::{ asset, balances, compliance_manager, governance_group, group, identity, multisig, nft, - portfolio, transaction_payment, CommonConfig, + portfolio, CommonConfig, }; pub mod context; pub use context::Context; diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index 8710a5b30a..4dd6d89aaf 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -26,12 +26,11 @@ use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; use polymesh_primitives::{ - protocol_fee::ChargeProtocolFee, secondary_key::SecondaryKey, AuthorizationData, Balance, - CustomClaimTypeId, IdentityClaim, IdentityId, Permissions, Ticker, + protocol_fee::ChargeProtocolFee, secondary_key::SecondaryKey, traits::CddAndFeeDetails, + AuthorizationData, Balance, CustomClaimTypeId, IdentityClaim, IdentityId, Permissions, Ticker, }; use crate::traits::group::GroupTrait; -use crate::traits::transaction_payment::CddAndFeeDetails; pub type AuthorizationNonce = u64; diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index a6247fb2dd..920e4b8693 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -33,8 +33,6 @@ pub mod identity; pub mod multisig; pub mod nft; pub mod portfolio; -pub mod transaction_payment; -pub use transaction_payment::CddAndFeeDetails; pub mod relayer; pub mod settlement; pub mod statistics; diff --git a/pallets/common/src/traits/transaction_payment.rs b/pallets/common/src/traits/transaction_payment.rs deleted file mode 100644 index ba142bab10..0000000000 --- a/pallets/common/src/traits/transaction_payment.rs +++ /dev/null @@ -1,12 +0,0 @@ -use sp_runtime::transaction_validity::InvalidTransaction; - -// Polymesh note: This was specifically added for Polymesh -pub trait CddAndFeeDetails { - fn get_valid_payer( - call: &Call, - caller: &AccountId, - ) -> Result, InvalidTransaction>; - fn clear_context(); - fn set_payer_context(payer: Option); - fn get_payer_from_context() -> Option; -} diff --git a/pallets/protocol-fee/src/lib.rs b/pallets/protocol-fee/src/lib.rs index 06f8708964..145d3783e6 100644 --- a/pallets/protocol-fee/src/lib.rs +++ b/pallets/protocol-fee/src/lib.rs @@ -47,10 +47,10 @@ use frame_support::{ use frame_system::ensure_root; use polymesh_common_utilities::{ identity::Config as IdentityConfig, traits::relayer::SubsidiserTrait, - transaction_payment::CddAndFeeDetails, }; use polymesh_primitives::{ protocol_fee::{ChargeProtocolFee, ProtocolOp}, + traits::CddAndFeeDetails, Balance, IdentityId, PosRatio, GC_DID, }; use sp_runtime::{traits::Zero, Perbill}; diff --git a/pallets/runtime/common/src/fee_details.rs b/pallets/runtime/common/src/fee_details.rs index 53e03bc513..288f0f9142 100644 --- a/pallets/runtime/common/src/fee_details.rs +++ b/pallets/runtime/common/src/fee_details.rs @@ -3,8 +3,10 @@ use core::convert::{TryFrom, TryInto}; use core::marker::PhantomData; use pallet_identity::Module; use polymesh_common_utilities::traits::identity::Config; -use polymesh_common_utilities::{traits::transaction_payment::CddAndFeeDetails, Context}; -use polymesh_primitives::{AccountId, AuthorizationData, IdentityId, Signatory, TransactionError}; +use polymesh_common_utilities::Context; +use polymesh_primitives::{ + traits::CddAndFeeDetails, AccountId, AuthorizationData, IdentityId, Signatory, TransactionError, +}; use sp_runtime::transaction_validity::InvalidTransaction; /// The set of `Call`s from pallets that `CddHandler` recognizes specially. diff --git a/pallets/runtime/tests/src/fee_details.rs b/pallets/runtime/tests/src/fee_details.rs index 609cf31fde..68a3a61dc5 100644 --- a/pallets/runtime/tests/src/fee_details.rs +++ b/pallets/runtime/tests/src/fee_details.rs @@ -7,8 +7,7 @@ use frame_support::assert_noop; use pallet_balances as balances; use pallet_identity as identity; use pallet_multisig as multisig; -use polymesh_common_utilities::traits::transaction_payment::CddAndFeeDetails; -use polymesh_primitives::{Signatory, TransactionError}; +use polymesh_primitives::{traits::CddAndFeeDetails, Signatory, TransactionError}; use polymesh_runtime_develop::runtime::{CddHandler, RuntimeCall}; use sp_keyring::AccountKeyring; use sp_runtime::transaction_validity::InvalidTransaction; diff --git a/pallets/runtime/tests/src/identity_test.rs b/pallets/runtime/tests/src/identity_test.rs index 9b8278113e..d0894c00a5 100644 --- a/pallets/runtime/tests/src/identity_test.rs +++ b/pallets/runtime/tests/src/identity_test.rs @@ -25,15 +25,14 @@ use polymesh_common_utilities::traits::{ Config as IdentityConfig, CreateChildIdentityWithAuth, RawEvent, SecondaryKeyWithAuth, TargetIdAuthorization, }, - transaction_payment::CddAndFeeDetails, }; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - constants::currency::POLY, AccountId, AssetPermissions, AuthorizationData, AuthorizationType, - Claim, ClaimType, CustomClaimTypeId, ExtrinsicName, ExtrinsicPermissions, IdentityClaim, - IdentityId, KeyRecord, PalletName, PalletPermissions, Permissions, PortfolioId, - PortfolioNumber, Scope, SecondaryKey, Signatory, SubsetRestriction, SystematicIssuers, Ticker, - TransactionError, GC_DID, + constants::currency::POLY, traits::CddAndFeeDetails, AccountId, AssetPermissions, + AuthorizationData, AuthorizationType, Claim, ClaimType, CustomClaimTypeId, ExtrinsicName, + ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, PalletName, PalletPermissions, + Permissions, PortfolioId, PortfolioNumber, Scope, SecondaryKey, Signatory, SubsetRestriction, + SystematicIssuers, Ticker, TransactionError, GC_DID, }; use polymesh_runtime_develop::runtime::{CddHandler, RuntimeCall}; use sp_core::H512; diff --git a/pallets/runtime/tests/src/protocol_fee.rs b/pallets/runtime/tests/src/protocol_fee.rs index dcf6d7e292..3888a847a8 100644 --- a/pallets/runtime/tests/src/protocol_fee.rs +++ b/pallets/runtime/tests/src/protocol_fee.rs @@ -4,8 +4,8 @@ use super::{ ExtBuilder, }; use frame_support::{assert_noop, assert_ok}; -use polymesh_common_utilities::traits::transaction_payment::CddAndFeeDetails; use polymesh_primitives::protocol_fee::ProtocolOp; +use polymesh_primitives::traits::CddAndFeeDetails; use sp_keyring::AccountKeyring; type Error = pallet_protocol_fee::Error; diff --git a/pallets/runtime/tests/src/relayer_test.rs b/pallets/runtime/tests/src/relayer_test.rs index 3ea47be7ad..6a6e1fbce1 100644 --- a/pallets/runtime/tests/src/relayer_test.rs +++ b/pallets/runtime/tests/src/relayer_test.rs @@ -9,10 +9,9 @@ use frame_support::{ }; use frame_system; use pallet_relayer::Subsidy; -use polymesh_common_utilities::traits::transaction_payment::CddAndFeeDetails; use polymesh_primitives::{ - constants::currency::POLY, protocol_fee::ProtocolOp, AccountId, Balance, Signatory, Ticker, - TransactionError, + constants::currency::POLY, protocol_fee::ProtocolOp, traits::CddAndFeeDetails, AccountId, + Balance, Signatory, Ticker, TransactionError, }; use polymesh_runtime_develop::runtime::{CddHandler, RuntimeCall as DevRuntimeCall}; use sp_keyring::AccountKeyring; diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index f963af49a2..66d8262611 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -342,7 +342,7 @@ impl pallet_preimage::Config for Test { type ByteDeposit = PreimageByteDeposit; } -impl polymesh_common_utilities::transaction_payment::CddAndFeeDetails for Test { +impl polymesh_primitives::traits::CddAndFeeDetails for Test { fn get_valid_payer( _: &Call, _: &AccountId, diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index 568b1d1fa4..bad5ecfd34 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -47,14 +47,13 @@ use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::RuntimeDispatchInfo; use pallet_utility; use polymesh_common_utilities::traits::group::GroupTrait; -use polymesh_common_utilities::traits::transaction_payment::CddAndFeeDetails; use polymesh_common_utilities::Context; use polymesh_primitives::constants::currency::{DOLLARS, POLY}; use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{ - AccountId, Authorization, AuthorizationData, BlockNumber, Claim, Moment, - Permissions as AuthPermissions, PortfolioNumber, Scope, SecondaryKey, TrustedFor, + traits::CddAndFeeDetails, AccountId, Authorization, AuthorizationData, BlockNumber, Claim, + Moment, Permissions as AuthPermissions, PortfolioNumber, Scope, SecondaryKey, TrustedFor, TrustedIssuer, }; use polymesh_runtime_common::merge_active_and_inactive; diff --git a/pallets/runtime/tests/src/utility_test.rs b/pallets/runtime/tests/src/utility_test.rs index 0c8487eafa..31c781c123 100644 --- a/pallets/runtime/tests/src/utility_test.rs +++ b/pallets/runtime/tests/src/utility_test.rs @@ -18,10 +18,9 @@ use pallet_portfolio::Call as PortfolioCall; use pallet_utility::{ self as utility, Call as UtilityCall, Config as UtilityConfig, Event, UniqueCall, WeightInfo, }; -use polymesh_common_utilities::traits::transaction_payment::CddAndFeeDetails; use polymesh_primitives::{ - AccountId, Balance, ExtrinsicPermissions, PalletPermissions, Permissions, PortfolioName, - PortfolioNumber, SubsetRestriction, Ticker, + traits::CddAndFeeDetails, AccountId, Balance, ExtrinsicPermissions, PalletPermissions, + Permissions, PortfolioName, PortfolioNumber, SubsetRestriction, Ticker, }; use sp_core::sr25519::Signature; use sp_keyring::AccountKeyring; diff --git a/pallets/transaction-payment/src/lib.rs b/pallets/transaction-payment/src/lib.rs index e303ee2405..c3d88f8004 100644 --- a/pallets/transaction-payment/src/lib.rs +++ b/pallets/transaction-payment/src/lib.rs @@ -63,9 +63,8 @@ use frame_support::{ use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; use polymesh_common_utilities::traits::{ group::GroupTrait, identity::IdentityFnTrait, relayer::SubsidiserTrait, - transaction_payment::CddAndFeeDetails, }; -use polymesh_primitives::TransactionError; +use polymesh_primitives::{traits::CddAndFeeDetails, TransactionError}; use scale_info::TypeInfo; use sp_runtime::{ traits::{ diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index 37e3a759ed..357afe7cca 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -14,6 +14,18 @@ // along with this program. If not, see . use crate::Balance; +use sp_runtime::transaction_validity::InvalidTransaction; + +// Polymesh note: This was specifically added for Polymesh +pub trait CddAndFeeDetails { + fn get_valid_payer( + call: &Call, + caller: &AccountId, + ) -> Result, InvalidTransaction>; + fn clear_context(); + fn set_payer_context(payer: Option); + fn get_payer_from_context() -> Option; +} /// A currency that has a block rewards reserve. pub trait BlockRewardsReserveCurrency { From 82624f74678d16c17aeeb72a925ae1009442d832 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 04:43:06 +0800 Subject: [PATCH 13/45] Move GroupTrait trait and InactiveMember to primitives. --- pallets/committee/src/lib.rs | 8 +- pallets/common/src/benchs/user_builder.rs | 6 +- pallets/common/src/traits/governance_group.rs | 2 +- pallets/common/src/traits/group.rs | 121 +--------------- pallets/common/src/traits/identity.rs | 7 +- pallets/contracts/src/benchmarking.rs | 5 +- pallets/group/rpc/runtime-api/src/lib.rs | 2 +- pallets/group/src/benchmarking.rs | 3 +- pallets/group/src/lib.rs | 8 +- pallets/identity/src/claims.rs | 10 +- pallets/identity/src/keys.rs | 5 +- pallets/pips/src/lib.rs | 2 +- pallets/runtime/common/src/lib.rs | 2 +- pallets/runtime/tests/src/group_test.rs | 2 +- pallets/runtime/tests/src/identity_test.rs | 19 ++- pallets/runtime/tests/src/staking/mock.rs | 2 +- pallets/runtime/tests/src/storage.rs | 6 +- pallets/transaction-payment/src/lib.rs | 7 +- primitives/src/traits.rs | 3 + primitives/src/traits/group.rs | 135 ++++++++++++++++++ 20 files changed, 186 insertions(+), 169 deletions(-) create mode 100644 primitives/src/traits/group.rs diff --git a/pallets/committee/src/lib.rs b/pallets/committee/src/lib.rs index 18884eeba1..e2259b27f3 100644 --- a/pallets/committee/src/lib.rs +++ b/pallets/committee/src/lib.rs @@ -72,12 +72,12 @@ use frame_support::{ }; use pallet_identity as identity; use polymesh_common_utilities::{ - governance_group::GovernanceGroupTrait, - group::{GroupTrait, InactiveMember, MemberCount}, - identity::Config as IdentityConfig, + governance_group::GovernanceGroupTrait, identity::Config as IdentityConfig, }; use polymesh_primitives::{ - storage_migration_ver, IdentityId, MaybeBlock, SystematicIssuers, GC_DID, + storage_migration_ver, + traits::group::{GroupTrait, InactiveMember, MemberCount}, + IdentityId, MaybeBlock, SystematicIssuers, GC_DID, }; use scale_info::TypeInfo; use sp_runtime::traits::Hash; diff --git a/pallets/common/src/benchs/user_builder.rs b/pallets/common/src/benchs/user_builder.rs index abb7d8d815..ee32627364 100644 --- a/pallets/common/src/benchs/user_builder.rs +++ b/pallets/common/src/benchs/user_builder.rs @@ -14,16 +14,14 @@ // along with this program. If not, see . use crate::{ benchs::{SecretKey, User}, - traits::{ - group::GroupTrait, - identity::{Config, IdentityFnTrait}, - }, + traits::identity::{Config, IdentityFnTrait}, }; use schnorrkel::{ExpansionMode, MiniSecretKey}; use codec::{Decode, Encode}; use frame_support::traits::Currency; use frame_system::RawOrigin; +use polymesh_primitives::traits::group::GroupTrait; use polymesh_primitives::IdentityId; use sp_io::hashing::blake2_256; use sp_std::prelude::*; diff --git a/pallets/common/src/traits/governance_group.rs b/pallets/common/src/traits/governance_group.rs index 4493b261ef..fc630dadea 100644 --- a/pallets/common/src/traits/governance_group.rs +++ b/pallets/common/src/traits/governance_group.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::traits::group::GroupTrait; +use polymesh_primitives::traits::group::GroupTrait; use polymesh_primitives::IdentityId; pub trait GovernanceGroupTrait: GroupTrait { diff --git a/pallets/common/src/traits/group.rs b/pallets/common/src/traits/group.rs index 7646b9442f..43e368907a 100644 --- a/pallets/common/src/traits/group.rs +++ b/pallets/common/src/traits/group.rs @@ -16,71 +16,14 @@ use crate::identity::Config as IdentityConfig; use crate::traits::CommonConfig; -use polymesh_primitives::IdentityId; +use polymesh_primitives::{traits::group::MemberCount, IdentityId}; -use codec::{Decode, Encode}; use frame_support::{ decl_event, - dispatch::DispatchResult, traits::{ChangeMembers, EnsureOrigin, InitializeMembers}, weights::Weight, }; -use scale_info::TypeInfo; -use sp_std::{ - cmp::{Eq, Ordering, PartialEq}, - vec::Vec, -}; - -/// The number of group members. -pub type MemberCount = u32; - -#[derive(Encode, Decode, TypeInfo, Default, Clone, PartialEq, Eq, Debug)] -pub struct InactiveMember { - pub id: IdentityId, - pub deactivated_at: Moment, - pub expiry: Option, -} - -impl PartialOrd for InactiveMember -where - M: Eq, -{ - fn partial_cmp(&self, other: &InactiveMember) -> Option { - Some(self.cmp(other)) - } -} -impl PartialOrd for InactiveMember -where - M: Eq, -{ - fn partial_cmp(&self, other: &IdentityId) -> Option { - Some(self.id.cmp(other)) - } -} - -impl Ord for InactiveMember -where - M: Eq, -{ - fn cmp(&self, other: &InactiveMember) -> Ordering { - self.id.cmp(&other.id) - } -} - -impl PartialEq for InactiveMember { - fn eq(&self, other: &IdentityId) -> bool { - self.id.eq(other) - } -} - -impl From for InactiveMember { - fn from(id: IdentityId) -> Self { - InactiveMember { - id, - ..Default::default() - } - } -} +use sp_std::vec::Vec; pub trait WeightInfo { fn set_active_members_limit() -> Weight; @@ -151,63 +94,3 @@ decl_event!( Dummy(sp_std::marker::PhantomData<(AccountId, RuntimeEvent)>), } ); - -pub trait GroupTrait { - /// Retrieve members - fn get_members() -> Vec; - - /// Retrieve valid members: active and revoked members. - fn get_inactive_members() -> Vec>; - - /// It moves `who` from active to inactive group. - /// Any generated claim from `at` is considered as invalid. If `at` is `None` it will use `now` - /// by default. - /// If `expiry` is some value, that member will be removed automatically from this group at the - /// specific moment, and any generated claim will be invalidated. - fn disable_member( - who: IdentityId, - expiry: Option, - at: Option, - ) -> DispatchResult; - - /// Adds a member `who` to the group. - fn add_member(who: IdentityId) -> DispatchResult; - - /// It returns the current "active members" and any "inactive member" which its - /// expiration time-stamp is greater than `moment`. - fn get_valid_members_at(moment: Moment) -> Vec { - Self::get_active_members() - .into_iter() - .chain( - Self::get_inactive_members() - .into_iter() - .filter(|m| !Self::is_member_expired(&m, moment)) - .map(|m| m.id), - ) - .collect::>() - } - - fn is_member_expired(member: &InactiveMember, now: Moment) -> bool { - if let Some(expiry) = member.expiry { - expiry <= now - } else { - false - } - } - - #[inline] - fn get_active_members() -> Vec { - Self::get_members() - } - - /// Current set size - #[inline] - fn member_count() -> usize { - Self::get_members().len() - } - - #[inline] - fn is_member(member_id: &IdentityId) -> bool { - Self::get_members().contains(member_id) - } -} diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index 4dd6d89aaf..78a3dbf4e9 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -26,12 +26,11 @@ use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; use polymesh_primitives::{ - protocol_fee::ChargeProtocolFee, secondary_key::SecondaryKey, traits::CddAndFeeDetails, - AuthorizationData, Balance, CustomClaimTypeId, IdentityClaim, IdentityId, Permissions, Ticker, + protocol_fee::ChargeProtocolFee, secondary_key::SecondaryKey, traits::group::GroupTrait, + traits::CddAndFeeDetails, AuthorizationData, Balance, CustomClaimTypeId, IdentityClaim, + IdentityId, Permissions, Ticker, }; -use crate::traits::group::GroupTrait; - pub type AuthorizationNonce = u64; /// It represents an authorization that any account could sign to allow operations related with a diff --git a/pallets/contracts/src/benchmarking.rs b/pallets/contracts/src/benchmarking.rs index 480a4218ea..4f451c830a 100644 --- a/pallets/contracts/src/benchmarking.rs +++ b/pallets/contracts/src/benchmarking.rs @@ -30,7 +30,6 @@ use wasm_instrument::parity_wasm::elements::{Instruction, ValueType}; use pallet_identity::ParentDid; use polymesh_common_utilities::benchs::{cdd_provider, user, User, UserBuilder}; -use polymesh_common_utilities::group::GroupTrait; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::identity::limits::{ @@ -38,8 +37,8 @@ use polymesh_primitives::identity::limits::{ }; use polymesh_primitives::secondary_key::ExtrinsicNames; use polymesh_primitives::{ - AssetPermissions, Balance, ExtrinsicName, ExtrinsicPermissions, PalletName, PalletPermissions, - Permissions, PortfolioId, PortfolioNumber, PortfolioPermissions, + traits::group::GroupTrait, AssetPermissions, Balance, ExtrinsicName, ExtrinsicPermissions, + PalletName, PalletPermissions, Permissions, PortfolioId, PortfolioNumber, PortfolioPermissions, }; use crate::chain_extension::*; diff --git a/pallets/group/rpc/runtime-api/src/lib.rs b/pallets/group/rpc/runtime-api/src/lib.rs index ed614f3069..7c61143b45 100644 --- a/pallets/group/rpc/runtime-api/src/lib.rs +++ b/pallets/group/rpc/runtime-api/src/lib.rs @@ -1,7 +1,7 @@ //! Runtime API definition for group module. #![cfg_attr(not(feature = "std"), no_std)] -use polymesh_common_utilities::traits::group::InactiveMember; +use polymesh_primitives::traits::group::InactiveMember; use polymesh_primitives::{IdentityId, Moment}; use codec::{Decode, Encode}; diff --git a/pallets/group/src/benchmarking.rs b/pallets/group/src/benchmarking.rs index 6093ef46ca..f5f0477e8b 100644 --- a/pallets/group/src/benchmarking.rs +++ b/pallets/group/src/benchmarking.rs @@ -1,8 +1,9 @@ use crate::*; use polymesh_common_utilities::{ benchs::{User, UserBuilder}, - group::{Config, GroupTrait}, + group::Config, }; +use polymesh_primitives::traits::group::GroupTrait; use frame_benchmarking::benchmarks_instance; use frame_system::RawOrigin; diff --git a/pallets/group/src/lib.rs b/pallets/group/src/lib.rs index 8a8e87eaee..c6cc071999 100644 --- a/pallets/group/src/lib.rs +++ b/pallets/group/src/lib.rs @@ -79,10 +79,14 @@ pub mod benchmarking; use pallet_identity as identity; pub use polymesh_common_utilities::{ - group::{Config, GroupTrait, InactiveMember, MemberCount, RawEvent, WeightInfo}, + group::{Config, RawEvent, WeightInfo}, Context, }; -use polymesh_primitives::{committee::COMMITTEE_MEMBERS_MAX, IdentityId, GC_DID}; +use polymesh_primitives::{ + committee::COMMITTEE_MEMBERS_MAX, + traits::group::{GroupTrait, InactiveMember, MemberCount}, + IdentityId, GC_DID, +}; use frame_support::{ decl_error, decl_module, decl_storage, diff --git a/pallets/identity/src/claims.rs b/pallets/identity/src/claims.rs index e04c1c8f79..97e767f2b6 100644 --- a/pallets/identity/src/claims.rs +++ b/pallets/identity/src/claims.rs @@ -24,14 +24,12 @@ use frame_support::{ use frame_system::ensure_root; use pallet_base::{ensure_string_limited, try_next_pre}; -use polymesh_common_utilities::traits::{ - group::{GroupTrait, InactiveMember}, - identity::{Config, RawEvent}, -}; +use polymesh_common_utilities::traits::identity::{Config, RawEvent}; use polymesh_primitives::identity_claim::CustomClaimTypeId; use polymesh_primitives::{ - protocol_fee::ProtocolOp, CddId, Claim, ClaimType, IdentityClaim, IdentityId, Scope, - SecondaryKey, SystematicIssuers, + protocol_fee::ProtocolOp, + traits::group::{GroupTrait, InactiveMember}, + CddId, Claim, ClaimType, IdentityClaim, IdentityId, Scope, SecondaryKey, SystematicIssuers, }; use sp_runtime::traits::{CheckedAdd, SaturatedConversion, Zero}; use sp_std::prelude::*; diff --git a/pallets/identity/src/keys.rs b/pallets/identity/src/keys.rs index 1581aa0ae1..7d878e430b 100644 --- a/pallets/identity/src/keys.rs +++ b/pallets/identity/src/keys.rs @@ -28,7 +28,6 @@ use frame_support::{ use frame_system::ensure_signed; use pallet_base::{ensure_custom_length_ok, ensure_custom_string_limited}; use pallet_permissions::{AccountCallPermissionsData, CheckAccountCallPermissions}; -use polymesh_common_utilities::group::GroupTrait; use polymesh_common_utilities::identity::{ CreateChildIdentityWithAuth, SecondaryKeyWithAuth, TargetIdAuthorization, }; @@ -39,8 +38,8 @@ use polymesh_primitives::identity::limits::{ use polymesh_primitives::protocol_fee::{ChargeProtocolFee as _, ProtocolOp}; use polymesh_primitives::SystematicIssuers; use polymesh_primitives::{ - extract_auth, AuthorizationData, CddId, DidRecord, ExtrinsicName, ExtrinsicPermissions, - IdentityId, KeyRecord, PalletName, Permissions, SecondaryKey, Signatory, + extract_auth, traits::group::GroupTrait, AuthorizationData, CddId, DidRecord, ExtrinsicName, + ExtrinsicPermissions, IdentityId, KeyRecord, PalletName, Permissions, SecondaryKey, Signatory, }; use sp_core::sr25519::Signature; use sp_io::hashing::blake2_256; diff --git a/pallets/pips/src/lib.rs b/pallets/pips/src/lib.rs index 19a720d090..38ce0ba7b0 100644 --- a/pallets/pips/src/lib.rs +++ b/pallets/pips/src/lib.rs @@ -110,11 +110,11 @@ use pallet_base::{ensure_opt_string_limited, try_next_post}; use pallet_identity::PermissionedCallOriginData; use polymesh_common_utilities::traits::balances::LockableCurrencyExt; use polymesh_common_utilities::traits::governance_group::GovernanceGroupTrait; -use polymesh_common_utilities::traits::group::GroupTrait; use polymesh_common_utilities::traits::identity::Config as IdentityConfig; use polymesh_common_utilities::CommonConfig; use polymesh_primitives::constants::PIP_MAX_REPORTING_SIZE; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; +use polymesh_primitives::traits::group::GroupTrait; use polymesh_primitives::{storage_migration_ver, with_transaction}; use polymesh_primitives::{Balance, IdentityId, MaybeBlock, Url}; use polymesh_primitives::{GC_DID, TECHNICAL_DID, UPGRADE_DID}; diff --git a/pallets/runtime/common/src/lib.rs b/pallets/runtime/common/src/lib.rs index 41b25975f1..059cd986fe 100644 --- a/pallets/runtime/common/src/lib.rs +++ b/pallets/runtime/common/src/lib.rs @@ -218,7 +218,7 @@ impl Get>> for WeightToFee { } use pallet_group_rpc_runtime_api::Member; -use polymesh_common_utilities::traits::group::InactiveMember; +use polymesh_primitives::traits::group::InactiveMember; use sp_std::{convert::From, prelude::*}; /// It merges actives and in-actives members. diff --git a/pallets/runtime/tests/src/group_test.rs b/pallets/runtime/tests/src/group_test.rs index 21d7e21744..4a4864e29a 100644 --- a/pallets/runtime/tests/src/group_test.rs +++ b/pallets/runtime/tests/src/group_test.rs @@ -4,7 +4,7 @@ use super::{ }; use pallet_group::{self as group}; use pallet_identity as identity; -use polymesh_common_utilities::traits::group::GroupTrait; +use polymesh_primitives::traits::group::GroupTrait; use polymesh_primitives::IdentityId; use frame_support::{assert_noop, assert_ok, dispatch::DispatchError}; diff --git a/pallets/runtime/tests/src/identity_test.rs b/pallets/runtime/tests/src/identity_test.rs index d0894c00a5..49f6be3694 100644 --- a/pallets/runtime/tests/src/identity_test.rs +++ b/pallets/runtime/tests/src/identity_test.rs @@ -19,20 +19,17 @@ use frame_support::{ }; use pallet_balances as balances; use pallet_identity::{ChildDid, CustomClaimIdSequence, CustomClaims, CustomClaimsInverse}; -use polymesh_common_utilities::traits::{ - group::GroupTrait, - identity::{ - Config as IdentityConfig, CreateChildIdentityWithAuth, RawEvent, SecondaryKeyWithAuth, - TargetIdAuthorization, - }, +use polymesh_common_utilities::traits::identity::{ + Config as IdentityConfig, CreateChildIdentityWithAuth, RawEvent, SecondaryKeyWithAuth, + TargetIdAuthorization, }; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - constants::currency::POLY, traits::CddAndFeeDetails, AccountId, AssetPermissions, - AuthorizationData, AuthorizationType, Claim, ClaimType, CustomClaimTypeId, ExtrinsicName, - ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, PalletName, PalletPermissions, - Permissions, PortfolioId, PortfolioNumber, Scope, SecondaryKey, Signatory, SubsetRestriction, - SystematicIssuers, Ticker, TransactionError, GC_DID, + constants::currency::POLY, traits::group::GroupTrait, traits::CddAndFeeDetails, AccountId, + AssetPermissions, AuthorizationData, AuthorizationType, Claim, ClaimType, CustomClaimTypeId, + ExtrinsicName, ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, PalletName, + PalletPermissions, Permissions, PortfolioId, PortfolioNumber, Scope, SecondaryKey, Signatory, + SubsetRestriction, SystematicIssuers, Ticker, TransactionError, GC_DID, }; use polymesh_runtime_develop::runtime::{CddHandler, RuntimeCall}; use sp_core::H512; diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index 66d8262611..342c2859b5 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -42,7 +42,6 @@ use sp_staking::{EraIndex, SessionIndex}; use pallet_staking::types::SlashingSwitch; use pallet_staking::{self as pallet_staking, *}; use polymesh_common_utilities::traits::balances::{AccountData, CheckCdd}; -use polymesh_common_utilities::traits::group::{GroupTrait, InactiveMember}; use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_common_utilities::traits::CommonConfig; @@ -50,6 +49,7 @@ use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::identity_id::GenesisIdentityRecord; use polymesh_primitives::{ + traits::group::{GroupTrait, InactiveMember}, Authorization, AuthorizationData, Claim, IdentityId, Moment, NFTId, Permissions, PortfolioId, SecondaryKey, Signatory, }; diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index bad5ecfd34..4e1e76802f 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -46,14 +46,14 @@ use pallet_protocol_fee as protocol_fee; use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::RuntimeDispatchInfo; use pallet_utility; -use polymesh_common_utilities::traits::group::GroupTrait; use polymesh_common_utilities::Context; use polymesh_primitives::constants::currency::{DOLLARS, POLY}; use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; use polymesh_primitives::{ - traits::CddAndFeeDetails, AccountId, Authorization, AuthorizationData, BlockNumber, Claim, - Moment, Permissions as AuthPermissions, PortfolioNumber, Scope, SecondaryKey, TrustedFor, + traits::{group::GroupTrait, CddAndFeeDetails}, + AccountId, Authorization, AuthorizationData, BlockNumber, Claim, Moment, + Permissions as AuthPermissions, PortfolioNumber, Scope, SecondaryKey, TrustedFor, TrustedIssuer, }; use polymesh_runtime_common::merge_active_and_inactive; diff --git a/pallets/transaction-payment/src/lib.rs b/pallets/transaction-payment/src/lib.rs index c3d88f8004..001b5e0910 100644 --- a/pallets/transaction-payment/src/lib.rs +++ b/pallets/transaction-payment/src/lib.rs @@ -61,10 +61,11 @@ use frame_support::{ weights::{WeightToFee, WeightToFeeCoefficient, WeightToFeePolynomial}, }; use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; -use polymesh_common_utilities::traits::{ - group::GroupTrait, identity::IdentityFnTrait, relayer::SubsidiserTrait, +use polymesh_common_utilities::traits::{identity::IdentityFnTrait, relayer::SubsidiserTrait}; +use polymesh_primitives::{ + traits::{group::GroupTrait, CddAndFeeDetails}, + TransactionError, }; -use polymesh_primitives::{traits::CddAndFeeDetails, TransactionError}; use scale_info::TypeInfo; use sp_runtime::{ traits::{ diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index 357afe7cca..cd74aa41ef 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] // This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). // Copyright (c) 2020 Polymesh Association @@ -16,6 +17,8 @@ use crate::Balance; use sp_runtime::transaction_validity::InvalidTransaction; +pub mod group; + // Polymesh note: This was specifically added for Polymesh pub trait CddAndFeeDetails { fn get_valid_payer( diff --git a/primitives/src/traits/group.rs b/primitives/src/traits/group.rs new file mode 100644 index 0000000000..2e09314e39 --- /dev/null +++ b/primitives/src/traits/group.rs @@ -0,0 +1,135 @@ +#![allow(missing_docs)] +// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). +// Copyright (c) 2020 Polymesh Association + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3. + +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use crate::IdentityId; +use codec::{Decode, Encode}; +use frame_support::dispatch::DispatchResult; +use scale_info::TypeInfo; +use sp_std::{ + cmp::{Eq, Ordering, PartialEq}, + vec::Vec, +}; + +/// The number of group members. +pub type MemberCount = u32; + +#[derive(Encode, Decode, TypeInfo, Default, Clone, PartialEq, Eq, Debug)] +pub struct InactiveMember { + pub id: IdentityId, + pub deactivated_at: Moment, + pub expiry: Option, +} + +impl PartialOrd for InactiveMember +where + M: Eq, +{ + fn partial_cmp(&self, other: &InactiveMember) -> Option { + Some(self.cmp(other)) + } +} +impl PartialOrd for InactiveMember +where + M: Eq, +{ + fn partial_cmp(&self, other: &IdentityId) -> Option { + Some(self.id.cmp(other)) + } +} + +impl Ord for InactiveMember +where + M: Eq, +{ + fn cmp(&self, other: &InactiveMember) -> Ordering { + self.id.cmp(&other.id) + } +} + +impl PartialEq for InactiveMember { + fn eq(&self, other: &IdentityId) -> bool { + self.id.eq(other) + } +} + +impl From for InactiveMember { + fn from(id: IdentityId) -> Self { + InactiveMember { + id, + ..Default::default() + } + } +} + +pub trait GroupTrait { + /// Retrieve members + fn get_members() -> Vec; + + /// Retrieve valid members: active and revoked members. + fn get_inactive_members() -> Vec>; + + /// It moves `who` from active to inactive group. + /// Any generated claim from `at` is considered as invalid. If `at` is `None` it will use `now` + /// by default. + /// If `expiry` is some value, that member will be removed automatically from this group at the + /// specific moment, and any generated claim will be invalidated. + fn disable_member( + who: IdentityId, + expiry: Option, + at: Option, + ) -> DispatchResult; + + /// Adds a member `who` to the group. + fn add_member(who: IdentityId) -> DispatchResult; + + /// It returns the current "active members" and any "inactive member" which its + /// expiration time-stamp is greater than `moment`. + fn get_valid_members_at(moment: Moment) -> Vec { + Self::get_active_members() + .into_iter() + .chain( + Self::get_inactive_members() + .into_iter() + .filter(|m| !Self::is_member_expired(&m, moment)) + .map(|m| m.id), + ) + .collect::>() + } + + fn is_member_expired(member: &InactiveMember, now: Moment) -> bool { + if let Some(expiry) = member.expiry { + expiry <= now + } else { + false + } + } + + #[inline] + fn get_active_members() -> Vec { + Self::get_members() + } + + /// Current set size + #[inline] + fn member_count() -> usize { + Self::get_members().len() + } + + #[inline] + fn is_member(member_id: &IdentityId) -> bool { + Self::get_members().contains(member_id) + } +} From 2d43f9193a09ada2a9eaf2e3e61524fb5f068e64 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 04:51:34 +0800 Subject: [PATCH 14/45] Remove extra dep. --- Cargo.lock | 1 - pallets/identity/Cargo.toml | 2 -- 2 files changed, 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a77aba51dc..a3051d920a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5158,7 +5158,6 @@ dependencies = [ "hex", "hex-literal 0.3.4", "log", - "pallet-balances 0.1.0", "pallet-base", "pallet-permissions", "pallet-timestamp", diff --git a/pallets/identity/Cargo.toml b/pallets/identity/Cargo.toml index e21bf656e6..af22eeb3d6 100644 --- a/pallets/identity/Cargo.toml +++ b/pallets/identity/Cargo.toml @@ -5,7 +5,6 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -pallet-balances = { path = "../balances", default-features = false } pallet-base = { path = "../base", default-features = false } pallet-permissions = { path = "../permissions", default-features = false } polymesh-common-utilities = { path = "../common", default-features = false } @@ -50,7 +49,6 @@ std = [ "frame-support/std", "frame-system/std", "pallet-base/std", - "pallet-balances/std", "pallet-permissions/std", "pallet-timestamp/std", "polymesh-common-utilities/std", From 199b160673446fa722dda13ec2958bc024bc1048 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 05:03:44 +0800 Subject: [PATCH 15/45] Move TargetIdAuthorization, SecondaryKeyWithAuth, and CreateChildIdentityWithAuth to primitives. --- pallets/common/src/traits/identity.rs | 51 ++-------------------- pallets/identity/src/benchmarking.rs | 7 ++- pallets/identity/src/keys.rs | 6 +-- pallets/identity/src/lib.rs | 6 +-- pallets/runtime/tests/src/identity_test.rs | 18 ++++---- pallets/utility/src/lib.rs | 4 +- primitives/src/identity.rs | 48 ++++++++++++++++++++ 7 files changed, 70 insertions(+), 70 deletions(-) diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index 78a3dbf4e9..606847b46f 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -18,7 +18,6 @@ use frame_support::dispatch::{DispatchError, GetDispatchInfo, PostDispatchInfo, use frame_support::traits::{Currency, EnsureOrigin, Get, GetCallMetadata}; use frame_support::{decl_event, Parameter}; use scale_info::TypeInfo; -use sp_core::H512; use sp_runtime::traits::{Dispatchable, IdentifyAccount, Member, Verify}; use sp_std::vec::Vec; @@ -26,55 +25,11 @@ use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; use polymesh_primitives::{ - protocol_fee::ChargeProtocolFee, secondary_key::SecondaryKey, traits::group::GroupTrait, - traits::CddAndFeeDetails, AuthorizationData, Balance, CustomClaimTypeId, IdentityClaim, - IdentityId, Permissions, Ticker, + identity::SecondaryKeyWithAuth, protocol_fee::ChargeProtocolFee, secondary_key::SecondaryKey, + traits::group::GroupTrait, traits::CddAndFeeDetails, AuthorizationData, Balance, + CustomClaimTypeId, IdentityClaim, IdentityId, Permissions, Ticker, }; -pub type AuthorizationNonce = u64; - -/// It represents an authorization that any account could sign to allow operations related with a -/// target identity. -/// -/// # Safety -/// -/// Please note, that `nonce` has been added to avoid **replay attack** and it should be the current -/// value of nonce of primary key of `target_id`. See `System::account_nonce`. -/// In this way, the authorization is delimited to an specific transaction (usually the next one) -/// of primary key of target identity. -#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)] -pub struct TargetIdAuthorization { - /// Target identity which is authorized to make an operation. - pub target_id: IdentityId, - /// It HAS TO be `target_id` authorization nonce: See `Identity::offchain_authorization_nonce` - pub nonce: AuthorizationNonce, - pub expires_at: Moment, -} - -/// Secondary key with authorization of that secondary key (off-chain operation) to be added -/// to an identity. -/// -/// `auth_signature` is the signature, generated by secondary key, of `TargetIdAuthorization`. -#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, Eq, Debug)] -pub struct SecondaryKeyWithAuth { - /// Secondary key to be added. - pub secondary_key: SecondaryKey, - /// Off-chain authorization signature. - pub auth_signature: H512, -} - -/// Create a child identity using `key` as the primary key of the new child identity. -/// -/// The `key` needs to sign (off-chain) an authorization. -#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, Eq, Debug)] -pub struct CreateChildIdentityWithAuth { - /// The key to be used as the primary key of a new child identity. - pub key: AccountId, - /// Off-chain authorization signature. - /// The signature is generated by `key` signing of `TargetIdAuthorization`. - pub auth_signature: H512, -} - pub trait WeightInfo { fn create_child_identity() -> Weight; fn create_child_identities(i: u32) -> Weight; diff --git a/pallets/identity/src/benchmarking.rs b/pallets/identity/src/benchmarking.rs index d8acf042d3..ef5e5a8760 100644 --- a/pallets/identity/src/benchmarking.rs +++ b/pallets/identity/src/benchmarking.rs @@ -21,16 +21,15 @@ use sp_core::H512; use sp_std::prelude::*; use polymesh_common_utilities::benchs::{cdd_provider, user, user_without_did, UserBuilder}; -use polymesh_common_utilities::traits::identity::TargetIdAuthorization; use polymesh_primitives::asset::AssetId; use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, MAX_SECONDARY_KEYS, }; use polymesh_primitives::secondary_key::ExtrinsicNames; use polymesh_primitives::{ - AssetPermissions, AuthorizationData, Claim, CountryCode, ExtrinsicName, ExtrinsicPermissions, - PalletName, PalletPermissions, Permissions, PortfolioId, PortfolioNumber, PortfolioPermissions, - Scope, SecondaryKey, Signatory, + identity::TargetIdAuthorization, AssetPermissions, AuthorizationData, Claim, CountryCode, + ExtrinsicName, ExtrinsicPermissions, PalletName, PalletPermissions, Permissions, PortfolioId, + PortfolioNumber, PortfolioPermissions, Scope, SecondaryKey, Signatory, }; const SEED: u32 = 0; diff --git a/pallets/identity/src/keys.rs b/pallets/identity/src/keys.rs index 7d878e430b..514c9078bd 100644 --- a/pallets/identity/src/keys.rs +++ b/pallets/identity/src/keys.rs @@ -28,13 +28,13 @@ use frame_support::{ use frame_system::ensure_signed; use pallet_base::{ensure_custom_length_ok, ensure_custom_string_limited}; use pallet_permissions::{AccountCallPermissionsData, CheckAccountCallPermissions}; -use polymesh_common_utilities::identity::{ - CreateChildIdentityWithAuth, SecondaryKeyWithAuth, TargetIdAuthorization, -}; use polymesh_primitives::constants::did::USER; use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; +use polymesh_primitives::identity::{ + CreateChildIdentityWithAuth, SecondaryKeyWithAuth, TargetIdAuthorization, +}; use polymesh_primitives::protocol_fee::{ChargeProtocolFee as _, ProtocolOp}; use polymesh_primitives::SystematicIssuers; use polymesh_primitives::{ diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index c455fbcf1c..d5b920d470 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -99,12 +99,10 @@ use frame_support::dispatch::DispatchClass::{Normal, Operational}; use frame_support::dispatch::{DispatchError, DispatchResult, Pays, Weight}; use frame_support::traits::{ChangeMembers, Currency, EnsureOrigin, Get, InitializeMembers}; use frame_support::{decl_error, decl_module, decl_storage}; -use polymesh_common_utilities::traits::identity::{ - AuthorizationNonce, Config, CreateChildIdentityWithAuth, IdentityFnTrait, RawEvent, - SecondaryKeyWithAuth, -}; +use polymesh_common_utilities::traits::identity::{Config, IdentityFnTrait, RawEvent}; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{ + identity::{AuthorizationNonce, CreateChildIdentityWithAuth, SecondaryKeyWithAuth}, storage_migration_ver, AssetPermissions, Authorization, AuthorizationData, AuthorizationType, CddId, Claim, ClaimType, CustomClaimTypeId, DidRecord, ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, Permissions, PortfolioPermissions, Scope, SecondaryKey, Signatory, diff --git a/pallets/runtime/tests/src/identity_test.rs b/pallets/runtime/tests/src/identity_test.rs index 49f6be3694..70a6af14a7 100644 --- a/pallets/runtime/tests/src/identity_test.rs +++ b/pallets/runtime/tests/src/identity_test.rs @@ -19,17 +19,17 @@ use frame_support::{ }; use pallet_balances as balances; use pallet_identity::{ChildDid, CustomClaimIdSequence, CustomClaims, CustomClaimsInverse}; -use polymesh_common_utilities::traits::identity::{ - Config as IdentityConfig, CreateChildIdentityWithAuth, RawEvent, SecondaryKeyWithAuth, - TargetIdAuthorization, -}; +use polymesh_common_utilities::traits::identity::{Config as IdentityConfig, RawEvent}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - constants::currency::POLY, traits::group::GroupTrait, traits::CddAndFeeDetails, AccountId, - AssetPermissions, AuthorizationData, AuthorizationType, Claim, ClaimType, CustomClaimTypeId, - ExtrinsicName, ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, PalletName, - PalletPermissions, Permissions, PortfolioId, PortfolioNumber, Scope, SecondaryKey, Signatory, - SubsetRestriction, SystematicIssuers, Ticker, TransactionError, GC_DID, + constants::currency::POLY, + identity::{CreateChildIdentityWithAuth, SecondaryKeyWithAuth, TargetIdAuthorization}, + traits::group::GroupTrait, + traits::CddAndFeeDetails, + AccountId, AssetPermissions, AuthorizationData, AuthorizationType, Claim, ClaimType, + CustomClaimTypeId, ExtrinsicName, ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, + PalletName, PalletPermissions, Permissions, PortfolioId, PortfolioNumber, Scope, SecondaryKey, + Signatory, SubsetRestriction, SystematicIssuers, Ticker, TransactionError, GC_DID, }; use polymesh_runtime_develop::runtime::{CddHandler, RuntimeCall}; use sp_core::H512; diff --git a/pallets/utility/src/lib.rs b/pallets/utility/src/lib.rs index b0f9fb3858..0201536cd4 100644 --- a/pallets/utility/src/lib.rs +++ b/pallets/utility/src/lib.rs @@ -86,9 +86,9 @@ use sp_std::prelude::*; use pallet_permissions::with_call_metadata; use polymesh_common_utilities::balances::{CheckCdd, Config as BalancesConfig}; -use polymesh_common_utilities::identity::{AuthorizationNonce, Config as IdentityConfig}; +use polymesh_common_utilities::identity::Config as IdentityConfig; use polymesh_common_utilities::Context; -use polymesh_primitives::IdentityId; +use polymesh_primitives::{identity::AuthorizationNonce, IdentityId}; type Identity = pallet_identity::Module; diff --git a/primitives/src/identity.rs b/primitives/src/identity.rs index eca4845836..9d3f8dff03 100644 --- a/primitives/src/identity.rs +++ b/primitives/src/identity.rs @@ -1,3 +1,4 @@ +#![allow(missing_docs)] // This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). // Copyright (c) 2020 Polymesh Association @@ -18,6 +19,9 @@ use sp_runtime::{Deserialize, Serialize}; use codec::{Decode, Encode}; use scale_info::TypeInfo; +use sp_core::H512; + +use crate::{secondary_key::SecondaryKey, IdentityId}; #[cfg(feature = "running-ci")] /// Defines the constants for the identity pallet. @@ -76,3 +80,47 @@ impl DidRecord { } } } + +pub type AuthorizationNonce = u64; + +/// It represents an authorization that any account could sign to allow operations related with a +/// target identity. +/// +/// # Safety +/// +/// Please note, that `nonce` has been added to avoid **replay attack** and it should be the current +/// value of nonce of primary key of `target_id`. See `System::account_nonce`. +/// In this way, the authorization is delimited to an specific transaction (usually the next one) +/// of primary key of target identity. +#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)] +pub struct TargetIdAuthorization { + /// Target identity which is authorized to make an operation. + pub target_id: IdentityId, + /// It HAS TO be `target_id` authorization nonce: See `Identity::offchain_authorization_nonce` + pub nonce: AuthorizationNonce, + pub expires_at: Moment, +} + +/// Secondary key with authorization of that secondary key (off-chain operation) to be added +/// to an identity. +/// +/// `auth_signature` is the signature, generated by secondary key, of `TargetIdAuthorization`. +#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, Eq, Debug)] +pub struct SecondaryKeyWithAuth { + /// Secondary key to be added. + pub secondary_key: SecondaryKey, + /// Off-chain authorization signature. + pub auth_signature: H512, +} + +/// Create a child identity using `key` as the primary key of the new child identity. +/// +/// The `key` needs to sign (off-chain) an authorization. +#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, Eq, Debug)] +pub struct CreateChildIdentityWithAuth { + /// The key to be used as the primary key of a new child identity. + pub key: AccountId, + /// Off-chain authorization signature. + /// The signature is generated by `key` signing of `TargetIdAuthorization`. + pub auth_signature: H512, +} From dfa6363eaea2603a74188e0393f5f2036ddf56b6 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 05:13:36 +0800 Subject: [PATCH 16/45] Move IdentityFnTrait trait to primitives. --- pallets/balances/src/lib.rs | 3 +-- pallets/common/src/benchs/user_builder.rs | 4 ++-- pallets/common/src/context.rs | 2 +- pallets/common/src/traits/identity.rs | 26 ++++++----------------- pallets/identity/src/lib.rs | 10 +++++---- pallets/staking/src/pallet/impls.rs | 2 +- pallets/staking/src/pallet/mod.rs | 4 ++-- pallets/transaction-payment/src/lib.rs | 4 ++-- primitives/src/traits.rs | 18 +++++++++++++++- 9 files changed, 39 insertions(+), 34 deletions(-) diff --git a/pallets/balances/src/lib.rs b/pallets/balances/src/lib.rs index 96ac308182..f12ad85b10 100644 --- a/pallets/balances/src/lib.rs +++ b/pallets/balances/src/lib.rs @@ -179,10 +179,9 @@ use frame_system::{self as system, ensure_root, ensure_signed}; pub use polymesh_common_utilities::traits::balances::WeightInfo; use polymesh_common_utilities::traits::{ balances::{AccountData, BalancesTrait, CheckCdd, RawEvent, Reasons}, - identity::IdentityFnTrait, NegativeImbalance, PositiveImbalance, }; -use polymesh_primitives::traits::BlockRewardsReserveCurrency; +use polymesh_primitives::traits::{BlockRewardsReserveCurrency, IdentityFnTrait}; use polymesh_primitives::{Balance, Memo, SystematicIssuers, GC_DID}; use scale_info::TypeInfo; use sp_runtime::{ diff --git a/pallets/common/src/benchs/user_builder.rs b/pallets/common/src/benchs/user_builder.rs index ee32627364..33d921685a 100644 --- a/pallets/common/src/benchs/user_builder.rs +++ b/pallets/common/src/benchs/user_builder.rs @@ -14,14 +14,14 @@ // along with this program. If not, see . use crate::{ benchs::{SecretKey, User}, - traits::identity::{Config, IdentityFnTrait}, + traits::identity::Config, }; use schnorrkel::{ExpansionMode, MiniSecretKey}; use codec::{Decode, Encode}; use frame_support::traits::Currency; use frame_system::RawOrigin; -use polymesh_primitives::traits::group::GroupTrait; +use polymesh_primitives::traits::{group::GroupTrait, IdentityFnTrait}; use polymesh_primitives::IdentityId; use sp_io::hashing::blake2_256; use sp_std::prelude::*; diff --git a/pallets/common/src/context.rs b/pallets/common/src/context.rs index 419ab0e782..03876a40db 100644 --- a/pallets/common/src/context.rs +++ b/pallets/common/src/context.rs @@ -1,4 +1,4 @@ -use crate::traits::identity::IdentityFnTrait; +use polymesh_primitives::traits::IdentityFnTrait; use sp_std::marker::PhantomData; /// Helper class to access to some context information. diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs index 606847b46f..d97bcd9ea3 100644 --- a/pallets/common/src/traits/identity.rs +++ b/pallets/common/src/traits/identity.rs @@ -14,7 +14,7 @@ // along with this program. If not, see . use codec::{Decode, Encode}; -use frame_support::dispatch::{DispatchError, GetDispatchInfo, PostDispatchInfo, Weight}; +use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo, Weight}; use frame_support::traits::{Currency, EnsureOrigin, Get, GetCallMetadata}; use frame_support::{decl_event, Parameter}; use scale_info::TypeInfo; @@ -25,9 +25,12 @@ use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, }; use polymesh_primitives::{ - identity::SecondaryKeyWithAuth, protocol_fee::ChargeProtocolFee, secondary_key::SecondaryKey, - traits::group::GroupTrait, traits::CddAndFeeDetails, AuthorizationData, Balance, - CustomClaimTypeId, IdentityClaim, IdentityId, Permissions, Ticker, + identity::SecondaryKeyWithAuth, + protocol_fee::ChargeProtocolFee, + secondary_key::SecondaryKey, + traits::group::GroupTrait, + traits::{CddAndFeeDetails, IdentityFnTrait}, + AuthorizationData, Balance, CustomClaimTypeId, IdentityClaim, IdentityId, Permissions, Ticker, }; pub trait WeightInfo { @@ -279,18 +282,3 @@ decl_event!( ChildDidUnlinked(IdentityId, IdentityId, IdentityId), } ); - -pub trait IdentityFnTrait { - fn get_identity(key: &AccountId) -> Option; - fn current_payer() -> Option; - fn set_current_payer(payer: Option); - - /// Provides the DID status for the given DID - fn has_valid_cdd(target_did: IdentityId) -> bool; - - /// Creates a new did and attaches a CDD claim. - fn testing_cdd_register_did( - target: AccountId, - secondary_keys: sp_std::vec::Vec>, - ) -> Result; -} diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index d5b920d470..19405df27c 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -99,13 +99,15 @@ use frame_support::dispatch::DispatchClass::{Normal, Operational}; use frame_support::dispatch::{DispatchError, DispatchResult, Pays, Weight}; use frame_support::traits::{ChangeMembers, Currency, EnsureOrigin, Get, InitializeMembers}; use frame_support::{decl_error, decl_module, decl_storage}; -use polymesh_common_utilities::traits::identity::{Config, IdentityFnTrait, RawEvent}; +use polymesh_common_utilities::traits::identity::{Config, RawEvent}; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{ identity::{AuthorizationNonce, CreateChildIdentityWithAuth, SecondaryKeyWithAuth}, - storage_migration_ver, AssetPermissions, Authorization, AuthorizationData, AuthorizationType, - CddId, Claim, ClaimType, CustomClaimTypeId, DidRecord, ExtrinsicPermissions, IdentityClaim, - IdentityId, KeyRecord, Permissions, PortfolioPermissions, Scope, SecondaryKey, Signatory, + storage_migration_ver, + traits::IdentityFnTrait, + AssetPermissions, Authorization, AuthorizationData, AuthorizationType, CddId, Claim, ClaimType, + CustomClaimTypeId, DidRecord, ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, + Permissions, PortfolioPermissions, Scope, SecondaryKey, Signatory, }; use polymesh_primitives::{SystematicIssuers, GC_DID}; diff --git a/pallets/staking/src/pallet/impls.rs b/pallets/staking/src/pallet/impls.rs index 4395c0652f..b33c5c05da 100644 --- a/pallets/staking/src/pallet/impls.rs +++ b/pallets/staking/src/pallet/impls.rs @@ -57,7 +57,7 @@ use frame_support::traits::schedule::Anon; use frame_support::traits::schedule::{DispatchTime, HIGHEST_PRIORITY}; use frame_support::traits::DefensiveSaturating; -use polymesh_common_utilities::identity::IdentityFnTrait; +use polymesh_primitives::traits::IdentityFnTrait; use polymesh_primitives::IdentityId; use polymesh_primitives::GC_DID; diff --git a/pallets/staking/src/pallet/mod.rs b/pallets/staking/src/pallet/mod.rs index 1355daeea8..c47f793cd2 100644 --- a/pallets/staking/src/pallet/mod.rs +++ b/pallets/staking/src/pallet/mod.rs @@ -56,10 +56,10 @@ use frame_system::offchain::SendTransactionTypes; use sp_runtime::traits::{AccountIdConversion, Dispatchable}; use sp_runtime::Permill; -use polymesh_common_utilities::identity::{Config as IdentityConfig, IdentityFnTrait}; +use polymesh_common_utilities::identity::Config as IdentityConfig; use polymesh_primitives::constants::GC_PALLET_ID; use polymesh_primitives::GC_DID; -use polymesh_primitives::{storage_migration_ver, IdentityId}; +use polymesh_primitives::{storage_migration_ver, traits::IdentityFnTrait, IdentityId}; use crate::types::{PermissionedIdentityPrefs, SlashingSwitch}; // ----------------------------------------------------------------- diff --git a/pallets/transaction-payment/src/lib.rs b/pallets/transaction-payment/src/lib.rs index 001b5e0910..e3547ec120 100644 --- a/pallets/transaction-payment/src/lib.rs +++ b/pallets/transaction-payment/src/lib.rs @@ -61,9 +61,9 @@ use frame_support::{ weights::{WeightToFee, WeightToFeeCoefficient, WeightToFeePolynomial}, }; use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; -use polymesh_common_utilities::traits::{identity::IdentityFnTrait, relayer::SubsidiserTrait}; +use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_primitives::{ - traits::{group::GroupTrait, CddAndFeeDetails}, + traits::{group::GroupTrait, CddAndFeeDetails, IdentityFnTrait}, TransactionError, }; use scale_info::TypeInfo; diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index cd74aa41ef..2658d95f05 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -14,7 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::Balance; +use crate::{secondary_key::SecondaryKey, Balance, IdentityId}; +use frame_support::dispatch::DispatchError; use sp_runtime::transaction_validity::InvalidTransaction; pub mod group; @@ -30,6 +31,21 @@ pub trait CddAndFeeDetails { fn get_payer_from_context() -> Option; } +pub trait IdentityFnTrait { + fn get_identity(key: &AccountId) -> Option; + fn current_payer() -> Option; + fn set_current_payer(payer: Option); + + /// Provides the DID status for the given DID + fn has_valid_cdd(target_did: IdentityId) -> bool; + + /// Creates a new did and attaches a CDD claim. + fn testing_cdd_register_did( + target: AccountId, + secondary_keys: sp_std::vec::Vec>, + ) -> Result; +} + /// A currency that has a block rewards reserve. pub trait BlockRewardsReserveCurrency { /// An instance of `Drop` for positive imbalance. From f8db2e26adf7cf4496d350466a0b02d1799b2a73 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 20:34:23 +0800 Subject: [PATCH 17/45] Move WeightInfo, Config, Events and UserBuilder into the Identity pallet. --- Cargo.lock | 4 +- Cargo.toml | 18 +- pallets/asset/Cargo.toml | 22 +- pallets/asset/src/benchmarking.rs | 3 +- pallets/asset/src/checkpoint/benchmarking.rs | 2 +- pallets/balances/Cargo.toml | 14 +- pallets/balances/src/benchmarking.rs | 2 +- pallets/bridge/Cargo.toml | 12 +- pallets/committee/Cargo.toml | 8 +- pallets/committee/src/benchmarking.rs | 2 +- pallets/committee/src/lib.rs | 15 +- pallets/common/Cargo.toml | 7 +- pallets/common/src/benchs/asset.rs | 2 +- pallets/common/src/benchs/mod.rs | 27 +- pallets/common/src/benchs/user.rs | 55 ---- pallets/common/src/lib.rs | 4 +- pallets/common/src/traits/balances.rs | 4 +- .../common/src/traits/compliance_manager.rs | 3 +- pallets/common/src/traits/group.rs | 3 +- pallets/common/src/traits/identity.rs | 284 ----------------- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/nft.rs | 4 +- pallets/common/src/traits/portfolio.rs | 4 +- pallets/common/src/traits/relayer.rs | 3 +- pallets/common/src/traits/statistics.rs | 2 +- pallets/compliance-manager/Cargo.toml | 16 +- .../compliance-manager/src/benchmarking.rs | 4 +- pallets/contracts/Cargo.toml | 10 +- pallets/contracts/src/benchmarking.rs | 2 +- pallets/contracts/src/lib.rs | 5 +- pallets/corporate-actions/Cargo.toml | 20 +- .../src/ballot/benchmarking.rs | 2 +- pallets/corporate-actions/src/benchmarking.rs | 3 +- .../src/distribution/benchmarking.rs | 2 +- pallets/corporate-actions/src/lib.rs | 5 +- pallets/external-agents/Cargo.toml | 12 +- pallets/external-agents/src/benchmarking.rs | 3 +- pallets/group/Cargo.toml | 6 +- pallets/group/rpc/Cargo.toml | 4 +- pallets/group/rpc/runtime-api/Cargo.toml | 4 +- pallets/group/src/benchmarking.rs | 6 +- pallets/identity/Cargo.toml | 9 +- pallets/identity/src/benchmarking.rs | 9 +- .../src/benchmarking/user.rs} | 64 +++- pallets/identity/src/claims.rs | 5 +- pallets/identity/src/lib.rs | 291 ++++++++++++++++-- pallets/multisig/Cargo.toml | 10 +- pallets/multisig/src/benchmarking.rs | 2 +- pallets/multisig/src/lib.rs | 3 +- pallets/nft/Cargo.toml | 14 +- pallets/nft/src/benchmarking.rs | 3 +- pallets/permissions/Cargo.toml | 2 +- pallets/pips/Cargo.toml | 22 +- pallets/pips/src/benchmarking.rs | 2 +- pallets/pips/src/lib.rs | 3 +- pallets/portfolio/Cargo.toml | 12 +- pallets/portfolio/src/benchmarking.rs | 3 +- pallets/protocol-fee/Cargo.toml | 9 +- pallets/protocol-fee/rpc/Cargo.toml | 4 +- pallets/protocol-fee/src/lib.rs | 5 +- pallets/relayer/Cargo.toml | 6 +- pallets/relayer/src/benchmarking.rs | 6 +- pallets/runtime/common/Cargo.toml | 16 +- pallets/runtime/common/src/cdd_check.rs | 7 +- pallets/runtime/common/src/fee_details.rs | 21 +- pallets/runtime/develop/Cargo.toml | 70 ++--- pallets/runtime/develop/src/runtime.rs | 2 +- pallets/runtime/mainnet/Cargo.toml | 70 ++--- pallets/runtime/mainnet/src/runtime.rs | 2 +- pallets/runtime/testnet/Cargo.toml | 70 ++--- pallets/runtime/testnet/src/runtime.rs | 2 +- pallets/runtime/tests/Cargo.toml | 70 ++--- pallets/runtime/tests/src/identity_test.rs | 2 +- pallets/runtime/tests/src/staking/mock.rs | 2 +- pallets/runtime/tests/src/storage.rs | 2 +- pallets/settlement/Cargo.toml | 22 +- pallets/settlement/src/benchmarking.rs | 3 +- pallets/settlement/src/lib.rs | 6 +- pallets/staking/Cargo.toml | 6 +- pallets/staking/rpc/Cargo.toml | 2 +- pallets/staking/src/benchmarking.rs | 2 +- pallets/staking/src/pallet/mod.rs | 2 +- pallets/staking/src/testing_utils.rs | 2 +- pallets/statistics/Cargo.toml | 8 +- pallets/statistics/src/benchmarking.rs | 3 +- pallets/sto/Cargo.toml | 24 +- pallets/sto/src/benchmarking.rs | 2 +- pallets/sto/src/lib.rs | 4 +- pallets/transaction-payment/Cargo.toml | 6 +- pallets/treasury/Cargo.toml | 10 +- pallets/treasury/src/benchmarking.rs | 2 +- pallets/utility/Cargo.toml | 13 +- pallets/utility/src/benchmarking.rs | 2 +- pallets/utility/src/lib.rs | 2 +- pallets/weights/Cargo.toml | 44 +-- 95 files changed, 770 insertions(+), 824 deletions(-) delete mode 100644 pallets/common/src/benchs/user.rs delete mode 100644 pallets/common/src/traits/identity.rs rename pallets/{common/src/benchs/user_builder.rs => identity/src/benchmarking/user.rs} (73%) diff --git a/Cargo.lock b/Cargo.lock index a3051d920a..d5b9d46d38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4800,6 +4800,7 @@ dependencies = [ "frame-support", "frame-system", "log", + "pallet-identity", "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", @@ -5162,7 +5163,6 @@ dependencies = [ "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "schnorrkel 0.11.4", @@ -5382,6 +5382,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "pallet-identity", "parity-scale-codec 3.6.9", "polymesh-common-utilities", "polymesh-primitives", @@ -6267,6 +6268,7 @@ dependencies = [ "frame-system", "lazy_static", "pallet-base", + "pallet-identity", "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", diff --git a/Cargo.toml b/Cargo.toml index 4d3c6d87e1..8c1c9b2bbf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,6 +142,7 @@ members = [ "pallets/utility", "pallets/weights", "primitives", + "primitives_derive", "primitives/asset-metadata", "rpc", "rpc/runtime-api", @@ -187,17 +188,18 @@ polymesh-contracts = { path = "pallets/contracts", default-features = false } polymesh-common-utilities = { path = "pallets/common", default-features = false } polymesh-runtime-common = { path = "pallets/runtime/common", default-features = false } polymesh-primitives = { path = "primitives", default-features = false } +polymesh-primitives-derive = { path = "primitives_derive", default-features = false } polymesh-weights = { path = "pallets/weights/", default-features = false } # RPC -node-rpc = { path = "rpc" } -node-rpc-runtime-api = { path = "rpc/runtime-api" } -pallet-group-rpc = { path = "pallets/group/rpc" } -pallet-group-rpc-runtime-api = { path = "pallets/group/rpc/runtime-api" } -pallet-protocol-fee-rpc = { path = "pallets/protocol-fee/rpc" } -pallet-protocol-fee-rpc-runtime-api = { path = "pallets/protocol-fee/rpc/runtime-api" } -pallet-staking-rpc-runtime-api = { path = "pallets/staking/rpc/runtime-api" } -polymesh-node-rpc = { path = "node-rpc" } +node-rpc = { path = "rpc", default-features = false } +node-rpc-runtime-api = { path = "rpc/runtime-api", default-features = false } +pallet-group-rpc = { path = "pallets/group/rpc", default-features = false } +pallet-group-rpc-runtime-api = { path = "pallets/group/rpc/runtime-api", default-features = false } +pallet-protocol-fee-rpc = { path = "pallets/protocol-fee/rpc", default-features = false } +pallet-protocol-fee-rpc-runtime-api = { path = "pallets/protocol-fee/rpc/runtime-api", default-features = false } +pallet-staking-rpc-runtime-api = { path = "pallets/staking/rpc/runtime-api", default-features = false } +polymesh-node-rpc = { path = "node-rpc", default-features = false } # Runtimes polymesh-runtime-develop = { path = "pallets/runtime/develop" } diff --git a/pallets/asset/Cargo.toml b/pallets/asset/Cargo.toml index 6c0f56612d..e2c60f74be 100644 --- a/pallets/asset/Cargo.toml +++ b/pallets/asset/Cargo.toml @@ -6,19 +6,19 @@ edition = "2021" [dependencies] # Common -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-primitives-derive = { path = "../../primitives_derive", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-primitives-derive = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets -pallet-balances = { path = "../balances", default-features = false } -pallet-base = { path = "../base", default-features = false } -pallet-external-agents = { path = "../external-agents", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } -pallet-portfolio = { path = "../portfolio", default-features = false } -pallet-statistics = { path = "../statistics", default-features = false } -polymesh-runtime-common = { path = "../runtime/common", default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } +pallet-statistics = { workspace = true, default-features = false } +polymesh-runtime-common = { workspace = true, default-features = false } # Other serde = { version = "1.0.104", default-features = false } diff --git a/pallets/asset/src/benchmarking.rs b/pallets/asset/src/benchmarking.rs index 8d08281be3..a8e720d060 100644 --- a/pallets/asset/src/benchmarking.rs +++ b/pallets/asset/src/benchmarking.rs @@ -20,8 +20,9 @@ use scale_info::prelude::format; use sp_std::collections::btree_set::BTreeSet; use sp_std::{convert::TryInto, iter, prelude::*}; +use pallet_identity::benchmarking::{user, User, UserBuilder}; use pallet_statistics::benchmarking::setup_transfer_restrictions; -use polymesh_common_utilities::benchs::{reg_unique_ticker, user, User, UserBuilder}; +use polymesh_common_utilities::benchs::reg_unique_ticker; use polymesh_common_utilities::traits::compliance_manager::ComplianceFnConfig; use polymesh_common_utilities::traits::nft::NFTTrait; use polymesh_primitives::agent::AgentGroup; diff --git a/pallets/asset/src/checkpoint/benchmarking.rs b/pallets/asset/src/checkpoint/benchmarking.rs index 83be0ae60f..95ee082e9c 100644 --- a/pallets/asset/src/checkpoint/benchmarking.rs +++ b/pallets/asset/src/checkpoint/benchmarking.rs @@ -16,7 +16,7 @@ use frame_benchmarking::benchmarks; use frame_system::RawOrigin; -use polymesh_common_utilities::benchs::{User, UserBuilder}; +use pallet_identity::benchmarking::{User, UserBuilder}; use super::*; use crate::benchmarking::create_sample_asset; diff --git a/pallets/balances/Cargo.toml b/pallets/balances/Cargo.toml index cd8a6cd110..c8a919b018 100644 --- a/pallets/balances/Cargo.toml +++ b/pallets/balances/Cargo.toml @@ -5,9 +5,11 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -pallet-permissions = { path = "../permissions", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } +# Our pallets +pallet-permissions = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } log = "0.4.8" serde = { version = "1.0.104", default-features = false } @@ -49,8 +51,12 @@ std = [ "pallet-timestamp/std", "polymesh-common-utilities/std", "polymesh-primitives/std", + "pallet-permissions/std", + "pallet-identity/std", ] runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks" + "polymesh-common-utilities/runtime-benchmarks", + "pallet-permissions/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", ] diff --git a/pallets/balances/src/benchmarking.rs b/pallets/balances/src/benchmarking.rs index 34bdd96bc4..6f46d1c98c 100644 --- a/pallets/balances/src/benchmarking.rs +++ b/pallets/balances/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; use crate::Module as Balances; use frame_benchmarking::benchmarks; use frame_system::RawOrigin; -use polymesh_common_utilities::benchs::UserBuilder; +use pallet_identity::benchmarking::UserBuilder; fn make_worst_memo() -> Option { Some(Memo([7u8; 32])) diff --git a/pallets/bridge/Cargo.toml b/pallets/bridge/Cargo.toml index d3aa058669..5c2090e95d 100644 --- a/pallets/bridge/Cargo.toml +++ b/pallets/bridge/Cargo.toml @@ -5,13 +5,13 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } -pallet-balances = { path = "../balances", default-features = false } -pallet-base = { path = "../base", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-multisig = { path = "../multisig", default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-multisig = { workspace = true, default-features = false } # Substrate codec = { workspace = true, default-features = false, features = ["derive"] } diff --git a/pallets/committee/Cargo.toml b/pallets/committee/Cargo.toml index 1c6e10dbcc..fbb2200e7a 100644 --- a/pallets/committee/Cargo.toml +++ b/pallets/committee/Cargo.toml @@ -5,10 +5,10 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { path = "../common", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } -pallet-identity = { path = "../identity", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } # General serde = { version = "1.0.104", default-features = false } diff --git a/pallets/committee/src/benchmarking.rs b/pallets/committee/src/benchmarking.rs index 116cb049f3..f0db53da30 100644 --- a/pallets/committee/src/benchmarking.rs +++ b/pallets/committee/src/benchmarking.rs @@ -21,7 +21,7 @@ use frame_support::{ StorageValue, }; use frame_system::RawOrigin as SystemOrigin; -use polymesh_common_utilities::benchs::{user, User}; +use pallet_identity::benchmarking::{user, User}; use polymesh_primitives::committee::COMMITTEE_MEMBERS_MAX; use polymesh_primitives::MaybeBlock; use sp_std::prelude::*; diff --git a/pallets/committee/src/lib.rs b/pallets/committee/src/lib.rs index e2259b27f3..fca264ec29 100644 --- a/pallets/committee/src/lib.rs +++ b/pallets/committee/src/lib.rs @@ -70,10 +70,7 @@ use frame_support::{ ensure, traits::{ChangeMembers, EnsureOrigin, InitializeMembers}, }; -use pallet_identity as identity; -use polymesh_common_utilities::{ - governance_group::GovernanceGroupTrait, identity::Config as IdentityConfig, -}; +use polymesh_common_utilities::governance_group::GovernanceGroupTrait; use polymesh_primitives::{ storage_migration_ver, traits::group::{GroupTrait, InactiveMember, MemberCount}, @@ -102,7 +99,7 @@ pub trait WeightInfo { pub type ProposalIndex = u32; /// The committee trait. -pub trait Config: frame_system::Config + IdentityConfig { +pub trait Config: frame_system::Config + pallet_identity::Config { /// The outer origin type. type RuntimeOrigin: From> + Into<::RuntimeOrigin>; @@ -247,7 +244,7 @@ decl_error! { } } -type Identity = identity::Module; +type Identity = pallet_identity::Module; decl_module! { pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: >::RuntimeOrigin { @@ -662,8 +659,8 @@ impl, I: Instance> ChangeMembers for Module { // Add/remove Systematic CDD claims for new/removed members. let issuer = SystematicIssuers::Committee; - >::add_systematic_cdd_claims(incoming, issuer); - >::revoke_systematic_cdd_claims(outgoing, issuer); + >::add_systematic_cdd_claims(incoming, issuer); + >::revoke_systematic_cdd_claims(outgoing, issuer); } } @@ -678,7 +675,7 @@ impl, I: Instance> InitializeMembers for Module { >::get().is_empty(), "Members are already initialized!" ); - >::add_systematic_cdd_claims(members, SystematicIssuers::Committee); + >::add_systematic_cdd_claims(members, SystematicIssuers::Committee); >::put(members); } } diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index 103cccbb4f..c20cb22399 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -5,12 +5,13 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-primitives-derive = { path = "../../primitives_derive", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-primitives-derive = { workspace = true, default-features = false } # Our Pallets pallet-base = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } # Other serde = { version = "1.0.112", default-features = false } @@ -56,6 +57,7 @@ std = [ "pallet-timestamp/std", "pallet-base/std", "pallet-permissions/std", + "pallet-identity/std", "polymesh-primitives/std", "serde/std", "serde_derive", @@ -69,5 +71,6 @@ std = [ runtime-benchmarks = [ "frame-benchmarking", "pallet-permissions/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", "schnorrkel", ] diff --git a/pallets/common/src/benchs/asset.rs b/pallets/common/src/benchs/asset.rs index 8ab8a5e872..bad0b72bfd 100644 --- a/pallets/common/src/benchs/asset.rs +++ b/pallets/common/src/benchs/asset.rs @@ -4,8 +4,8 @@ use polymesh_primitives::asset::{AssetId, AssetName, AssetType}; use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::{PortfolioKind, Ticker}; -use crate::benchs::User; use crate::traits::asset::{AssetFnTrait, Config}; +use pallet_identity::benchmarking::User; /// Registers a unique ticker named `ticker_name` for `ticker_owner`. pub fn reg_unique_ticker( diff --git a/pallets/common/src/benchs/mod.rs b/pallets/common/src/benchs/mod.rs index da10c71402..c0ccba2e09 100644 --- a/pallets/common/src/benchs/mod.rs +++ b/pallets/common/src/benchs/mod.rs @@ -16,29 +16,4 @@ mod asset; pub use asset::{create_and_issue_sample_asset, reg_unique_ticker}; -mod user; -pub use user::{PublicKey, SecretKey, User}; - -mod user_builder; -pub use user_builder::UserBuilder; - -use crate::traits::identity::Config; - -pub fn user(prefix: &'static str, u: u32) -> User { - UserBuilder::::default() - .generate_did() - .seed(u) - .build(prefix) -} - -pub fn user_without_did(prefix: &'static str, u: u32) -> User { - UserBuilder::::default().seed(u).build(prefix) -} - -pub fn cdd_provider(prefix: &'static str, u: u32) -> User { - UserBuilder::::default() - .generate_did() - .seed(u) - .become_cdd_provider() - .build(prefix) -} +pub use pallet_identity::benchmarking::{cdd_provider, user, user_without_did, User, UserBuilder}; diff --git a/pallets/common/src/benchs/user.rs b/pallets/common/src/benchs/user.rs deleted file mode 100644 index dcceaec5b9..0000000000 --- a/pallets/common/src/benchs/user.rs +++ /dev/null @@ -1,55 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use crate::traits::identity::Config; -use frame_system::RawOrigin; -use polymesh_primitives::{crypto::native_schnorrkel, IdentityId}; -use sp_core::sr25519::Signature; -use sp_runtime::traits::StaticLookup; - -pub use schnorrkel::keys::{PublicKey, SecretKey}; - -/// Helper class to create accounts and its DID to simplify benchmarks and UT. -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct User { - pub account: T::AccountId, - pub secret: Option, - pub origin: RawOrigin, - pub did: Option, -} - -impl User { - pub fn did(&self) -> IdentityId { - self.did.expect("User without DID") - } - - pub fn account(&self) -> T::AccountId { - self.account.clone() - } - - pub fn origin(&self) -> RawOrigin { - self.origin.clone() - } - - pub fn lookup(&self) -> ::Source { - T::Lookup::unlookup(self.account.clone()) - } - - pub fn sign(&self, message: &[u8]) -> Option { - self.secret - .as_ref() - .and_then(|sk| native_schnorrkel::sign(sk.to_bytes(), message)) - } -} diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index db70a72e4e..2d089acde3 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -17,8 +17,8 @@ pub mod traits; pub use traits::{ - asset, balances, compliance_manager, governance_group, group, identity, multisig, nft, - portfolio, CommonConfig, + asset, balances, compliance_manager, governance_group, group, multisig, nft, portfolio, + CommonConfig, }; pub mod context; pub use context::Context; diff --git a/pallets/common/src/traits/balances.rs b/pallets/common/src/traits/balances.rs index 71ab61cf00..fd376add1a 100644 --- a/pallets/common/src/traits/balances.rs +++ b/pallets/common/src/traits/balances.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::traits::{identity::Config as IdentityConfig, CommonConfig, NegativeImbalance}; +use crate::traits::{CommonConfig, NegativeImbalance}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ decl_event, @@ -151,7 +151,7 @@ pub trait WeightInfo { fn burn_account_balance() -> Weight; } -pub trait Config: CommonConfig + IdentityConfig { +pub trait Config: CommonConfig + pallet_identity::Config { /// The means of storing the balances of an account. type AccountStore: StoredMap; diff --git a/pallets/common/src/traits/compliance_manager.rs b/pallets/common/src/traits/compliance_manager.rs index 613d20ef93..14360cf309 100644 --- a/pallets/common/src/traits/compliance_manager.rs +++ b/pallets/common/src/traits/compliance_manager.rs @@ -27,13 +27,12 @@ use polymesh_primitives::{IdentityId, TrustedIssuer, WeightMeter}; use crate::asset::AssetFnTrait; use crate::balances::Config as BalancesConfig; -use crate::identity::Config as IdentityConfig; use crate::traits::external_agents::Config as EAConfig; use crate::traits::CommonConfig; /// The module's configuration trait. pub trait Config: - pallet_timestamp::Config + CommonConfig + BalancesConfig + IdentityConfig + EAConfig + pallet_timestamp::Config + CommonConfig + BalancesConfig + pallet_identity::Config + EAConfig { /// The overarching event type. type RuntimeEvent: From + Into<::RuntimeEvent>; diff --git a/pallets/common/src/traits/group.rs b/pallets/common/src/traits/group.rs index 43e368907a..01daa9309c 100644 --- a/pallets/common/src/traits/group.rs +++ b/pallets/common/src/traits/group.rs @@ -13,7 +13,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::identity::Config as IdentityConfig; use crate::traits::CommonConfig; use polymesh_primitives::{traits::group::MemberCount, IdentityId}; @@ -35,7 +34,7 @@ pub trait WeightInfo { fn abdicate_membership() -> Weight; } -pub trait Config: CommonConfig + pallet_timestamp::Config + IdentityConfig { +pub trait Config: CommonConfig + pallet_timestamp::Config + pallet_identity::Config { /// The overarching event type. type RuntimeEvent: From> + Into<::RuntimeEvent>; diff --git a/pallets/common/src/traits/identity.rs b/pallets/common/src/traits/identity.rs deleted file mode 100644 index d97bcd9ea3..0000000000 --- a/pallets/common/src/traits/identity.rs +++ /dev/null @@ -1,284 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use codec::{Decode, Encode}; -use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo, Weight}; -use frame_support::traits::{Currency, EnsureOrigin, Get, GetCallMetadata}; -use frame_support::{decl_event, Parameter}; -use scale_info::TypeInfo; -use sp_runtime::traits::{Dispatchable, IdentifyAccount, Member, Verify}; -use sp_std::vec::Vec; - -use polymesh_primitives::identity::limits::{ - MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, -}; -use polymesh_primitives::{ - identity::SecondaryKeyWithAuth, - protocol_fee::ChargeProtocolFee, - secondary_key::SecondaryKey, - traits::group::GroupTrait, - traits::{CddAndFeeDetails, IdentityFnTrait}, - AuthorizationData, Balance, CustomClaimTypeId, IdentityClaim, IdentityId, Permissions, Ticker, -}; - -pub trait WeightInfo { - fn create_child_identity() -> Weight; - fn create_child_identities(i: u32) -> Weight; - fn unlink_child_identity() -> Weight; - fn cdd_register_did(i: u32) -> Weight; - fn invalidate_cdd_claims() -> Weight; - fn remove_secondary_keys(i: u32) -> Weight; - fn accept_primary_key() -> Weight; - fn rotate_primary_key_to_secondary() -> Weight; - fn change_cdd_requirement_for_mk_rotation() -> Weight; - fn join_identity_as_key() -> Weight; - fn leave_identity_as_key() -> Weight; - fn add_claim() -> Weight; - fn revoke_claim() -> Weight; - fn set_secondary_key_permissions() -> Weight; - /// Complexity Parameters: - /// `a` = Number of (A)ssets - /// `p` = Number of (P)ortfolios - /// `l` = Number of pa(L)lets - /// `e` = Number of (E)xtrinsics - fn permissions_cost(a: u32, p: u32, l: u32, e: u32) -> Weight; - - fn permissions_cost_perms(perms: &Permissions) -> Weight { - let (assets, portfolios, pallets, extrinsics) = perms.counts(); - - if assets > MAX_ASSETS as u32 - || portfolios > MAX_PORTFOLIOS as u32 - || pallets > MAX_PALLETS as u32 - || extrinsics > MAX_EXTRINSICS as u32 - { - return Weight::MAX; - } - - Self::permissions_cost( - assets.max(1), - portfolios.max(1), - pallets.max(1), - extrinsics.max(1), - ) - } - - fn freeze_secondary_keys() -> Weight; - fn unfreeze_secondary_keys() -> Weight; - fn add_authorization() -> Weight; - fn remove_authorization() -> Weight; - fn add_secondary_keys_with_authorization(n: u32) -> Weight; - fn revoke_claim_by_index() -> Weight; - fn register_custom_claim_type(n: u32) -> Weight; - - /// Add complexity cost of Permissions to `add_secondary_keys_with_authorization` extrinsic. - fn add_secondary_keys_full( - additional_keys: &[SecondaryKeyWithAuth], - ) -> Weight { - Self::add_secondary_keys_perms_cost( - additional_keys - .iter() - .map(|auth| &auth.secondary_key.permissions), - ) - } - - /// Add complexity cost of Permissions to `add_secondary_keys_with_authorization` extrinsic. - fn add_secondary_keys_perms_cost<'a>( - perms: impl ExactSizeIterator, - ) -> Weight { - let len_cost = Self::add_secondary_keys_with_authorization(perms.len() as u32); - perms.fold(len_cost, |cost, key| { - cost.saturating_add(Self::permissions_cost_perms(key)) - }) - } - - /// Add complexity cost of Permissions to `add_authorization` extrinsic. - fn add_authorization_full(data: &AuthorizationData) -> Weight { - let perm_cost = match data { - AuthorizationData::JoinIdentity(perms) => Self::permissions_cost_perms(perms), - _ => Weight::zero(), - }; - perm_cost.saturating_add(Self::add_authorization()) - } - - /// Add complexity cost of Permissions to `set_secondary_key_permissions` extrinsic. - fn set_secondary_key_permissions_full(perms: &Permissions) -> Weight { - Self::permissions_cost_perms(perms).saturating_add(Self::set_secondary_key_permissions()) - } -} - -/// The module's configuration trait. -pub trait Config: - frame_system::Config + pallet_timestamp::Config + pallet_base::Config + pallet_permissions::Config -{ - /// The overarching event type. - type RuntimeEvent: From> + Into<::RuntimeEvent>; - /// An extrinsic call. - type Proposal: Parameter - + Dispatchable< - RuntimeOrigin = ::RuntimeOrigin, - PostInfo = PostDispatchInfo, - > + GetCallMetadata - + GetDispatchInfo - + From>; - /// Group module - type CddServiceProviders: GroupTrait; - /// Balances module - type Balances: Currency; - /// Used to check and update CDD - type CddHandler: CddAndFeeDetails::RuntimeCall>; - - type Public: IdentifyAccount; - type OffChainSignature: Verify + Member + Decode + Encode + TypeInfo; - type ProtocolFee: ChargeProtocolFee; - - /// Origin for Governance Committee voting majority origin. - type GCVotingMajorityOrigin: EnsureOrigin; - - /// Weight information for extrinsics in the identity pallet. - type WeightInfo: WeightInfo; - - /// Identity functions - type IdentityFn: IdentityFnTrait; - - /// A type for identity-mapping the `Origin` type. Used by the scheduler. - type SchedulerOrigin: From>; - - /// POLYX given to primary keys of all new Identities - type InitialPOLYX: Get<>::Balance>; - - /// Maximum number of authorizations an identity can give. - type MaxGivenAuths: Get; -} - -decl_event!( - pub enum Event - where - AccountId = ::AccountId, - Moment = ::Moment, - { - /// Identity created. - /// - /// (DID, primary key, secondary keys) - DidCreated(IdentityId, AccountId, Vec>), - - /// Secondary keys added to identity. - /// - /// (DID, new keys) - SecondaryKeysAdded(IdentityId, Vec>), - - /// Secondary keys removed from identity. - /// - /// (DID, the keys that got removed) - SecondaryKeysRemoved(IdentityId, Vec), - - /// A secondary key left their identity. - /// - /// (DID, secondary key) - SecondaryKeyLeftIdentity(IdentityId, AccountId), - - /// Secondary key permissions updated. - /// - /// (DID, updated secondary key, previous permissions, new permissions) - SecondaryKeyPermissionsUpdated(IdentityId, AccountId, Permissions, Permissions), - - /// Primary key of identity changed. - /// - /// (DID, old primary key account ID, new ID) - PrimaryKeyUpdated(IdentityId, AccountId, AccountId), - - /// Claim added to identity. - /// - /// (DID, claim) - ClaimAdded(IdentityId, IdentityClaim), - - /// Claim revoked from identity. - /// - /// (DID, claim) - ClaimRevoked(IdentityId, IdentityClaim), - - /// Asset's identity registered. - /// - /// (Asset DID, ticker) - AssetDidRegistered(IdentityId, Ticker), - - /// New authorization added. - /// - /// (authorised_by, target_did, target_key, auth_id, authorization_data, expiry) - AuthorizationAdded( - IdentityId, - Option, - Option, - u64, - AuthorizationData, - Option, - ), - - /// Authorization revoked by the authorizer. - /// - /// (authorized_identity, authorized_key, auth_id) - AuthorizationRevoked(Option, Option, u64), - - /// Authorization rejected by the user who was authorized. - /// - /// (authorized_identity, authorized_key, auth_id) - AuthorizationRejected(Option, Option, u64), - - /// Authorization consumed. - /// - /// (authorized_identity, authorized_key, auth_id) - AuthorizationConsumed(Option, Option, u64), - - /// Accepting Authorization retry limit reached. - /// - /// (authorized_identity, authorized_key, auth_id) - AuthorizationRetryLimitReached(Option, Option, u64), - - /// CDD requirement for updating primary key changed. - /// - /// (new_requirement) - CddRequirementForPrimaryKeyUpdated(bool), - - /// CDD claims generated by `IdentityId` (a CDD Provider) have been invalidated from - /// `Moment`. - /// - /// (CDD provider DID, disable from date) - CddClaimsInvalidated(IdentityId, Moment), - - /// All Secondary keys of the identity ID are frozen. - /// - /// (DID) - SecondaryKeysFrozen(IdentityId), - - /// All Secondary keys of the identity ID are unfrozen. - /// - /// (DID) - SecondaryKeysUnfrozen(IdentityId), - - /// A new CustomClaimType was added. - /// - /// (DID, id, Type) - CustomClaimTypeAdded(IdentityId, CustomClaimTypeId, Vec), - - /// Child identity created. - /// - /// (Parent DID, Child DID, primary key) - ChildDidCreated(IdentityId, IdentityId, AccountId), - - /// Child identity unlinked from parent identity. - /// - /// (Caller DID, Parent DID, Child DID) - ChildDidUnlinked(IdentityId, IdentityId, IdentityId), - } -); diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 920e4b8693..2ee71aedaf 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -29,7 +29,6 @@ pub mod compliance_manager; pub mod external_agents; pub mod governance_group; pub mod group; -pub mod identity; pub mod multisig; pub mod nft; pub mod portfolio; diff --git a/pallets/common/src/traits/nft.rs b/pallets/common/src/traits/nft.rs index adeb0f3ded..d9de68acb1 100644 --- a/pallets/common/src/traits/nft.rs +++ b/pallets/common/src/traits/nft.rs @@ -14,10 +14,10 @@ use polymesh_primitives::nft::{NFTCollectionId, NFTs}; use polymesh_primitives::{IdentityId, NFTId, PortfolioId, PortfolioUpdateReason}; use crate::compliance_manager::ComplianceFnConfig; -use crate::{asset, identity, portfolio}; +use crate::{asset, portfolio}; pub trait Config: - frame_system::Config + asset::Config + identity::Config + portfolio::Config + frame_system::Config + asset::Config + pallet_identity::Config + portfolio::Config { type RuntimeEvent: From + Into<::RuntimeEvent>; diff --git a/pallets/common/src/traits/portfolio.rs b/pallets/common/src/traits/portfolio.rs index 08b5195789..7e54b922c3 100644 --- a/pallets/common/src/traits/portfolio.rs +++ b/pallets/common/src/traits/portfolio.rs @@ -17,7 +17,7 @@ //! //! The interface allows to accept portfolio custody -use crate::{asset::AssetFnTrait, identity, nft::NFTTrait, CommonConfig}; +use crate::{asset::AssetFnTrait, nft::NFTTrait, CommonConfig}; use frame_support::decl_event; use frame_support::dispatch::DispatchResult; use frame_support::pallet_prelude::Get; @@ -117,7 +117,7 @@ pub trait WeightInfo { fn create_custody_portfolio() -> Weight; } -pub trait Config: CommonConfig + identity::Config { +pub trait Config: CommonConfig + pallet_identity::Config { type RuntimeEvent: From + Into<::RuntimeEvent>; type WeightInfo: WeightInfo; /// Asset module. diff --git a/pallets/common/src/traits/relayer.rs b/pallets/common/src/traits/relayer.rs index 3104f6377c..5392f54b5a 100644 --- a/pallets/common/src/traits/relayer.rs +++ b/pallets/common/src/traits/relayer.rs @@ -1,4 +1,3 @@ -use crate::traits::identity; use frame_support::{decl_event, weights::Weight}; use polymesh_primitives::{Balance, EventDid}; use sp_runtime::transaction_validity::InvalidTransaction; @@ -27,7 +26,7 @@ pub trait SubsidiserTrait { ) -> Result, InvalidTransaction>; } -pub trait Config: frame_system::Config + identity::Config { +pub trait Config: frame_system::Config + pallet_identity::Config { /// The overarching event type. type RuntimeEvent: From> + Into<::RuntimeEvent>; /// Subsidy pallet weights. diff --git a/pallets/common/src/traits/statistics.rs b/pallets/common/src/traits/statistics.rs index d087b6e306..e87be85eb2 100644 --- a/pallets/common/src/traits/statistics.rs +++ b/pallets/common/src/traits/statistics.rs @@ -12,7 +12,7 @@ use sp_std::vec::Vec; /// The main trait for statistics module pub trait Config: - frame_system::Config + crate::traits::identity::Config + crate::traits::external_agents::Config + frame_system::Config + pallet_identity::Config + crate::traits::external_agents::Config { /// The overarching event type. type RuntimeEvent: From + Into<::RuntimeEvent>; diff --git a/pallets/compliance-manager/Cargo.toml b/pallets/compliance-manager/Cargo.toml index 23c19921a3..10a56d9231 100644 --- a/pallets/compliance-manager/Cargo.toml +++ b/pallets/compliance-manager/Cargo.toml @@ -6,17 +6,17 @@ edition = "2021" [dependencies] # Common -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } # Our pallets -pallet-base = { path = "../base", default-features = false } -pallet-external-agents = { path = "../external-agents", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } ## Only for benchmarks -pallet-asset = { path = "../asset", optional = true, default-features = false } -pallet-balances = { path = "../balances", optional = true, default-features = false } +pallet-asset = { workspace = true, optional = true, default-features = false } +pallet-balances = { workspace = true, optional = true, default-features = false } # Other serde = { version = "1.0.104", default-features = false } diff --git a/pallets/compliance-manager/src/benchmarking.rs b/pallets/compliance-manager/src/benchmarking.rs index 1d0330ea4e..a3789520f6 100644 --- a/pallets/compliance-manager/src/benchmarking.rs +++ b/pallets/compliance-manager/src/benchmarking.rs @@ -16,9 +16,9 @@ use frame_benchmarking::benchmarks; use scale_info::prelude::format; +use pallet_identity::benchmarking::{User, UserBuilder}; +use pallet_identity::Config as IdentityConfig; use polymesh_common_utilities::asset::AssetFnTrait; -use polymesh_common_utilities::benchs::{User, UserBuilder}; -use polymesh_common_utilities::identity::Config as IdentityConfig; use polymesh_primitives::agent::AgentGroup; use polymesh_primitives::{ asset::AssetType, AuthorizationData, ClaimType, CountryCode, PortfolioKind, Scope, diff --git a/pallets/contracts/Cargo.toml b/pallets/contracts/Cargo.toml index 7f26c692eb..100d54dbac 100644 --- a/pallets/contracts/Cargo.toml +++ b/pallets/contracts/Cargo.toml @@ -21,11 +21,11 @@ sp-runtime = { version = "7.0.0", default-features = false } sp-std = { version = "5.0.0", default-features = false } # Polymesh specific -pallet-base = { path = "../base", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true } diff --git a/pallets/contracts/src/benchmarking.rs b/pallets/contracts/src/benchmarking.rs index 4f451c830a..3cb898be0a 100644 --- a/pallets/contracts/src/benchmarking.rs +++ b/pallets/contracts/src/benchmarking.rs @@ -28,8 +28,8 @@ use sp_runtime::Perbill; use sp_std::prelude::*; use wasm_instrument::parity_wasm::elements::{Instruction, ValueType}; +use pallet_identity::benchmarking::{cdd_provider, user, User, UserBuilder}; use pallet_identity::ParentDid; -use polymesh_common_utilities::benchs::{cdd_provider, user, User, UserBuilder}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::identity::limits::{ diff --git a/pallets/contracts/src/lib.rs b/pallets/contracts/src/lib.rs index 6f1f1a0ba2..8a57a57928 100644 --- a/pallets/contracts/src/lib.rs +++ b/pallets/contracts/src/lib.rs @@ -76,11 +76,8 @@ pub use chain_extension::{ExtrinsicId, PolymeshExtension}; use pallet_contracts::weights::WeightInfo as FrameWeightInfo; use pallet_contracts::Config as BConfig; use pallet_contracts_primitives::Code; -use pallet_identity::ParentDid; +use pallet_identity::{Config as IdentityConfig, ParentDid, WeightInfo as IdentityWeightInfo}; use polymesh_common_utilities::asset::AssetFnTrait; -use polymesh_common_utilities::traits::identity::{ - Config as IdentityConfig, WeightInfo as IdentityWeightInfo, -}; use polymesh_primitives::{storage_migration_ver, Balance, Permissions}; type Identity = pallet_identity::Module; diff --git a/pallets/corporate-actions/Cargo.toml b/pallets/corporate-actions/Cargo.toml index d134686606..d51a142c3a 100644 --- a/pallets/corporate-actions/Cargo.toml +++ b/pallets/corporate-actions/Cargo.toml @@ -6,17 +6,17 @@ edition = "2021" [dependencies] # Common -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-primitives-derive = { path = "../../primitives_derive", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-primitives-derive = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets -pallet-balances = { path = "../balances", default-features = false } -pallet-base = { path = "../base", default-features = false } -pallet-external-agents = { path = "../external-agents", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-asset = { path = "../asset", default-features = false } -pallet-portfolio = { path = "../portfolio", default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } # Other serde = { version = "1.0.104", default-features = false } @@ -38,7 +38,7 @@ frame-support = { version = "4.0.0-dev", default-features = false } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true } pallet-timestamp = { version = "4.0.0-dev", default-features = false } -pallet-compliance-manager = { path = "../compliance-manager", default-features = false, optional = true } +pallet-compliance-manager = { workspace = true, default-features = false, optional = true } [features] default = ["std"] diff --git a/pallets/corporate-actions/src/ballot/benchmarking.rs b/pallets/corporate-actions/src/ballot/benchmarking.rs index 3161903f4a..b85340fada 100644 --- a/pallets/corporate-actions/src/ballot/benchmarking.rs +++ b/pallets/corporate-actions/src/ballot/benchmarking.rs @@ -17,7 +17,7 @@ use super::*; use crate::benchmarking::{set_ca_targets, setup_ca}; use core::iter; use frame_benchmarking::benchmarks; -use polymesh_common_utilities::benchs::User; +use pallet_identity::benchmarking::User; const MAX_CHOICES: u32 = 1000; const MAX_TARGETS: u32 = 1000; diff --git a/pallets/corporate-actions/src/benchmarking.rs b/pallets/corporate-actions/src/benchmarking.rs index 1d2bb5b1e5..866b55585d 100644 --- a/pallets/corporate-actions/src/benchmarking.rs +++ b/pallets/corporate-actions/src/benchmarking.rs @@ -18,7 +18,8 @@ use frame_benchmarking::benchmarks; use frame_system::RawOrigin; use pallet_asset::benchmarking::make_document; -use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, user, User}; +use pallet_identity::benchmarking::{user, User}; +use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_primitives::asset::{AssetId, AssetName}; use polymesh_primitives::PortfolioKind; diff --git a/pallets/corporate-actions/src/distribution/benchmarking.rs b/pallets/corporate-actions/src/distribution/benchmarking.rs index 97cdf8ff8b..a182084874 100644 --- a/pallets/corporate-actions/src/distribution/benchmarking.rs +++ b/pallets/corporate-actions/src/distribution/benchmarking.rs @@ -16,7 +16,7 @@ use frame_benchmarking::benchmarks; use pallet_compliance_manager::Module as ComplianceManager; -use polymesh_common_utilities::benchs::{user, User}; +use pallet_identity::benchmarking::{user, User}; use polymesh_primitives::{Fund, FundDescription, PortfolioId, PortfolioNumber}; use super::*; diff --git a/pallets/corporate-actions/src/lib.rs b/pallets/corporate-actions/src/lib.rs index 882af74cbe..8e3633aa3a 100644 --- a/pallets/corporate-actions/src/lib.rs +++ b/pallets/corporate-actions/src/lib.rs @@ -103,10 +103,9 @@ use frame_support::{ use frame_system::ensure_root; use pallet_asset::checkpoint; use pallet_base::try_next_post; -use pallet_identity::PermissionedCallOriginData; +use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; use polymesh_common_utilities::{ - balances::Config as BalancesConfig, identity::Config as IdentityConfig, traits::asset, - traits::checkpoint::ScheduleId, + balances::Config as BalancesConfig, traits::asset, traits::checkpoint::ScheduleId, }; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ diff --git a/pallets/external-agents/Cargo.toml b/pallets/external-agents/Cargo.toml index a1726a2a2a..c8aedf2514 100644 --- a/pallets/external-agents/Cargo.toml +++ b/pallets/external-agents/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" [dependencies] # Common -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-primitives-derive = { path = "../../primitives_derive", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-primitives-derive = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets -pallet-base = { path = "../base", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } # Other serde = { version = "1.0.104", default-features = false } diff --git a/pallets/external-agents/src/benchmarking.rs b/pallets/external-agents/src/benchmarking.rs index a0c2116fc9..e4abb7fb02 100644 --- a/pallets/external-agents/src/benchmarking.rs +++ b/pallets/external-agents/src/benchmarking.rs @@ -15,7 +15,8 @@ use crate::*; use frame_benchmarking::benchmarks; -use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, user, User}; +use pallet_identity::benchmarking::{user, User}; +use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_common_utilities::traits::asset::Config as Asset; use polymesh_primitives::{AuthorizationData, ExtrinsicPermissions, PalletName, PalletPermissions}; use sp_std::prelude::*; diff --git a/pallets/group/Cargo.toml b/pallets/group/Cargo.toml index ac63d0da17..17e87f68ee 100644 --- a/pallets/group/Cargo.toml +++ b/pallets/group/Cargo.toml @@ -5,9 +5,9 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { path = "../common", default-features = false} -polymesh-primitives = { path = "../../primitives", default-features = false} -pallet-identity = { path = "../identity", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false} +polymesh-primitives = { workspace = true, default-features = false} +pallet-identity = { workspace = true, default-features = false } # Others serde = { version = "1.0.104", default-features = false } diff --git a/pallets/group/rpc/Cargo.toml b/pallets/group/rpc/Cargo.toml index 9d9ac76353..efdc9cc897 100644 --- a/pallets/group/rpc/Cargo.toml +++ b/pallets/group/rpc/Cargo.toml @@ -20,8 +20,8 @@ frame-support = { version = "4.0.0-dev", default-features = false } frame-system = { version = "4.0.0-dev", default-features = false } # Common -node-rpc = { path = "../../../rpc" } -polymesh-primitives = { package = "polymesh-primitives", path = "../../../primitives", default-features = false} +node-rpc = { workspace = true } +polymesh-primitives = { workspace = true, default-features = false} # RPC pallet-group-rpc-runtime-api = { version = "2.0.0", path = "./runtime-api" } diff --git a/pallets/group/rpc/runtime-api/Cargo.toml b/pallets/group/rpc/runtime-api/Cargo.toml index 26dfc76bf1..d2b85d471e 100644 --- a/pallets/group/rpc/runtime-api/Cargo.toml +++ b/pallets/group/rpc/runtime-api/Cargo.toml @@ -9,8 +9,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # Common -polymesh-primitives = { path = "../../../../primitives", default-features = false} -polymesh-common-utilities = { path = "../../../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false} +polymesh-common-utilities = { workspace = true, default-features = false } # Others serde = { version = "1.0.104", optional = true, features = ["derive"] } diff --git a/pallets/group/src/benchmarking.rs b/pallets/group/src/benchmarking.rs index f5f0477e8b..f99fa4a54a 100644 --- a/pallets/group/src/benchmarking.rs +++ b/pallets/group/src/benchmarking.rs @@ -1,8 +1,6 @@ use crate::*; -use polymesh_common_utilities::{ - benchs::{User, UserBuilder}, - group::Config, -}; +use pallet_identity::benchmarking::{User, UserBuilder}; +use polymesh_common_utilities::traits::group::Config; use polymesh_primitives::traits::group::GroupTrait; use frame_benchmarking::benchmarks_instance; diff --git a/pallets/identity/Cargo.toml b/pallets/identity/Cargo.toml index af22eeb3d6..3939958e4f 100644 --- a/pallets/identity/Cargo.toml +++ b/pallets/identity/Cargo.toml @@ -5,10 +5,9 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -pallet-base = { path = "../base", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } # Others log = "0.4.8" @@ -51,7 +50,6 @@ std = [ "pallet-base/std", "pallet-permissions/std", "pallet-timestamp/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "serde/std", "serde_derive", @@ -64,7 +62,6 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks", "schnorrkel", "hex", ] diff --git a/pallets/identity/src/benchmarking.rs b/pallets/identity/src/benchmarking.rs index ef5e5a8760..f01ef3cbfe 100644 --- a/pallets/identity/src/benchmarking.rs +++ b/pallets/identity/src/benchmarking.rs @@ -17,10 +17,6 @@ use crate::*; use frame_benchmarking::{account, benchmarks}; use frame_system::RawOrigin; -use sp_core::H512; -use sp_std::prelude::*; - -use polymesh_common_utilities::benchs::{cdd_provider, user, user_without_did, UserBuilder}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::identity::limits::{ MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, MAX_SECONDARY_KEYS, @@ -31,9 +27,14 @@ use polymesh_primitives::{ ExtrinsicName, ExtrinsicPermissions, PalletName, PalletPermissions, Permissions, PortfolioId, PortfolioNumber, PortfolioPermissions, Scope, SecondaryKey, Signatory, }; +use sp_core::H512; +use sp_std::prelude::*; const SEED: u32 = 0; +mod user; +pub use user::*; + pub fn generate_secondary_keys(n: usize) -> Vec> { let mut secondary_keys = Vec::with_capacity(n); for x in 0..n { diff --git a/pallets/common/src/benchs/user_builder.rs b/pallets/identity/src/benchmarking/user.rs similarity index 73% rename from pallets/common/src/benchs/user_builder.rs rename to pallets/identity/src/benchmarking/user.rs index 33d921685a..33a4b49bb1 100644 --- a/pallets/common/src/benchs/user_builder.rs +++ b/pallets/identity/src/benchmarking/user.rs @@ -12,20 +12,53 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{ - benchs::{SecretKey, User}, - traits::identity::Config, -}; -use schnorrkel::{ExpansionMode, MiniSecretKey}; +use crate::Config; use codec::{Decode, Encode}; use frame_support::traits::Currency; use frame_system::RawOrigin; use polymesh_primitives::traits::{group::GroupTrait, IdentityFnTrait}; -use polymesh_primitives::IdentityId; +use polymesh_primitives::{crypto::native_schnorrkel, IdentityId}; +use schnorrkel::keys::SecretKey; +use schnorrkel::{ExpansionMode, MiniSecretKey}; +use sp_core::sr25519::Signature; use sp_io::hashing::blake2_256; +use sp_runtime::traits::StaticLookup; use sp_std::prelude::*; +/// Helper class to create accounts and its DID to simplify benchmarks and UT. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct User { + pub account: T::AccountId, + pub secret: Option, + pub origin: RawOrigin, + pub did: Option, +} + +impl User { + pub fn did(&self) -> IdentityId { + self.did.expect("User without DID") + } + + pub fn account(&self) -> T::AccountId { + self.account.clone() + } + + pub fn origin(&self) -> RawOrigin { + self.origin.clone() + } + + pub fn lookup(&self) -> ::Source { + T::Lookup::unlookup(self.account.clone()) + } + + pub fn sign(&self, message: &[u8]) -> Option { + self.secret + .as_ref() + .and_then(|sk| native_schnorrkel::sign(sk.to_bytes(), message)) + } +} + pub struct UserBuilder { account: Option, did: Option, @@ -139,3 +172,22 @@ impl Default for UserBuilder { } } } + +pub fn user(prefix: &'static str, u: u32) -> User { + UserBuilder::::default() + .generate_did() + .seed(u) + .build(prefix) +} + +pub fn user_without_did(prefix: &'static str, u: u32) -> User { + UserBuilder::::default().seed(u).build(prefix) +} + +pub fn cdd_provider(prefix: &'static str, u: u32) -> User { + UserBuilder::::default() + .generate_did() + .seed(u) + .become_cdd_provider() + .build(prefix) +} diff --git a/pallets/identity/src/claims.rs b/pallets/identity/src/claims.rs index 97e767f2b6..2343c3f178 100644 --- a/pallets/identity/src/claims.rs +++ b/pallets/identity/src/claims.rs @@ -14,8 +14,8 @@ // along with this program. If not, see . use crate::{ - Claim1stKey, Claim2ndKey, Claims, CustomClaimIdSequence, CustomClaims, CustomClaimsInverse, - DidRecords, Error, Event, Module, ParentDid, + Claim1stKey, Claim2ndKey, Claims, Config, CustomClaimIdSequence, CustomClaims, + CustomClaimsInverse, DidRecords, Error, Event, Module, ParentDid, RawEvent, }; use frame_support::{ dispatch::{DispatchError, DispatchResult}, @@ -24,7 +24,6 @@ use frame_support::{ use frame_system::ensure_root; use pallet_base::{ensure_string_limited, try_next_pre}; -use polymesh_common_utilities::traits::identity::{Config, RawEvent}; use polymesh_primitives::identity_claim::CustomClaimTypeId; use polymesh_primitives::{ protocol_fee::ProtocolOp, diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index 19405df27c..53a091f107 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -84,37 +84,292 @@ pub mod benchmarking; mod auth; mod claims; mod keys; -pub mod types; -pub use polymesh_common_utilities::traits::identity::WeightInfo; +pub mod types; pub use types::{Claim1stKey, Claim2ndKey, DidStatus, PermissionedCallOriginData, RpcDidRecords}; -use core::convert::From; - use codec::{Decode, Encode}; -use frame_system::ensure_root; -use sp_std::prelude::*; - +use core::convert::From; use frame_support::dispatch::DispatchClass::{Normal, Operational}; -use frame_support::dispatch::{DispatchError, DispatchResult, Pays, Weight}; -use frame_support::traits::{ChangeMembers, Currency, EnsureOrigin, Get, InitializeMembers}; -use frame_support::{decl_error, decl_module, decl_storage}; -use polymesh_common_utilities::traits::identity::{Config, RawEvent}; -use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; +use frame_support::dispatch::{ + DispatchError, DispatchResult, GetDispatchInfo, Pays, PostDispatchInfo, Weight, +}; +use frame_support::traits::{ + ChangeMembers, Currency, EnsureOrigin, Get, GetCallMetadata, InitializeMembers, +}; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, Parameter}; +use frame_system::ensure_root; +use polymesh_primitives::identity::limits::{ + MAX_ASSETS, MAX_EXTRINSICS, MAX_PALLETS, MAX_PORTFOLIOS, +}; use polymesh_primitives::{ identity::{AuthorizationNonce, CreateChildIdentityWithAuth, SecondaryKeyWithAuth}, + protocol_fee::{ChargeProtocolFee, ProtocolOp}, storage_migration_ver, - traits::IdentityFnTrait, - AssetPermissions, Authorization, AuthorizationData, AuthorizationType, CddId, Claim, ClaimType, - CustomClaimTypeId, DidRecord, ExtrinsicPermissions, IdentityClaim, IdentityId, KeyRecord, - Permissions, PortfolioPermissions, Scope, SecondaryKey, Signatory, + traits::group::GroupTrait, + traits::{CddAndFeeDetails, IdentityFnTrait}, + AssetPermissions, Authorization, AuthorizationData, AuthorizationType, Balance, CddId, Claim, + ClaimType, CustomClaimTypeId, DidRecord, ExtrinsicPermissions, IdentityClaim, IdentityId, + KeyRecord, Permissions, PortfolioPermissions, Scope, SecondaryKey, Signatory, Ticker, }; use polymesh_primitives::{SystematicIssuers, GC_DID}; - -pub type Event = polymesh_common_utilities::traits::identity::Event; +use scale_info::TypeInfo; +use sp_runtime::traits::{Dispatchable, IdentifyAccount, Member, Verify}; +use sp_std::prelude::*; +use sp_std::vec::Vec; storage_migration_ver!(7); +pub trait WeightInfo { + fn create_child_identity() -> Weight; + fn create_child_identities(i: u32) -> Weight; + fn unlink_child_identity() -> Weight; + fn cdd_register_did(i: u32) -> Weight; + fn invalidate_cdd_claims() -> Weight; + fn remove_secondary_keys(i: u32) -> Weight; + fn accept_primary_key() -> Weight; + fn rotate_primary_key_to_secondary() -> Weight; + fn change_cdd_requirement_for_mk_rotation() -> Weight; + fn join_identity_as_key() -> Weight; + fn leave_identity_as_key() -> Weight; + fn add_claim() -> Weight; + fn revoke_claim() -> Weight; + fn set_secondary_key_permissions() -> Weight; + /// Complexity Parameters: + /// `a` = Number of (A)ssets + /// `p` = Number of (P)ortfolios + /// `l` = Number of pa(L)lets + /// `e` = Number of (E)xtrinsics + fn permissions_cost(a: u32, p: u32, l: u32, e: u32) -> Weight; + + fn permissions_cost_perms(perms: &Permissions) -> Weight { + let (assets, portfolios, pallets, extrinsics) = perms.counts(); + + if assets > MAX_ASSETS as u32 + || portfolios > MAX_PORTFOLIOS as u32 + || pallets > MAX_PALLETS as u32 + || extrinsics > MAX_EXTRINSICS as u32 + { + return Weight::MAX; + } + + Self::permissions_cost( + assets.max(1), + portfolios.max(1), + pallets.max(1), + extrinsics.max(1), + ) + } + + fn freeze_secondary_keys() -> Weight; + fn unfreeze_secondary_keys() -> Weight; + fn add_authorization() -> Weight; + fn remove_authorization() -> Weight; + fn add_secondary_keys_with_authorization(n: u32) -> Weight; + fn revoke_claim_by_index() -> Weight; + fn register_custom_claim_type(n: u32) -> Weight; + + /// Add complexity cost of Permissions to `add_secondary_keys_with_authorization` extrinsic. + fn add_secondary_keys_full( + additional_keys: &[SecondaryKeyWithAuth], + ) -> Weight { + Self::add_secondary_keys_perms_cost( + additional_keys + .iter() + .map(|auth| &auth.secondary_key.permissions), + ) + } + + /// Add complexity cost of Permissions to `add_secondary_keys_with_authorization` extrinsic. + fn add_secondary_keys_perms_cost<'a>( + perms: impl ExactSizeIterator, + ) -> Weight { + let len_cost = Self::add_secondary_keys_with_authorization(perms.len() as u32); + perms.fold(len_cost, |cost, key| { + cost.saturating_add(Self::permissions_cost_perms(key)) + }) + } + + /// Add complexity cost of Permissions to `add_authorization` extrinsic. + fn add_authorization_full(data: &AuthorizationData) -> Weight { + let perm_cost = match data { + AuthorizationData::JoinIdentity(perms) => Self::permissions_cost_perms(perms), + _ => Weight::zero(), + }; + perm_cost.saturating_add(Self::add_authorization()) + } + + /// Add complexity cost of Permissions to `set_secondary_key_permissions` extrinsic. + fn set_secondary_key_permissions_full(perms: &Permissions) -> Weight { + Self::permissions_cost_perms(perms).saturating_add(Self::set_secondary_key_permissions()) + } +} + +/// The module's configuration trait. +pub trait Config: + frame_system::Config + pallet_timestamp::Config + pallet_base::Config + pallet_permissions::Config +{ + /// The overarching event type. + type RuntimeEvent: From> + Into<::RuntimeEvent>; + /// An extrinsic call. + type Proposal: Parameter + + Dispatchable< + RuntimeOrigin = ::RuntimeOrigin, + PostInfo = PostDispatchInfo, + > + GetCallMetadata + + GetDispatchInfo + + From>; + /// Group module + type CddServiceProviders: GroupTrait; + /// Balances module + type Balances: Currency; + /// Used to check and update CDD + type CddHandler: CddAndFeeDetails::RuntimeCall>; + + type Public: IdentifyAccount; + type OffChainSignature: Verify + Member + Decode + Encode + TypeInfo; + type ProtocolFee: ChargeProtocolFee; + + /// Origin for Governance Committee voting majority origin. + type GCVotingMajorityOrigin: EnsureOrigin; + + /// Weight information for extrinsics in the identity pallet. + type WeightInfo: WeightInfo; + + /// Identity functions + type IdentityFn: IdentityFnTrait; + + /// A type for identity-mapping the `Origin` type. Used by the scheduler. + type SchedulerOrigin: From>; + + /// POLYX given to primary keys of all new Identities + type InitialPOLYX: Get<>::Balance>; + + /// Maximum number of authorizations an identity can give. + type MaxGivenAuths: Get; +} + +decl_event!( + pub enum Event + where + AccountId = ::AccountId, + Moment = ::Moment, + { + /// Identity created. + /// + /// (DID, primary key, secondary keys) + DidCreated(IdentityId, AccountId, Vec>), + + /// Secondary keys added to identity. + /// + /// (DID, new keys) + SecondaryKeysAdded(IdentityId, Vec>), + + /// Secondary keys removed from identity. + /// + /// (DID, the keys that got removed) + SecondaryKeysRemoved(IdentityId, Vec), + + /// A secondary key left their identity. + /// + /// (DID, secondary key) + SecondaryKeyLeftIdentity(IdentityId, AccountId), + + /// Secondary key permissions updated. + /// + /// (DID, updated secondary key, previous permissions, new permissions) + SecondaryKeyPermissionsUpdated(IdentityId, AccountId, Permissions, Permissions), + + /// Primary key of identity changed. + /// + /// (DID, old primary key account ID, new ID) + PrimaryKeyUpdated(IdentityId, AccountId, AccountId), + + /// Claim added to identity. + /// + /// (DID, claim) + ClaimAdded(IdentityId, IdentityClaim), + + /// Claim revoked from identity. + /// + /// (DID, claim) + ClaimRevoked(IdentityId, IdentityClaim), + + /// Asset's identity registered. + /// + /// (Asset DID, ticker) + AssetDidRegistered(IdentityId, Ticker), + + /// New authorization added. + /// + /// (authorised_by, target_did, target_key, auth_id, authorization_data, expiry) + AuthorizationAdded( + IdentityId, + Option, + Option, + u64, + AuthorizationData, + Option, + ), + + /// Authorization revoked by the authorizer. + /// + /// (authorized_identity, authorized_key, auth_id) + AuthorizationRevoked(Option, Option, u64), + + /// Authorization rejected by the user who was authorized. + /// + /// (authorized_identity, authorized_key, auth_id) + AuthorizationRejected(Option, Option, u64), + + /// Authorization consumed. + /// + /// (authorized_identity, authorized_key, auth_id) + AuthorizationConsumed(Option, Option, u64), + + /// Accepting Authorization retry limit reached. + /// + /// (authorized_identity, authorized_key, auth_id) + AuthorizationRetryLimitReached(Option, Option, u64), + + /// CDD requirement for updating primary key changed. + /// + /// (new_requirement) + CddRequirementForPrimaryKeyUpdated(bool), + + /// CDD claims generated by `IdentityId` (a CDD Provider) have been invalidated from + /// `Moment`. + /// + /// (CDD provider DID, disable from date) + CddClaimsInvalidated(IdentityId, Moment), + + /// All Secondary keys of the identity ID are frozen. + /// + /// (DID) + SecondaryKeysFrozen(IdentityId), + + /// All Secondary keys of the identity ID are unfrozen. + /// + /// (DID) + SecondaryKeysUnfrozen(IdentityId), + + /// A new CustomClaimType was added. + /// + /// (DID, id, Type) + CustomClaimTypeAdded(IdentityId, CustomClaimTypeId, Vec), + + /// Child identity created. + /// + /// (Parent DID, Child DID, primary key) + ChildDidCreated(IdentityId, IdentityId, AccountId), + + /// Child identity unlinked from parent identity. + /// + /// (Caller DID, Parent DID, Child DID) + ChildDidUnlinked(IdentityId, IdentityId, IdentityId), + } +); + decl_storage! { trait Store for Module as Identity { diff --git a/pallets/multisig/Cargo.toml b/pallets/multisig/Cargo.toml index 81edea90ec..30f2ffc813 100644 --- a/pallets/multisig/Cargo.toml +++ b/pallets/multisig/Cargo.toml @@ -7,11 +7,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -pallet-identity = { path = "../identity", default-features = false} -pallet-permissions = { path = "../permissions", default-features = false } -polymesh-common-utilities = {path = "../common", default-features = false} -polymesh-primitives = { path = "../../primitives", default-features = false} -#polymesh-runtime-common = { path = "../runtime/common", default-features = false } +pallet-identity = { workspace = true, default-features = false} +pallet-permissions = { workspace = true, default-features = false } +polymesh-common-utilities = {workspace = true, default-features = false} +polymesh-primitives = { workspace = true, default-features = false} +#polymesh-runtime-common = { workspace = true, default-features = false } # General log = "0.4.8" diff --git a/pallets/multisig/src/benchmarking.rs b/pallets/multisig/src/benchmarking.rs index be60e0e57e..d31dd183b4 100644 --- a/pallets/multisig/src/benchmarking.rs +++ b/pallets/multisig/src/benchmarking.rs @@ -17,7 +17,7 @@ use frame_benchmarking::benchmarks; use frame_support::storage::StorageDoubleMap; use frame_system::RawOrigin; -use polymesh_common_utilities::benchs::{User, UserBuilder}; +use pallet_identity::benchmarking::{User, UserBuilder}; use crate::*; diff --git a/pallets/multisig/src/lib.rs b/pallets/multisig/src/lib.rs index 2a2f570c5c..7cc4364cb2 100644 --- a/pallets/multisig/src/lib.rs +++ b/pallets/multisig/src/lib.rs @@ -83,10 +83,9 @@ use sp_runtime::traits::{Dispatchable, Hash}; use sp_std::convert::TryFrom; use sp_std::prelude::*; -use pallet_identity::PermissionedCallOriginData; +use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; use pallet_permissions::with_call_metadata; pub use polymesh_common_utilities::multisig::WeightInfo; -use polymesh_common_utilities::traits::identity::Config as IdentityConfig; use polymesh_primitives::multisig::{ProposalState, ProposalVoteCount}; use polymesh_primitives::{ extract_auth, storage_migration_ver, AuthorizationData, IdentityId, KeyRecord, Permissions, diff --git a/pallets/nft/Cargo.toml b/pallets/nft/Cargo.toml index acb9b5531e..5c5ab47157 100644 --- a/pallets/nft/Cargo.toml +++ b/pallets/nft/Cargo.toml @@ -6,13 +6,13 @@ edition = "2021" [dependencies] # Our crates -pallet-asset = { path = "../asset", default-features = false } -pallet-base = { path = "../base", default-features = false } -pallet-external-agents = { path = "../external-agents", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-portfolio = { path = "../portfolio", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } # Substrate codec = { workspace = true, default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false } diff --git a/pallets/nft/src/benchmarking.rs b/pallets/nft/src/benchmarking.rs index 1134d0dca1..ec02debf69 100644 --- a/pallets/nft/src/benchmarking.rs +++ b/pallets/nft/src/benchmarking.rs @@ -5,7 +5,8 @@ use sp_std::prelude::*; use sp_std::vec::Vec; use pallet_asset::benchmarking::create_portfolio; -use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, user, User, UserBuilder}; +use pallet_identity::benchmarking::{user, User, UserBuilder}; +use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_common_utilities::traits::asset::AssetFnTrait; use polymesh_common_utilities::traits::compliance_manager::ComplianceFnConfig; use polymesh_primitives::asset::{AssetType, NonFungibleType}; diff --git a/pallets/permissions/Cargo.toml b/pallets/permissions/Cargo.toml index 566bd34d13..4b5378b5aa 100644 --- a/pallets/permissions/Cargo.toml +++ b/pallets/permissions/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] # Common -polymesh-primitives = { path = "../../primitives", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } # Other serde = { version = "1.0.104", default-features = false } diff --git a/pallets/pips/Cargo.toml b/pallets/pips/Cargo.toml index 2fac00b53e..b46d83eafc 100644 --- a/pallets/pips/Cargo.toml +++ b/pallets/pips/Cargo.toml @@ -5,17 +5,17 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-primitives-derive = { path = "../../primitives_derive", default-features = false } -polymesh-runtime-common = { path = "../runtime/common", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-primitives-derive = { workspace = true, default-features = false } +polymesh-runtime-common = { workspace = true, default-features = false } -pallet-group = { path = "../group", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-balances = { path = "../balances", default-features = false } -pallet-base = { path = "../base", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } -pallet-treasury = { path = "../treasury", default-features = false } +pallet-group = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +pallet-treasury = { workspace = true, default-features = false } # General serde = { version = "1.0.104", default-features = false } @@ -41,7 +41,7 @@ pallet-timestamp = { version = "4.0.0-dev", default-features = false } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true } rand = { version = "0.8.2", default-features = false, optional = true } rand_chacha = { version = "0.3.0", default-features = false, optional = true } -pallet-committee = { path = "../committee", default-features = false, optional = true } +pallet-committee = { workspace = true, default-features = false, optional = true } [features] equalize = [] diff --git a/pallets/pips/src/benchmarking.rs b/pallets/pips/src/benchmarking.rs index 5e90d153b6..651f6b8e52 100644 --- a/pallets/pips/src/benchmarking.rs +++ b/pallets/pips/src/benchmarking.rs @@ -21,7 +21,7 @@ use frame_support::{ traits::UnfilteredDispatchable, }; use frame_system::RawOrigin; -use polymesh_common_utilities::benchs::{user, User}; +use pallet_identity::benchmarking::{user, User}; use polymesh_primitives::{MaybeBlock, SystematicIssuers, GC_DID}; use rand::{seq::SliceRandom, SeedableRng}; use rand_chacha::ChaCha20Rng; diff --git a/pallets/pips/src/lib.rs b/pallets/pips/src/lib.rs index 38ce0ba7b0..f36a865d83 100644 --- a/pallets/pips/src/lib.rs +++ b/pallets/pips/src/lib.rs @@ -107,10 +107,9 @@ use sp_std::vec::Vec; use sp_version::RuntimeVersion; use pallet_base::{ensure_opt_string_limited, try_next_post}; -use pallet_identity::PermissionedCallOriginData; +use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; use polymesh_common_utilities::traits::balances::LockableCurrencyExt; use polymesh_common_utilities::traits::governance_group::GovernanceGroupTrait; -use polymesh_common_utilities::traits::identity::Config as IdentityConfig; use polymesh_common_utilities::CommonConfig; use polymesh_primitives::constants::PIP_MAX_REPORTING_SIZE; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; diff --git a/pallets/portfolio/Cargo.toml b/pallets/portfolio/Cargo.toml index 3bc361d36f..9a6125ef36 100644 --- a/pallets/portfolio/Cargo.toml +++ b/pallets/portfolio/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" [dependencies] # Common -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } # Our Pallets -pallet-balances = { path = "../balances", default-features = false } -pallet-base = { path = "../base", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } # Other serde = { version = "1.0.104", default-features = false } diff --git a/pallets/portfolio/src/benchmarking.rs b/pallets/portfolio/src/benchmarking.rs index e277261812..fd05bd4687 100644 --- a/pallets/portfolio/src/benchmarking.rs +++ b/pallets/portfolio/src/benchmarking.rs @@ -19,8 +19,9 @@ use scale_info::prelude::format; use sp_api_hidden_includes_decl_storage::hidden_include::traits::Get; use sp_std::prelude::*; +use pallet_identity::benchmarking::{user, User, UserBuilder}; use polymesh_common_utilities::asset::Config as AssetConfig; -use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, user, User, UserBuilder}; +use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::{AuthorizationData, NFTs, PortfolioName, Signatory}; diff --git a/pallets/protocol-fee/Cargo.toml b/pallets/protocol-fee/Cargo.toml index 13a78c3324..1d7264ac32 100644 --- a/pallets/protocol-fee/Cargo.toml +++ b/pallets/protocol-fee/Cargo.toml @@ -5,8 +5,11 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } + +# Our Pallets +pallet-identity = { workspace = true, default-features = false } # General serde = { version = "1.0.104", default-features = false } @@ -34,6 +37,7 @@ std = [ "frame-system/std", "polymesh-common-utilities/std", "polymesh-primitives/std", + "pallet-identity/std", "serde/std", "sp-core/std", "sp-io/std", @@ -42,4 +46,5 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking", + "pallet-identity/runtime-benchmarks", ] diff --git a/pallets/protocol-fee/rpc/Cargo.toml b/pallets/protocol-fee/rpc/Cargo.toml index c47df1ca84..3f464b4e54 100644 --- a/pallets/protocol-fee/rpc/Cargo.toml +++ b/pallets/protocol-fee/rpc/Cargo.toml @@ -19,9 +19,9 @@ sp-std = {version = "5.0.0", default-features = false } frame-support = { version = "4.0.0-dev", default-features = false } frame-system = { version = "4.0.0-dev", default-features = false } -node-rpc = { path = "../../../rpc" } +node-rpc = { workspace = true } polymesh-primitives = { workspace = true, default-features = false } -pallet-protocol-fee-rpc-runtime-api = { path = "./runtime-api" } +pallet-protocol-fee-rpc-runtime-api = { workspace = true } # General serde = { version = "1.0.104", features = ["derive"] } diff --git a/pallets/protocol-fee/src/lib.rs b/pallets/protocol-fee/src/lib.rs index 145d3783e6..fd5f3e5263 100644 --- a/pallets/protocol-fee/src/lib.rs +++ b/pallets/protocol-fee/src/lib.rs @@ -45,9 +45,8 @@ use frame_support::{ weights::Weight, }; use frame_system::ensure_root; -use polymesh_common_utilities::{ - identity::Config as IdentityConfig, traits::relayer::SubsidiserTrait, -}; +use pallet_identity::Config as IdentityConfig; +use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_primitives::{ protocol_fee::{ChargeProtocolFee, ProtocolOp}, traits::CddAndFeeDetails, diff --git a/pallets/relayer/Cargo.toml b/pallets/relayer/Cargo.toml index 8ebc1c6672..c1555017e4 100644 --- a/pallets/relayer/Cargo.toml +++ b/pallets/relayer/Cargo.toml @@ -5,9 +5,9 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -pallet-identity = { path = "../identity", default-features = false} -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false} +pallet-identity = { workspace = true, default-features = false} +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false} # Substrate codec = { workspace = true, default-features = false, features = ["derive"] } diff --git a/pallets/relayer/src/benchmarking.rs b/pallets/relayer/src/benchmarking.rs index b722241b37..8dc50f9646 100644 --- a/pallets/relayer/src/benchmarking.rs +++ b/pallets/relayer/src/benchmarking.rs @@ -16,10 +16,8 @@ use crate::*; use frame_benchmarking::benchmarks; -use polymesh_common_utilities::{ - benchs::{user, User}, - traits::relayer::Config, -}; +use pallet_identity::benchmarking::{user, User}; +use polymesh_common_utilities::traits::relayer::Config; type Relayer = crate::Module; diff --git a/pallets/runtime/common/Cargo.toml b/pallets/runtime/common/Cargo.toml index c0d3476c57..003ca2233b 100644 --- a/pallets/runtime/common/Cargo.toml +++ b/pallets/runtime/common/Cargo.toml @@ -5,17 +5,17 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { path = "../../common", default-features = false } -polymesh-primitives = { path = "../../../primitives", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } -pallet-balances = { path = "../../balances", default-features = false } -pallet-committee = { path = "../../committee", default-features = false } -pallet-identity = { path = "../../identity", default-features = false } -pallet-multisig = { path = "../../multisig", default-features = false } -pallet-relayer = { path = "../../relayer", default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-committee = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-multisig = { workspace = true, default-features = false } +pallet-relayer = { workspace = true, default-features = false } # RPC -pallet-group-rpc-runtime-api = { path = "../../group/rpc/runtime-api", default-features = false} +pallet-group-rpc-runtime-api = { workspace = true, default-features = false} # General smallvec = "1.4.0" diff --git a/pallets/runtime/common/src/cdd_check.rs b/pallets/runtime/common/src/cdd_check.rs index 926617e4a1..df62585ccb 100644 --- a/pallets/runtime/common/src/cdd_check.rs +++ b/pallets/runtime/common/src/cdd_check.rs @@ -13,8 +13,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use pallet_identity as identity; -use polymesh_common_utilities::traits::{balances::CheckCdd, identity::Config as IdentityConfig}; +use pallet_identity::{Config as IdentityConfig, Module as Identity}; +use polymesh_common_utilities::traits::balances::CheckCdd; use polymesh_primitives::IdentityId; pub struct CddChecker(sp_std::marker::PhantomData); @@ -28,7 +28,6 @@ where } fn get_key_cdd_did(key: &::AccountId) -> Option { - identity::Module::::get_identity(key) - .filter(|&did| identity::Module::::has_valid_cdd(did)) + Identity::::get_identity(key).filter(|&did| Identity::::has_valid_cdd(did)) } } diff --git a/pallets/runtime/common/src/fee_details.rs b/pallets/runtime/common/src/fee_details.rs index 288f0f9142..ab243c29ee 100644 --- a/pallets/runtime/common/src/fee_details.rs +++ b/pallets/runtime/common/src/fee_details.rs @@ -1,8 +1,7 @@ use codec::{Decode, Encode}; use core::convert::{TryFrom, TryInto}; use core::marker::PhantomData; -use pallet_identity::Module; -use polymesh_common_utilities::traits::identity::Config; +use pallet_identity::{Config as IdentityConfig, Module as Identity}; use polymesh_common_utilities::Context; use polymesh_primitives::{ traits::CddAndFeeDetails, AccountId, AuthorizationData, IdentityId, Signatory, TransactionError, @@ -12,7 +11,7 @@ use sp_runtime::transaction_validity::InvalidTransaction; /// The set of `Call`s from pallets that `CddHandler` recognizes specially. pub enum Call<'a, R> where - R: Config + pallet_multisig::Config + pallet_relayer::Config, + R: IdentityConfig + pallet_multisig::Config + pallet_relayer::Config, { MultiSig(&'a pallet_multisig::Call), Identity(&'a pallet_identity::Call), @@ -26,7 +25,7 @@ pub struct CddHandler(PhantomData); impl CddAndFeeDetails for CddHandler where for<'a> Call<'a, A>: TryFrom<&'a C>, - A: Config + pallet_multisig::Config + pallet_relayer::Config, + A: IdentityConfig + pallet_multisig::Config + pallet_relayer::Config, { /// Check if there's an eligible payer with valid CDD. /// Return the payer if found or else an error. @@ -38,7 +37,7 @@ where fn get_valid_payer(call: &C, caller: &AccountId) -> ValidPayerResult { // Check if the `did` has a valid CDD claim. let check_did_cdd = |did: &IdentityId| { - if Module::::has_valid_cdd(*did) { + if Identity::::has_valid_cdd(*did) { Ok(None) } else { CDD_REQUIRED @@ -49,13 +48,13 @@ where // and return the primary key as the payer. let did_primary_pays = |did: &IdentityId| { check_did_cdd(did)?; - Ok(Module::::get_primary_key(*did)) + Ok(Identity::::get_primary_key(*did)) }; // Check if the `caller` key has a DID and a valid CDD claim. // The caller is also the payer. let caller_pays = |caller: &AccountId| { - match pallet_identity::Module::::get_identity(caller) { + match Identity::::get_identity(caller) { Some(did) => { check_did_cdd(&did)?; Ok(Some(caller.clone())) @@ -70,7 +69,7 @@ where let ms_pays = caller_pays(multisig)?; // If the `multisig` has a paying DID, then it's primary key pays. match pallet_multisig::Pallet::::get_paying_did(multisig) { - Some(did) => Ok(Module::::get_primary_key(did)), + Some(did) => Ok(Identity::::get_primary_key(did)), None => Ok(ms_pays), } } else { @@ -82,7 +81,7 @@ where // pays the fee to accept the authorization. let is_auth_valid = |acc: &AccountId, auth_id: &u64, call_type: CallType| { // Fetch the auth if it exists and has not expired. - match Module::::get_non_expired_auth(&Signatory::Account(acc.clone()), auth_id) + match Identity::::get_non_expired_auth(&Signatory::Account(acc.clone()), auth_id) .map(|auth| (auth.authorized_by, (auth.authorization_data, call_type))) { // Different auths have different authorization data requirements. @@ -180,12 +179,12 @@ where /// Sets payer in context. Should be called by the signed extension that first charges fee. fn set_payer_context(payer: Option) { - Context::set_current_payer::>(payer); + Context::set_current_payer::>(payer); } /// Fetches fee payer for further payments (forwarded calls) fn get_payer_from_context() -> Option { - Context::current_payer::>() + Context::current_payer::>() } } diff --git a/pallets/runtime/develop/Cargo.toml b/pallets/runtime/develop/Cargo.toml index f238a8da09..e2eee56160 100644 --- a/pallets/runtime/develop/Cargo.toml +++ b/pallets/runtime/develop/Cargo.toml @@ -9,39 +9,39 @@ build = "build.rs" [dependencies] # Common -polymesh-common-utilities = { path = "../../common", default-features = false } -polymesh-runtime-common = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../../primitives", default-features = false } -polymesh-weights = { path = "../../weights", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-runtime-common = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-weights = { workspace = true, default-features = false } # Our pallets -pallet-asset = { path = "../../asset", default-features = false } -pallet-balances = { path = "../../balances", default-features = false } -pallet-base = { path = "../../base", default-features = false } -pallet-bridge = { path = "../../bridge", default-features = false } -pallet-committee = { path = "../../committee", default-features = false } -pallet-compliance-manager = { path = "../../compliance-manager", default-features = false } -pallet-corporate-actions = { path = "../../corporate-actions", default-features = false } -pallet-external-agents = { path = "../../external-agents", default-features = false } -pallet-group = { path = "../../group", default-features = false } -pallet-identity = { path = "../../identity", default-features = false } -pallet-multisig = { path = "../../multisig", default-features = false } -pallet-nft = { path = "../../nft", default-features = false } -pallet-permissions = { path = "../../permissions", default-features = false } -pallet-pips = { path = "../../pips", default-features = false } -pallet-portfolio = { path = "../../portfolio", default-features = false } -pallet-protocol-fee = { path = "../../protocol-fee", default-features = false } -pallet-relayer = { path = "../../relayer", default-features = false } -pallet-sto = { path = "../../sto", default-features = false } -pallet-settlement = { path = "../../settlement", default-features = false } -pallet-staking = { path = "../../staking", default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-bridge = { workspace = true, default-features = false } +pallet-committee = { workspace = true, default-features = false } +pallet-compliance-manager = { workspace = true, default-features = false } +pallet-corporate-actions = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-group = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-multisig = { workspace = true, default-features = false } +pallet-nft = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +pallet-pips = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } +pallet-protocol-fee = { workspace = true, default-features = false } +pallet-relayer = { workspace = true, default-features = false } +pallet-sto = { workspace = true, default-features = false } +pallet-settlement = { workspace = true, default-features = false } +pallet-staking = { workspace = true, default-features = false } pallet-staking-reward-curve = { version = "4.0.0-dev", default-features = false } -pallet-statistics = { path = "../../statistics", default-features = false } -pallet-transaction-payment = { path = "../../transaction-payment", default-features = false } -pallet-treasury = { path = "../../treasury", default-features = false } -pallet-utility = { path = "../../utility", default-features = false } -pallet-sudo = { path = "../../sudo", default-features = false } -polymesh-contracts = { path = "../../contracts", default-features = false } +pallet-statistics = { workspace = true, default-features = false } +pallet-transaction-payment = { workspace = true, default-features = false } +pallet-treasury = { workspace = true, default-features = false } +pallet-utility = { workspace = true, default-features = false } +pallet-sudo = { workspace = true, default-features = false } +polymesh-contracts = { workspace = true, default-features = false } # Others serde = { version = "1.0.104", default-features = false } @@ -90,10 +90,10 @@ frame-support = { version = "4.0.0-dev", default-features = false } # RPC frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false } -pallet-group-rpc-runtime-api = { path = "../../group/rpc/runtime-api", default-features = false } -pallet-protocol-fee-rpc-runtime-api = { path = "../../protocol-fee/rpc/runtime-api", default-features = false } -pallet-staking-rpc-runtime-api = { path = "../../staking/rpc/runtime-api", default-features = false } -node-rpc-runtime-api = { path = "../../../rpc/runtime-api", default-features = false } +pallet-group-rpc-runtime-api = { workspace = true, default-features = false } +pallet-protocol-fee-rpc-runtime-api = { workspace = true, default-features = false } +pallet-staking-rpc-runtime-api = { workspace = true, default-features = false } +node-rpc-runtime-api = { workspace = true, default-features = false } # Used for runtime benchmarking frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true } @@ -104,7 +104,7 @@ hex-literal = { version = "0.3.1", optional = true } getrandom = { version = "0.2.6", default-features = false, optional = true } [build-dependencies] -polymesh-build-tool = { path = "../build_tool", default-features = false } +polymesh-build-tool = { workspace = true, default-features = false } [features] default = ["std", "equalize"] diff --git a/pallets/runtime/develop/src/runtime.rs b/pallets/runtime/develop/src/runtime.rs index 54e993a3c3..50443368f8 100644 --- a/pallets/runtime/develop/src/runtime.rs +++ b/pallets/runtime/develop/src/runtime.rs @@ -194,7 +194,7 @@ polymesh_runtime_common::misc_pallet_impls!(); pub type CddHandler = polymesh_runtime_common::fee_details::CddHandler; -impl polymesh_common_utilities::traits::identity::Config for Runtime { +impl pallet_identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; type CddServiceProviders = CddServiceProviders; diff --git a/pallets/runtime/mainnet/Cargo.toml b/pallets/runtime/mainnet/Cargo.toml index 31b9477811..ef04d74d2c 100644 --- a/pallets/runtime/mainnet/Cargo.toml +++ b/pallets/runtime/mainnet/Cargo.toml @@ -9,44 +9,44 @@ build = "build.rs" [dependencies] # Common -polymesh-common-utilities = { path = "../../common", default-features = false } -polymesh-primitives = { path = "../../../primitives", default-features = false } -polymesh-runtime-common = { path = "../common", default-features = false} -polymesh-weights = { path = "../../weights", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-runtime-common = { workspace = true, default-features = false} +polymesh-weights = { workspace = true, default-features = false } # Our pallets -pallet-asset = { path = "../../asset", default-features = false } -pallet-balances = { path = "../../balances", default-features = false } -pallet-base = { path = "../../base", default-features = false } -pallet-bridge = { path = "../../bridge", default-features = false } -pallet-committee = { path = "../../committee", default-features = false } -pallet-compliance-manager = { path = "../../compliance-manager", default-features = false } -pallet-corporate-actions = { path = "../../corporate-actions", default-features = false } -pallet-external-agents = { path = "../../external-agents", default-features = false } -pallet-group = { path = "../../group", default-features = false } -pallet-group-rpc-runtime-api = { path = "../../group/rpc/runtime-api", default-features = false } -pallet-identity = { path = "../../identity", default-features = false } -pallet-multisig = { path = "../../multisig", default-features = false } -pallet-nft = { path = "../../nft", default-features = false } -pallet-permissions = { path = "../../permissions", default-features = false } -pallet-pips = { path = "../../pips", default-features = false } -pallet-portfolio = { path = "../../portfolio", default-features = false } -pallet-protocol-fee = { path = "../../protocol-fee", default-features = false } -pallet-relayer = { path = "../../relayer", default-features = false } -pallet-settlement = { path = "../../settlement", default-features = false } -pallet-staking = { path = "../../staking", default-features = false } -pallet-statistics = { path = "../../statistics", default-features = false } -pallet-sto = { path = "../../sto", default-features = false } -pallet-sudo = { path = "../../sudo", default-features = false } -pallet-transaction-payment = { path = "../../transaction-payment", default-features = false } -pallet-treasury = { path = "../../treasury", default-features = false } -pallet-utility = { path = "../../utility", default-features = false } -polymesh-contracts = { path = "../../contracts", default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-bridge = { workspace = true, default-features = false } +pallet-committee = { workspace = true, default-features = false } +pallet-compliance-manager = { workspace = true, default-features = false } +pallet-corporate-actions = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-group = { workspace = true, default-features = false } +pallet-group-rpc-runtime-api = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-multisig = { workspace = true, default-features = false } +pallet-nft = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +pallet-pips = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } +pallet-protocol-fee = { workspace = true, default-features = false } +pallet-relayer = { workspace = true, default-features = false } +pallet-settlement = { workspace = true, default-features = false } +pallet-staking = { workspace = true, default-features = false } +pallet-statistics = { workspace = true, default-features = false } +pallet-sto = { workspace = true, default-features = false } +pallet-sudo = { workspace = true, default-features = false } +pallet-transaction-payment = { workspace = true, default-features = false } +pallet-treasury = { workspace = true, default-features = false } +pallet-utility = { workspace = true, default-features = false } +polymesh-contracts = { workspace = true, default-features = false } # RPC -node-rpc-runtime-api = { path = "../../../rpc/runtime-api", default-features = false } -pallet-staking-rpc-runtime-api = { package = "pallet-staking-rpc-runtime-api", path = "../../staking/rpc/runtime-api", default-features = false } -pallet-protocol-fee-rpc-runtime-api = { package = "pallet-protocol-fee-rpc-runtime-api", path = "../../protocol-fee/rpc/runtime-api", default-features = false } +node-rpc-runtime-api = { workspace = true, default-features = false } +pallet-staking-rpc-runtime-api = { workspace = true, default-features = false } +pallet-protocol-fee-rpc-runtime-api = { workspace = true, default-features = false } # Others log = "0.4.8" @@ -97,7 +97,7 @@ sp-transaction-pool = { version = "4.0.0-dev", default-features = false } sp-version = { version = "5.0.0", default-features = false } [build-dependencies] -polymesh-build-tool = { path = "../build_tool", default-features = false } +polymesh-build-tool = { workspace = true, default-features = false } [features] default = ["std", "equalize"] diff --git a/pallets/runtime/mainnet/src/runtime.rs b/pallets/runtime/mainnet/src/runtime.rs index 624c51d800..6a36b32027 100644 --- a/pallets/runtime/mainnet/src/runtime.rs +++ b/pallets/runtime/mainnet/src/runtime.rs @@ -193,7 +193,7 @@ polymesh_runtime_common::misc_pallet_impls!(); type CddHandler = polymesh_runtime_common::fee_details::CddHandler; -impl polymesh_common_utilities::traits::identity::Config for Runtime { +impl pallet_identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; type CddServiceProviders = CddServiceProviders; diff --git a/pallets/runtime/testnet/Cargo.toml b/pallets/runtime/testnet/Cargo.toml index 813482bb18..41f0ca1943 100644 --- a/pallets/runtime/testnet/Cargo.toml +++ b/pallets/runtime/testnet/Cargo.toml @@ -9,44 +9,44 @@ build = "build.rs" [dependencies] # Common -polymesh-common-utilities = { path = "../../common", default-features = false } -polymesh-runtime-common = { path = "../common", default-features = false} -polymesh-primitives = { path = "../../../primitives", default-features = false } -polymesh-weights = { path = "../../weights", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-runtime-common = { workspace = true, default-features = false} +polymesh-primitives = { workspace = true, default-features = false } +polymesh-weights = { workspace = true, default-features = false } # Our pallets -pallet-asset = { path = "../../asset", default-features = false } -pallet-balances = { path = "../../balances", default-features = false } -pallet-base = { path = "../../base", default-features = false } -pallet-sto = { path = "../../sto", default-features = false } -pallet-bridge = { path = "../../bridge", default-features = false } -pallet-committee = { path = "../../committee", default-features = false } -pallet-compliance-manager = { path = "../../compliance-manager", default-features = false } -pallet-corporate-actions = { path = "../../corporate-actions", default-features = false } -pallet-external-agents = { path = "../../external-agents", default-features = false } -pallet-group = { path = "../../group", default-features = false } -pallet-group-rpc-runtime-api = { path = "../../group/rpc/runtime-api", default-features = false } -pallet-identity = { path = "../../identity", default-features = false } -pallet-multisig = { path = "../../multisig", default-features = false } -pallet-nft = { path = "../../nft", default-features = false } -pallet-permissions = { path = "../../permissions", default-features = false } -pallet-pips = { path = "../../pips", default-features = false } -pallet-portfolio = { path = "../../portfolio", default-features = false } -pallet-protocol-fee = { path = "../../protocol-fee", default-features = false } -pallet-relayer = { path = "../../relayer", default-features = false } -pallet-settlement = { path = "../../settlement", default-features = false } -pallet-staking = { path = "../../staking", default-features = false } -pallet-statistics = { path = "../../statistics", default-features = false } -pallet-transaction-payment = { path = "../../transaction-payment", default-features = false } -pallet-treasury = { path = "../../treasury", default-features = false } -pallet-utility = { path = "../../utility", default-features = false } -pallet-sudo = { path = "../../sudo", default-features = false } -polymesh-contracts = { path = "../../contracts", default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-sto = { workspace = true, default-features = false } +pallet-bridge = { workspace = true, default-features = false } +pallet-committee = { workspace = true, default-features = false } +pallet-compliance-manager = { workspace = true, default-features = false } +pallet-corporate-actions = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-group = { workspace = true, default-features = false } +pallet-group-rpc-runtime-api = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-multisig = { workspace = true, default-features = false } +pallet-nft = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +pallet-pips = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } +pallet-protocol-fee = { workspace = true, default-features = false } +pallet-relayer = { workspace = true, default-features = false } +pallet-settlement = { workspace = true, default-features = false } +pallet-staking = { workspace = true, default-features = false } +pallet-statistics = { workspace = true, default-features = false } +pallet-transaction-payment = { workspace = true, default-features = false } +pallet-treasury = { workspace = true, default-features = false } +pallet-utility = { workspace = true, default-features = false } +pallet-sudo = { workspace = true, default-features = false } +polymesh-contracts = { workspace = true, default-features = false } # RPC -node-rpc-runtime-api = { path = "../../../rpc/runtime-api", default-features = false } -pallet-staking-rpc-runtime-api = { package = "pallet-staking-rpc-runtime-api", path = "../../staking/rpc/runtime-api", default-features = false } -pallet-protocol-fee-rpc-runtime-api = { package = "pallet-protocol-fee-rpc-runtime-api", path = "../../protocol-fee/rpc/runtime-api", default-features = false } +node-rpc-runtime-api = { workspace = true, default-features = false } +pallet-staking-rpc-runtime-api = { workspace = true, default-features = false } +pallet-protocol-fee-rpc-runtime-api = { workspace = true, default-features = false } # Others lazy_static = { version = "1.4.0", default-features = false } @@ -99,7 +99,7 @@ frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false smallvec = "1.4.0" [build-dependencies] -polymesh-build-tool = { path = "../build_tool", default-features = false } +polymesh-build-tool = { workspace = true, default-features = false } [features] default = ["std", "equalize"] diff --git a/pallets/runtime/testnet/src/runtime.rs b/pallets/runtime/testnet/src/runtime.rs index 717f2cfb11..45a430d598 100644 --- a/pallets/runtime/testnet/src/runtime.rs +++ b/pallets/runtime/testnet/src/runtime.rs @@ -196,7 +196,7 @@ polymesh_runtime_common::misc_pallet_impls!(); type CddHandler = polymesh_runtime_common::fee_details::CddHandler; -impl polymesh_common_utilities::traits::identity::Config for Runtime { +impl pallet_identity::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; type CddServiceProviders = CddServiceProviders; diff --git a/pallets/runtime/tests/Cargo.toml b/pallets/runtime/tests/Cargo.toml index 1576784e68..6558185109 100644 --- a/pallets/runtime/tests/Cargo.toml +++ b/pallets/runtime/tests/Cargo.toml @@ -5,41 +5,41 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -node-rpc-runtime-api = { path = "../../../rpc/runtime-api", default-features = false } -pallet-asset = { path = "../../asset", default-features = false } -pallet-balances = { path = "../../balances", default-features = false } -pallet-base = { path = "../../base", default-features = false } -pallet-bridge = { path = "../../bridge", default-features = false } -pallet-committee = { path = "../../committee", default-features = false } -pallet-compliance-manager = { path = "../../compliance-manager", default-features = false } -pallet-corporate-actions = { path = "../../corporate-actions", default-features = false } -pallet-external-agents = { path = "../../external-agents", default-features = false } -pallet-group = { path = "../../group", default-features = false } -pallet-group-rpc-runtime-api = { path = "../../group/rpc/runtime-api", default-features = false } -pallet-identity = { path = "../../identity", default-features = false, features = ["no_cdd"] } -pallet-multisig = { path = "../../multisig", default-features = false } -pallet-nft = { path = "../../nft", default-features = false } -pallet-permissions = { path = "../../permissions", default-features = false } -pallet-pips = { path = "../../pips", default-features = false } -pallet-portfolio = { path = "../../portfolio", default-features = false } -pallet-protocol-fee = { path = "../../protocol-fee", default-features = false } -pallet-protocol-fee-rpc-runtime-api = { path = "../../protocol-fee/rpc/runtime-api", default-features = false } -pallet-relayer = { path = "../../relayer", default-features = false } -pallet-settlement = { path = "../../settlement", default-features = false } -pallet-staking = { path = "../../staking", default-features = false } -pallet-staking-rpc-runtime-api = { path = "../../staking/rpc/runtime-api", default-features = false } -pallet-statistics = { path = "../../statistics", default-features = false } -pallet-sto = { path = "../../sto", default-features = false } -pallet-sudo = { path = "../../sudo", default-features = false } -pallet-transaction-payment = { path = "../../transaction-payment", default-features = false } -pallet-treasury = { path = "../../treasury", default-features = false } -pallet-utility = { path = "../../utility", default-features = false } -polymesh-common-utilities = { path = "../../common", default-features = false } -polymesh-contracts = { path = "../../contracts", default-features = false } -polymesh-primitives = { path = "../../../primitives", default-features = false } -polymesh-runtime-common = { path = "../common", default-features = false, features = ["testing"] } -polymesh-runtime-develop = { path = "../develop" } -polymesh-weights = { path = "../../weights", default-features = false } +node-rpc-runtime-api = { workspace = true, default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-bridge = { workspace = true, default-features = false } +pallet-committee = { workspace = true, default-features = false } +pallet-compliance-manager = { workspace = true, default-features = false } +pallet-corporate-actions = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-group = { workspace = true, default-features = false } +pallet-group-rpc-runtime-api = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false, features = ["no_cdd"] } +pallet-multisig = { workspace = true, default-features = false } +pallet-nft = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +pallet-pips = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } +pallet-protocol-fee = { workspace = true, default-features = false } +pallet-protocol-fee-rpc-runtime-api = { workspace = true, default-features = false } +pallet-relayer = { workspace = true, default-features = false } +pallet-settlement = { workspace = true, default-features = false } +pallet-staking = { workspace = true, default-features = false } +pallet-staking-rpc-runtime-api = { workspace = true, default-features = false } +pallet-statistics = { workspace = true, default-features = false } +pallet-sto = { workspace = true, default-features = false } +pallet-sudo = { workspace = true, default-features = false } +pallet-transaction-payment = { workspace = true, default-features = false } +pallet-treasury = { workspace = true, default-features = false } +pallet-utility = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-contracts = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-runtime-common = { workspace = true, default-features = false, features = ["testing"] } +polymesh-runtime-develop = { workspace = true } +polymesh-weights = { workspace = true, default-features = false } polymesh-exec-macro = { path = "exec_macro" } # General diff --git a/pallets/runtime/tests/src/identity_test.rs b/pallets/runtime/tests/src/identity_test.rs index 70a6af14a7..9fa4fd57d7 100644 --- a/pallets/runtime/tests/src/identity_test.rs +++ b/pallets/runtime/tests/src/identity_test.rs @@ -19,7 +19,7 @@ use frame_support::{ }; use pallet_balances as balances; use pallet_identity::{ChildDid, CustomClaimIdSequence, CustomClaims, CustomClaimsInverse}; -use polymesh_common_utilities::traits::identity::{Config as IdentityConfig, RawEvent}; +use pallet_identity::{Config as IdentityConfig, RawEvent}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ constants::currency::POLY, diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index 342c2859b5..2a9e5a94e3 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -290,7 +290,7 @@ impl pallet_protocol_fee::Config for Test { type Subsidiser = Test; } -impl polymesh_common_utilities::traits::identity::Config for Test { +impl pallet_identity::Config for Test { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; type CddServiceProviders = pallet_group::Module; diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index 4e1e76802f..95a5751517 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -607,7 +607,7 @@ impl committee::Config for TestStorage { type WeightInfo = polymesh_weights::pallet_committee::SubstrateWeight; } -impl polymesh_common_utilities::traits::identity::Config for TestStorage { +impl pallet_identity::Config for TestStorage { type RuntimeEvent = RuntimeEvent; type Proposal = RuntimeCall; type CddServiceProviders = CddServiceProvider; diff --git a/pallets/settlement/Cargo.toml b/pallets/settlement/Cargo.toml index 5e25227f79..6cc8de044f 100644 --- a/pallets/settlement/Cargo.toml +++ b/pallets/settlement/Cargo.toml @@ -5,17 +5,17 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { path = "../common", default-features = false } -pallet-balances = { path = "../balances", default-features = false } -pallet-base = { path = "../base", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-asset = { path = "../asset", default-features = false } -pallet-external-agents = { path = "../external-agents", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-primitives-derive = { path = "../../primitives_derive", default-features = false } -pallet-compliance-manager = { path = "../compliance-manager", default-features = false } -pallet-statistics = { path = "../statistics", default-features = false } -pallet-nft = { path = "../nft", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-primitives-derive = { workspace = true, default-features = false } +pallet-compliance-manager = { workspace = true, default-features = false } +pallet-statistics = { workspace = true, default-features = false } +pallet-nft = { workspace = true, default-features = false } serde = { version = "1.0.104", default-features = false } serde_derive = { version = "1.0.104", optional = true, default-features = false } diff --git a/pallets/settlement/src/benchmarking.rs b/pallets/settlement/src/benchmarking.rs index d2cc61b6f3..bb3e8a359a 100644 --- a/pallets/settlement/src/benchmarking.rs +++ b/pallets/settlement/src/benchmarking.rs @@ -22,8 +22,9 @@ use sp_runtime::MultiSignature; use sp_std::prelude::*; use pallet_asset::benchmarking::setup_asset_transfer; +use pallet_identity::benchmarking::{User, UserBuilder}; use pallet_nft::benchmarking::setup_nft_transfer; -use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, User, UserBuilder}; +use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_primitives::checked_inc::CheckedInc; use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::constants::ENSURED_MAX_LEN; diff --git a/pallets/settlement/src/lib.rs b/pallets/settlement/src/lib.rs index 925657fee1..2740a80a9d 100644 --- a/pallets/settlement/src/lib.rs +++ b/pallets/settlement/src/lib.rs @@ -71,7 +71,7 @@ use pallet_asset::MandatoryMediators; use pallet_base::{ensure_string_limited, try_next_post}; use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; pub use polymesh_common_utilities::traits::settlement::{Event, RawEvent, WeightInfo}; -use polymesh_common_utilities::traits::{asset, compliance_manager, identity, nft, CommonConfig}; +use polymesh_common_utilities::traits::{asset, compliance_manager, nft, CommonConfig}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::queue_priority::SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY; use polymesh_primitives::settlement::{ @@ -105,7 +105,7 @@ pub trait Config: + CommonConfig + compliance_manager::Config + frame_system::Config - + identity::Config + + pallet_identity::Config + nft::Config + pallet_timestamp::Config { @@ -113,7 +113,7 @@ pub trait Config: type RuntimeEvent: From> + Into<::RuntimeEvent>; /// A call type used by the scheduler. - type Proposal: From> + Into<::Proposal>; + type Proposal: From> + Into<::Proposal>; /// Scheduler of settlement instructions. type Scheduler: Named::Proposal, Self::SchedulerOrigin>; diff --git a/pallets/staking/Cargo.toml b/pallets/staking/Cargo.toml index fecec3459d..d75a504a81 100644 --- a/pallets/staking/Cargo.toml +++ b/pallets/staking/Cargo.toml @@ -5,9 +5,9 @@ authors = ["Parity Technologies "] edition = "2021" [dependencies] -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } -pallet-identity = { path = "../identity", default-features = false} +polymesh-primitives = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false} # General static_assertions = "1.1.0" diff --git a/pallets/staking/rpc/Cargo.toml b/pallets/staking/rpc/Cargo.toml index 1480dab7d3..cca6e62550 100644 --- a/pallets/staking/rpc/Cargo.toml +++ b/pallets/staking/rpc/Cargo.toml @@ -22,5 +22,5 @@ frame-system = { version = "4.0.0-dev", default-features = false } # General serde = { version = "1.0.104", features = ["derive"] } -node-rpc = { path = "../../../rpc" } +node-rpc = { workspace = true } pallet-staking-rpc-runtime-api = { version = "2.0.0", path = "./runtime-api" } diff --git a/pallets/staking/src/benchmarking.rs b/pallets/staking/src/benchmarking.rs index 19fc6b1296..2e5b337686 100644 --- a/pallets/staking/src/benchmarking.rs +++ b/pallets/staking/src/benchmarking.rs @@ -52,7 +52,7 @@ type MaxNominators = <::BenchmarkingConfig as BenchmarkingConfig use frame_support::StorageDoubleMap; -use polymesh_common_utilities::benchs::{User, UserBuilder}; +use pallet_identity::benchmarking::{User, UserBuilder}; use polymesh_primitives::identity_claim::ClaimType; use polymesh_primitives::{IdentityId, Permissions}; diff --git a/pallets/staking/src/pallet/mod.rs b/pallets/staking/src/pallet/mod.rs index c47f793cd2..6a34dbdc85 100644 --- a/pallets/staking/src/pallet/mod.rs +++ b/pallets/staking/src/pallet/mod.rs @@ -56,7 +56,7 @@ use frame_system::offchain::SendTransactionTypes; use sp_runtime::traits::{AccountIdConversion, Dispatchable}; use sp_runtime::Permill; -use polymesh_common_utilities::identity::Config as IdentityConfig; +use pallet_identity::Config as IdentityConfig; use polymesh_primitives::constants::GC_PALLET_ID; use polymesh_primitives::GC_DID; use polymesh_primitives::{storage_migration_ver, traits::IdentityFnTrait, IdentityId}; diff --git a/pallets/staking/src/testing_utils.rs b/pallets/staking/src/testing_utils.rs index 37d02b3103..e8b2c6366c 100644 --- a/pallets/staking/src/testing_utils.rs +++ b/pallets/staking/src/testing_utils.rs @@ -36,7 +36,7 @@ const SEED: u32 = 0; // Polymesh change // ----------------------------------------------------------------- -use polymesh_common_utilities::benchs::{User, UserBuilder}; +use pallet_identity::benchmarking::{User, UserBuilder}; use polymesh_primitives::{AuthorizationData, Permissions, Signatory}; // ----------------------------------------------------------------- diff --git a/pallets/statistics/Cargo.toml b/pallets/statistics/Cargo.toml index 26382b84f7..498937c19a 100644 --- a/pallets/statistics/Cargo.toml +++ b/pallets/statistics/Cargo.toml @@ -5,10 +5,10 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } -pallet-external-agents = { path = "../external-agents", default-features = false } -pallet-identity = { path = "../identity", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } # Other log = "0.4.8" diff --git a/pallets/statistics/src/benchmarking.rs b/pallets/statistics/src/benchmarking.rs index 38f86f3090..77cde31ad8 100644 --- a/pallets/statistics/src/benchmarking.rs +++ b/pallets/statistics/src/benchmarking.rs @@ -3,7 +3,8 @@ use sp_runtime::Permill; use sp_std::collections::btree_set::BTreeSet; use sp_std::prelude::*; -use polymesh_common_utilities::benchs::{create_and_issue_sample_asset, User, UserBuilder}; +use pallet_identity::benchmarking::{User, UserBuilder}; +use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_common_utilities::traits::asset::Config as Asset; use polymesh_primitives::constants::currency::{ONE_UNIT, POLY}; use polymesh_primitives::{jurisdiction::*, statistics::*, Claim, ClaimType, Scope}; diff --git a/pallets/sto/Cargo.toml b/pallets/sto/Cargo.toml index 43448759af..665e30c936 100644 --- a/pallets/sto/Cargo.toml +++ b/pallets/sto/Cargo.toml @@ -5,18 +5,18 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -pallet-asset = { path = "../asset", default-features = false } -pallet-balances = { path = "../balances", default-features = false } -pallet-base = { path = "../base", default-features = false } -pallet-compliance-manager = { path = "../compliance-manager", default-features = false } -pallet-external-agents = { path = "../external-agents", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } -pallet-portfolio = { path = "../portfolio", default-features = false } -pallet-settlement = { path = "../settlement", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-primitives-derive = { path = "../../primitives_derive", default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-base = { workspace = true, default-features = false } +pallet-compliance-manager = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } +pallet-settlement = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-primitives-derive = { workspace = true, default-features = false } serde = { version = "1.0.104", default-features = false } serde_derive = { version = "1.0.104", optional = true, default-features = false } diff --git a/pallets/sto/src/benchmarking.rs b/pallets/sto/src/benchmarking.rs index 8b3f4b767c..d9afd21464 100644 --- a/pallets/sto/src/benchmarking.rs +++ b/pallets/sto/src/benchmarking.rs @@ -3,7 +3,7 @@ use frame_support::dispatch::DispatchError; use scale_info::prelude::format; use pallet_asset::benchmarking::setup_asset_transfer; -use polymesh_common_utilities::benchs::{User, UserBuilder}; +use pallet_identity::benchmarking::{User, UserBuilder}; use polymesh_primitives::settlement::VenueDetails; use polymesh_primitives::TrustedIssuer; diff --git a/pallets/sto/src/lib.rs b/pallets/sto/src/lib.rs index 1ec3a14c87..54aa522ab8 100644 --- a/pallets/sto/src/lib.rs +++ b/pallets/sto/src/lib.rs @@ -39,7 +39,7 @@ use pallet_base::try_next_post; use pallet_identity::PermissionedCallOriginData; use pallet_settlement::VenueInfo; use polymesh_common_utilities::portfolio::PortfolioSubTrait; -use polymesh_common_utilities::traits::{identity, portfolio}; +use polymesh_common_utilities::traits::portfolio; use polymesh_primitives::asset::AssetId; use polymesh_primitives::impl_checked_inc; use polymesh_primitives::settlement::{Leg, ReceiptDetails, SettlementType, VenueId, VenueType}; @@ -169,7 +169,7 @@ pub trait WeightInfo { pub trait Config: frame_system::Config - + identity::Config + + pallet_identity::Config + pallet_settlement::Config + portfolio::Config + pallet_base::Config diff --git a/pallets/transaction-payment/Cargo.toml b/pallets/transaction-payment/Cargo.toml index 96fa38bc6d..818abf8aa2 100644 --- a/pallets/transaction-payment/Cargo.toml +++ b/pallets/transaction-payment/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" [dependencies] # Our deps -polymesh-primitives = { path = "../../primitives", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } # General serde = { version = "1.0.104", default-features = false, optional = true } @@ -42,4 +42,4 @@ std = [ "frame-system/std", "pallet-timestamp/std", ] -try-runtime = [] \ No newline at end of file +try-runtime = [] diff --git a/pallets/treasury/Cargo.toml b/pallets/treasury/Cargo.toml index 46b17b0ec8..8c6946b8b0 100644 --- a/pallets/treasury/Cargo.toml +++ b/pallets/treasury/Cargo.toml @@ -5,11 +5,11 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { path = "../common", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } -pallet-balances = { path = "../balances", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } -pallet-identity = { path = "../identity", default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } # General serde = { version = "1.0.104", default-features = false } diff --git a/pallets/treasury/src/benchmarking.rs b/pallets/treasury/src/benchmarking.rs index 0e8e051076..3f5a5d882c 100644 --- a/pallets/treasury/src/benchmarking.rs +++ b/pallets/treasury/src/benchmarking.rs @@ -17,7 +17,7 @@ use crate::*; use frame_benchmarking::benchmarks; use frame_system::RawOrigin; -use polymesh_common_utilities::benchs::UserBuilder; +use pallet_identity::benchmarking::UserBuilder; use sp_std::vec::Vec; const MAX_BENEFICIARIES: u32 = 128; diff --git a/pallets/utility/Cargo.toml b/pallets/utility/Cargo.toml index 2cc849681c..cb655300f8 100644 --- a/pallets/utility/Cargo.toml +++ b/pallets/utility/Cargo.toml @@ -5,11 +5,12 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -pallet-balances = { path = "../balances", default-features = false } -pallet-permissions = { path = "../permissions", default-features = false } -polymesh-common-utilities = { path = "../common", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -polymesh-primitives = { path = "../../primitives", default-features = false } +# Out Pallets +pallet-balances = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } +polymesh-common-utilities = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +polymesh-primitives = { workspace = true, default-features = false } # Substrate codec = { workspace = true, default-features = false, features = ["derive"] } @@ -37,7 +38,7 @@ std = [ "polymesh-common-utilities/std", "polymesh-primitives/std", "pallet-balances/std", - "pallet-identity/std" + "pallet-identity/std", ] runtime-benchmarks = [ diff --git a/pallets/utility/src/benchmarking.rs b/pallets/utility/src/benchmarking.rs index 90a94254ac..d206334097 100644 --- a/pallets/utility/src/benchmarking.rs +++ b/pallets/utility/src/benchmarking.rs @@ -24,7 +24,7 @@ use frame_system::RawOrigin; use sp_core::sr25519::Signature; use sp_runtime::MultiSignature; -use polymesh_common_utilities::benchs::{user, User, UserBuilder}; +use pallet_identity::benchmarking::{user, User, UserBuilder}; use super::*; diff --git a/pallets/utility/src/lib.rs b/pallets/utility/src/lib.rs index 0201536cd4..e6bec565db 100644 --- a/pallets/utility/src/lib.rs +++ b/pallets/utility/src/lib.rs @@ -84,9 +84,9 @@ use sp_runtime::traits::{BadOrigin, Dispatchable}; use sp_runtime::{traits::Verify, DispatchError, RuntimeDebug}; use sp_std::prelude::*; +use pallet_identity::Config as IdentityConfig; use pallet_permissions::with_call_metadata; use polymesh_common_utilities::balances::{CheckCdd, Config as BalancesConfig}; -use polymesh_common_utilities::identity::Config as IdentityConfig; use polymesh_common_utilities::Context; use polymesh_primitives::{identity::AuthorizationNonce, IdentityId}; diff --git a/pallets/weights/Cargo.toml b/pallets/weights/Cargo.toml index 781ceaa7fc..70066c660d 100644 --- a/pallets/weights/Cargo.toml +++ b/pallets/weights/Cargo.toml @@ -20,28 +20,28 @@ pallet-session = { version = "4.0.0-dev", default-features = false } sp-std = { version = "5.0.0", default-features = false } # our pallets -pallet-asset = { path = "../asset", default-features = false } -pallet-balances = { path = "../balances", default-features = false } -pallet-staking = { path = "../staking", default-features = false } -pallet-committee = { path = "../committee", default-features = false } -pallet-compliance-manager = { path = "../compliance-manager", default-features = false } -pallet-corporate-actions = { path = "../corporate-actions", default-features = false } -pallet-external-agents = { path = "../external-agents", default-features = false } -pallet-group = { path = "../group", default-features = false } -pallet-identity = { path = "../identity", default-features = false } -pallet-multisig = { path = "../multisig", default-features = false } -pallet-nft = { path = "../nft", default-features = false } -pallet-pips = { path = "../pips", default-features = false } -pallet-portfolio = { path = "../portfolio", default-features = false } -pallet-protocol-fee = { path = "../protocol-fee", default-features = false } -pallet-relayer = { path = "../relayer", default-features = false } -pallet-settlement = { path = "../settlement", default-features = false } -pallet-statistics = { path = "../statistics", default-features = false } -pallet-sto = { path = "../sto", default-features = false } -pallet-treasury = { path = "../treasury", default-features = false } -pallet-utility = { path = "../utility", default-features = false } -polymesh-contracts = { path = "../contracts", default-features = false } -polymesh-runtime-common = { path = "../runtime/common", default-features = false } +pallet-asset = { workspace = true, default-features = false } +pallet-balances = { workspace = true, default-features = false } +pallet-staking = { workspace = true, default-features = false } +pallet-committee = { workspace = true, default-features = false } +pallet-compliance-manager = { workspace = true, default-features = false } +pallet-corporate-actions = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } +pallet-group = { workspace = true, default-features = false } +pallet-identity = { workspace = true, default-features = false } +pallet-multisig = { workspace = true, default-features = false } +pallet-nft = { workspace = true, default-features = false } +pallet-pips = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } +pallet-protocol-fee = { workspace = true, default-features = false } +pallet-relayer = { workspace = true, default-features = false } +pallet-settlement = { workspace = true, default-features = false } +pallet-statistics = { workspace = true, default-features = false } +pallet-sto = { workspace = true, default-features = false } +pallet-treasury = { workspace = true, default-features = false } +pallet-utility = { workspace = true, default-features = false } +polymesh-contracts = { workspace = true, default-features = false } +polymesh-runtime-common = { workspace = true, default-features = false } [features] default = ["std"] From 5392fb146ecf530c8ce12720906a15781ff1d42f Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 22:37:29 +0800 Subject: [PATCH 18/45] Move AssetFnTrait and asset bench helpers to primitives. --- pallets/asset/src/benchmarking.rs | 10 +-- pallets/asset/src/lib.rs | 46 +++++++----- pallets/common/src/benchs/mod.rs | 19 ----- pallets/common/src/lib.rs | 3 - pallets/common/src/traits/asset.rs | 69 ++---------------- .../common/src/traits/compliance_manager.rs | 12 ++-- pallets/common/src/traits/portfolio.rs | 7 +- pallets/common/src/traits/statistics.rs | 7 +- .../compliance-manager/src/benchmarking.rs | 12 ++-- pallets/contracts/src/chain_extension.rs | 2 +- pallets/contracts/src/lib.rs | 7 +- pallets/corporate-actions/src/benchmarking.rs | 5 +- pallets/external-agents/src/benchmarking.rs | 5 +- pallets/nft/src/benchmarking.rs | 10 ++- pallets/portfolio/src/benchmarking.rs | 4 +- pallets/portfolio/src/lib.rs | 13 ++-- pallets/runtime/common/src/runtime.rs | 9 ++- pallets/runtime/tests/src/asset_test.rs | 2 +- pallets/settlement/src/benchmarking.rs | 4 +- pallets/statistics/src/benchmarking.rs | 19 ++--- pallets/statistics/src/lib.rs | 8 +-- .../asset.rs => primitives/src/bench.rs | 31 ++++---- primitives/src/lib.rs | 4 ++ primitives/src/traits.rs | 2 + primitives/src/traits/asset.rs | 70 +++++++++++++++++++ 25 files changed, 195 insertions(+), 185 deletions(-) delete mode 100644 pallets/common/src/benchs/mod.rs rename pallets/common/src/benchs/asset.rs => primitives/src/bench.rs (60%) create mode 100644 primitives/src/traits/asset.rs diff --git a/pallets/asset/src/benchmarking.rs b/pallets/asset/src/benchmarking.rs index a8e720d060..ac5ad96f4f 100644 --- a/pallets/asset/src/benchmarking.rs +++ b/pallets/asset/src/benchmarking.rs @@ -22,7 +22,6 @@ use sp_std::{convert::TryInto, iter, prelude::*}; use pallet_identity::benchmarking::{user, User, UserBuilder}; use pallet_statistics::benchmarking::setup_transfer_restrictions; -use polymesh_common_utilities::benchs::reg_unique_ticker; use polymesh_common_utilities::traits::compliance_manager::ComplianceFnConfig; use polymesh_common_utilities::traits::nft::NFTTrait; use polymesh_primitives::agent::AgentGroup; @@ -31,6 +30,7 @@ use polymesh_primitives::asset_metadata::{ AssetMetadataDescription, AssetMetadataKey, AssetMetadataName, AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, }; +use polymesh_primitives::bench::reg_unique_ticker; use polymesh_primitives::constants::currency::{ONE_UNIT, POLY}; use polymesh_primitives::ticker::TICKER_LEN; use polymesh_primitives::{ @@ -259,7 +259,7 @@ benchmarks! { let bob = UserBuilder::::default().generate_did().build("Bob"); let alice = UserBuilder::::default().generate_did().build("Alice"); - let ticker = reg_unique_ticker::(alice.origin().into(), None); + let ticker = reg_unique_ticker::(alice.account(), None); let new_owner_auth_id = pallet_identity::Module::::add_auth( alice.did(), Signatory::from(bob.did()), @@ -288,7 +288,7 @@ benchmarks! { let bob = UserBuilder::::default().generate_did().build("Bob"); let alice = UserBuilder::::default().generate_did().build("Alice"); let asset_id = create_sample_asset::(&alice, true); - let ticker = reg_unique_ticker::(alice.origin().into(), None); + let ticker = reg_unique_ticker::(alice.account(), None); Module::::link_ticker_to_asset_id(alice.origin().into(), ticker, asset_id).unwrap(); let new_owner_auth_id = pallet_identity::Module::::add_auth( @@ -748,14 +748,14 @@ benchmarks! { set_ticker_registration_config::(); let alice = UserBuilder::::default().generate_did().build("Alice"); let asset_id = create_sample_asset::(&alice, true); - let ticker = reg_unique_ticker::(alice.origin().into(), None); + let ticker = reg_unique_ticker::(alice.account(), None); }: _(alice.origin, ticker, asset_id) unlink_ticker_from_asset_id { set_ticker_registration_config::(); let alice = UserBuilder::::default().generate_did().build("Alice"); let asset_id = create_sample_asset::(&alice, true); - let ticker = reg_unique_ticker::(alice.origin().into(), None); + let ticker = reg_unique_ticker::(alice.account(), None); Module::::link_ticker_to_asset_id( alice.clone().origin().into(), ticker, diff --git a/pallets/asset/src/lib.rs b/pallets/asset/src/lib.rs index e1adf71af2..79b09dd368 100644 --- a/pallets/asset/src/lib.rs +++ b/pallets/asset/src/lib.rs @@ -80,6 +80,9 @@ pub mod benchmarking; pub mod checkpoint; +#[cfg(feature = "runtime-benchmarks")] +use frame_system::RawOrigin; + mod error; mod migrations; mod types; @@ -103,7 +106,6 @@ use pallet_base::{ }; use pallet_identity::PermissionedCallOriginData; use pallet_portfolio::{Error as PortfolioError, PortfolioAssetBalances}; -use polymesh_common_utilities::asset::AssetFnTrait; use polymesh_common_utilities::compliance_manager::ComplianceFnConfig; pub use polymesh_common_utilities::traits::asset::{Config, Event, RawEvent, WeightInfo}; use polymesh_common_utilities::traits::nft::NFTTrait; @@ -118,6 +120,7 @@ use polymesh_primitives::asset_metadata::{ use polymesh_primitives::constants::*; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::settlement::InstructionId; +use polymesh_primitives::traits::AssetFnTrait; use polymesh_primitives::{ extract_auth, storage_migrate_on, storage_migration_ver, AssetIdentifier, Balance, Document, DocumentId, IdentityId, Memo, PortfolioId, PortfolioKind, PortfolioUpdateReason, SecondaryKey, @@ -2863,7 +2866,7 @@ impl Module { // Trait implementation! //========================================================================== -impl AssetFnTrait for Module { +impl AssetFnTrait for Module { fn ensure_granular(asset_id: &AssetId, value: Balance) -> DispatchResult { let asset_details = Self::try_get_asset_details(&asset_id)?; Self::ensure_asset_granular(&asset_details, &value) @@ -2893,21 +2896,23 @@ impl AssetFnTrait for Module { } #[cfg(feature = "runtime-benchmarks")] - fn register_unique_ticker(origin: T::RuntimeOrigin, ticker: Ticker) -> DispatchResult { - Self::register_unique_ticker(origin, ticker) + fn register_unique_ticker(caller: T::AccountId, ticker: Ticker) -> DispatchResult { + let origin = RawOrigin::Signed(caller); + Self::register_unique_ticker(origin.into(), ticker) } #[cfg(feature = "runtime-benchmarks")] fn create_asset( - origin: T::RuntimeOrigin, + caller: T::AccountId, asset_name: AssetName, divisible: bool, asset_type: AssetType, asset_identifiers: Vec, funding_round: Option, ) -> DispatchResult { + let origin = RawOrigin::Signed(caller); Self::create_asset( - origin, + origin.into(), asset_name, divisible, asset_type, @@ -2918,35 +2923,44 @@ impl AssetFnTrait for Module { #[cfg(feature = "runtime-benchmarks")] fn issue( - origin: T::RuntimeOrigin, + caller: T::AccountId, asset_id: AssetId, amount: Balance, portfolio_kind: PortfolioKind, ) -> DispatchResult { - Self::issue(origin, asset_id, amount, portfolio_kind) + let origin = RawOrigin::Signed(caller); + Self::issue(origin.into(), asset_id, amount, portfolio_kind) } #[cfg(feature = "runtime-benchmarks")] fn register_asset_metadata_type( - origin: T::RuntimeOrigin, - asset_id: Option, + asset_and_caller: Option<(AssetId, T::AccountId)>, name: AssetMetadataName, spec: AssetMetadataSpec, ) -> DispatchResult { - match asset_id { - Some(asset_id) => { - Self::register_asset_metadata_local_type(origin, asset_id, name, spec) + match asset_and_caller { + Some((asset_id, caller)) => { + let origin = RawOrigin::Signed(caller); + Self::register_asset_metadata_local_type(origin.into(), asset_id, name, spec) + } + None => { + let origin = RawOrigin::Root; + Self::register_asset_metadata_global_type(origin.into(), name, spec) } - None => Self::register_asset_metadata_global_type(origin, name, spec), } } #[cfg(feature = "runtime-benchmarks")] fn add_mandatory_mediators( - origin: T::RuntimeOrigin, + caller: T::AccountId, asset_id: AssetId, mediators: BTreeSet, ) -> DispatchResult { - Self::add_mandatory_mediators(origin, asset_id, mediators.try_into().unwrap_or_default()) + let origin = RawOrigin::Signed(caller); + Self::add_mandatory_mediators( + origin.into(), + asset_id, + mediators.try_into().unwrap_or_default(), + ) } } diff --git a/pallets/common/src/benchs/mod.rs b/pallets/common/src/benchs/mod.rs deleted file mode 100644 index c0ccba2e09..0000000000 --- a/pallets/common/src/benchs/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -mod asset; -pub use asset::{create_and_issue_sample_asset, reg_unique_ticker}; - -pub use pallet_identity::benchmarking::{cdd_provider, user, user_without_did, User, UserBuilder}; diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 2d089acde3..655363e7d8 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -22,6 +22,3 @@ pub use traits::{ }; pub mod context; pub use context::Context; - -#[cfg(feature = "runtime-benchmarks")] -pub mod benchs; diff --git a/pallets/common/src/traits/asset.rs b/pallets/common/src/traits/asset.rs index d22a066775..0d098aa785 100644 --- a/pallets/common/src/traits/asset.rs +++ b/pallets/common/src/traits/asset.rs @@ -13,11 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#[cfg(feature = "runtime-benchmarks")] -use polymesh_primitives::PortfolioKind; - use frame_support::decl_event; -use frame_support::dispatch::{DispatchError, DispatchResult}; use frame_support::traits::{Currency, Get, UnixTime}; use frame_support::weights::Weight; use sp_std::collections::btree_set::BTreeSet; @@ -30,6 +26,7 @@ use polymesh_primitives::asset_metadata::{ AssetMetadataGlobalKey, AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataName, AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, }; +use polymesh_primitives::traits::AssetFnConfig; use polymesh_primitives::{ AssetIdentifier, Balance, Document, DocumentId, IdentityId, PortfolioId, PortfolioUpdateReason, Ticker, @@ -40,7 +37,11 @@ use crate::traits::{checkpoint, compliance_manager, external_agents, portfolio, /// The module's configuration trait. pub trait Config: - crate::balances::Config + external_agents::Config + statistics::Config + portfolio::Config + crate::balances::Config + + external_agents::Config + + statistics::Config + + portfolio::Config + + AssetFnConfig { /// The overarching event type. type RuntimeEvent: From> @@ -69,8 +70,6 @@ pub trait Config: /// Max length for the Asset Metadata type definition. type AssetMetadataTypeDefMaxLength: Get; - type AssetFn: AssetFnTrait; - type WeightInfo: WeightInfo; type CPWeightInfo: crate::traits::checkpoint::WeightInfo; @@ -223,59 +222,3 @@ pub trait WeightInfo { fn link_ticker_to_asset_id() -> Weight; fn unlink_ticker_from_asset_id() -> Weight; } - -pub trait AssetFnTrait { - /// Returns `Ok` if [`AssetDetails::divisible`] or `value` % ONE_UNIT == 0. - fn ensure_granular(asset_id: &AssetId, value: Balance) -> DispatchResult; - - /// Returns `true` if the given `identity_id` is exempt from affirming the receivement of `asset_id`, otherwise returns `false`. - fn skip_asset_affirmation(identity_id: &IdentityId, asset_id: &AssetId) -> bool; - - /// Returns `true` if the receivement of `asset_id` is exempt from being affirmed, otherwise returns `false`. - fn asset_affirmation_exemption(asset_id: &AssetId) -> bool; - - /// Returns the `did` balance for the given `asset_id`. - fn asset_balance(asset_id: &AssetId, did: &IdentityId) -> Balance; - - /// Returns the total supply for the given `asset_id`. - fn asset_total_supply(asset_id: &AssetId) -> Result; - - /// Returns the next [`AssetID`] for the `caller_acc`. - fn generate_asset_id(caller_acc: Account) -> AssetId; - - #[cfg(feature = "runtime-benchmarks")] - fn register_unique_ticker(origin: Origin, ticker: Ticker) -> DispatchResult; - - #[cfg(feature = "runtime-benchmarks")] - fn create_asset( - origin: Origin, - asset_name: AssetName, - divisible: bool, - asset_type: AssetType, - asset_identifiers: Vec, - funding_round: Option, - ) -> DispatchResult; - - #[cfg(feature = "runtime-benchmarks")] - fn issue( - origin: Origin, - asset_id: AssetId, - amount: Balance, - portfolio_kind: PortfolioKind, - ) -> DispatchResult; - - #[cfg(feature = "runtime-benchmarks")] - fn register_asset_metadata_type( - origin: Origin, - asset_id: Option, - name: AssetMetadataName, - spec: AssetMetadataSpec, - ) -> DispatchResult; - - #[cfg(feature = "runtime-benchmarks")] - fn add_mandatory_mediators( - origin: Origin, - asset_id: AssetId, - mediators: BTreeSet, - ) -> DispatchResult; -} diff --git a/pallets/common/src/traits/compliance_manager.rs b/pallets/common/src/traits/compliance_manager.rs index 14360cf309..faa1c8d6c5 100644 --- a/pallets/common/src/traits/compliance_manager.rs +++ b/pallets/common/src/traits/compliance_manager.rs @@ -23,23 +23,25 @@ use sp_std::prelude::*; use polymesh_primitives::asset::AssetId; use polymesh_primitives::compliance_manager::{AssetComplianceResult, ComplianceRequirement}; use polymesh_primitives::condition::{conditions_total_counts, Condition}; +use polymesh_primitives::traits::AssetFnConfig; use polymesh_primitives::{IdentityId, TrustedIssuer, WeightMeter}; -use crate::asset::AssetFnTrait; use crate::balances::Config as BalancesConfig; use crate::traits::external_agents::Config as EAConfig; use crate::traits::CommonConfig; /// The module's configuration trait. pub trait Config: - pallet_timestamp::Config + CommonConfig + BalancesConfig + pallet_identity::Config + EAConfig + pallet_timestamp::Config + + CommonConfig + + BalancesConfig + + pallet_identity::Config + + EAConfig + + AssetFnConfig { /// The overarching event type. type RuntimeEvent: From + Into<::RuntimeEvent>; - /// Asset module - type Asset: AssetFnTrait; - /// Weight details of all extrinsic type WeightInfo: WeightInfo; diff --git a/pallets/common/src/traits/portfolio.rs b/pallets/common/src/traits/portfolio.rs index 7e54b922c3..d20269b686 100644 --- a/pallets/common/src/traits/portfolio.rs +++ b/pallets/common/src/traits/portfolio.rs @@ -17,12 +17,13 @@ //! //! The interface allows to accept portfolio custody -use crate::{asset::AssetFnTrait, nft::NFTTrait, CommonConfig}; +use crate::{nft::NFTTrait, CommonConfig}; use frame_support::decl_event; use frame_support::dispatch::DispatchResult; use frame_support::pallet_prelude::Get; use frame_support::weights::Weight; use polymesh_primitives::asset::AssetId; +use polymesh_primitives::traits::AssetFnConfig; use polymesh_primitives::{ Balance, Fund, FundDescription, IdentityId, Memo, NFTId, PortfolioId, PortfolioName, PortfolioNumber, SecondaryKey, @@ -117,11 +118,9 @@ pub trait WeightInfo { fn create_custody_portfolio() -> Weight; } -pub trait Config: CommonConfig + pallet_identity::Config { +pub trait Config: CommonConfig + pallet_identity::Config + AssetFnConfig { type RuntimeEvent: From + Into<::RuntimeEvent>; type WeightInfo: WeightInfo; - /// Asset module. - type Asset: AssetFnTrait; /// Maximum number of fungible assets that can be moved in a single transfer call. type MaxNumberOfFungibleMoves: Get; /// Maximum number of NFTs that can be moved in a single transfer call. diff --git a/pallets/common/src/traits/statistics.rs b/pallets/common/src/traits/statistics.rs index e87be85eb2..a0b1b69f71 100644 --- a/pallets/common/src/traits/statistics.rs +++ b/pallets/common/src/traits/statistics.rs @@ -1,8 +1,9 @@ -use crate::asset::AssetFnTrait; +use crate::traits::external_agents::Config as EAConfig; use frame_support::decl_event; use frame_support::traits::Get; use frame_support::weights::Weight; use polymesh_primitives::asset::AssetId; +use polymesh_primitives::traits::AssetFnConfig; use polymesh_primitives::{ statistics::{StatType, StatUpdate}, transfer_compliance::{TransferCondition, TransferConditionExemptKey}, @@ -12,12 +13,10 @@ use sp_std::vec::Vec; /// The main trait for statistics module pub trait Config: - frame_system::Config + pallet_identity::Config + crate::traits::external_agents::Config + frame_system::Config + pallet_identity::Config + EAConfig + AssetFnConfig { /// The overarching event type. type RuntimeEvent: From + Into<::RuntimeEvent>; - /// Asset module. - type Asset: AssetFnTrait; /// Maximum stats that can be enabled for an Asset. type MaxStatsPerAsset: Get; /// Maximum transfer conditions that can be enabled for an Asset. diff --git a/pallets/compliance-manager/src/benchmarking.rs b/pallets/compliance-manager/src/benchmarking.rs index a3789520f6..2e2f86a614 100644 --- a/pallets/compliance-manager/src/benchmarking.rs +++ b/pallets/compliance-manager/src/benchmarking.rs @@ -18,8 +18,8 @@ use scale_info::prelude::format; use pallet_identity::benchmarking::{User, UserBuilder}; use pallet_identity::Config as IdentityConfig; -use polymesh_common_utilities::asset::AssetFnTrait; use polymesh_primitives::agent::AgentGroup; +use polymesh_primitives::traits::AssetFnTrait; use polymesh_primitives::{ asset::AssetType, AuthorizationData, ClaimType, CountryCode, PortfolioKind, Scope, TargetIdentity, TrustedFor, TrustedIssuer, WeightMeter, @@ -118,9 +118,9 @@ pub fn create_and_issue_sample_asset( asset_owner: &User, asset_name: Vec, ) -> AssetId { - let asset_id = T::Asset::generate_asset_id(asset_owner.account()); - T::Asset::create_asset( - asset_owner.origin.clone().into(), + let asset_id = T::AssetFn::generate_asset_id(asset_owner.account()); + T::AssetFn::create_asset( + asset_owner.account(), asset_name.into(), true, AssetType::default(), @@ -129,8 +129,8 @@ pub fn create_and_issue_sample_asset( ) .unwrap(); - T::Asset::issue( - asset_owner.origin.clone().into(), + T::AssetFn::issue( + asset_owner.account(), asset_id, 1_000_000 as u128, PortfolioKind::Default, diff --git a/pallets/contracts/src/chain_extension.rs b/pallets/contracts/src/chain_extension.rs index c6bf9e04de..ab855ce8be 100644 --- a/pallets/contracts/src/chain_extension.rs +++ b/pallets/contracts/src/chain_extension.rs @@ -478,7 +478,7 @@ where target: "runtime", "PolymeshExtension contract GetNextAssetId: caller_account={caller_account:?}", ); - let asset_id = T::Asset::generate_asset_id(caller_account); + let asset_id = T::AssetFn::generate_asset_id(caller_account); trace!( target: "runtime", "PolymeshExtension contract GetNextAssetId: asset_id={asset_id:?}", diff --git a/pallets/contracts/src/lib.rs b/pallets/contracts/src/lib.rs index 8a57a57928..e782b5f44b 100644 --- a/pallets/contracts/src/lib.rs +++ b/pallets/contracts/src/lib.rs @@ -77,7 +77,7 @@ use pallet_contracts::weights::WeightInfo as FrameWeightInfo; use pallet_contracts::Config as BConfig; use pallet_contracts_primitives::Code; use pallet_identity::{Config as IdentityConfig, ParentDid, WeightInfo as IdentityWeightInfo}; -use polymesh_common_utilities::asset::AssetFnTrait; +use polymesh_primitives::traits::{AssetFnConfig, AssetFnTrait}; use polymesh_primitives::{storage_migration_ver, Balance, Permissions}; type Identity = pallet_identity::Module; @@ -296,7 +296,7 @@ pub trait WeightInfo { /// The `Config` trait for the smart contracts pallet. pub trait Config: - IdentityConfig + BConfig + frame_system::Config + IdentityConfig + BConfig + frame_system::Config + AssetFnConfig { /// The overarching event type. type RuntimeEvent: From> + Into<::RuntimeEvent>; @@ -308,9 +308,6 @@ pub trait Config: /// Max value that can be returned from the ChainExtension. type MaxOutLen: Get; - /// Asset module trait - type Asset: AssetFnTrait; - /// The weight configuration for the pallet. type WeightInfo: WeightInfo; } diff --git a/pallets/corporate-actions/src/benchmarking.rs b/pallets/corporate-actions/src/benchmarking.rs index 866b55585d..06036d9a83 100644 --- a/pallets/corporate-actions/src/benchmarking.rs +++ b/pallets/corporate-actions/src/benchmarking.rs @@ -19,8 +19,8 @@ use frame_system::RawOrigin; use pallet_asset::benchmarking::make_document; use pallet_identity::benchmarking::{user, User}; -use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_primitives::asset::{AssetId, AssetName}; +use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::PortfolioKind; use crate::*; @@ -42,7 +42,8 @@ fn setup() -> (User, AssetId) { >::set(1000u32.into()); let owner = user("owner", SEED); - let asset_id = create_and_issue_sample_asset::(&owner, true, None, b"SampleAsset", true); + let asset_id = + create_and_issue_sample_asset::(owner.account(), true, None, b"SampleAsset", true); (owner, asset_id) } diff --git a/pallets/external-agents/src/benchmarking.rs b/pallets/external-agents/src/benchmarking.rs index e4abb7fb02..f4e7417f37 100644 --- a/pallets/external-agents/src/benchmarking.rs +++ b/pallets/external-agents/src/benchmarking.rs @@ -16,8 +16,8 @@ use crate::*; use frame_benchmarking::benchmarks; use pallet_identity::benchmarking::{user, User}; -use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_common_utilities::traits::asset::Config as Asset; +use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::{AuthorizationData, ExtrinsicPermissions, PalletName, PalletPermissions}; use sp_std::prelude::*; @@ -26,7 +26,8 @@ const MAX_PALLETS: u32 = 19; fn setup() -> (User, AssetId) { let owner = user("owner", SEED); - let asset_id = create_and_issue_sample_asset::(&owner, true, None, b"SampleAsset", false); + let asset_id = + create_and_issue_sample_asset::(owner.account(), true, None, b"SampleAsset", false); (owner, asset_id) } diff --git a/pallets/nft/src/benchmarking.rs b/pallets/nft/src/benchmarking.rs index ec02debf69..fa26e12392 100644 --- a/pallets/nft/src/benchmarking.rs +++ b/pallets/nft/src/benchmarking.rs @@ -1,19 +1,18 @@ use frame_benchmarking::benchmarks; -use frame_system::RawOrigin; use scale_info::prelude::format; use sp_std::prelude::*; use sp_std::vec::Vec; use pallet_asset::benchmarking::create_portfolio; use pallet_identity::benchmarking::{user, User, UserBuilder}; -use polymesh_common_utilities::benchs::create_and_issue_sample_asset; -use polymesh_common_utilities::traits::asset::AssetFnTrait; use polymesh_common_utilities::traits::compliance_manager::ComplianceFnConfig; use polymesh_primitives::asset::{AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{ AssetMetadataGlobalKey, AssetMetadataKey, AssetMetadataSpec, AssetMetadataValue, }; +use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::nft::{NFTCollectionId, NFTCollectionKeys, NFTId}; +use polymesh_primitives::traits::AssetFnTrait; use polymesh_primitives::{with_transaction, IdentityId, PortfolioKind, WeightMeter}; use crate::*; @@ -23,7 +22,7 @@ const MAX_COLLECTION_KEYS: u32 = 255; /// Creates an NFT collection with `n` global metadata keys. fn create_collection(collection_owner: &User, n: u32) -> (AssetId, NFTCollectionId) { let asset_id = create_and_issue_sample_asset::( - collection_owner, + collection_owner.account(), false, Some(AssetType::NonFungible(NonFungibleType::Invoice)), b"MyNFT", @@ -49,7 +48,6 @@ fn creates_keys_register_metadata_types(n: u32) -> NFTCollectionKeys for i in 1..n + 1 { let asset_metadata_name = format!("key{}", i).as_bytes().to_vec(); T::AssetFn::register_asset_metadata_type( - RawOrigin::Root.into(), None, asset_metadata_name.into(), AssetMetadataSpec::default(), @@ -120,7 +118,7 @@ where mediator.did() }) .collect(); - T::AssetFn::add_mandatory_mediators(sender.origin().into(), asset_id, mediators_identity) + T::AssetFn::add_mandatory_mediators(sender.account(), asset_id, mediators_identity) .unwrap(); } diff --git a/pallets/portfolio/src/benchmarking.rs b/pallets/portfolio/src/benchmarking.rs index fd05bd4687..5d2cc9e8ca 100644 --- a/pallets/portfolio/src/benchmarking.rs +++ b/pallets/portfolio/src/benchmarking.rs @@ -21,7 +21,7 @@ use sp_std::prelude::*; use pallet_identity::benchmarking::{user, User, UserBuilder}; use polymesh_common_utilities::asset::Config as AssetConfig; -use polymesh_common_utilities::benchs::create_and_issue_sample_asset; +use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::{AuthorizationData, NFTs, PortfolioName, Signatory}; @@ -144,7 +144,7 @@ benchmarks! { let nfts = NFTs::new_unverified(nft_asset_id, (1..n + 1).map(|id| NFTId(id.into())).collect()); let mut funds = vec![Fund { description: FundDescription::NonFungible(nfts), memo: None }]; for i in 0..f { - let asset_id = create_and_issue_sample_asset(&alice, true, None, format!("TICKER{}", i).as_bytes(), true); + let asset_id = create_and_issue_sample_asset::(alice.account(), true, None, format!("TICKER{}", i).as_bytes(), true); funds.push(Fund { description: FundDescription::Fungible{ asset_id, amount: ONE_UNIT }, memo: None }) } }: _(alice.origin, alice_default_portfolio.clone(), alice_custom_portfolio.clone(), funds) diff --git a/pallets/portfolio/src/lib.rs b/pallets/portfolio/src/lib.rs index 6b5296bb7c..97e7ee3df0 100644 --- a/pallets/portfolio/src/lib.rs +++ b/pallets/portfolio/src/lib.rs @@ -56,14 +56,13 @@ use sp_std::prelude::*; use pallet_identity::PermissionedCallOriginData; pub use polymesh_common_utilities::portfolio::{Config, Event, WeightInfo}; -use polymesh_common_utilities::traits::asset::AssetFnTrait; use polymesh_common_utilities::traits::nft::NFTTrait; use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - extract_auth, identity_id::PortfolioValidityResult, storage_migration_ver, Balance, Fund, - FundDescription, IdentityId, NFTId, PortfolioId, PortfolioKind, PortfolioName, PortfolioNumber, - SecondaryKey, + extract_auth, identity_id::PortfolioValidityResult, storage_migration_ver, + traits::AssetFnTrait, Balance, Fund, FundDescription, IdentityId, NFTId, PortfolioId, + PortfolioKind, PortfolioName, PortfolioNumber, SecondaryKey, }; type Identity = pallet_identity::Module; @@ -648,7 +647,7 @@ impl Module { asset_id: &AssetId, amount: Balance, ) -> DispatchResult { - T::Asset::ensure_granular(asset_id, amount)?; + T::AssetFn::ensure_granular(asset_id, amount)?; Self::portfolio_asset_balances(portfolio, asset_id) .saturating_sub(Self::locked_assets(portfolio, asset_id)) .checked_sub(amount) @@ -1004,13 +1003,13 @@ impl PortfolioSubTrait for Module { fn skip_portfolio_affirmation(portfolio_id: &PortfolioId, asset_id: &AssetId) -> bool { if Self::portfolio_custodian(portfolio_id).is_some() { - if T::Asset::asset_affirmation_exemption(asset_id) { + if T::AssetFn::asset_affirmation_exemption(asset_id) { return true; } return PreApprovedPortfolios::get(portfolio_id, asset_id); } - if T::Asset::skip_asset_affirmation(&portfolio_id.did, asset_id) { + if T::AssetFn::skip_asset_affirmation(&portfolio_id.did, asset_id) { return true; } PreApprovedPortfolios::get(portfolio_id, asset_id) diff --git a/pallets/runtime/common/src/runtime.rs b/pallets/runtime/common/src/runtime.rs index 908d830c12..6374a2e188 100644 --- a/pallets/runtime/common/src/runtime.rs +++ b/pallets/runtime/common/src/runtime.rs @@ -292,7 +292,6 @@ macro_rules! misc_pallet_impls { impl pallet_portfolio::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Asset = Asset; type WeightInfo = polymesh_weights::pallet_portfolio::SubstrateWeight; type MaxNumberOfFungibleMoves = MaxNumberOfFungibleMoves; type MaxNumberOfNFTsMoves = MaxNumberOfNFTsMoves; @@ -364,6 +363,10 @@ macro_rules! misc_pallet_impls { type SubsidyCallFilter = SubsidyFilter; } + impl polymesh_primitives::traits::AssetFnConfig for Runtime { + type AssetFn = Asset; + } + impl pallet_asset::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; @@ -374,7 +377,6 @@ macro_rules! misc_pallet_impls { type AssetMetadataNameMaxLength = AssetMetadataNameMaxLength; type AssetMetadataValueMaxLength = AssetMetadataValueMaxLength; type AssetMetadataTypeDefMaxLength = AssetMetadataTypeDefMaxLength; - type AssetFn = Asset; type WeightInfo = polymesh_weights::pallet_asset::SubstrateWeight; type CPWeightInfo = polymesh_weights::pallet_checkpoint::SubstrateWeight; type NFTFn = pallet_nft::Module; @@ -385,7 +387,6 @@ macro_rules! misc_pallet_impls { type RuntimeEvent = RuntimeEvent; type MaxInLen = MaxInLen; type MaxOutLen = MaxOutLen; - type Asset = pallet_asset::Module; type WeightInfo = polymesh_weights::polymesh_contracts::SubstrateWeight; } @@ -422,7 +423,6 @@ macro_rules! misc_pallet_impls { impl pallet_compliance_manager::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Asset = Asset; type WeightInfo = polymesh_weights::pallet_compliance_manager::SubstrateWeight; type MaxConditionComplexity = MaxConditionComplexity; } @@ -438,7 +438,6 @@ macro_rules! misc_pallet_impls { impl pallet_statistics::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Asset = Asset; type MaxStatsPerAsset = MaxStatsPerAsset; type MaxTransferConditionsPerAsset = MaxTransferConditionsPerAsset; type WeightInfo = polymesh_weights::pallet_statistics::SubstrateWeight; diff --git a/pallets/runtime/tests/src/asset_test.rs b/pallets/runtime/tests/src/asset_test.rs index a399953e4f..cd181b4719 100644 --- a/pallets/runtime/tests/src/asset_test.rs +++ b/pallets/runtime/tests/src/asset_test.rs @@ -22,7 +22,6 @@ use pallet_portfolio::{ NextPortfolioNumber, PortfolioAssetBalances, PortfolioAssetCount, PortfolioLockedAssets, }; use pallet_statistics::AssetStats; -use polymesh_common_utilities::asset::AssetFnTrait; use polymesh_common_utilities::traits::checkpoint::{ NextCheckpoints, ScheduleCheckpoints, ScheduleId, }; @@ -42,6 +41,7 @@ use polymesh_primitives::settlement::{ }; use polymesh_primitives::statistics::StatType; use polymesh_primitives::statistics::{Stat1stKey, Stat2ndKey}; +use polymesh_primitives::traits::AssetFnTrait; use polymesh_primitives::{ AssetIdentifier, AssetPermissions, AuthorizationData, AuthorizationError, Document, DocumentId, Fund, FundDescription, IdentityId, Memo, Moment, NFTCollectionKeys, Permissions, PortfolioId, diff --git a/pallets/settlement/src/benchmarking.rs b/pallets/settlement/src/benchmarking.rs index bb3e8a359a..95da402a23 100644 --- a/pallets/settlement/src/benchmarking.rs +++ b/pallets/settlement/src/benchmarking.rs @@ -24,7 +24,7 @@ use sp_std::prelude::*; use pallet_asset::benchmarking::setup_asset_transfer; use pallet_identity::benchmarking::{User, UserBuilder}; use pallet_nft::benchmarking::setup_nft_transfer; -use polymesh_common_utilities::benchs::create_and_issue_sample_asset; +use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::checked_inc::CheckedInc; use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::constants::ENSURED_MAX_LEN; @@ -105,7 +105,7 @@ fn create_venue_(did: IdentityId, signers: Vec) -> Venu } pub fn create_asset_(owner: &User) -> AssetId { - create_and_issue_sample_asset::(owner, true, None, b"MyAsset", true) + create_and_issue_sample_asset::(owner.account(), true, None, b"MyAsset", true) } fn setup_legs( diff --git a/pallets/statistics/src/benchmarking.rs b/pallets/statistics/src/benchmarking.rs index 77cde31ad8..03cc1f3f7e 100644 --- a/pallets/statistics/src/benchmarking.rs +++ b/pallets/statistics/src/benchmarking.rs @@ -4,8 +4,8 @@ use sp_std::collections::btree_set::BTreeSet; use sp_std::prelude::*; use pallet_identity::benchmarking::{User, UserBuilder}; -use polymesh_common_utilities::benchs::create_and_issue_sample_asset; use polymesh_common_utilities::traits::asset::Config as Asset; +use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::constants::currency::{ONE_UNIT, POLY}; use polymesh_primitives::{jurisdiction::*, statistics::*, Claim, ClaimType, Scope}; @@ -83,7 +83,8 @@ fn make_transfer_conditions(stats: &BTreeSet, count: u32) -> BTreeSet< fn init_asset() -> (User, AssetId) { let owner = UserBuilder::::default().generate_did().build("OWNER"); - let asset_id = create_and_issue_sample_asset::(&owner, true, None, b"MyAsset", true); + let asset_id = + create_and_issue_sample_asset::(owner.account(), true, None, b"MyAsset", true); (owner, asset_id) } @@ -251,7 +252,7 @@ benchmarks! { let bob = UserBuilder::::default().generate_did().build("Bob"); let mut weight_meter = WeightMeter::max_limit_no_minimum(); - let asset_id = create_and_issue_sample_asset::(&alice, true, None, b"MyAsset", true); + let asset_id = create_and_issue_sample_asset::(alice.account(), true, None, b"MyAsset", true); let transfer_condition = TransferCondition::MaxInvestorCount(1); let changes = if a == 1 { Some((false, true)) } else { Some((true, true)) }; }: { @@ -273,7 +274,7 @@ benchmarks! { let bob = UserBuilder::::default().generate_did().build("Bob"); let mut weight_meter = WeightMeter::max_limit_no_minimum(); - let asset_id = create_and_issue_sample_asset::(&alice, true, None, b"MyAsset", true); + let asset_id = create_and_issue_sample_asset::(alice.account(), true, None, b"MyAsset", true); let transfer_condition = TransferCondition::MaxInvestorOwnership(Permill::one()); }: { assert!(Module::::check_transfer_condition( @@ -297,7 +298,7 @@ benchmarks! { let bob = UserBuilder::::default().generate_did().build("Bob"); let mut weight_meter = WeightMeter::max_limit_no_minimum(); - let asset_id = create_and_issue_sample_asset::(&alice, true, None, b"MyAsset", true); + let asset_id = create_and_issue_sample_asset::(alice.account(), true, None, b"MyAsset", true); let changes = if c == 0 { None } else { Some((false, false)) }; let transfer_condition = TransferCondition::ClaimCount(StatClaim::Accredited(true), alice.did(), 0, Some(1)); @@ -320,7 +321,7 @@ benchmarks! { let bob = UserBuilder::::default().generate_did().build("Bob"); let mut weight_meter = WeightMeter::max_limit_no_minimum(); - let asset_id = create_and_issue_sample_asset::(&alice, true, None, b"MyAsset", true); + let asset_id = create_and_issue_sample_asset::(alice.account(), true, None, b"MyAsset", true); let transfer_condition = TransferCondition::ClaimCount(StatClaim::Accredited(true), alice.did(), 0, Some(1)); }: { @@ -345,7 +346,7 @@ benchmarks! { let bob = UserBuilder::::default().generate_did().build("Bob"); let mut weight_meter = WeightMeter::max_limit_no_minimum(); - let asset_id = create_and_issue_sample_asset::(&alice, true, None, b"MyAsset", true); + let asset_id = create_and_issue_sample_asset::(alice.account(), true, None, b"MyAsset", true); let transfer_condition = TransferCondition::ClaimOwnership(StatClaim::Accredited(true), IdentityId::from(0), Permill::zero(), Permill::one()); if a == 1 { @@ -382,7 +383,7 @@ benchmarks! { }; let mut weight_meter = WeightMeter::max_limit_no_minimum(); - let asset_id = create_and_issue_sample_asset::(&alice, true, None, b"MyAsset", true); + let asset_id = create_and_issue_sample_asset::(alice.account(), true, None, b"MyAsset", true); let key1 = Stat1stKey { asset_id, stat_type }; let changes = { @@ -422,7 +423,7 @@ benchmarks! { let stat_type = StatType{operation_type: StatOpType::Balance, claim_issuer: Some((ClaimType::Accredited, issuer_id))}; let mut weight_meter = WeightMeter::max_limit_no_minimum(); - let asset_id = create_and_issue_sample_asset::(&alice, true, None, b"MyAsset", true); + let asset_id = create_and_issue_sample_asset::(alice.account(), true, None, b"MyAsset", true); let key1 = Stat1stKey { asset_id, stat_type }; let (from_balance, to_balance) = { if a == 0 { diff --git a/pallets/statistics/src/lib.rs b/pallets/statistics/src/lib.rs index 3809ba6189..f12f935f06 100644 --- a/pallets/statistics/src/lib.rs +++ b/pallets/statistics/src/lib.rs @@ -25,12 +25,12 @@ use frame_support::weights::Weight; use frame_support::{decl_error, decl_module, decl_storage, ensure, BoundedBTreeSet}; use sp_std::{collections::btree_set::BTreeSet, vec, vec::Vec}; -use polymesh_common_utilities::asset::AssetFnTrait; pub use polymesh_common_utilities::traits::statistics::{Config, Event, WeightInfo}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::statistics::{ Percentage, Stat1stKey, Stat2ndKey, StatOpType, StatType, StatUpdate, }; +use polymesh_primitives::traits::AssetFnTrait; use polymesh_primitives::transfer_compliance::{ AssetTransferCompliance, TransferCondition, TransferConditionExemptKey, }; @@ -912,15 +912,15 @@ impl Module { ) -> Result, DispatchError> { let mut failed_conditions = Vec::new(); - let asset_total_supply = T::Asset::asset_total_supply(&asset_id)?; + let asset_total_supply = T::AssetFn::asset_total_supply(&asset_id)?; let asset_compliance = AssetTransferCompliances::::get(&asset_id); if asset_compliance.paused { return Ok(failed_conditions); } - let sender_current_balance = T::Asset::asset_balance(&asset_id, sender_did); - let receiver_current_balance = T::Asset::asset_balance(&asset_id, receiver_did); + let sender_current_balance = T::AssetFn::asset_balance(&asset_id, sender_did); + let receiver_current_balance = T::AssetFn::asset_balance(&asset_id, receiver_did); let count_changes = Self::investor_count_changes( Some(sender_current_balance.saturating_sub(transfer_amount)), diff --git a/pallets/common/src/benchs/asset.rs b/primitives/src/bench.rs similarity index 60% rename from pallets/common/src/benchs/asset.rs rename to primitives/src/bench.rs index bad0b72bfd..861ed1922e 100644 --- a/pallets/common/src/benchs/asset.rs +++ b/primitives/src/bench.rs @@ -1,15 +1,17 @@ -use sp_std::vec; - -use polymesh_primitives::asset::{AssetId, AssetName, AssetType}; -use polymesh_primitives::constants::currency::POLY; -use polymesh_primitives::{PortfolioKind, Ticker}; +#![allow(missing_docs)] -use crate::traits::asset::{AssetFnTrait, Config}; -use pallet_identity::benchmarking::User; +use crate::{ + asset::{AssetId, AssetName, AssetType}, + constants::currency::POLY, + traits::{AssetFnConfig, AssetFnTrait}, + PortfolioKind, Ticker, +}; +use sp_std::vec; /// Registers a unique ticker named `ticker_name` for `ticker_owner`. -pub fn reg_unique_ticker( - ticker_owner: T::RuntimeOrigin, +#[cfg(feature = "runtime-benchmarks")] +pub fn reg_unique_ticker( + ticker_owner: T::AccountId, ticker_name: Option<&[u8]>, ) -> Ticker { let ticker = match ticker_name { @@ -20,17 +22,18 @@ pub fn reg_unique_ticker( ticker } -pub fn create_and_issue_sample_asset( - asset_owner: &User, +#[cfg(feature = "runtime-benchmarks")] +pub fn create_and_issue_sample_asset( + asset_owner: T::AccountId, divisible: bool, asset_type: Option, asset_name: &[u8], issue_tokens: bool, ) -> AssetId { - let asset_id = T::AssetFn::generate_asset_id(asset_owner.account()); + let asset_id = T::AssetFn::generate_asset_id(asset_owner.clone()); T::AssetFn::create_asset( - asset_owner.origin().into(), + asset_owner.clone(), AssetName::from(asset_name), divisible, asset_type.unwrap_or_default(), @@ -41,7 +44,7 @@ pub fn create_and_issue_sample_asset( if issue_tokens { T::AssetFn::issue( - asset_owner.origin().into(), + asset_owner, asset_id, (1_000_000 * POLY).into(), PortfolioKind::Default, diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index cc4c83dbce..6eda7278a9 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -218,6 +218,10 @@ pub use authorization::{Authorization, AuthorizationData, AuthorizationError, Au /// Pub Traits pub mod traits; +/// Benchmarking helpers. +#[cfg(feature = "runtime-benchmarks")] +pub mod bench; + pub mod ticker; pub use ticker::Ticker; diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index 2658d95f05..8a661f3bb8 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -18,7 +18,9 @@ use crate::{secondary_key::SecondaryKey, Balance, IdentityId}; use frame_support::dispatch::DispatchError; use sp_runtime::transaction_validity::InvalidTransaction; +mod asset; pub mod group; +pub use asset::*; // Polymesh note: This was specifically added for Polymesh pub trait CddAndFeeDetails { diff --git a/primitives/src/traits/asset.rs b/primitives/src/traits/asset.rs new file mode 100644 index 0000000000..588dc8cd61 --- /dev/null +++ b/primitives/src/traits/asset.rs @@ -0,0 +1,70 @@ +#[cfg(feature = "runtime-benchmarks")] +use crate::{ + asset::{AssetName, AssetType, FundingRoundName}, + asset_metadata::{AssetMetadataName, AssetMetadataSpec}, + AssetIdentifier, PortfolioKind, Ticker, +}; +#[cfg(feature = "runtime-benchmarks")] +use sp_std::{collections::btree_set::BTreeSet, prelude::Vec}; + +use crate::{asset::AssetId, Balance, IdentityId}; +use frame_support::dispatch::{DispatchError, DispatchResult}; + +pub trait AssetFnConfig: frame_system::Config { + type AssetFn: AssetFnTrait; +} + +pub trait AssetFnTrait { + /// Returns `Ok` if [`AssetDetails::divisible`] or `value` % ONE_UNIT == 0. + fn ensure_granular(asset_id: &AssetId, value: Balance) -> DispatchResult; + + /// Returns `true` if the given `identity_id` is exempt from affirming the receivement of `asset_id`, otherwise returns `false`. + fn skip_asset_affirmation(identity_id: &IdentityId, asset_id: &AssetId) -> bool; + + /// Returns `true` if the receivement of `asset_id` is exempt from being affirmed, otherwise returns `false`. + fn asset_affirmation_exemption(asset_id: &AssetId) -> bool; + + /// Returns the `did` balance for the given `asset_id`. + fn asset_balance(asset_id: &AssetId, did: &IdentityId) -> Balance; + + /// Returns the total supply for the given `asset_id`. + fn asset_total_supply(asset_id: &AssetId) -> Result; + + /// Returns the next [`AssetID`] for the `caller_acc`. + fn generate_asset_id(caller_acc: AccountId) -> AssetId; + + #[cfg(feature = "runtime-benchmarks")] + fn register_unique_ticker(caller: AccountId, ticker: Ticker) -> DispatchResult; + + #[cfg(feature = "runtime-benchmarks")] + fn create_asset( + caller: AccountId, + asset_name: AssetName, + divisible: bool, + asset_type: AssetType, + asset_identifiers: Vec, + funding_round: Option, + ) -> DispatchResult; + + #[cfg(feature = "runtime-benchmarks")] + fn issue( + caller: AccountId, + asset_id: AssetId, + amount: Balance, + portfolio_kind: PortfolioKind, + ) -> DispatchResult; + + #[cfg(feature = "runtime-benchmarks")] + fn register_asset_metadata_type( + asset_and_caller: Option<(AssetId, AccountId)>, + name: AssetMetadataName, + spec: AssetMetadataSpec, + ) -> DispatchResult; + + #[cfg(feature = "runtime-benchmarks")] + fn add_mandatory_mediators( + caller: AccountId, + asset_id: AssetId, + mediators: BTreeSet, + ) -> DispatchResult; +} From d70afb54ca16ac876c96a71327323c6f67cb357c Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 23:26:32 +0800 Subject: [PATCH 19/45] Move WeightInfo, Config, Events into ExternalAgent pallet. --- Cargo.lock | 2 +- pallets/common/Cargo.toml | 3 + pallets/common/src/traits/asset.rs | 9 +-- .../common/src/traits/compliance_manager.rs | 2 +- pallets/common/src/traits/external_agents.rs | 52 ---------------- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/statistics.rs | 2 +- pallets/external-agents/Cargo.toml | 3 - pallets/external-agents/src/benchmarking.rs | 9 ++- pallets/external-agents/src/lib.rs | 59 +++++++++++++++++-- 10 files changed, 67 insertions(+), 75 deletions(-) delete mode 100644 pallets/common/src/traits/external_agents.rs diff --git a/Cargo.lock b/Cargo.lock index d5b9d46d38..1c945e17dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5060,7 +5060,6 @@ dependencies = [ "pallet-identity", "pallet-permissions", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "polymesh-primitives-derive", "scale-info", @@ -6268,6 +6267,7 @@ dependencies = [ "frame-system", "lazy_static", "pallet-base", + "pallet-external-agents", "pallet-identity", "pallet-permissions", "pallet-timestamp", diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index c20cb22399..102f8c6eea 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -12,6 +12,7 @@ polymesh-primitives-derive = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } +pallet-external-agents = { workspace = true, default-features = false } # Other serde = { version = "1.0.112", default-features = false } @@ -58,6 +59,7 @@ std = [ "pallet-base/std", "pallet-permissions/std", "pallet-identity/std", + "pallet-external-agents/std", "polymesh-primitives/std", "serde/std", "serde_derive", @@ -72,5 +74,6 @@ runtime-benchmarks = [ "frame-benchmarking", "pallet-permissions/runtime-benchmarks", "pallet-identity/runtime-benchmarks", + "pallet-external-agents/runtime-benchmarks", "schnorrkel", ] diff --git a/pallets/common/src/traits/asset.rs b/pallets/common/src/traits/asset.rs index 0d098aa785..e9fa547fea 100644 --- a/pallets/common/src/traits/asset.rs +++ b/pallets/common/src/traits/asset.rs @@ -19,6 +19,7 @@ use frame_support::weights::Weight; use sp_std::collections::btree_set::BTreeSet; use sp_std::prelude::Vec; +use pallet_external_agents::Config as EAConfig; use polymesh_primitives::asset::{ AssetId, AssetName, AssetType, CustomAssetTypeId, FundingRoundName, }; @@ -33,15 +34,11 @@ use polymesh_primitives::{ }; use crate::traits::nft::NFTTrait; -use crate::traits::{checkpoint, compliance_manager, external_agents, portfolio, statistics}; +use crate::traits::{checkpoint, compliance_manager, portfolio, statistics}; /// The module's configuration trait. pub trait Config: - crate::balances::Config - + external_agents::Config - + statistics::Config - + portfolio::Config - + AssetFnConfig + crate::balances::Config + EAConfig + statistics::Config + portfolio::Config + AssetFnConfig { /// The overarching event type. type RuntimeEvent: From> diff --git a/pallets/common/src/traits/compliance_manager.rs b/pallets/common/src/traits/compliance_manager.rs index faa1c8d6c5..8df882b5ac 100644 --- a/pallets/common/src/traits/compliance_manager.rs +++ b/pallets/common/src/traits/compliance_manager.rs @@ -20,6 +20,7 @@ use frame_support::traits::Get; use frame_support::weights::Weight; use sp_std::prelude::*; +use pallet_external_agents::Config as EAConfig; use polymesh_primitives::asset::AssetId; use polymesh_primitives::compliance_manager::{AssetComplianceResult, ComplianceRequirement}; use polymesh_primitives::condition::{conditions_total_counts, Condition}; @@ -27,7 +28,6 @@ use polymesh_primitives::traits::AssetFnConfig; use polymesh_primitives::{IdentityId, TrustedIssuer, WeightMeter}; use crate::balances::Config as BalancesConfig; -use crate::traits::external_agents::Config as EAConfig; use crate::traits::CommonConfig; /// The module's configuration trait. diff --git a/pallets/common/src/traits/external_agents.rs b/pallets/common/src/traits/external_agents.rs deleted file mode 100644 index db03600a75..0000000000 --- a/pallets/common/src/traits/external_agents.rs +++ /dev/null @@ -1,52 +0,0 @@ -use frame_support::{decl_event, weights::Weight}; -use polymesh_primitives::agent::{AGId, AgentGroup}; -use polymesh_primitives::asset::AssetId; -use polymesh_primitives::{EventDid, ExtrinsicPermissions, IdentityId}; - -pub trait WeightInfo { - fn create_group(p: u32) -> Weight; - fn create_group_and_add_auth(p: u32) -> Weight; - fn create_and_change_custom_group(p: u32) -> Weight; - fn set_group_permissions(p: u32) -> Weight; - fn remove_agent() -> Weight; - fn abdicate() -> Weight; - fn change_group_builtin() -> Weight; - fn change_group_custom() -> Weight; - fn accept_become_agent() -> Weight; -} - -pub trait Config: frame_system::Config + crate::balances::Config { - /// The overarching event type. - type RuntimeEvent: From + Into<::RuntimeEvent>; - - type WeightInfo: WeightInfo; -} - -decl_event! { - pub enum Event { - /// An Agent Group was created. - /// - /// (Caller DID, AG's AssetId, AG's ID, AG's permissions) - GroupCreated(EventDid, AssetId, AGId, ExtrinsicPermissions), - - /// An Agent Group's permissions was updated. - /// - /// (Caller DID, AG's AssetId, AG's ID, AG's new permissions) - GroupPermissionsUpdated(EventDid, AssetId, AGId, ExtrinsicPermissions), - - /// An agent was added. - /// - /// (Caller/Agent DID, Agent's AssetId, Agent's group) - AgentAdded(EventDid, AssetId, AgentGroup), - - /// An agent was removed. - /// - /// (Caller DID, Agent's AssetId, Agent's DID) - AgentRemoved(EventDid, AssetId, IdentityId), - - /// An agent's group was changed. - /// - /// (Caller DID, Agent's AssetId, Agent's DID, The new group of the agent) - GroupChanged(EventDid, AssetId, IdentityId, AgentGroup), - } -} diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 2ee71aedaf..8ab7d9f2ec 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -26,7 +26,6 @@ pub mod asset; pub mod balances; pub mod checkpoint; pub mod compliance_manager; -pub mod external_agents; pub mod governance_group; pub mod group; pub mod multisig; diff --git a/pallets/common/src/traits/statistics.rs b/pallets/common/src/traits/statistics.rs index a0b1b69f71..f64a80b2fe 100644 --- a/pallets/common/src/traits/statistics.rs +++ b/pallets/common/src/traits/statistics.rs @@ -1,7 +1,7 @@ -use crate::traits::external_agents::Config as EAConfig; use frame_support::decl_event; use frame_support::traits::Get; use frame_support::weights::Weight; +use pallet_external_agents::Config as EAConfig; use polymesh_primitives::asset::AssetId; use polymesh_primitives::traits::AssetFnConfig; use polymesh_primitives::{ diff --git a/pallets/external-agents/Cargo.toml b/pallets/external-agents/Cargo.toml index c8aedf2514..4a3c9a5a40 100644 --- a/pallets/external-agents/Cargo.toml +++ b/pallets/external-agents/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" # Common polymesh-primitives = { workspace = true, default-features = false } polymesh-primitives-derive = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets pallet-base = { workspace = true, default-features = false } @@ -40,13 +39,11 @@ std = [ "frame-system/std", "pallet-base/std", "pallet-identity/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "serde/std", "serde_derive", ] runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks", "pallet-identity/runtime-benchmarks", ] diff --git a/pallets/external-agents/src/benchmarking.rs b/pallets/external-agents/src/benchmarking.rs index f4e7417f37..34b9d6cc97 100644 --- a/pallets/external-agents/src/benchmarking.rs +++ b/pallets/external-agents/src/benchmarking.rs @@ -16,7 +16,6 @@ use crate::*; use frame_benchmarking::benchmarks; use pallet_identity::benchmarking::{user, User}; -use polymesh_common_utilities::traits::asset::Config as Asset; use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::{AuthorizationData, ExtrinsicPermissions, PalletName, PalletPermissions}; use sp_std::prelude::*; @@ -24,7 +23,7 @@ use sp_std::prelude::*; pub(crate) const SEED: u32 = 0; const MAX_PALLETS: u32 = 19; -fn setup() -> (User, AssetId) { +fn setup() -> (User, AssetId) { let owner = user("owner", SEED); let asset_id = create_and_issue_sample_asset::(owner.account(), true, None, b"SampleAsset", false); @@ -37,7 +36,7 @@ fn perms(n: u32) -> ExtrinsicPermissions { ) } -fn add_auth(owner: &User, asset_id: AssetId) -> (User, u64) { +fn add_auth(owner: &User, asset_id: AssetId) -> (User, u64) { let other = user("other", SEED); let auth_id = pallet_identity::Module::::add_auth( owner.did(), @@ -49,7 +48,7 @@ fn add_auth(owner: &User, asset_id: AssetId) -> (User, u64) { (other, auth_id) } -fn setup_removal() -> (User, User, AssetId) { +fn setup_removal() -> (User, User, AssetId) { let (owner, asset_id) = setup::(); let (other, auth_id) = add_auth::(&owner, asset_id); Module::::accept_become_agent(other.origin().into(), auth_id).unwrap(); @@ -61,7 +60,7 @@ fn custom_group(owner: User, asset_id: AssetId) { } benchmarks! { - where_clause { where T: Asset } + where_clause { where T: Config } create_group { let p in 0..MAX_PALLETS; diff --git a/pallets/external-agents/src/lib.rs b/pallets/external-agents/src/lib.rs index 82b681cf21..2f7f832cf6 100644 --- a/pallets/external-agents/src/lib.rs +++ b/pallets/external-agents/src/lib.rs @@ -54,19 +54,20 @@ pub mod benchmarking; use codec::{Decode, Encode}; use frame_support::{ - decl_error, decl_module, decl_storage, + decl_error, decl_event, decl_module, decl_storage, dispatch::{DispatchError, DispatchResult}, ensure, weights::Weight, }; use pallet_base::{try_next_post, try_next_pre}; -use pallet_identity::PermissionedCallOriginData; -pub use polymesh_common_utilities::traits::external_agents::{Config, Event, WeightInfo}; +use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; +use pallet_permissions::Config as PermConfig; use polymesh_primitives::agent::{AGId, AgentGroup}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - extract_auth, storage_migration_ver, with_transaction, AuthorizationData, EventDid, - ExtrinsicPermissions, IdentityId, PalletPermissions, Signatory, SubsetRestriction, + extract_auth, storage_migration_ver, traits::AssetFnConfig, with_transaction, + AuthorizationData, EventDid, ExtrinsicPermissions, IdentityId, PalletPermissions, Signatory, + SubsetRestriction, }; use sp_std::prelude::*; @@ -75,6 +76,54 @@ type Permissions = pallet_permissions::Module; storage_migration_ver!(1); +pub trait WeightInfo { + fn create_group(p: u32) -> Weight; + fn create_group_and_add_auth(p: u32) -> Weight; + fn create_and_change_custom_group(p: u32) -> Weight; + fn set_group_permissions(p: u32) -> Weight; + fn remove_agent() -> Weight; + fn abdicate() -> Weight; + fn change_group_builtin() -> Weight; + fn change_group_custom() -> Weight; + fn accept_become_agent() -> Weight; +} + +pub trait Config: frame_system::Config + PermConfig + IdentityConfig + AssetFnConfig { + /// The overarching event type. + type RuntimeEvent: From + Into<::RuntimeEvent>; + + type WeightInfo: WeightInfo; +} + +decl_event! { + pub enum Event { + /// An Agent Group was created. + /// + /// (Caller DID, AG's AssetId, AG's ID, AG's permissions) + GroupCreated(EventDid, AssetId, AGId, ExtrinsicPermissions), + + /// An Agent Group's permissions was updated. + /// + /// (Caller DID, AG's AssetId, AG's ID, AG's new permissions) + GroupPermissionsUpdated(EventDid, AssetId, AGId, ExtrinsicPermissions), + + /// An agent was added. + /// + /// (Caller/Agent DID, Agent's AssetId, Agent's group) + AgentAdded(EventDid, AssetId, AgentGroup), + + /// An agent was removed. + /// + /// (Caller DID, Agent's AssetId, Agent's DID) + AgentRemoved(EventDid, AssetId, IdentityId), + + /// An agent's group was changed. + /// + /// (Caller DID, Agent's AssetId, Agent's DID, The new group of the agent) + GroupChanged(EventDid, AssetId, IdentityId, AgentGroup), + } +} + decl_storage! { trait Store for Module as ExternalAgents { /// The next per-asset AG ID in the sequence. From 130b7e7f681eeaeaff59c59226529821517719ad Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 23:38:58 +0800 Subject: [PATCH 20/45] Move WeightInfo, Config, Event into relayer pallet. --- Cargo.lock | 3 -- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/relayer.rs | 63 ----------------------- pallets/protocol-fee/Cargo.toml | 2 - pallets/protocol-fee/src/lib.rs | 3 +- pallets/relayer/Cargo.toml | 3 -- pallets/relayer/src/benchmarking.rs | 1 - pallets/relayer/src/lib.rs | 54 +++++++++++++++++-- pallets/runtime/tests/src/staking/mock.rs | 6 ++- pallets/transaction-payment/Cargo.toml | 2 - pallets/transaction-payment/src/lib.rs | 3 +- primitives/src/traits.rs | 15 ++++++ 12 files changed, 70 insertions(+), 86 deletions(-) delete mode 100644 pallets/common/src/traits/relayer.rs diff --git a/Cargo.lock b/Cargo.lock index 1c945e17dc..c92b5d8c2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5383,7 +5383,6 @@ dependencies = [ "frame-system", "pallet-identity", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -5433,7 +5432,6 @@ dependencies = [ "frame-system", "pallet-identity", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "sp-runtime", @@ -5683,7 +5681,6 @@ dependencies = [ "frame-system", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 8ab7d9f2ec..8d8a8f095c 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -31,6 +31,5 @@ pub mod group; pub mod multisig; pub mod nft; pub mod portfolio; -pub mod relayer; pub mod settlement; pub mod statistics; diff --git a/pallets/common/src/traits/relayer.rs b/pallets/common/src/traits/relayer.rs deleted file mode 100644 index 5392f54b5a..0000000000 --- a/pallets/common/src/traits/relayer.rs +++ /dev/null @@ -1,63 +0,0 @@ -use frame_support::{decl_event, weights::Weight}; -use polymesh_primitives::{Balance, EventDid}; -use sp_runtime::transaction_validity::InvalidTransaction; - -pub trait WeightInfo { - fn set_paying_key() -> Weight; - fn accept_paying_key() -> Weight; - fn remove_paying_key() -> Weight; - fn update_polyx_limit() -> Weight; - fn increase_polyx_limit() -> Weight; - fn decrease_polyx_limit() -> Weight; -} - -pub trait SubsidiserTrait { - /// Check if a `user_key` has a subsidiser and that the subsidy can pay the `fee`. - fn check_subsidy( - user_key: &AccountId, - fee: Balance, - call: Option<&RuntimeCall>, - ) -> Result, InvalidTransaction>; - - /// Debit `fee` from the remaining balance of the subsidy for `user_key`. - fn debit_subsidy( - user_key: &AccountId, - fee: Balance, - ) -> Result, InvalidTransaction>; -} - -pub trait Config: frame_system::Config + pallet_identity::Config { - /// The overarching event type. - type RuntimeEvent: From> + Into<::RuntimeEvent>; - /// Subsidy pallet weights. - type WeightInfo: WeightInfo; - /// Subsidy call filter. - type SubsidyCallFilter: frame_support::traits::Contains; -} - -decl_event! { - pub enum Event - where - AccountId = ::AccountId, - { - /// Authorization given for `paying_key` to `user_key`. - /// - /// (Caller DID, User Key, Paying Key, Initial POLYX limit, Auth ID) - AuthorizedPayingKey(EventDid, AccountId, AccountId, Balance, u64), - - /// Accepted paying key. - /// - /// (Caller DID, User Key, Paying Key) - AcceptedPayingKey(EventDid, AccountId, AccountId), - - /// Removed paying key. - /// - /// (Caller DID, User Key, Paying Key) - RemovedPayingKey(EventDid, AccountId, AccountId), - - /// Updated polyx limit. - /// - /// (Caller DID, User Key, Paying Key, POLYX limit, old remaining POLYX) - UpdatedPolyxLimit(EventDid, AccountId, AccountId, Balance, Balance), - } -} diff --git a/pallets/protocol-fee/Cargo.toml b/pallets/protocol-fee/Cargo.toml index 1d7264ac32..ae4121fac6 100644 --- a/pallets/protocol-fee/Cargo.toml +++ b/pallets/protocol-fee/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] polymesh-primitives = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets pallet-identity = { workspace = true, default-features = false } @@ -35,7 +34,6 @@ std = [ "frame-benchmarking/std", "frame-support/std", "frame-system/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "pallet-identity/std", "serde/std", diff --git a/pallets/protocol-fee/src/lib.rs b/pallets/protocol-fee/src/lib.rs index fd5f3e5263..ab2d3c512e 100644 --- a/pallets/protocol-fee/src/lib.rs +++ b/pallets/protocol-fee/src/lib.rs @@ -46,10 +46,9 @@ use frame_support::{ }; use frame_system::ensure_root; use pallet_identity::Config as IdentityConfig; -use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_primitives::{ protocol_fee::{ChargeProtocolFee, ProtocolOp}, - traits::CddAndFeeDetails, + traits::{CddAndFeeDetails, SubsidiserTrait}, Balance, IdentityId, PosRatio, GC_DID, }; use sp_runtime::{traits::Zero, Perbill}; diff --git a/pallets/relayer/Cargo.toml b/pallets/relayer/Cargo.toml index c1555017e4..369a06fda8 100644 --- a/pallets/relayer/Cargo.toml +++ b/pallets/relayer/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] pallet-identity = { workspace = true, default-features = false} -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false} # Substrate @@ -31,9 +30,7 @@ std = [ "sp-std/std", "pallet-identity/std", "polymesh-primitives/std", - "polymesh-common-utilities/std", ] runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks", ] diff --git a/pallets/relayer/src/benchmarking.rs b/pallets/relayer/src/benchmarking.rs index 8dc50f9646..b2038b36dd 100644 --- a/pallets/relayer/src/benchmarking.rs +++ b/pallets/relayer/src/benchmarking.rs @@ -17,7 +17,6 @@ use crate::*; use frame_benchmarking::benchmarks; use pallet_identity::benchmarking::{user, User}; -use polymesh_common_utilities::traits::relayer::Config; type Relayer = crate::Module; diff --git a/pallets/relayer/src/lib.rs b/pallets/relayer/src/lib.rs index 21fa77a758..737e85d5da 100644 --- a/pallets/relayer/src/lib.rs +++ b/pallets/relayer/src/lib.rs @@ -45,18 +45,17 @@ pub mod benchmarking; use codec::{Decode, Encode}; use frame_support::{ - decl_error, decl_module, decl_storage, + decl_error, decl_event, decl_module, decl_storage, dispatch::{DispatchError, DispatchResult}, ensure, fail, traits::{Contains, GetCallMetadata}, + weights::Weight, }; use frame_system::ensure_signed; use pallet_identity::PermissionedCallOriginData; -pub use polymesh_common_utilities::traits::relayer::{ - Config, Event, RawEvent, SubsidiserTrait, WeightInfo, -}; use polymesh_primitives::{ - extract_auth, AuthorizationData, Balance, IdentityId, Signatory, TransactionError, + extract_auth, traits::SubsidiserTrait, AuthorizationData, Balance, EventDid, IdentityId, + Signatory, TransactionError, }; use scale_info::TypeInfo; use sp_runtime::transaction_validity::InvalidTransaction; @@ -64,6 +63,51 @@ use sp_std::vec; type Identity = pallet_identity::Module; +pub trait WeightInfo { + fn set_paying_key() -> Weight; + fn accept_paying_key() -> Weight; + fn remove_paying_key() -> Weight; + fn update_polyx_limit() -> Weight; + fn increase_polyx_limit() -> Weight; + fn decrease_polyx_limit() -> Weight; +} + +pub trait Config: frame_system::Config + pallet_identity::Config { + /// The overarching event type. + type RuntimeEvent: From> + Into<::RuntimeEvent>; + /// Subsidy pallet weights. + type WeightInfo: WeightInfo; + /// Subsidy call filter. + type SubsidyCallFilter: frame_support::traits::Contains; +} + +decl_event! { + pub enum Event + where + AccountId = ::AccountId, + { + /// Authorization given for `paying_key` to `user_key`. + /// + /// (Caller DID, User Key, Paying Key, Initial POLYX limit, Auth ID) + AuthorizedPayingKey(EventDid, AccountId, AccountId, Balance, u64), + + /// Accepted paying key. + /// + /// (Caller DID, User Key, Paying Key) + AcceptedPayingKey(EventDid, AccountId, AccountId), + + /// Removed paying key. + /// + /// (Caller DID, User Key, Paying Key) + RemovedPayingKey(EventDid, AccountId, AccountId), + + /// Updated polyx limit. + /// + /// (Caller DID, User Key, Paying Key, POLYX limit, old remaining POLYX) + UpdatedPolyxLimit(EventDid, AccountId, AccountId, Balance, Balance), + } +} + /// A Subsidy for transaction and protocol fees. /// /// This holds the subsidiser's paying key and the remaining POLYX balance diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index 2a9e5a94e3..bd9fd65e48 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -43,13 +43,15 @@ use pallet_staking::types::SlashingSwitch; use pallet_staking::{self as pallet_staking, *}; use polymesh_common_utilities::traits::balances::{AccountData, CheckCdd}; use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; -use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_common_utilities::traits::CommonConfig; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::identity_id::GenesisIdentityRecord; use polymesh_primitives::{ - traits::group::{GroupTrait, InactiveMember}, + traits::{ + group::{GroupTrait, InactiveMember}, + SubsidiserTrait, + }, Authorization, AuthorizationData, Claim, IdentityId, Moment, NFTId, Permissions, PortfolioId, SecondaryKey, Signatory, }; diff --git a/pallets/transaction-payment/Cargo.toml b/pallets/transaction-payment/Cargo.toml index 818abf8aa2..a469be17bc 100644 --- a/pallets/transaction-payment/Cargo.toml +++ b/pallets/transaction-payment/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" [dependencies] # Our deps polymesh-primitives = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } # General serde = { version = "1.0.104", default-features = false, optional = true } @@ -33,7 +32,6 @@ no_std = [] std = [ "serde", "polymesh-primitives/std", - "polymesh-common-utilities/std", "codec/std", "sp-api/std", "sp-std/std", diff --git a/pallets/transaction-payment/src/lib.rs b/pallets/transaction-payment/src/lib.rs index e3547ec120..b0dfc4318d 100644 --- a/pallets/transaction-payment/src/lib.rs +++ b/pallets/transaction-payment/src/lib.rs @@ -61,9 +61,8 @@ use frame_support::{ weights::{WeightToFee, WeightToFeeCoefficient, WeightToFeePolynomial}, }; use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; -use polymesh_common_utilities::traits::relayer::SubsidiserTrait; use polymesh_primitives::{ - traits::{group::GroupTrait, CddAndFeeDetails, IdentityFnTrait}, + traits::{group::GroupTrait, CddAndFeeDetails, IdentityFnTrait, SubsidiserTrait}, TransactionError, }; use scale_info::TypeInfo; diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index 8a661f3bb8..510e7fd42a 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -48,6 +48,21 @@ pub trait IdentityFnTrait { ) -> Result; } +pub trait SubsidiserTrait { + /// Check if a `user_key` has a subsidiser and that the subsidy can pay the `fee`. + fn check_subsidy( + user_key: &AccountId, + fee: Balance, + call: Option<&RuntimeCall>, + ) -> Result, InvalidTransaction>; + + /// Debit `fee` from the remaining balance of the subsidy for `user_key`. + fn debit_subsidy( + user_key: &AccountId, + fee: Balance, + ) -> Result, InvalidTransaction>; +} + /// A currency that has a block rewards reserve. pub trait BlockRewardsReserveCurrency { /// An instance of `Drop` for positive imbalance. From 8b79887ac7688252586c331bb6e133e8231c0a5e Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Wed, 18 Dec 2024 23:55:45 +0800 Subject: [PATCH 21/45] Move Context type to Identity pallet. --- pallets/common/src/lib.rs | 2 -- pallets/contracts/src/chain_extension.rs | 2 +- pallets/group/src/lib.rs | 5 +---- pallets/{common => identity}/src/context.rs | 0 pallets/identity/src/lib.rs | 3 +++ pallets/runtime/common/src/fee_details.rs | 3 +-- pallets/runtime/tests/src/storage.rs | 3 +-- pallets/utility/src/lib.rs | 3 +-- 8 files changed, 8 insertions(+), 13 deletions(-) rename pallets/{common => identity}/src/context.rs (100%) diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 655363e7d8..6dc2439531 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -20,5 +20,3 @@ pub use traits::{ asset, balances, compliance_manager, governance_group, group, multisig, nft, portfolio, CommonConfig, }; -pub mod context; -pub use context::Context; diff --git a/pallets/contracts/src/chain_extension.rs b/pallets/contracts/src/chain_extension.rs index ab855ce8be..fb8e172a4c 100644 --- a/pallets/contracts/src/chain_extension.rs +++ b/pallets/contracts/src/chain_extension.rs @@ -15,8 +15,8 @@ use sp_core::crypto::UncheckedFrom; use pallet_contracts::chain_extension as ce; use pallet_contracts::Config as BConfig; +use pallet_identity::Context; use pallet_permissions::with_call_metadata; -use polymesh_common_utilities::Context; use super::*; diff --git a/pallets/group/src/lib.rs b/pallets/group/src/lib.rs index c6cc071999..3e5f2b310d 100644 --- a/pallets/group/src/lib.rs +++ b/pallets/group/src/lib.rs @@ -78,10 +78,7 @@ pub mod benchmarking; use pallet_identity as identity; -pub use polymesh_common_utilities::{ - group::{Config, RawEvent, WeightInfo}, - Context, -}; +pub use polymesh_common_utilities::group::{Config, RawEvent, WeightInfo}; use polymesh_primitives::{ committee::COMMITTEE_MEMBERS_MAX, traits::group::{GroupTrait, InactiveMember, MemberCount}, diff --git a/pallets/common/src/context.rs b/pallets/identity/src/context.rs similarity index 100% rename from pallets/common/src/context.rs rename to pallets/identity/src/context.rs diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index 53a091f107..ee0251bc24 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -85,6 +85,9 @@ mod auth; mod claims; mod keys; +mod context; +pub use context::Context; + pub mod types; pub use types::{Claim1stKey, Claim2ndKey, DidStatus, PermissionedCallOriginData, RpcDidRecords}; diff --git a/pallets/runtime/common/src/fee_details.rs b/pallets/runtime/common/src/fee_details.rs index ab243c29ee..9b025da338 100644 --- a/pallets/runtime/common/src/fee_details.rs +++ b/pallets/runtime/common/src/fee_details.rs @@ -1,8 +1,7 @@ use codec::{Decode, Encode}; use core::convert::{TryFrom, TryInto}; use core::marker::PhantomData; -use pallet_identity::{Config as IdentityConfig, Module as Identity}; -use polymesh_common_utilities::Context; +use pallet_identity::{Config as IdentityConfig, Context, Module as Identity}; use polymesh_primitives::{ traits::CddAndFeeDetails, AccountId, AuthorizationData, IdentityId, Signatory, TransactionError, }; diff --git a/pallets/runtime/tests/src/storage.rs b/pallets/runtime/tests/src/storage.rs index 95a5751517..85d52cddd8 100644 --- a/pallets/runtime/tests/src/storage.rs +++ b/pallets/runtime/tests/src/storage.rs @@ -40,13 +40,12 @@ use pallet_corporate_actions as corporate_actions; use pallet_corporate_actions::ballot as corporate_ballots; use pallet_corporate_actions::distribution as capital_distributions; use pallet_group as group; -use pallet_identity as identity; +use pallet_identity::{self as identity, Context}; use pallet_pips as pips; use pallet_protocol_fee as protocol_fee; use pallet_session::historical as pallet_session_historical; use pallet_transaction_payment::RuntimeDispatchInfo; use pallet_utility; -use polymesh_common_utilities::Context; use polymesh_primitives::constants::currency::{DOLLARS, POLY}; use polymesh_primitives::protocol_fee::ProtocolOp; use polymesh_primitives::settlement::Leg; diff --git a/pallets/utility/src/lib.rs b/pallets/utility/src/lib.rs index e6bec565db..33708a2114 100644 --- a/pallets/utility/src/lib.rs +++ b/pallets/utility/src/lib.rs @@ -84,10 +84,9 @@ use sp_runtime::traits::{BadOrigin, Dispatchable}; use sp_runtime::{traits::Verify, DispatchError, RuntimeDebug}; use sp_std::prelude::*; -use pallet_identity::Config as IdentityConfig; +use pallet_identity::{Config as IdentityConfig, Context}; use pallet_permissions::with_call_metadata; use polymesh_common_utilities::balances::{CheckCdd, Config as BalancesConfig}; -use polymesh_common_utilities::Context; use polymesh_primitives::{identity::AuthorizationNonce, IdentityId}; type Identity = pallet_identity::Module; From 03d5ae8ea22b221f20c4d4c8cca2d741c530a315 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 01:53:38 +0800 Subject: [PATCH 22/45] Move more traits to primitives. --- pallets/asset/src/benchmarking.rs | 3 +- pallets/asset/src/lib.rs | 4 +- pallets/committee/src/lib.rs | 6 +- pallets/common/src/lib.rs | 3 +- pallets/common/src/traits/asset.rs | 7 +- .../common/src/traits/compliance_manager.rs | 36 +---- pallets/common/src/traits/governance_group.rs | 24 ---- pallets/common/src/traits/group.rs | 9 +- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/nft.rs | 27 +--- pallets/common/src/traits/portfolio.rs | 81 +---------- pallets/compliance-manager/src/lib.rs | 8 +- .../corporate-actions/src/distribution/mod.rs | 7 +- pallets/nft/src/benchmarking.rs | 3 +- pallets/nft/src/lib.rs | 8 +- pallets/pips/src/lib.rs | 2 +- pallets/portfolio/src/lib.rs | 11 +- .../tests/src/compliance_manager_test.rs | 6 +- pallets/runtime/tests/src/portfolio.rs | 7 +- pallets/runtime/tests/src/staking/mock.rs | 3 +- pallets/settlement/src/lib.rs | 4 +- pallets/sto/src/lib.rs | 5 +- primitives/src/traits.rs | 129 +++++++++++++++++- 23 files changed, 184 insertions(+), 210 deletions(-) delete mode 100644 pallets/common/src/traits/governance_group.rs diff --git a/pallets/asset/src/benchmarking.rs b/pallets/asset/src/benchmarking.rs index ac5ad96f4f..960a9254e4 100644 --- a/pallets/asset/src/benchmarking.rs +++ b/pallets/asset/src/benchmarking.rs @@ -22,8 +22,6 @@ use sp_std::{convert::TryInto, iter, prelude::*}; use pallet_identity::benchmarking::{user, User, UserBuilder}; use pallet_statistics::benchmarking::setup_transfer_restrictions; -use polymesh_common_utilities::traits::compliance_manager::ComplianceFnConfig; -use polymesh_common_utilities::traits::nft::NFTTrait; use polymesh_primitives::agent::AgentGroup; use polymesh_primitives::asset::{AssetName, NonFungibleType}; use polymesh_primitives::asset_metadata::{ @@ -34,6 +32,7 @@ use polymesh_primitives::bench::reg_unique_ticker; use polymesh_primitives::constants::currency::{ONE_UNIT, POLY}; use polymesh_primitives::ticker::TICKER_LEN; use polymesh_primitives::{ + traits::{ComplianceFnConfig, NFTTrait}, AuthorizationData, Fund, FundDescription, IdentityId, NFTCollectionKeys, PortfolioKind, PortfolioName, PortfolioNumber, Signatory, Ticker, Url, WeightMeter, }; diff --git a/pallets/asset/src/lib.rs b/pallets/asset/src/lib.rs index 79b09dd368..c4316393be 100644 --- a/pallets/asset/src/lib.rs +++ b/pallets/asset/src/lib.rs @@ -106,9 +106,7 @@ use pallet_base::{ }; use pallet_identity::PermissionedCallOriginData; use pallet_portfolio::{Error as PortfolioError, PortfolioAssetBalances}; -use polymesh_common_utilities::compliance_manager::ComplianceFnConfig; pub use polymesh_common_utilities::traits::asset::{Config, Event, RawEvent, WeightInfo}; -use polymesh_common_utilities::traits::nft::NFTTrait; use polymesh_primitives::agent::AgentGroup; use polymesh_primitives::asset::{ AssetId, AssetName, AssetType, CheckpointId, CustomAssetTypeId, FundingRoundName, @@ -120,7 +118,7 @@ use polymesh_primitives::asset_metadata::{ use polymesh_primitives::constants::*; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::settlement::InstructionId; -use polymesh_primitives::traits::AssetFnTrait; +use polymesh_primitives::traits::{AssetFnTrait, ComplianceFnConfig, NFTTrait}; use polymesh_primitives::{ extract_auth, storage_migrate_on, storage_migration_ver, AssetIdentifier, Balance, Document, DocumentId, IdentityId, Memo, PortfolioId, PortfolioKind, PortfolioUpdateReason, SecondaryKey, diff --git a/pallets/committee/src/lib.rs b/pallets/committee/src/lib.rs index fca264ec29..f342474209 100644 --- a/pallets/committee/src/lib.rs +++ b/pallets/committee/src/lib.rs @@ -70,10 +70,12 @@ use frame_support::{ ensure, traits::{ChangeMembers, EnsureOrigin, InitializeMembers}, }; -use polymesh_common_utilities::governance_group::GovernanceGroupTrait; use polymesh_primitives::{ storage_migration_ver, - traits::group::{GroupTrait, InactiveMember, MemberCount}, + traits::{ + group::{GroupTrait, InactiveMember, MemberCount}, + GovernanceGroupTrait, + }, IdentityId, MaybeBlock, SystematicIssuers, GC_DID, }; use scale_info::TypeInfo; diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 6dc2439531..3815265e7b 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -17,6 +17,5 @@ pub mod traits; pub use traits::{ - asset, balances, compliance_manager, governance_group, group, multisig, nft, portfolio, - CommonConfig, + asset, balances, compliance_manager, group, multisig, nft, portfolio, CommonConfig, }; diff --git a/pallets/common/src/traits/asset.rs b/pallets/common/src/traits/asset.rs index e9fa547fea..7e8a038d34 100644 --- a/pallets/common/src/traits/asset.rs +++ b/pallets/common/src/traits/asset.rs @@ -27,14 +27,13 @@ use polymesh_primitives::asset_metadata::{ AssetMetadataGlobalKey, AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataName, AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, }; -use polymesh_primitives::traits::AssetFnConfig; +use polymesh_primitives::traits::{AssetFnConfig, ComplianceFnConfig, NFTTrait}; use polymesh_primitives::{ AssetIdentifier, Balance, Document, DocumentId, IdentityId, PortfolioId, PortfolioUpdateReason, Ticker, }; -use crate::traits::nft::NFTTrait; -use crate::traits::{checkpoint, compliance_manager, portfolio, statistics}; +use crate::traits::{checkpoint, portfolio, statistics}; /// The module's configuration trait. pub trait Config: @@ -47,7 +46,7 @@ pub trait Config: type Currency: Currency; - type ComplianceManager: compliance_manager::ComplianceFnConfig; + type ComplianceManager: ComplianceFnConfig; /// Time used in computation of checkpoints. type UnixTime: UnixTime; diff --git a/pallets/common/src/traits/compliance_manager.rs b/pallets/common/src/traits/compliance_manager.rs index 8df882b5ac..773f0cd40a 100644 --- a/pallets/common/src/traits/compliance_manager.rs +++ b/pallets/common/src/traits/compliance_manager.rs @@ -13,27 +13,25 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use core::result::Result; use frame_support::decl_event; -use frame_support::dispatch::DispatchError; use frame_support::traits::Get; use frame_support::weights::Weight; use sp_std::prelude::*; use pallet_external_agents::Config as EAConfig; use polymesh_primitives::asset::AssetId; -use polymesh_primitives::compliance_manager::{AssetComplianceResult, ComplianceRequirement}; +use polymesh_primitives::compliance_manager::ComplianceRequirement; use polymesh_primitives::condition::{conditions_total_counts, Condition}; use polymesh_primitives::traits::AssetFnConfig; -use polymesh_primitives::{IdentityId, TrustedIssuer, WeightMeter}; +use polymesh_primitives::{IdentityId, TrustedIssuer}; use crate::balances::Config as BalancesConfig; -use crate::traits::CommonConfig; /// The module's configuration trait. pub trait Config: pallet_timestamp::Config - + CommonConfig + + frame_system::Config + + pallet_permissions::Config + BalancesConfig + pallet_identity::Config + EAConfig @@ -81,32 +79,6 @@ decl_event!( } ); -pub trait ComplianceFnConfig { - /// Returns `true` if there are no requirements or if any requirement is satisfied. - /// Otherwise, returns `false`. - fn is_compliant( - asset_id: &AssetId, - sender_did: IdentityId, - receiver_did: IdentityId, - weight_meter: &mut WeightMeter, - ) -> Result; - - fn verify_restriction_granular( - asset_id: &AssetId, - from_did_opt: Option, - to_did_opt: Option, - weight_meter: &mut WeightMeter, - ) -> Result; - - #[cfg(feature = "runtime-benchmarks")] - fn setup_asset_compliance( - caler_did: IdentityId, - asset_id: AssetId, - n: u32, - pause_compliance: bool, - ); -} - pub trait WeightInfo { fn add_compliance_requirement(c: u32) -> Weight; fn remove_compliance_requirement() -> Weight; diff --git a/pallets/common/src/traits/governance_group.rs b/pallets/common/src/traits/governance_group.rs deleted file mode 100644 index fc630dadea..0000000000 --- a/pallets/common/src/traits/governance_group.rs +++ /dev/null @@ -1,24 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use polymesh_primitives::traits::group::GroupTrait; -use polymesh_primitives::IdentityId; - -pub trait GovernanceGroupTrait: GroupTrait { - fn release_coordinator() -> Option; - - #[cfg(feature = "runtime-benchmarks")] - fn bench_set_release_coordinator(did: IdentityId); -} diff --git a/pallets/common/src/traits/group.rs b/pallets/common/src/traits/group.rs index 01daa9309c..48057095bb 100644 --- a/pallets/common/src/traits/group.rs +++ b/pallets/common/src/traits/group.rs @@ -13,8 +13,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::traits::CommonConfig; - use polymesh_primitives::{traits::group::MemberCount, IdentityId}; use frame_support::{ @@ -34,7 +32,12 @@ pub trait WeightInfo { fn abdicate_membership() -> Weight; } -pub trait Config: CommonConfig + pallet_timestamp::Config + pallet_identity::Config { +pub trait Config: + frame_system::Config + + pallet_permissions::Config + + pallet_timestamp::Config + + pallet_identity::Config +{ /// The overarching event type. type RuntimeEvent: From> + Into<::RuntimeEvent>; diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 8d8a8f095c..a210f5f560 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -26,7 +26,6 @@ pub mod asset; pub mod balances; pub mod checkpoint; pub mod compliance_manager; -pub mod governance_group; pub mod group; pub mod multisig; pub mod nft; diff --git a/pallets/common/src/traits/nft.rs b/pallets/common/src/traits/nft.rs index d9de68acb1..5fd9de68d5 100644 --- a/pallets/common/src/traits/nft.rs +++ b/pallets/common/src/traits/nft.rs @@ -1,19 +1,11 @@ -#[cfg(feature = "runtime-benchmarks")] -use frame_support::dispatch::DispatchResult; -#[cfg(feature = "runtime-benchmarks")] -use polymesh_primitives::asset::NonFungibleType; -#[cfg(feature = "runtime-benchmarks")] -use polymesh_primitives::nft::NFTCollectionKeys; - use frame_support::decl_event; use frame_support::traits::Get; use frame_support::weights::Weight; use polymesh_primitives::asset::AssetId; -use polymesh_primitives::asset_metadata::AssetMetadataKey; use polymesh_primitives::nft::{NFTCollectionId, NFTs}; -use polymesh_primitives::{IdentityId, NFTId, PortfolioId, PortfolioUpdateReason}; +use polymesh_primitives::traits::ComplianceFnConfig; +use polymesh_primitives::{IdentityId, PortfolioId, PortfolioUpdateReason}; -use crate::compliance_manager::ComplianceFnConfig; use crate::{asset, portfolio}; pub trait Config: @@ -54,18 +46,3 @@ pub trait WeightInfo { fn base_nft_transfer(n: u32) -> Weight; fn controller_transfer(n: u32) -> Weight; } - -pub trait NFTTrait { - /// Returns `true` if the given `metadata_key` is a mandatory key for the `asset_id` NFT collection. - fn is_collection_key(asset_id: &AssetId, metadata_key: &AssetMetadataKey) -> bool; - /// Updates the NFTOwner storage after moving funds. - fn move_portfolio_owner(asset_id: AssetId, nft_id: NFTId, new_owner_portfolio: PortfolioId); - - #[cfg(feature = "runtime-benchmarks")] - fn create_nft_collection( - origin: Origin, - asset_id: Option, - nft_type: Option, - collection_keys: NFTCollectionKeys, - ) -> DispatchResult; -} diff --git a/pallets/common/src/traits/portfolio.rs b/pallets/common/src/traits/portfolio.rs index d20269b686..8dcd32e6c6 100644 --- a/pallets/common/src/traits/portfolio.rs +++ b/pallets/common/src/traits/portfolio.rs @@ -17,89 +17,16 @@ //! //! The interface allows to accept portfolio custody -use crate::{nft::NFTTrait, CommonConfig}; use frame_support::decl_event; -use frame_support::dispatch::DispatchResult; use frame_support::pallet_prelude::Get; use frame_support::weights::Weight; use polymesh_primitives::asset::AssetId; -use polymesh_primitives::traits::AssetFnConfig; +use polymesh_primitives::traits::{AssetFnConfig, NFTTrait}; use polymesh_primitives::{ - Balance, Fund, FundDescription, IdentityId, Memo, NFTId, PortfolioId, PortfolioName, - PortfolioNumber, SecondaryKey, + Fund, FundDescription, IdentityId, Memo, PortfolioId, PortfolioName, PortfolioNumber, }; use sp_std::vec::Vec; -/// This trait is used to accept custody of a portfolio -pub trait PortfolioSubTrait { - /// Checks that the custodian is authorized for the portfolio - /// - /// # Arguments - /// * `portfolio` - Portfolio to check - /// * `custodian` - DID of the custodian - fn ensure_portfolio_custody(portfolio: PortfolioId, custodian: IdentityId) -> DispatchResult; - - /// Ensure that the `portfolio` exists. - /// - /// # Arguments - /// * `portfolio` - Portfolio to check - fn ensure_portfolio_validity(portfolio: &PortfolioId) -> DispatchResult; - - /// Locks some tokens of a portfolio - /// - /// # Arguments - /// * `portfolio` - Portfolio to lock tokens - /// * `asset_id` - [`AssetId`] of the token to lock - /// * `amount` - Amount of tokens to lock - - fn lock_tokens(portfolio: &PortfolioId, asset_id: &AssetId, amount: Balance) -> DispatchResult; - - /// Unlocks some tokens of a portfolio - /// - /// # Arguments - /// * `portfolio` - Portfolio to unlock tokens - /// * asset_id` - [`AssetId`] of the token to unlock - /// * `amount` - Amount of tokens to unlock - fn unlock_tokens( - portfolio: &PortfolioId, - asset_id: &AssetId, - amount: Balance, - ) -> DispatchResult; - - /// Ensures that the portfolio's custody is with the provided identity - /// And the secondary key has the relevant portfolio permission - /// - /// # Arguments - /// * `portfolio` - PortfolioId of the portfolio to check - /// * `custodian` - Identity of the custodian - /// * `secondary_key` - Secondary key that is accessing the portfolio - fn ensure_portfolio_custody_and_permission( - portfolio: PortfolioId, - custodian: IdentityId, - secondary_key: Option<&SecondaryKey>, - ) -> DispatchResult; - - /// Locks the given nft. This prevents transfering the same NFT more than once. - /// - /// # Arguments - /// * `portfolio_id` - PortfolioId that contains the nft to be locked. - /// asset_id` - [`AssetId`] of the NFT. - /// * `nft_id` - the id of the nft to be unlocked. - fn lock_nft(portfolio_id: &PortfolioId, asset_id: &AssetId, nft_id: &NFTId) -> DispatchResult; - - /// Unlocks the given nft. - /// - /// # Arguments - /// * `portfolio_id` - PortfolioId that contains the locked nft. - /// asset_id` - [`AssetId`] of the NFT. - /// * `nft_id` - the id of the nft to be unlocked. - fn unlock_nft(portfolio_id: &PortfolioId, asset_id: &AssetId, nft_id: &NFTId) - -> DispatchResult; - - /// Returns `true` if the portfolio has pre-approved the receivement of `asset_id`, otherwise returns `false`. - fn skip_portfolio_affirmation(portfolio_id: &PortfolioId, asset_id: &AssetId) -> bool; -} - pub trait WeightInfo { fn create_portfolio(l: u32) -> Weight; fn delete_portfolio() -> Weight; @@ -118,7 +45,9 @@ pub trait WeightInfo { fn create_custody_portfolio() -> Weight; } -pub trait Config: CommonConfig + pallet_identity::Config + AssetFnConfig { +pub trait Config: + frame_system::Config + pallet_permissions::Config + pallet_identity::Config + AssetFnConfig +{ type RuntimeEvent: From + Into<::RuntimeEvent>; type WeightInfo: WeightInfo; /// Maximum number of fungible assets that can be moved in a single transfer call. diff --git a/pallets/compliance-manager/src/lib.rs b/pallets/compliance-manager/src/lib.rs index 604a82f2ef..b60a4f29f1 100644 --- a/pallets/compliance-manager/src/lib.rs +++ b/pallets/compliance-manager/src/lib.rs @@ -84,9 +84,7 @@ use frame_support::{decl_error, decl_module, decl_storage, ensure}; use sp_std::{convert::From, prelude::*}; use pallet_base::ensure_length_ok; -pub use polymesh_common_utilities::traits::compliance_manager::{ - ComplianceFnConfig, Config, Event, WeightInfo, -}; +pub use polymesh_common_utilities::traits::compliance_manager::{Config, Event, WeightInfo}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::compliance_manager::{ AssetCompliance, AssetComplianceResult, ComplianceReport, ComplianceRequirement, @@ -94,8 +92,8 @@ use polymesh_primitives::compliance_manager::{ }; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{ - proposition, storage_migration_ver, Claim, Condition, ConditionType, Context, IdentityId, - TargetIdentity, TrustedFor, TrustedIssuer, WeightMeter, + proposition, storage_migration_ver, traits::ComplianceFnConfig, Claim, Condition, + ConditionType, Context, IdentityId, TargetIdentity, TrustedFor, TrustedIssuer, WeightMeter, }; type ExternalAgents = pallet_external_agents::Module; diff --git a/pallets/corporate-actions/src/distribution/mod.rs b/pallets/corporate-actions/src/distribution/mod.rs index 6d87066115..140ac271fc 100644 --- a/pallets/corporate-actions/src/distribution/mod.rs +++ b/pallets/corporate-actions/src/distribution/mod.rs @@ -76,13 +76,14 @@ use frame_support::{ }; use pallet_asset::{self as asset, checkpoint}; use pallet_identity::{self as identity, PermissionedCallOriginData}; -use polymesh_common_utilities::portfolio::PortfolioSubTrait; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ constants::currency::ONE_UNIT, protocol_fee::{ChargeProtocolFee, ProtocolOp}, - storage_migration_ver, with_transaction, Balance, EventDid, IdentityId, Moment, PortfolioId, - PortfolioNumber, SecondaryKey, WeightMeter, + storage_migration_ver, + traits::PortfolioSubTrait, + with_transaction, Balance, EventDid, IdentityId, Moment, PortfolioId, PortfolioNumber, + SecondaryKey, WeightMeter, }; use scale_info::TypeInfo; use sp_runtime::traits::Zero; diff --git a/pallets/nft/src/benchmarking.rs b/pallets/nft/src/benchmarking.rs index fa26e12392..e0a2f193e1 100644 --- a/pallets/nft/src/benchmarking.rs +++ b/pallets/nft/src/benchmarking.rs @@ -5,14 +5,13 @@ use sp_std::vec::Vec; use pallet_asset::benchmarking::create_portfolio; use pallet_identity::benchmarking::{user, User, UserBuilder}; -use polymesh_common_utilities::traits::compliance_manager::ComplianceFnConfig; use polymesh_primitives::asset::{AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{ AssetMetadataGlobalKey, AssetMetadataKey, AssetMetadataSpec, AssetMetadataValue, }; use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::nft::{NFTCollectionId, NFTCollectionKeys, NFTId}; -use polymesh_primitives::traits::AssetFnTrait; +use polymesh_primitives::traits::{AssetFnTrait, ComplianceFnConfig}; use polymesh_primitives::{with_transaction, IdentityId, PortfolioKind, WeightMeter}; use crate::*; diff --git a/pallets/nft/src/lib.rs b/pallets/nft/src/lib.rs index 4367cecdff..a82dbc2f17 100644 --- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -15,8 +15,7 @@ use sp_std::{vec, vec::Vec}; use pallet_asset::Frozen; use pallet_base::try_next_pre; use pallet_portfolio::{PortfolioLockedNFT, PortfolioNFT}; -use polymesh_common_utilities::compliance_manager::ComplianceFnConfig; -pub use polymesh_common_utilities::traits::nft::{Config, Event, NFTTrait, WeightInfo}; +pub use polymesh_common_utilities::traits::nft::{Config, Event, WeightInfo}; use polymesh_primitives::asset::{AssetId, AssetName, AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{AssetMetadataKey, AssetMetadataValue}; use polymesh_primitives::nft::{ @@ -24,8 +23,9 @@ use polymesh_primitives::nft::{ }; use polymesh_primitives::settlement::InstructionId; use polymesh_primitives::{ - storage_migration_ver, IdentityId, Memo, PortfolioId, PortfolioKind, PortfolioUpdateReason, - WeightMeter, + storage_migration_ver, + traits::{ComplianceFnConfig, NFTTrait}, + IdentityId, Memo, PortfolioId, PortfolioKind, PortfolioUpdateReason, WeightMeter, }; type Asset = pallet_asset::Module; diff --git a/pallets/pips/src/lib.rs b/pallets/pips/src/lib.rs index f36a865d83..1ca9326a13 100644 --- a/pallets/pips/src/lib.rs +++ b/pallets/pips/src/lib.rs @@ -109,11 +109,11 @@ use sp_version::RuntimeVersion; use pallet_base::{ensure_opt_string_limited, try_next_post}; use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; use polymesh_common_utilities::traits::balances::LockableCurrencyExt; -use polymesh_common_utilities::traits::governance_group::GovernanceGroupTrait; use polymesh_common_utilities::CommonConfig; use polymesh_primitives::constants::PIP_MAX_REPORTING_SIZE; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::traits::group::GroupTrait; +use polymesh_primitives::traits::GovernanceGroupTrait; use polymesh_primitives::{storage_migration_ver, with_transaction}; use polymesh_primitives::{Balance, IdentityId, MaybeBlock, Url}; use polymesh_primitives::{GC_DID, TECHNICAL_DID, UPGRADE_DID}; diff --git a/pallets/portfolio/src/lib.rs b/pallets/portfolio/src/lib.rs index 97e7ee3df0..df57d62194 100644 --- a/pallets/portfolio/src/lib.rs +++ b/pallets/portfolio/src/lib.rs @@ -56,13 +56,14 @@ use sp_std::prelude::*; use pallet_identity::PermissionedCallOriginData; pub use polymesh_common_utilities::portfolio::{Config, Event, WeightInfo}; -use polymesh_common_utilities::traits::nft::NFTTrait; -use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ - extract_auth, identity_id::PortfolioValidityResult, storage_migration_ver, - traits::AssetFnTrait, Balance, Fund, FundDescription, IdentityId, NFTId, PortfolioId, - PortfolioKind, PortfolioName, PortfolioNumber, SecondaryKey, + extract_auth, + identity_id::PortfolioValidityResult, + storage_migration_ver, + traits::{AssetFnTrait, NFTTrait, PortfolioSubTrait}, + Balance, Fund, FundDescription, IdentityId, NFTId, PortfolioId, PortfolioKind, PortfolioName, + PortfolioNumber, SecondaryKey, }; type Identity = pallet_identity::Module; diff --git a/pallets/runtime/tests/src/compliance_manager_test.rs b/pallets/runtime/tests/src/compliance_manager_test.rs index c5c5542999..d1b05e8c20 100644 --- a/pallets/runtime/tests/src/compliance_manager_test.rs +++ b/pallets/runtime/tests/src/compliance_manager_test.rs @@ -4,15 +4,15 @@ use frame_support::{assert_noop, assert_ok}; use sp_std::prelude::*; use pallet_compliance_manager::Error as CMError; -use polymesh_common_utilities::compliance_manager::ComplianceFnConfig; use polymesh_primitives::agent::AgentGroup; use polymesh_primitives::asset::AssetId; use polymesh_primitives::compliance_manager::{ ComplianceReport, ComplianceRequirement, ComplianceRequirementResult, }; use polymesh_primitives::{ - AuthorizationData, Claim, ClaimType, Condition, ConditionType, CountryCode, IdentityId, - PortfolioId, Scope, Signatory, TargetIdentity, TrustedFor, WeightMeter, + traits::ComplianceFnConfig, AuthorizationData, Claim, ClaimType, Condition, ConditionType, + CountryCode, IdentityId, PortfolioId, Scope, Signatory, TargetIdentity, TrustedFor, + WeightMeter, }; use sp_keyring::AccountKeyring; diff --git a/pallets/runtime/tests/src/portfolio.rs b/pallets/runtime/tests/src/portfolio.rs index d8d1d56d80..87b44f4a41 100644 --- a/pallets/runtime/tests/src/portfolio.rs +++ b/pallets/runtime/tests/src/portfolio.rs @@ -6,16 +6,15 @@ use pallet_portfolio::{ AllowedCustodians, Event, NameToNumber, PortfolioAssetBalances, PortfolioCustodian, PortfolioNFT, Portfolios, PreApprovedPortfolios, }; -use polymesh_common_utilities::portfolio::PortfolioSubTrait; use polymesh_primitives::asset::{AssetId, AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{ AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataValue, }; use polymesh_primitives::settlement::{Leg, SettlementType}; use polymesh_primitives::{ - AuthorizationData, AuthorizationError, Fund, FundDescription, Memo, NFTCollectionKeys, NFTId, - NFTMetadataAttribute, NFTs, PortfolioId, PortfolioKind, PortfolioName, PortfolioNumber, - Signatory, + traits::PortfolioSubTrait, AuthorizationData, AuthorizationError, Fund, FundDescription, Memo, + NFTCollectionKeys, NFTId, NFTMetadataAttribute, NFTs, PortfolioId, PortfolioKind, + PortfolioName, PortfolioNumber, Signatory, }; use sp_keyring::AccountKeyring; diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index bd9fd65e48..554fe5b45e 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -42,7 +42,6 @@ use sp_staking::{EraIndex, SessionIndex}; use pallet_staking::types::SlashingSwitch; use pallet_staking::{self as pallet_staking, *}; use polymesh_common_utilities::traits::balances::{AccountData, CheckCdd}; -use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; use polymesh_common_utilities::traits::CommonConfig; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::currency::POLY; @@ -50,7 +49,7 @@ use polymesh_primitives::identity_id::GenesisIdentityRecord; use polymesh_primitives::{ traits::{ group::{GroupTrait, InactiveMember}, - SubsidiserTrait, + PortfolioSubTrait, SubsidiserTrait, }, Authorization, AuthorizationData, Claim, IdentityId, Moment, NFTId, Permissions, PortfolioId, SecondaryKey, Signatory, diff --git a/pallets/settlement/src/lib.rs b/pallets/settlement/src/lib.rs index 2740a80a9d..900fecaf06 100644 --- a/pallets/settlement/src/lib.rs +++ b/pallets/settlement/src/lib.rs @@ -69,7 +69,6 @@ use sp_std::vec; use pallet_asset::MandatoryMediators; use pallet_base::{ensure_string_limited, try_next_post}; -use polymesh_common_utilities::traits::portfolio::PortfolioSubTrait; pub use polymesh_common_utilities::traits::settlement::{Event, RawEvent, WeightInfo}; use polymesh_common_utilities::traits::{asset, compliance_manager, nft, CommonConfig}; use polymesh_primitives::asset::AssetId; @@ -83,7 +82,8 @@ use polymesh_primitives::settlement::{ use polymesh_primitives::with_transaction; use polymesh_primitives::SystematicIssuers::Settlement as SettlementDID; use polymesh_primitives::{ - storage_migration_ver, Balance, IdentityId, Memo, NFTs, PortfolioId, SecondaryKey, WeightMeter, + storage_migration_ver, traits::PortfolioSubTrait, Balance, IdentityId, Memo, NFTs, PortfolioId, + SecondaryKey, WeightMeter, }; type Identity = pallet_identity::Module; diff --git a/pallets/sto/src/lib.rs b/pallets/sto/src/lib.rs index 54aa522ab8..dd00ceff62 100644 --- a/pallets/sto/src/lib.rs +++ b/pallets/sto/src/lib.rs @@ -38,14 +38,13 @@ use sp_std::prelude::*; use pallet_base::try_next_post; use pallet_identity::PermissionedCallOriginData; use pallet_settlement::VenueInfo; -use polymesh_common_utilities::portfolio::PortfolioSubTrait; use polymesh_common_utilities::traits::portfolio; use polymesh_primitives::asset::AssetId; use polymesh_primitives::impl_checked_inc; use polymesh_primitives::settlement::{Leg, ReceiptDetails, SettlementType, VenueId, VenueType}; use polymesh_primitives::{ - storage_migration_ver, with_transaction, Balance, EventDid, IdentityId, PortfolioId, - WeightMeter, + storage_migration_ver, traits::PortfolioSubTrait, with_transaction, Balance, EventDid, + IdentityId, PortfolioId, WeightMeter, }; use polymesh_primitives_derive::VecU8StrongTyped; diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index 510e7fd42a..36db568c2c 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -14,10 +14,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{secondary_key::SecondaryKey, Balance, IdentityId}; -use frame_support::dispatch::DispatchError; +use frame_support::dispatch::{DispatchError, DispatchResult}; use sp_runtime::transaction_validity::InvalidTransaction; +use crate::{ + asset::AssetId, asset_metadata::AssetMetadataKey, compliance_manager::AssetComplianceResult, + secondary_key::SecondaryKey, Balance, IdentityId, NFTId, PortfolioId, WeightMeter, +}; + +#[cfg(feature = "runtime-benchmarks")] +use crate::{asset::NonFungibleType, NFTCollectionKeys}; + mod asset; pub mod group; pub use asset::*; @@ -63,6 +70,124 @@ pub trait SubsidiserTrait { ) -> Result, InvalidTransaction>; } +/// This trait is used to accept custody of a portfolio +pub trait PortfolioSubTrait { + /// Checks that the custodian is authorized for the portfolio + /// + /// # Arguments + /// * `portfolio` - Portfolio to check + /// * `custodian` - DID of the custodian + fn ensure_portfolio_custody(portfolio: PortfolioId, custodian: IdentityId) -> DispatchResult; + + /// Ensure that the `portfolio` exists. + /// + /// # Arguments + /// * `portfolio` - Portfolio to check + fn ensure_portfolio_validity(portfolio: &PortfolioId) -> DispatchResult; + + /// Locks some tokens of a portfolio + /// + /// # Arguments + /// * `portfolio` - Portfolio to lock tokens + /// * `asset_id` - [`AssetId`] of the token to lock + /// * `amount` - Amount of tokens to lock + + fn lock_tokens(portfolio: &PortfolioId, asset_id: &AssetId, amount: Balance) -> DispatchResult; + + /// Unlocks some tokens of a portfolio + /// + /// # Arguments + /// * `portfolio` - Portfolio to unlock tokens + /// * asset_id` - [`AssetId`] of the token to unlock + /// * `amount` - Amount of tokens to unlock + fn unlock_tokens( + portfolio: &PortfolioId, + asset_id: &AssetId, + amount: Balance, + ) -> DispatchResult; + + /// Ensures that the portfolio's custody is with the provided identity + /// And the secondary key has the relevant portfolio permission + /// + /// # Arguments + /// * `portfolio` - PortfolioId of the portfolio to check + /// * `custodian` - Identity of the custodian + /// * `secondary_key` - Secondary key that is accessing the portfolio + fn ensure_portfolio_custody_and_permission( + portfolio: PortfolioId, + custodian: IdentityId, + secondary_key: Option<&SecondaryKey>, + ) -> DispatchResult; + + /// Locks the given nft. This prevents transfering the same NFT more than once. + /// + /// # Arguments + /// * `portfolio_id` - PortfolioId that contains the nft to be locked. + /// asset_id` - [`AssetId`] of the NFT. + /// * `nft_id` - the id of the nft to be unlocked. + fn lock_nft(portfolio_id: &PortfolioId, asset_id: &AssetId, nft_id: &NFTId) -> DispatchResult; + + /// Unlocks the given nft. + /// + /// # Arguments + /// * `portfolio_id` - PortfolioId that contains the locked nft. + /// asset_id` - [`AssetId`] of the NFT. + /// * `nft_id` - the id of the nft to be unlocked. + fn unlock_nft(portfolio_id: &PortfolioId, asset_id: &AssetId, nft_id: &NFTId) + -> DispatchResult; + + /// Returns `true` if the portfolio has pre-approved the receivement of `asset_id`, otherwise returns `false`. + fn skip_portfolio_affirmation(portfolio_id: &PortfolioId, asset_id: &AssetId) -> bool; +} + +pub trait ComplianceFnConfig { + /// Returns `true` if there are no requirements or if any requirement is satisfied. + /// Otherwise, returns `false`. + fn is_compliant( + asset_id: &AssetId, + sender_did: IdentityId, + receiver_did: IdentityId, + weight_meter: &mut WeightMeter, + ) -> Result; + + fn verify_restriction_granular( + asset_id: &AssetId, + from_did_opt: Option, + to_did_opt: Option, + weight_meter: &mut WeightMeter, + ) -> Result; + + #[cfg(feature = "runtime-benchmarks")] + fn setup_asset_compliance( + caler_did: IdentityId, + asset_id: AssetId, + n: u32, + pause_compliance: bool, + ); +} + +pub trait NFTTrait { + /// Returns `true` if the given `metadata_key` is a mandatory key for the `asset_id` NFT collection. + fn is_collection_key(asset_id: &AssetId, metadata_key: &AssetMetadataKey) -> bool; + /// Updates the NFTOwner storage after moving funds. + fn move_portfolio_owner(asset_id: AssetId, nft_id: NFTId, new_owner_portfolio: PortfolioId); + + #[cfg(feature = "runtime-benchmarks")] + fn create_nft_collection( + origin: Origin, + asset_id: Option, + nft_type: Option, + collection_keys: NFTCollectionKeys, + ) -> DispatchResult; +} + +pub trait GovernanceGroupTrait: group::GroupTrait { + fn release_coordinator() -> Option; + + #[cfg(feature = "runtime-benchmarks")] + fn bench_set_release_coordinator(did: IdentityId); +} + /// A currency that has a block rewards reserve. pub trait BlockRewardsReserveCurrency { /// An instance of `Drop` for positive imbalance. From 29b440db257eeeff5e5ac8dec62811125dfc101f Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 01:57:13 +0800 Subject: [PATCH 23/45] Move WeightInfo into MultiSig pallet. --- pallets/common/src/lib.rs | 4 +- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/multisig.rs | 57 --------------------------- pallets/multisig/src/lib.rs | 37 ++++++++++++++++- 4 files changed, 37 insertions(+), 62 deletions(-) delete mode 100644 pallets/common/src/traits/multisig.rs diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 3815265e7b..fc15bba442 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -16,6 +16,4 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod traits; -pub use traits::{ - asset, balances, compliance_manager, group, multisig, nft, portfolio, CommonConfig, -}; +pub use traits::{asset, balances, compliance_manager, group, nft, portfolio, CommonConfig}; diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index a210f5f560..d6fcf460b4 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -27,7 +27,6 @@ pub mod balances; pub mod checkpoint; pub mod compliance_manager; pub mod group; -pub mod multisig; pub mod nft; pub mod portfolio; pub mod settlement; diff --git a/pallets/common/src/traits/multisig.rs b/pallets/common/src/traits/multisig.rs deleted file mode 100644 index 1ca7ee0369..0000000000 --- a/pallets/common/src/traits/multisig.rs +++ /dev/null @@ -1,57 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! # Trait Interface to the Multisig Module -//! -//! The interface allows to process addition of a multisig signer from modules other than the -//! multisig module itself. - -use frame_support::pallet_prelude::Weight; - -pub trait WeightInfo { - fn create_multisig(signers: u32) -> Weight; - fn create_proposal() -> Weight; - fn approve() -> Weight; - fn execute_proposal() -> Weight; - fn reject() -> Weight; - fn accept_multisig_signer() -> Weight; - fn add_multisig_signers(signers: u32) -> Weight; - fn remove_multisig_signers(signers: u32) -> Weight; - fn add_multisig_signers_via_admin(signers: u32) -> Weight; - fn remove_multisig_signers_via_admin(signers: u32) -> Weight; - fn change_sigs_required() -> Weight; - fn change_sigs_required_via_admin() -> Weight; - fn add_admin() -> Weight; - fn remove_admin_via_admin() -> Weight; - fn remove_payer() -> Weight; - fn remove_payer_via_payer() -> Weight; - fn create_join_identity() -> Weight; - fn approve_join_identity() -> Weight; - fn join_identity() -> Weight; - fn remove_admin() -> Weight; - - fn default_max_weight(max_weight: &Option) -> Weight { - max_weight.unwrap_or_else(|| { - // TODO: Use a better default weight. - Self::create_proposal() - }) - } - - fn approve_and_execute(max_weight: &Option) -> Weight { - Self::approve() - .saturating_add(Self::execute_proposal()) - .saturating_add(Self::default_max_weight(max_weight)) - } -} diff --git a/pallets/multisig/src/lib.rs b/pallets/multisig/src/lib.rs index 7cc4364cb2..807dcc09fe 100644 --- a/pallets/multisig/src/lib.rs +++ b/pallets/multisig/src/lib.rs @@ -85,7 +85,6 @@ use sp_std::prelude::*; use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; use pallet_permissions::with_call_metadata; -pub use polymesh_common_utilities::multisig::WeightInfo; use polymesh_primitives::multisig::{ProposalState, ProposalVoteCount}; use polymesh_primitives::{ extract_auth, storage_migration_ver, AuthorizationData, IdentityId, KeyRecord, Permissions, @@ -94,6 +93,42 @@ use polymesh_primitives::{ //use polymesh_runtime_common::RocksDbWeight as DbWeight; use frame_support::weights::constants::RocksDbWeight as DbWeight; +pub trait WeightInfo { + fn create_multisig(signers: u32) -> Weight; + fn create_proposal() -> Weight; + fn approve() -> Weight; + fn execute_proposal() -> Weight; + fn reject() -> Weight; + fn accept_multisig_signer() -> Weight; + fn add_multisig_signers(signers: u32) -> Weight; + fn remove_multisig_signers(signers: u32) -> Weight; + fn add_multisig_signers_via_admin(signers: u32) -> Weight; + fn remove_multisig_signers_via_admin(signers: u32) -> Weight; + fn change_sigs_required() -> Weight; + fn change_sigs_required_via_admin() -> Weight; + fn add_admin() -> Weight; + fn remove_admin_via_admin() -> Weight; + fn remove_payer() -> Weight; + fn remove_payer_via_payer() -> Weight; + fn create_join_identity() -> Weight; + fn approve_join_identity() -> Weight; + fn join_identity() -> Weight; + fn remove_admin() -> Weight; + + fn default_max_weight(max_weight: &Option) -> Weight { + max_weight.unwrap_or_else(|| { + // TODO: Use a better default weight. + Self::create_proposal() + }) + } + + fn approve_and_execute(max_weight: &Option) -> Weight { + Self::approve() + .saturating_add(Self::execute_proposal()) + .saturating_add(Self::default_max_weight(max_weight)) + } +} + type IdentityPallet = pallet_identity::Module; storage_migration_ver!(3); From caa5bf5ea39241b90133e696a5d9be46fdb6e453 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 03:09:37 +0800 Subject: [PATCH 24/45] Move WeightInfo, Config, Event into Group pallet. --- Cargo.lock | 2 +- pallets/common/src/lib.rs | 2 +- pallets/common/src/traits/group.rs | 98 ------------------------------ pallets/common/src/traits/mod.rs | 1 - pallets/group/Cargo.toml | 7 ++- pallets/group/src/benchmarking.rs | 1 - pallets/group/src/lib.rs | 94 +++++++++++++++++++++++++--- 7 files changed, 90 insertions(+), 115 deletions(-) delete mode 100644 pallets/common/src/traits/group.rs diff --git a/Cargo.lock b/Cargo.lock index c92b5d8c2a..c9654b5f23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5100,9 +5100,9 @@ dependencies = [ "frame-support", "frame-system", "pallet-identity", + "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index fc15bba442..73cff826c7 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -16,4 +16,4 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod traits; -pub use traits::{asset, balances, compliance_manager, group, nft, portfolio, CommonConfig}; +pub use traits::{asset, balances, compliance_manager, nft, portfolio, CommonConfig}; diff --git a/pallets/common/src/traits/group.rs b/pallets/common/src/traits/group.rs deleted file mode 100644 index 48057095bb..0000000000 --- a/pallets/common/src/traits/group.rs +++ /dev/null @@ -1,98 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use polymesh_primitives::{traits::group::MemberCount, IdentityId}; - -use frame_support::{ - decl_event, - traits::{ChangeMembers, EnsureOrigin, InitializeMembers}, - weights::Weight, -}; -use sp_std::vec::Vec; - -pub trait WeightInfo { - fn set_active_members_limit() -> Weight; - fn add_member() -> Weight; - fn remove_member() -> Weight; - fn disable_member() -> Weight; - fn swap_member() -> Weight; - fn reset_members(new_members_len: u32) -> Weight; - fn abdicate_membership() -> Weight; -} - -pub trait Config: - frame_system::Config - + pallet_permissions::Config - + pallet_timestamp::Config - + pallet_identity::Config -{ - /// The overarching event type. - type RuntimeEvent: From> + Into<::RuntimeEvent>; - - /// Required origin for changing the active limit. - /// It's recommended that e.g., in case of a committee, - /// this be an origin that cannot be formed through a committee majority. - type LimitOrigin: EnsureOrigin<::RuntimeOrigin>; - - /// Required origin for adding a member (though can always be Root). - type AddOrigin: EnsureOrigin<::RuntimeOrigin>; - - /// Required origin for removing a member (though can always be Root). - type RemoveOrigin: EnsureOrigin<::RuntimeOrigin>; - - /// Required origin for adding and removing a member in a single action. - type SwapOrigin: EnsureOrigin<::RuntimeOrigin>; - - /// Required origin for resetting membership. - type ResetOrigin: EnsureOrigin<::RuntimeOrigin>; - - /// The receiver of the signal for when the membership has been initialized. This happens pre- - /// genesis and will usually be the same as `MembershipChanged`. If you need to do something - /// different on initialization, then you can change this accordingly. - type MembershipInitialized: InitializeMembers; - - /// The receiver of the signal for when the membership has changed. - type MembershipChanged: ChangeMembers; - - /// Weight information for extrinsics in this pallet. - type WeightInfo: WeightInfo; -} - -decl_event!( - pub enum Event where - ::AccountId, - >::RuntimeEvent, - { - /// The given member was added; see the transaction for who. - /// caller DID, New member DID. - MemberAdded(IdentityId, IdentityId), - /// The given member was removed; see the transaction for who. - /// caller DID, member DID that get removed. - MemberRemoved(IdentityId, IdentityId), - /// The given member has been revoked at specific time-stamp. - /// caller DID, member DID that get revoked. - MemberRevoked(IdentityId, IdentityId), - /// Two members were swapped; see the transaction for who. - /// caller DID, Removed DID, New add DID. - MembersSwapped(IdentityId, IdentityId, IdentityId), - /// The membership was reset; see the transaction for who the new set is. - /// caller DID, List of new members. - MembersReset(IdentityId, Vec), - /// The limit of how many active members there can be concurrently was changed. - ActiveLimitChanged(IdentityId, MemberCount, MemberCount), - /// Phantom member, never used. - Dummy(sp_std::marker::PhantomData<(AccountId, RuntimeEvent)>), - } -); diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index d6fcf460b4..281f96496b 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -26,7 +26,6 @@ pub mod asset; pub mod balances; pub mod checkpoint; pub mod compliance_manager; -pub mod group; pub mod nft; pub mod portfolio; pub mod settlement; diff --git a/pallets/group/Cargo.toml b/pallets/group/Cargo.toml index 17e87f68ee..bd20176e98 100644 --- a/pallets/group/Cargo.toml +++ b/pallets/group/Cargo.toml @@ -5,9 +5,9 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { workspace = true, default-features = false} polymesh-primitives = { workspace = true, default-features = false} pallet-identity = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } # Others serde = { version = "1.0.104", default-features = false } @@ -50,10 +50,11 @@ std = [ "pallet-timestamp/std", "polymesh-primitives/std", "pallet-identity/std", - "polymesh-common-utilities/std", + "pallet-permissions/std", ] runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", + "pallet-permissions/runtime-benchmarks", ] diff --git a/pallets/group/src/benchmarking.rs b/pallets/group/src/benchmarking.rs index f99fa4a54a..6862f059ef 100644 --- a/pallets/group/src/benchmarking.rs +++ b/pallets/group/src/benchmarking.rs @@ -1,6 +1,5 @@ use crate::*; use pallet_identity::benchmarking::{User, UserBuilder}; -use polymesh_common_utilities::traits::group::Config; use polymesh_primitives::traits::group::GroupTrait; use frame_benchmarking::benchmarks_instance; diff --git a/pallets/group/src/lib.rs b/pallets/group/src/lib.rs index 3e5f2b310d..3d8a23e31a 100644 --- a/pallets/group/src/lib.rs +++ b/pallets/group/src/lib.rs @@ -77,26 +77,100 @@ #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; +use frame_support::{ + decl_error, decl_event, decl_module, decl_storage, + dispatch::DispatchResult, + ensure, + traits::{ChangeMembers, EnsureOrigin, InitializeMembers}, + weights::Weight, + StorageValue, +}; use pallet_identity as identity; -pub use polymesh_common_utilities::group::{Config, RawEvent, WeightInfo}; use polymesh_primitives::{ committee::COMMITTEE_MEMBERS_MAX, traits::group::{GroupTrait, InactiveMember, MemberCount}, IdentityId, GC_DID, }; - -use frame_support::{ - decl_error, decl_module, decl_storage, - dispatch::DispatchResult, - ensure, - traits::{ChangeMembers, EnsureOrigin}, - StorageValue, -}; use sp_std::prelude::*; +use sp_std::vec::Vec; -pub type Event = polymesh_common_utilities::group::Event; type Identity = identity::Module; +pub trait WeightInfo { + fn set_active_members_limit() -> Weight; + fn add_member() -> Weight; + fn remove_member() -> Weight; + fn disable_member() -> Weight; + fn swap_member() -> Weight; + fn reset_members(new_members_len: u32) -> Weight; + fn abdicate_membership() -> Weight; +} + +pub trait Config: + frame_system::Config + + pallet_permissions::Config + + pallet_timestamp::Config + + pallet_identity::Config +{ + /// The overarching event type. + type RuntimeEvent: From> + Into<::RuntimeEvent>; + + /// Required origin for changing the active limit. + /// It's recommended that e.g., in case of a committee, + /// this be an origin that cannot be formed through a committee majority. + type LimitOrigin: EnsureOrigin<::RuntimeOrigin>; + + /// Required origin for adding a member (though can always be Root). + type AddOrigin: EnsureOrigin<::RuntimeOrigin>; + + /// Required origin for removing a member (though can always be Root). + type RemoveOrigin: EnsureOrigin<::RuntimeOrigin>; + + /// Required origin for adding and removing a member in a single action. + type SwapOrigin: EnsureOrigin<::RuntimeOrigin>; + + /// Required origin for resetting membership. + type ResetOrigin: EnsureOrigin<::RuntimeOrigin>; + + /// The receiver of the signal for when the membership has been initialized. This happens pre- + /// genesis and will usually be the same as `MembershipChanged`. If you need to do something + /// different on initialization, then you can change this accordingly. + type MembershipInitialized: InitializeMembers; + + /// The receiver of the signal for when the membership has changed. + type MembershipChanged: ChangeMembers; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; +} + +decl_event!( + pub enum Event where + ::AccountId, + >::RuntimeEvent, + { + /// The given member was added; see the transaction for who. + /// caller DID, New member DID. + MemberAdded(IdentityId, IdentityId), + /// The given member was removed; see the transaction for who. + /// caller DID, member DID that get removed. + MemberRemoved(IdentityId, IdentityId), + /// The given member has been revoked at specific time-stamp. + /// caller DID, member DID that get revoked. + MemberRevoked(IdentityId, IdentityId), + /// Two members were swapped; see the transaction for who. + /// caller DID, Removed DID, New add DID. + MembersSwapped(IdentityId, IdentityId, IdentityId), + /// The membership was reset; see the transaction for who the new set is. + /// caller DID, List of new members. + MembersReset(IdentityId, Vec), + /// The limit of how many active members there can be concurrently was changed. + ActiveLimitChanged(IdentityId, MemberCount, MemberCount), + /// Phantom member, never used. + Dummy(sp_std::marker::PhantomData<(AccountId, RuntimeEvent)>), + } +); + decl_storage! { trait Store for Module, I: Instance=DefaultInstance> as Group { /// The current "active" membership, stored as an ordered Vec. From 9f8631be33fb45a5a6e89bfd8c8b12ab2f4d270e Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 03:16:39 +0800 Subject: [PATCH 25/45] Move WeightInfo, Config, Event into NFT pallet. --- pallets/common/src/lib.rs | 2 +- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/nft.rs | 48 -------------------------------- pallets/nft/src/lib.rs | 44 +++++++++++++++++++++++++++-- pallets/runtime/tests/src/nft.rs | 2 +- pallets/settlement/src/lib.rs | 4 +-- 6 files changed, 46 insertions(+), 55 deletions(-) delete mode 100644 pallets/common/src/traits/nft.rs diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 73cff826c7..6aeee41e4b 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -16,4 +16,4 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod traits; -pub use traits::{asset, balances, compliance_manager, nft, portfolio, CommonConfig}; +pub use traits::{asset, balances, compliance_manager, portfolio, CommonConfig}; diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 281f96496b..88c8ddc40f 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -26,7 +26,6 @@ pub mod asset; pub mod balances; pub mod checkpoint; pub mod compliance_manager; -pub mod nft; pub mod portfolio; pub mod settlement; pub mod statistics; diff --git a/pallets/common/src/traits/nft.rs b/pallets/common/src/traits/nft.rs deleted file mode 100644 index 5fd9de68d5..0000000000 --- a/pallets/common/src/traits/nft.rs +++ /dev/null @@ -1,48 +0,0 @@ -use frame_support::decl_event; -use frame_support::traits::Get; -use frame_support::weights::Weight; -use polymesh_primitives::asset::AssetId; -use polymesh_primitives::nft::{NFTCollectionId, NFTs}; -use polymesh_primitives::traits::ComplianceFnConfig; -use polymesh_primitives::{IdentityId, PortfolioId, PortfolioUpdateReason}; - -use crate::{asset, portfolio}; - -pub trait Config: - frame_system::Config + asset::Config + pallet_identity::Config + portfolio::Config -{ - type RuntimeEvent: From + Into<::RuntimeEvent>; - - type WeightInfo: WeightInfo; - - type Compliance: ComplianceFnConfig; - - type MaxNumberOfCollectionKeys: Get; - - type MaxNumberOfNFTsCount: Get; -} - -decl_event!( - pub enum Event { - /// Emitted when a new nft collection is created. - NftCollectionCreated(IdentityId, AssetId, NFTCollectionId), - /// Emitted when NFTs were issued, redeemed or transferred. - /// Contains the [`IdentityId`] of the receiver/issuer/redeemer, the [`NFTs`], the [`PortfolioId`] of the source, the [`PortfolioId`] - /// of the destination and the [`PortfolioUpdateReason`]. - NFTPortfolioUpdated( - IdentityId, - NFTs, - Option, - Option, - PortfolioUpdateReason, - ), - } -); - -pub trait WeightInfo { - fn create_nft_collection(n: u32) -> Weight; - fn issue_nft(n: u32) -> Weight; - fn redeem_nft(n: u32) -> Weight; - fn base_nft_transfer(n: u32) -> Weight; - fn controller_transfer(n: u32) -> Weight; -} diff --git a/pallets/nft/src/lib.rs b/pallets/nft/src/lib.rs index a82dbc2f17..23112c4e89 100644 --- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -7,7 +7,9 @@ use frame_support::dispatch::{ use frame_support::storage::StorageDoubleMap; use frame_support::traits::Get; use frame_support::weights::Weight; -use frame_support::{decl_error, decl_module, decl_storage, ensure, require_transactional}; +use frame_support::{ + decl_error, decl_event, decl_module, decl_storage, ensure, require_transactional, +}; use sp_std::collections::btree_map::BTreeMap; use sp_std::collections::btree_set::BTreeSet; use sp_std::{vec, vec::Vec}; @@ -15,7 +17,6 @@ use sp_std::{vec, vec::Vec}; use pallet_asset::Frozen; use pallet_base::try_next_pre; use pallet_portfolio::{PortfolioLockedNFT, PortfolioNFT}; -pub use polymesh_common_utilities::traits::nft::{Config, Event, WeightInfo}; use polymesh_primitives::asset::{AssetId, AssetName, AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{AssetMetadataKey, AssetMetadataValue}; use polymesh_primitives::nft::{ @@ -38,6 +39,45 @@ pub mod benchmarking; storage_migration_ver!(4); +pub trait WeightInfo { + fn create_nft_collection(n: u32) -> Weight; + fn issue_nft(n: u32) -> Weight; + fn redeem_nft(n: u32) -> Weight; + fn base_nft_transfer(n: u32) -> Weight; + fn controller_transfer(n: u32) -> Weight; +} + +pub trait Config: + frame_system::Config + pallet_asset::Config + pallet_identity::Config + pallet_portfolio::Config +{ + type RuntimeEvent: From + Into<::RuntimeEvent>; + + type WeightInfo: WeightInfo; + + type Compliance: ComplianceFnConfig; + + type MaxNumberOfCollectionKeys: Get; + + type MaxNumberOfNFTsCount: Get; +} + +decl_event!( + pub enum Event { + /// Emitted when a new nft collection is created. + NftCollectionCreated(IdentityId, AssetId, NFTCollectionId), + /// Emitted when NFTs were issued, redeemed or transferred. + /// Contains the [`IdentityId`] of the receiver/issuer/redeemer, the [`NFTs`], the [`PortfolioId`] of the source, the [`PortfolioId`] + /// of the destination and the [`PortfolioUpdateReason`]. + NFTPortfolioUpdated( + IdentityId, + NFTs, + Option, + Option, + PortfolioUpdateReason, + ), + } +); + decl_storage!( trait Store for Module as NFT { /// The total number of NFTs per identity. diff --git a/pallets/runtime/tests/src/nft.rs b/pallets/runtime/tests/src/nft.rs index 5e8afb9cb5..32142908f4 100644 --- a/pallets/runtime/tests/src/nft.rs +++ b/pallets/runtime/tests/src/nft.rs @@ -2,12 +2,12 @@ use chrono::prelude::Utc; use frame_support::storage::StorageValue; use frame_support::{assert_noop, assert_ok, StorageDoubleMap, StorageMap}; +use pallet_nft::Event; use pallet_nft::{ Collection, CollectionKeys, CurrentCollectionId, CurrentNFTId, MetadataValue, NFTOwner, NFTsInCollection, NumberOfNFTs, }; use pallet_portfolio::PortfolioNFT; -use polymesh_common_utilities::traits::nft::Event; use polymesh_primitives::asset::{AssetId, AssetName, AssetType, NonFungibleType}; use polymesh_primitives::asset_metadata::{ AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataName, AssetMetadataSpec, diff --git a/pallets/settlement/src/lib.rs b/pallets/settlement/src/lib.rs index 900fecaf06..ae378a22c9 100644 --- a/pallets/settlement/src/lib.rs +++ b/pallets/settlement/src/lib.rs @@ -70,7 +70,7 @@ use sp_std::vec; use pallet_asset::MandatoryMediators; use pallet_base::{ensure_string_limited, try_next_post}; pub use polymesh_common_utilities::traits::settlement::{Event, RawEvent, WeightInfo}; -use polymesh_common_utilities::traits::{asset, compliance_manager, nft, CommonConfig}; +use polymesh_common_utilities::traits::{asset, compliance_manager, CommonConfig}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::queue_priority::SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY; use polymesh_primitives::settlement::{ @@ -106,7 +106,7 @@ pub trait Config: + compliance_manager::Config + frame_system::Config + pallet_identity::Config - + nft::Config + + pallet_nft::Config + pallet_timestamp::Config { /// The overarching event type. From cdee3c62532a6ff337feaedb8598ccca17975513 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 03:29:33 +0800 Subject: [PATCH 26/45] Move WeightInfo, Config, Event into Portfolio pallet. --- Cargo.lock | 3 +- pallets/common/Cargo.toml | 3 + pallets/common/src/lib.rs | 2 +- pallets/common/src/traits/asset.rs | 4 +- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/portfolio.rs | 168 ------------------------- pallets/portfolio/Cargo.toml | 6 +- pallets/portfolio/src/benchmarking.rs | 3 - pallets/portfolio/src/lib.rs | 150 +++++++++++++++++++++- pallets/sto/src/lib.rs | 3 +- 10 files changed, 155 insertions(+), 188 deletions(-) delete mode 100644 pallets/common/src/traits/portfolio.rs diff --git a/Cargo.lock b/Cargo.lock index c9654b5f23..a8c5b9d715 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5343,12 +5343,10 @@ dependencies = [ "frame-support", "frame-system", "log", - "pallet-balances 0.1.0", "pallet-base", "pallet-identity", "pallet-permissions", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -6267,6 +6265,7 @@ dependencies = [ "pallet-external-agents", "pallet-identity", "pallet-permissions", + "pallet-portfolio", "pallet-timestamp", "parity-scale-codec 3.6.9", "polymesh-primitives", diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index 102f8c6eea..9a71065dbc 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -13,6 +13,7 @@ pallet-base = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-external-agents = { workspace = true, default-features = false } +pallet-portfolio = { workspace = true, default-features = false } # Other serde = { version = "1.0.112", default-features = false } @@ -60,6 +61,7 @@ std = [ "pallet-permissions/std", "pallet-identity/std", "pallet-external-agents/std", + "pallet-portfolio/std", "polymesh-primitives/std", "serde/std", "serde_derive", @@ -75,5 +77,6 @@ runtime-benchmarks = [ "pallet-permissions/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-external-agents/runtime-benchmarks", + "pallet-portfolio/runtime-benchmarks", "schnorrkel", ] diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 6aeee41e4b..c8ac068686 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -16,4 +16,4 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod traits; -pub use traits::{asset, balances, compliance_manager, portfolio, CommonConfig}; +pub use traits::{asset, balances, compliance_manager, CommonConfig}; diff --git a/pallets/common/src/traits/asset.rs b/pallets/common/src/traits/asset.rs index 7e8a038d34..9dd27be7bf 100644 --- a/pallets/common/src/traits/asset.rs +++ b/pallets/common/src/traits/asset.rs @@ -33,11 +33,11 @@ use polymesh_primitives::{ Ticker, }; -use crate::traits::{checkpoint, portfolio, statistics}; +use crate::traits::{checkpoint, statistics}; /// The module's configuration trait. pub trait Config: - crate::balances::Config + EAConfig + statistics::Config + portfolio::Config + AssetFnConfig + crate::balances::Config + EAConfig + statistics::Config + pallet_portfolio::Config + AssetFnConfig { /// The overarching event type. type RuntimeEvent: From> diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 88c8ddc40f..7d01590f2e 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -26,6 +26,5 @@ pub mod asset; pub mod balances; pub mod checkpoint; pub mod compliance_manager; -pub mod portfolio; pub mod settlement; pub mod statistics; diff --git a/pallets/common/src/traits/portfolio.rs b/pallets/common/src/traits/portfolio.rs deleted file mode 100644 index 8dcd32e6c6..0000000000 --- a/pallets/common/src/traits/portfolio.rs +++ /dev/null @@ -1,168 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! # Trait Interface to the Portfolio Module -//! -//! The interface allows to accept portfolio custody - -use frame_support::decl_event; -use frame_support::pallet_prelude::Get; -use frame_support::weights::Weight; -use polymesh_primitives::asset::AssetId; -use polymesh_primitives::traits::{AssetFnConfig, NFTTrait}; -use polymesh_primitives::{ - Fund, FundDescription, IdentityId, Memo, PortfolioId, PortfolioName, PortfolioNumber, -}; -use sp_std::vec::Vec; - -pub trait WeightInfo { - fn create_portfolio(l: u32) -> Weight; - fn delete_portfolio() -> Weight; - fn rename_portfolio(i: u32) -> Weight; - fn quit_portfolio_custody() -> Weight; - fn accept_portfolio_custody() -> Weight; - fn pre_approve_portfolio() -> Weight; - fn remove_portfolio_pre_approval() -> Weight; - fn move_portfolio(funds: &[Fund]) -> Weight { - let (f, n) = count_token_moves(funds); - Self::move_portfolio_funds(f, n) - } - fn move_portfolio_funds(f: u32, u: u32) -> Weight; - fn allow_identity_to_create_portfolios() -> Weight; - fn revoke_create_portfolios_permission() -> Weight; - fn create_custody_portfolio() -> Weight; -} - -pub trait Config: - frame_system::Config + pallet_permissions::Config + pallet_identity::Config + AssetFnConfig -{ - type RuntimeEvent: From + Into<::RuntimeEvent>; - type WeightInfo: WeightInfo; - /// Maximum number of fungible assets that can be moved in a single transfer call. - type MaxNumberOfFungibleMoves: Get; - /// Maximum number of NFTs that can be moved in a single transfer call. - type MaxNumberOfNFTsMoves: Get; - /// NFT module - required for updating the ownership of an NFT. - type NFT: NFTTrait; -} - -decl_event! { - pub enum Event { - /// The portfolio has been successfully created. - /// - /// # Parameters - /// * origin DID - /// * portfolio number - /// * portfolio name - PortfolioCreated(IdentityId, PortfolioNumber, PortfolioName), - /// The portfolio has been successfully removed. - /// - /// # Parameters - /// * origin DID - /// * portfolio number - PortfolioDeleted(IdentityId, PortfolioNumber), - /// The portfolio identified with `num` has been renamed to `name`. - /// - /// # Parameters - /// * origin DID - /// * portfolio number - /// * portfolio name - PortfolioRenamed(IdentityId, PortfolioNumber, PortfolioName), - /// All non-default portfolio numbers and names of a DID. - /// - /// # Parameters - /// * origin DID - /// * vector of number-name pairs - UserPortfolios(IdentityId, Vec<(PortfolioNumber, PortfolioName)>), - /// Custody of a portfolio has been given to a different identity - /// - /// # Parameters - /// * origin DID - /// * portfolio id - /// * portfolio custodian did - PortfolioCustodianChanged(IdentityId, PortfolioId, IdentityId), - /// Funds have moved between portfolios - /// - /// # Parameters - /// * Origin DID. - /// * Source portfolio. - /// * Destination portfolio. - /// * The type of fund that was moved. - /// * Optional memo for the move. - FundsMovedBetweenPortfolios( - IdentityId, - PortfolioId, - PortfolioId, - FundDescription, - Option - ), - /// A portfolio has pre approved the receivement of an asset. - /// - /// # Parameters - /// * [`IdentityId`] of the caller. - /// * [`PortfolioId`] that will receive assets without explicit affirmation. - /// * [`AssetId`] of the asset that has been exempt from explicit affirmation. - PreApprovedPortfolio( - IdentityId, - PortfolioId, - AssetId - ), - /// A portfolio has removed the approval of an asset. - /// - /// # Parameters - /// * [`IdentityId`] of the caller. - /// * [`PortfolioId`] that had its pre approval revoked. - /// * [`AssetId`] of the asset that had its pre approval revoked. - RevokePreApprovedPortfolio( - IdentityId, - PortfolioId, - AssetId - ), - /// Allow another identity to create portfolios. - /// - /// # Parameters - /// * [`IdentityId`] of the caller. - /// * [`IdentityId`] allowed to create portfolios. - AllowIdentityToCreatePortfolios( - IdentityId, - IdentityId, - ), - /// Revoke another identities permission to create portfolios. - /// - /// # Parameters - /// * [`IdentityId`] of the caller. - /// * [`IdentityId`] permissions to create portfolios is revoked. - RevokeCreatePortfoliosPermission( - IdentityId, - IdentityId, - ), - } -} - -fn count_token_moves(funds: &[Fund]) -> (u32, u32) { - let mut fungible_moves = 0; - let mut nfts_moves = 0; - for fund in funds { - match &fund.description { - FundDescription::Fungible { .. } => { - fungible_moves += 1; - } - FundDescription::NonFungible(nfts) => { - nfts_moves += nfts.len(); - } - } - } - (fungible_moves, nfts_moves as u32) -} diff --git a/pallets/portfolio/Cargo.toml b/pallets/portfolio/Cargo.toml index 9a6125ef36..67762547d3 100644 --- a/pallets/portfolio/Cargo.toml +++ b/pallets/portfolio/Cargo.toml @@ -6,11 +6,9 @@ edition = "2021" [dependencies] # Common -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } # Our Pallets -pallet-balances = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } @@ -41,14 +39,14 @@ std = [ "frame-support/std", "frame-system/std", "pallet-base/std", - "pallet-balances/std", "pallet-identity/std", "pallet-permissions/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "serde/std", "sp-std/std", ] runtime-benchmarks = [ "frame-benchmarking", + "pallet-identity/runtime-benchmarks", + "pallet-permissions/runtime-benchmarks", ] diff --git a/pallets/portfolio/src/benchmarking.rs b/pallets/portfolio/src/benchmarking.rs index 5d2cc9e8ca..18511f691c 100644 --- a/pallets/portfolio/src/benchmarking.rs +++ b/pallets/portfolio/src/benchmarking.rs @@ -20,7 +20,6 @@ use sp_api_hidden_includes_decl_storage::hidden_include::traits::Get; use sp_std::prelude::*; use pallet_identity::benchmarking::{user, User, UserBuilder}; -use polymesh_common_utilities::asset::Config as AssetConfig; use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::{AuthorizationData, NFTs, PortfolioName, Signatory}; @@ -62,8 +61,6 @@ fn assert_custodian(pid: PortfolioId, custodian: &User, holds: boo } benchmarks! { - where_clause { where T: AssetConfig } - create_portfolio { let l in 1..PORTFOLIO_NAME_LEN.try_into().unwrap(); diff --git a/pallets/portfolio/src/lib.rs b/pallets/portfolio/src/lib.rs index df57d62194..b5485f50fc 100644 --- a/pallets/portfolio/src/lib.rs +++ b/pallets/portfolio/src/lib.rs @@ -48,26 +48,166 @@ pub mod benchmarking; use codec::{Decode, Encode}; use core::{iter, mem}; use frame_support::dispatch::{DispatchError, DispatchResult}; +use frame_support::pallet_prelude::Get; use frame_support::weights::Weight; -use frame_support::{decl_error, decl_module, decl_storage, ensure}; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure}; use sp_arithmetic::traits::Zero; use sp_std::collections::btree_set::BTreeSet; use sp_std::prelude::*; use pallet_identity::PermissionedCallOriginData; -pub use polymesh_common_utilities::portfolio::{Config, Event, WeightInfo}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ extract_auth, identity_id::PortfolioValidityResult, storage_migration_ver, - traits::{AssetFnTrait, NFTTrait, PortfolioSubTrait}, - Balance, Fund, FundDescription, IdentityId, NFTId, PortfolioId, PortfolioKind, PortfolioName, - PortfolioNumber, SecondaryKey, + traits::{AssetFnConfig, AssetFnTrait, NFTTrait, PortfolioSubTrait}, + Balance, Fund, FundDescription, IdentityId, Memo, NFTId, PortfolioId, PortfolioKind, + PortfolioName, PortfolioNumber, SecondaryKey, }; type Identity = pallet_identity::Module; +fn count_token_moves(funds: &[Fund]) -> (u32, u32) { + let mut fungible_moves = 0; + let mut nfts_moves = 0; + for fund in funds { + match &fund.description { + FundDescription::Fungible { .. } => { + fungible_moves += 1; + } + FundDescription::NonFungible(nfts) => { + nfts_moves += nfts.len(); + } + } + } + (fungible_moves, nfts_moves as u32) +} + +pub trait WeightInfo { + fn create_portfolio(l: u32) -> Weight; + fn delete_portfolio() -> Weight; + fn rename_portfolio(i: u32) -> Weight; + fn quit_portfolio_custody() -> Weight; + fn accept_portfolio_custody() -> Weight; + fn pre_approve_portfolio() -> Weight; + fn remove_portfolio_pre_approval() -> Weight; + fn move_portfolio(funds: &[Fund]) -> Weight { + let (f, n) = count_token_moves(funds); + Self::move_portfolio_funds(f, n) + } + fn move_portfolio_funds(f: u32, u: u32) -> Weight; + fn allow_identity_to_create_portfolios() -> Weight; + fn revoke_create_portfolios_permission() -> Weight; + fn create_custody_portfolio() -> Weight; +} + +pub trait Config: + frame_system::Config + pallet_permissions::Config + pallet_identity::Config + AssetFnConfig +{ + type RuntimeEvent: From + Into<::RuntimeEvent>; + type WeightInfo: WeightInfo; + /// Maximum number of fungible assets that can be moved in a single transfer call. + type MaxNumberOfFungibleMoves: Get; + /// Maximum number of NFTs that can be moved in a single transfer call. + type MaxNumberOfNFTsMoves: Get; + /// NFT module - required for updating the ownership of an NFT. + type NFT: NFTTrait; +} + +decl_event! { + pub enum Event { + /// The portfolio has been successfully created. + /// + /// # Parameters + /// * origin DID + /// * portfolio number + /// * portfolio name + PortfolioCreated(IdentityId, PortfolioNumber, PortfolioName), + /// The portfolio has been successfully removed. + /// + /// # Parameters + /// * origin DID + /// * portfolio number + PortfolioDeleted(IdentityId, PortfolioNumber), + /// The portfolio identified with `num` has been renamed to `name`. + /// + /// # Parameters + /// * origin DID + /// * portfolio number + /// * portfolio name + PortfolioRenamed(IdentityId, PortfolioNumber, PortfolioName), + /// All non-default portfolio numbers and names of a DID. + /// + /// # Parameters + /// * origin DID + /// * vector of number-name pairs + UserPortfolios(IdentityId, Vec<(PortfolioNumber, PortfolioName)>), + /// Custody of a portfolio has been given to a different identity + /// + /// # Parameters + /// * origin DID + /// * portfolio id + /// * portfolio custodian did + PortfolioCustodianChanged(IdentityId, PortfolioId, IdentityId), + /// Funds have moved between portfolios + /// + /// # Parameters + /// * Origin DID. + /// * Source portfolio. + /// * Destination portfolio. + /// * The type of fund that was moved. + /// * Optional memo for the move. + FundsMovedBetweenPortfolios( + IdentityId, + PortfolioId, + PortfolioId, + FundDescription, + Option + ), + /// A portfolio has pre approved the receivement of an asset. + /// + /// # Parameters + /// * [`IdentityId`] of the caller. + /// * [`PortfolioId`] that will receive assets without explicit affirmation. + /// * [`AssetId`] of the asset that has been exempt from explicit affirmation. + PreApprovedPortfolio( + IdentityId, + PortfolioId, + AssetId + ), + /// A portfolio has removed the approval of an asset. + /// + /// # Parameters + /// * [`IdentityId`] of the caller. + /// * [`PortfolioId`] that had its pre approval revoked. + /// * [`AssetId`] of the asset that had its pre approval revoked. + RevokePreApprovedPortfolio( + IdentityId, + PortfolioId, + AssetId + ), + /// Allow another identity to create portfolios. + /// + /// # Parameters + /// * [`IdentityId`] of the caller. + /// * [`IdentityId`] allowed to create portfolios. + AllowIdentityToCreatePortfolios( + IdentityId, + IdentityId, + ), + /// Revoke another identities permission to create portfolios. + /// + /// # Parameters + /// * [`IdentityId`] of the caller. + /// * [`IdentityId`] permissions to create portfolios is revoked. + RevokeCreatePortfoliosPermission( + IdentityId, + IdentityId, + ), + } +} + decl_storage! { trait Store for Module as Portfolio { /// The next portfolio sequence number of an identity. diff --git a/pallets/sto/src/lib.rs b/pallets/sto/src/lib.rs index dd00ceff62..f93e0034f4 100644 --- a/pallets/sto/src/lib.rs +++ b/pallets/sto/src/lib.rs @@ -38,7 +38,6 @@ use sp_std::prelude::*; use pallet_base::try_next_post; use pallet_identity::PermissionedCallOriginData; use pallet_settlement::VenueInfo; -use polymesh_common_utilities::traits::portfolio; use polymesh_primitives::asset::AssetId; use polymesh_primitives::impl_checked_inc; use polymesh_primitives::settlement::{Leg, ReceiptDetails, SettlementType, VenueId, VenueType}; @@ -170,7 +169,7 @@ pub trait Config: frame_system::Config + pallet_identity::Config + pallet_settlement::Config - + portfolio::Config + + pallet_portfolio::Config + pallet_base::Config { /// The overarching event type. From 23bc0d201dd603f5b9485533920ba34b2137c50b Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 03:40:12 +0800 Subject: [PATCH 27/45] Move WeightInfo, Config, Event into Statistics pallet. --- Cargo.lock | 2 +- pallets/common/Cargo.toml | 3 + pallets/common/src/traits/asset.rs | 8 ++- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/statistics.rs | 77 ------------------------- pallets/statistics/Cargo.toml | 6 +- pallets/statistics/src/benchmarking.rs | 9 +-- pallets/statistics/src/lib.rs | 71 ++++++++++++++++++++++- 8 files changed, 85 insertions(+), 92 deletions(-) delete mode 100644 pallets/common/src/traits/statistics.rs diff --git a/Cargo.lock b/Cargo.lock index a8c5b9d715..9383857c73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5592,7 +5592,6 @@ dependencies = [ "pallet-identity", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -6266,6 +6265,7 @@ dependencies = [ "pallet-identity", "pallet-permissions", "pallet-portfolio", + "pallet-statistics", "pallet-timestamp", "parity-scale-codec 3.6.9", "polymesh-primitives", diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index 9a71065dbc..4e4f52adaf 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -14,6 +14,7 @@ pallet-permissions = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-external-agents = { workspace = true, default-features = false } pallet-portfolio = { workspace = true, default-features = false } +pallet-statistics = { workspace = true, default-features = false } # Other serde = { version = "1.0.112", default-features = false } @@ -62,6 +63,7 @@ std = [ "pallet-identity/std", "pallet-external-agents/std", "pallet-portfolio/std", + "pallet-statistics/std", "polymesh-primitives/std", "serde/std", "serde_derive", @@ -78,5 +80,6 @@ runtime-benchmarks = [ "pallet-identity/runtime-benchmarks", "pallet-external-agents/runtime-benchmarks", "pallet-portfolio/runtime-benchmarks", + "pallet-statistics/runtime-benchmarks", "schnorrkel", ] diff --git a/pallets/common/src/traits/asset.rs b/pallets/common/src/traits/asset.rs index 9dd27be7bf..25efe51d36 100644 --- a/pallets/common/src/traits/asset.rs +++ b/pallets/common/src/traits/asset.rs @@ -33,11 +33,15 @@ use polymesh_primitives::{ Ticker, }; -use crate::traits::{checkpoint, statistics}; +use crate::traits::checkpoint; /// The module's configuration trait. pub trait Config: - crate::balances::Config + EAConfig + statistics::Config + pallet_portfolio::Config + AssetFnConfig + crate::balances::Config + + EAConfig + + pallet_statistics::Config + + pallet_portfolio::Config + + AssetFnConfig { /// The overarching event type. type RuntimeEvent: From> diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 7d01590f2e..67963fe030 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -27,4 +27,3 @@ pub mod balances; pub mod checkpoint; pub mod compliance_manager; pub mod settlement; -pub mod statistics; diff --git a/pallets/common/src/traits/statistics.rs b/pallets/common/src/traits/statistics.rs deleted file mode 100644 index f64a80b2fe..0000000000 --- a/pallets/common/src/traits/statistics.rs +++ /dev/null @@ -1,77 +0,0 @@ -use frame_support::decl_event; -use frame_support::traits::Get; -use frame_support::weights::Weight; -use pallet_external_agents::Config as EAConfig; -use polymesh_primitives::asset::AssetId; -use polymesh_primitives::traits::AssetFnConfig; -use polymesh_primitives::{ - statistics::{StatType, StatUpdate}, - transfer_compliance::{TransferCondition, TransferConditionExemptKey}, - IdentityId, -}; -use sp_std::vec::Vec; - -/// The main trait for statistics module -pub trait Config: - frame_system::Config + pallet_identity::Config + EAConfig + AssetFnConfig -{ - /// The overarching event type. - type RuntimeEvent: From + Into<::RuntimeEvent>; - /// Maximum stats that can be enabled for an Asset. - type MaxStatsPerAsset: Get; - /// Maximum transfer conditions that can be enabled for an Asset. - type MaxTransferConditionsPerAsset: Get; - /// Weights for extrinsics. - type WeightInfo: WeightInfo; -} - -/// Weight info for extrinsics -pub trait WeightInfo { - fn set_active_asset_stats(i: u32) -> Weight; - fn batch_update_asset_stats(i: u32) -> Weight; - fn set_asset_transfer_compliance(i: u32) -> Weight; - fn set_entities_exempt(i: u32) -> Weight; - fn max_investor_count_restriction(a: u32) -> Weight; - fn max_investor_ownership_restriction() -> Weight; - fn claim_count_restriction_no_stats(c: u32) -> Weight; - fn claim_count_restriction_with_stats() -> Weight; - fn claim_ownership_restriction(a: u32) -> Weight; - fn update_asset_count_stats(a: u32) -> Weight; - fn update_asset_balance_stats(a: u32) -> Weight; - fn active_asset_statistics_load(_a: u32) -> Weight; - fn is_exempt() -> Weight; - fn verify_requirements(i: u32) -> Weight; - fn verify_requirements_loop(i: u32) -> Weight { - Self::verify_requirements(i) - .saturating_sub(Self::max_investor_count_restriction(0).saturating_mul(i.into())) - } -} - -decl_event!( - pub enum Event { - /// Stat types added to asset. - /// - /// (Caller DID, AssetId, Stat types) - StatTypesAdded(IdentityId, AssetId, Vec), - /// Stat types removed from asset. - /// - /// (Caller DID, AssetId, Stat types) - StatTypesRemoved(IdentityId, AssetId, Vec), - /// Asset stats updated. - /// - /// (Caller DID, AssetId, Stat type, Updates) - AssetStatsUpdated(IdentityId, AssetId, StatType, Vec), - /// Set Transfer compliance rules for asset. - /// - /// (Caller DID, AssetId, Transfer conditions) - SetAssetTransferCompliance(IdentityId, AssetId, Vec), - /// Add `IdentityId`s exempt for transfer conditions matching exempt key. - /// - /// (Caller DID, Exempt key, Entities) - TransferConditionExemptionsAdded(IdentityId, TransferConditionExemptKey, Vec), - /// Remove `IdentityId`s exempt for transfer conditions matching exempt key. - /// - /// (Caller DID, Exempt key, Entities) - TransferConditionExemptionsRemoved(IdentityId, TransferConditionExemptKey, Vec), - } -); diff --git a/pallets/statistics/Cargo.toml b/pallets/statistics/Cargo.toml index 498937c19a..5c0edd1286 100644 --- a/pallets/statistics/Cargo.toml +++ b/pallets/statistics/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] polymesh-primitives = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } pallet-external-agents = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } @@ -55,8 +54,11 @@ std = [ "frame-system/std", "pallet-timestamp/std", "polymesh-primitives/std", + "pallet-identity/std", "pallet-external-agents/std", ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking", + "pallet-identity/runtime-benchmarks", + "pallet-external-agents/runtime-benchmarks", ] diff --git a/pallets/statistics/src/benchmarking.rs b/pallets/statistics/src/benchmarking.rs index 03cc1f3f7e..c6c653acb8 100644 --- a/pallets/statistics/src/benchmarking.rs +++ b/pallets/statistics/src/benchmarking.rs @@ -4,7 +4,6 @@ use sp_std::collections::btree_set::BTreeSet; use sp_std::prelude::*; use pallet_identity::benchmarking::{User, UserBuilder}; -use polymesh_common_utilities::traits::asset::Config as Asset; use polymesh_primitives::bench::create_and_issue_sample_asset; use polymesh_primitives::constants::currency::{ONE_UNIT, POLY}; use polymesh_primitives::{jurisdiction::*, statistics::*, Claim, ClaimType, Scope}; @@ -81,14 +80,14 @@ fn make_transfer_conditions(stats: &BTreeSet, count: u32) -> BTreeSet< .collect() } -fn init_asset() -> (User, AssetId) { +fn init_asset() -> (User, AssetId) { let owner = UserBuilder::::default().generate_did().build("OWNER"); let asset_id = create_and_issue_sample_asset::(owner.account(), true, None, b"MyAsset", true); (owner, asset_id) } -fn init_transfer_conditions( +fn init_transfer_conditions( count_stats: u32, count_conditions: u32, ) -> ( @@ -103,7 +102,7 @@ fn init_transfer_conditions( (owner, asset_id, stats, conditions) } -fn init_exempts( +fn init_exempts( count: u32, ) -> (User, TransferConditionExemptKey, BTreeSet) { let (owner, asset_id) = init_asset::(); @@ -198,8 +197,6 @@ mod limits { } benchmarks! { - where_clause { where T: Asset } - set_active_asset_stats { let i in 1..T::MaxStatsPerAsset::get().saturating_sub(1); diff --git a/pallets/statistics/src/lib.rs b/pallets/statistics/src/lib.rs index f12f935f06..b1293728de 100644 --- a/pallets/statistics/src/lib.rs +++ b/pallets/statistics/src/lib.rs @@ -22,15 +22,15 @@ use codec::{Decode, Encode}; use frame_support::dispatch::{DispatchError, DispatchResult}; use frame_support::traits::Get; use frame_support::weights::Weight; -use frame_support::{decl_error, decl_module, decl_storage, ensure, BoundedBTreeSet}; +use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, BoundedBTreeSet}; use sp_std::{collections::btree_set::BTreeSet, vec, vec::Vec}; -pub use polymesh_common_utilities::traits::statistics::{Config, Event, WeightInfo}; +use pallet_external_agents::Config as EAConfig; use polymesh_primitives::asset::AssetId; use polymesh_primitives::statistics::{ Percentage, Stat1stKey, Stat2ndKey, StatOpType, StatType, StatUpdate, }; -use polymesh_primitives::traits::AssetFnTrait; +use polymesh_primitives::traits::{AssetFnConfig, AssetFnTrait}; use polymesh_primitives::transfer_compliance::{ AssetTransferCompliance, TransferCondition, TransferConditionExemptKey, }; @@ -41,6 +41,71 @@ type ExternalAgents = pallet_external_agents::Module; storage_migration_ver!(3); +/// The main trait for statistics module +pub trait Config: + frame_system::Config + pallet_identity::Config + EAConfig + AssetFnConfig +{ + /// The overarching event type. + type RuntimeEvent: From + Into<::RuntimeEvent>; + /// Maximum stats that can be enabled for an Asset. + type MaxStatsPerAsset: Get; + /// Maximum transfer conditions that can be enabled for an Asset. + type MaxTransferConditionsPerAsset: Get; + /// Weights for extrinsics. + type WeightInfo: WeightInfo; +} + +/// Weight info for extrinsics +pub trait WeightInfo { + fn set_active_asset_stats(i: u32) -> Weight; + fn batch_update_asset_stats(i: u32) -> Weight; + fn set_asset_transfer_compliance(i: u32) -> Weight; + fn set_entities_exempt(i: u32) -> Weight; + fn max_investor_count_restriction(a: u32) -> Weight; + fn max_investor_ownership_restriction() -> Weight; + fn claim_count_restriction_no_stats(c: u32) -> Weight; + fn claim_count_restriction_with_stats() -> Weight; + fn claim_ownership_restriction(a: u32) -> Weight; + fn update_asset_count_stats(a: u32) -> Weight; + fn update_asset_balance_stats(a: u32) -> Weight; + fn active_asset_statistics_load(_a: u32) -> Weight; + fn is_exempt() -> Weight; + fn verify_requirements(i: u32) -> Weight; + fn verify_requirements_loop(i: u32) -> Weight { + Self::verify_requirements(i) + .saturating_sub(Self::max_investor_count_restriction(0).saturating_mul(i.into())) + } +} + +decl_event!( + pub enum Event { + /// Stat types added to asset. + /// + /// (Caller DID, AssetId, Stat types) + StatTypesAdded(IdentityId, AssetId, Vec), + /// Stat types removed from asset. + /// + /// (Caller DID, AssetId, Stat types) + StatTypesRemoved(IdentityId, AssetId, Vec), + /// Asset stats updated. + /// + /// (Caller DID, AssetId, Stat type, Updates) + AssetStatsUpdated(IdentityId, AssetId, StatType, Vec), + /// Set Transfer compliance rules for asset. + /// + /// (Caller DID, AssetId, Transfer conditions) + SetAssetTransferCompliance(IdentityId, AssetId, Vec), + /// Add `IdentityId`s exempt for transfer conditions matching exempt key. + /// + /// (Caller DID, Exempt key, Entities) + TransferConditionExemptionsAdded(IdentityId, TransferConditionExemptKey, Vec), + /// Remove `IdentityId`s exempt for transfer conditions matching exempt key. + /// + /// (Caller DID, Exempt key, Entities) + TransferConditionExemptionsRemoved(IdentityId, TransferConditionExemptKey, Vec), + } +); + decl_storage! { trait Store for Module as Statistics { /// Maps a set of [`StatType`] for each [`AssetId`]. From 878738e9a8fb1ab6cebcca8d047d9356186e459a Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 03:50:32 +0800 Subject: [PATCH 28/45] Move WeightInfo, Event into Settlement pallet. --- Cargo.lock | 3 +- pallets/common/src/traits/mod.rs | 1 - pallets/common/src/traits/settlement.rs | 311 ----------------------- pallets/settlement/Cargo.toml | 6 +- pallets/settlement/src/lib.rs | 312 +++++++++++++++++++++++- 5 files changed, 309 insertions(+), 324 deletions(-) delete mode 100644 pallets/common/src/traits/settlement.rs diff --git a/Cargo.lock b/Cargo.lock index 9383857c73..961c14b04e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5485,14 +5485,13 @@ dependencies = [ "hex-literal 0.2.2", "log", "pallet-asset", - "pallet-balances 0.1.0", "pallet-base", "pallet-compliance-manager", "pallet-external-agents", "pallet-identity", "pallet-nft", + "pallet-permissions", "pallet-scheduler", - "pallet-statistics", "pallet-timestamp", "parity-scale-codec 3.6.9", "polymesh-common-utilities", diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 67963fe030..75dfd6c6f7 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -26,4 +26,3 @@ pub mod asset; pub mod balances; pub mod checkpoint; pub mod compliance_manager; -pub mod settlement; diff --git a/pallets/common/src/traits/settlement.rs b/pallets/common/src/traits/settlement.rs deleted file mode 100644 index 0ab96ed4f3..0000000000 --- a/pallets/common/src/traits/settlement.rs +++ /dev/null @@ -1,311 +0,0 @@ -use frame_support::decl_event; -use frame_support::dispatch::DispatchError; -use frame_support::weights::Weight; -use sp_std::collections::btree_set::BTreeSet; -use sp_std::vec::Vec; - -use polymesh_primitives::asset::AssetId; -use polymesh_primitives::settlement::{ - AffirmationCount, AssetCount, InstructionId, Leg, LegId, ReceiptMetadata, SettlementType, - VenueDetails, VenueId, VenueType, -}; -use polymesh_primitives::{IdentityId, Memo, PortfolioId}; - -decl_event!( - pub enum Event - where - Moment = ::Moment, - BlockNumber = ::BlockNumber, - AccountId = ::AccountId, - { - /// A new venue has been created (did, venue_id, details, type) - VenueCreated(IdentityId, VenueId, VenueDetails, VenueType), - /// An existing venue's details has been updated (did, venue_id, details) - VenueDetailsUpdated(IdentityId, VenueId, VenueDetails), - /// An existing venue's type has been updated (did, venue_id, type) - VenueTypeUpdated(IdentityId, VenueId, VenueType), - /// An instruction has been affirmed (did, portfolio, instruction_id) - InstructionAffirmed(IdentityId, PortfolioId, InstructionId), - /// An affirmation has been withdrawn (did, portfolio, instruction_id) - AffirmationWithdrawn(IdentityId, PortfolioId, InstructionId), - /// An instruction has been rejected (did, instruction_id) - InstructionRejected(IdentityId, InstructionId), - /// A receipt has been claimed (did, instruction_id, leg_id, receipt_uid, signer, receipt metadata) - ReceiptClaimed( - IdentityId, - InstructionId, - LegId, - u64, - AccountId, - Option, - ), - /// Venue filtering has been enabled or disabled for an asset (did, AssetId, filtering_enabled) - VenueFiltering(IdentityId, AssetId, bool), - /// Venues added to allow list (did, AssetId, vec) - VenuesAllowed(IdentityId, AssetId, Vec), - /// Venues added to block list (did, AssetId, vec) - VenuesBlocked(IdentityId, AssetId, Vec), - /// Execution of a leg failed (did, instruction_id, leg_id) - LegFailedExecution(IdentityId, InstructionId, LegId), - /// Instruction executed successfully(did, instruction_id) - InstructionExecuted(IdentityId, InstructionId), - /// Venue not part of the token's allow list (did, AssetId, venue_id) - VenueUnauthorized(IdentityId, AssetId, VenueId), - /// Scheduling of instruction fails. - SchedulingFailed(InstructionId, DispatchError), - /// Instruction is rescheduled. - /// (caller DID, instruction_id) - InstructionRescheduled(IdentityId, InstructionId), - /// An existing venue's signers has been updated (did, venue_id, signers, update_type) - VenueSignersUpdated(IdentityId, VenueId, Vec, bool), - /// Settlement manually executed (did, id) - SettlementManuallyExecuted(IdentityId, InstructionId), - /// A new instruction has been created - /// (did, venue_id, instruction_id, settlement_type, trade_date, value_date, legs, memo) - InstructionCreated( - IdentityId, - Option, - InstructionId, - SettlementType, - Option, - Option, - Vec, - Option, - ), - /// Failed to execute instruction. - FailedToExecuteInstruction(InstructionId, DispatchError), - /// An instruction has been automatically affirmed. - /// Parameters: [`IdentityId`] of the caller, [`PortfolioId`] of the receiver, and [`InstructionId`] of the instruction. - InstructionAutomaticallyAffirmed(IdentityId, PortfolioId, InstructionId), - /// An instruction has affirmed by a mediator. - /// Parameters: [`IdentityId`] of the mediator and [`InstructionId`] of the instruction. - MediatorAffirmationReceived(IdentityId, InstructionId, Option), - /// An instruction affirmation has been withdrawn by a mediator. - /// Parameters: [`IdentityId`] of the mediator and [`InstructionId`] of the instruction. - MediatorAffirmationWithdrawn(IdentityId, InstructionId), - /// An instruction with mediators has been created. - /// Parameters: [`InstructionId`] of the instruction and the [`IdentityId`] of all mediators. - InstructionMediators(InstructionId, BTreeSet), - } -); - -pub trait WeightInfo { - fn create_venue(d: u32, u: u32) -> Weight; - fn update_venue_details(d: u32) -> Weight; - fn update_venue_type() -> Weight; - fn update_venue_signers(u: u32) -> Weight; - fn affirm_with_receipts(f: u32, n: u32, o: u32) -> Weight; - fn set_venue_filtering() -> Weight; - fn allow_venues(u: u32) -> Weight; - fn disallow_venues(u: u32) -> Weight; - fn execute_manual_instruction(f: u32, n: u32, o: u32) -> Weight; - fn add_instruction(f: u32, n: u32, o: u32) -> Weight; - fn add_and_affirm_instruction(f: u32, n: u32, o: u32) -> Weight; - fn affirm_instruction(f: u32, n: u32) -> Weight; - fn withdraw_affirmation(f: u32, n: u32, o: u32) -> Weight; - fn reject_instruction(f: u32, n: u32, o: u32) -> Weight; - fn execute_instruction_paused(f: u32, n: u32, o: u32) -> Weight; - fn execute_scheduled_instruction(f: u32, n: u32, o: u32) -> Weight; - fn ensure_root_origin() -> Weight; - fn affirm_with_receipts_rcv(f: u32, n: u32, o: u32) -> Weight; - fn affirm_instruction_rcv(f: u32, n: u32) -> Weight; - fn withdraw_affirmation_rcv(f: u32, n: u32, o: u32) -> Weight; - fn add_instruction_with_mediators(f: u32, n: u32, o: u32, m: u32) -> Weight; - fn add_and_affirm_with_mediators(f: u32, n: u32, o: u32, m: u32) -> Weight; - fn affirm_instruction_as_mediator() -> Weight; - fn withdraw_affirmation_as_mediator() -> Weight; - fn reject_instruction_as_mediator(f: u32, n: u32, o: u32) -> Weight; - - fn add_and_affirm_with_mediators_legs( - legs: &[Leg], - portfolios: u32, - n_mediators: u32, - ) -> Weight { - let (f, n, o) = Self::get_transfer_by_asset(legs, portfolios); - Self::add_and_affirm_with_mediators(f, n, o, n_mediators) - } - fn add_instruction_with_mediators_legs(legs: &[Leg], n_mediators: u32) -> Weight { - let (f, n, o) = Self::get_transfer_by_asset(legs, 0); - Self::add_instruction_with_mediators(f, n, o, n_mediators) - } - fn add_instruction_legs(legs: &[Leg]) -> Weight { - let (f, n, o) = Self::get_transfer_by_asset(legs, 0); - Self::add_instruction(f, n, o) - } - fn add_and_affirm_instruction_legs(legs: &[Leg], portfolios: u32) -> Weight { - let (f, n, o) = Self::get_transfer_by_asset(legs, portfolios); - Self::add_and_affirm_instruction(f, n, o) - } - fn execute_manual_weight_limit( - weight_limit: &Option, - f: &u32, - n: &u32, - o: &u32, - ) -> Weight { - if let Some(weight_limit) = weight_limit { - return *weight_limit; - } - Self::execute_manual_instruction(*f, *n, *o) - } - fn get_transfer_by_asset(legs: &[Leg], portfolios: u32) -> (u32, u32, u32) { - let asset_count = - AssetCount::try_from_legs(legs).unwrap_or(AssetCount::new(1024, 1024, 1024)); - let f = asset_count.fungible(); - let n = asset_count.non_fungible(); - let max_portfolios = (f.saturating_add(n)).saturating_mul(2); // 2 portfolios per leg. (f+n = max legs). - if portfolios > max_portfolios { - // Too many portfolios, return worse-case count based on portfolio count. - return (portfolios, portfolios, 1024); - } - (f, n, asset_count.off_chain()) - } - fn affirm_with_receipts_input( - affirmation_count: Option, - portfolios: u32, - ) -> Weight { - match affirmation_count { - Some(affirmation_count) => { - let max_portfolios = affirmation_count.max_portfolios(); - if portfolios > max_portfolios { - // Too many portfolios, return worse-case weight based on portfolio count. - return Self::affirm_with_receipts(portfolios, portfolios, 10); - } - // The weight for the assets being sent - let sender_asset_count = affirmation_count.sender_asset_count(); - let sender_side_weight = Self::affirm_with_receipts( - sender_asset_count.fungible(), - sender_asset_count.non_fungible(), - affirmation_count.offchain_count(), - ); - // The weight for the assets being received - let receiver_asset_count = affirmation_count.receiver_asset_count(); - let receiver_side_weight = Self::affirm_with_receipts_rcv( - receiver_asset_count.fungible(), - receiver_asset_count.non_fungible(), - 0, - ); - // Common reads/writes are being added twice - let duplicated_weight = Self::affirm_with_receipts_rcv(0, 0, 0); - // The actual weight is the sum of the sender and receiver weights subtracted by the duplicated weight - sender_side_weight - .saturating_add(receiver_side_weight) - .saturating_sub(duplicated_weight) - } - None => { - if portfolios > (10 + 100) * 2 { - // Too many portfolios, return worse-case weight based on portfolio count. - Self::affirm_with_receipts(portfolios, portfolios, 10) - } else { - Self::affirm_with_receipts(10, 100, 10) - } - } - } - } - fn affirm_instruction_input( - affirmation_count: Option, - portfolios: u32, - ) -> Weight { - match affirmation_count { - Some(affirmation_count) => { - let max_portfolios = affirmation_count.max_portfolios(); - if portfolios > max_portfolios { - // Too many portfolios, return worse-case weight based on portfolio count. - return Self::affirm_instruction(portfolios, portfolios); - } - // The weight for the assets being sent - let sender_asset_count = affirmation_count.sender_asset_count(); - let sender_side_weight = Self::affirm_instruction( - sender_asset_count.fungible(), - sender_asset_count.non_fungible(), - ); - // The weight for the assets being received - let receiver_asset_count = affirmation_count.receiver_asset_count(); - let receiver_side_weight = Self::affirm_instruction_rcv( - receiver_asset_count.fungible(), - receiver_asset_count.non_fungible(), - ); - // Common reads/writes are being added twice - let duplicated_weight = Self::affirm_instruction_rcv(0, 0); - // The actual weight is the sum of the sender and receiver weights subtracted by the duplicated weight - sender_side_weight - .saturating_add(receiver_side_weight) - .saturating_sub(duplicated_weight) - } - None => { - if portfolios > (10 + 100) * 2 { - // Too many portfolios, return worse-case weight based on portfolio count. - Self::affirm_instruction(portfolios, portfolios) - } else { - Self::affirm_instruction(10, 100) - } - } - } - } - fn withdraw_affirmation_input( - affirmation_count: Option, - portfolios: u32, - ) -> Weight { - match affirmation_count { - Some(affirmation_count) => { - let max_portfolios = affirmation_count.max_portfolios(); - if portfolios > max_portfolios { - // Too many portfolios, return worse-case weight based on portfolio count. - return Self::withdraw_affirmation(portfolios, portfolios, 10); - } - // The weight for the assets being sent - let sender_asset_count = affirmation_count.sender_asset_count(); - let sender_side_weight = Self::withdraw_affirmation( - sender_asset_count.fungible(), - sender_asset_count.non_fungible(), - affirmation_count.offchain_count(), - ); - // The weight for the assets being received - let receiver_asset_count = affirmation_count.receiver_asset_count(); - let receiver_side_weight = Self::withdraw_affirmation_rcv( - receiver_asset_count.fungible(), - receiver_asset_count.non_fungible(), - 0, - ); - // Common reads/writes are being added twice - let duplicated_weight = Self::withdraw_affirmation_rcv(0, 0, 0); - // The actual weight is the sum of the sender and receiver weights subtracted by the duplicated weight - sender_side_weight - .saturating_add(receiver_side_weight) - .saturating_sub(duplicated_weight) - } - None => { - if portfolios > (10 + 100) * 2 { - // Too many portfolios, return worse-case weight based on portfolio count. - Self::withdraw_affirmation(portfolios, portfolios, 10) - } else { - Self::withdraw_affirmation(10, 100, 10) - } - } - } - } - fn reject_instruction_input(asset_count: Option, as_mediator: bool) -> Weight { - match asset_count { - Some(asset_count) => { - if as_mediator { - return Self::reject_instruction_as_mediator( - asset_count.fungible(), - asset_count.non_fungible(), - asset_count.off_chain(), - ); - } - Self::reject_instruction( - asset_count.fungible(), - asset_count.non_fungible(), - asset_count.off_chain(), - ) - } - None => { - let (f, n, o) = (10, 100, 10); - if as_mediator { - return Self::reject_instruction_as_mediator(f, n, o); - } - Self::reject_instruction(f, n, o) - } - } - } -} diff --git a/pallets/settlement/Cargo.toml b/pallets/settlement/Cargo.toml index 6cc8de044f..8a34acbfdd 100644 --- a/pallets/settlement/Cargo.toml +++ b/pallets/settlement/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] polymesh-common-utilities = { workspace = true, default-features = false } -pallet-balances = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-asset = { workspace = true, default-features = false } @@ -14,7 +13,7 @@ pallet-external-agents = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } polymesh-primitives-derive = { workspace = true, default-features = false } pallet-compliance-manager = { workspace = true, default-features = false } -pallet-statistics = { workspace = true, default-features = false } +pallet-permissions = { workspace = true, default-features = false } pallet-nft = { workspace = true, default-features = false } serde = { version = "1.0.104", default-features = false } @@ -50,11 +49,10 @@ std = [ "frame-support/std", "frame-system/std", "pallet-base/std", - "pallet-balances/std", "pallet-asset/std", "pallet-identity/std", "pallet-timestamp/std", - "pallet-statistics/std", + "pallet-permissions/std", "polymesh-common-utilities/std", "pallet-compliance-manager/std", "polymesh-primitives/std", diff --git a/pallets/settlement/src/lib.rs b/pallets/settlement/src/lib.rs index ae378a22c9..4727ccaa09 100644 --- a/pallets/settlement/src/lib.rs +++ b/pallets/settlement/src/lib.rs @@ -58,7 +58,8 @@ use frame_support::traits::schedule::{DispatchTime, Named}; use frame_support::traits::Get; use frame_support::weights::Weight; use frame_support::{ - decl_error, decl_module, decl_storage, ensure, BoundedBTreeSet, IterableStorageDoubleMap, + decl_error, decl_event, decl_module, decl_storage, ensure, BoundedBTreeSet, + IterableStorageDoubleMap, }; use frame_system::{ensure_root, RawOrigin}; use sp_runtime::traits::{One, Verify}; @@ -69,15 +70,14 @@ use sp_std::vec; use pallet_asset::MandatoryMediators; use pallet_base::{ensure_string_limited, try_next_post}; -pub use polymesh_common_utilities::traits::settlement::{Event, RawEvent, WeightInfo}; -use polymesh_common_utilities::traits::{asset, compliance_manager, CommonConfig}; +use polymesh_common_utilities::traits::{asset, compliance_manager}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::queue_priority::SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY; use polymesh_primitives::settlement::{ AffirmationCount, AffirmationStatus, AssetCount, ExecuteInstructionInfo, FilteredLegs, Instruction, InstructionId, InstructionInfo, InstructionStatus, Leg, LegId, LegStatus, - MediatorAffirmationStatus, Receipt, ReceiptDetails, SettlementType, Venue, VenueDetails, - VenueId, VenueType, + MediatorAffirmationStatus, Receipt, ReceiptDetails, ReceiptMetadata, SettlementType, Venue, + VenueDetails, VenueId, VenueType, }; use polymesh_primitives::with_transaction; use polymesh_primitives::SystematicIssuers::Settlement as SettlementDID; @@ -100,12 +100,312 @@ type EnsureValidInstructionResult = Result< DispatchError, >; +decl_event!( + pub enum Event + where + Moment = ::Moment, + BlockNumber = ::BlockNumber, + AccountId = ::AccountId, + { + /// A new venue has been created (did, venue_id, details, type) + VenueCreated(IdentityId, VenueId, VenueDetails, VenueType), + /// An existing venue's details has been updated (did, venue_id, details) + VenueDetailsUpdated(IdentityId, VenueId, VenueDetails), + /// An existing venue's type has been updated (did, venue_id, type) + VenueTypeUpdated(IdentityId, VenueId, VenueType), + /// An instruction has been affirmed (did, portfolio, instruction_id) + InstructionAffirmed(IdentityId, PortfolioId, InstructionId), + /// An affirmation has been withdrawn (did, portfolio, instruction_id) + AffirmationWithdrawn(IdentityId, PortfolioId, InstructionId), + /// An instruction has been rejected (did, instruction_id) + InstructionRejected(IdentityId, InstructionId), + /// A receipt has been claimed (did, instruction_id, leg_id, receipt_uid, signer, receipt metadata) + ReceiptClaimed( + IdentityId, + InstructionId, + LegId, + u64, + AccountId, + Option, + ), + /// Venue filtering has been enabled or disabled for an asset (did, AssetId, filtering_enabled) + VenueFiltering(IdentityId, AssetId, bool), + /// Venues added to allow list (did, AssetId, vec) + VenuesAllowed(IdentityId, AssetId, Vec), + /// Venues added to block list (did, AssetId, vec) + VenuesBlocked(IdentityId, AssetId, Vec), + /// Execution of a leg failed (did, instruction_id, leg_id) + LegFailedExecution(IdentityId, InstructionId, LegId), + /// Instruction executed successfully(did, instruction_id) + InstructionExecuted(IdentityId, InstructionId), + /// Venue not part of the token's allow list (did, AssetId, venue_id) + VenueUnauthorized(IdentityId, AssetId, VenueId), + /// Scheduling of instruction fails. + SchedulingFailed(InstructionId, DispatchError), + /// Instruction is rescheduled. + /// (caller DID, instruction_id) + InstructionRescheduled(IdentityId, InstructionId), + /// An existing venue's signers has been updated (did, venue_id, signers, update_type) + VenueSignersUpdated(IdentityId, VenueId, Vec, bool), + /// Settlement manually executed (did, id) + SettlementManuallyExecuted(IdentityId, InstructionId), + /// A new instruction has been created + /// (did, venue_id, instruction_id, settlement_type, trade_date, value_date, legs, memo) + InstructionCreated( + IdentityId, + Option, + InstructionId, + SettlementType, + Option, + Option, + Vec, + Option, + ), + /// Failed to execute instruction. + FailedToExecuteInstruction(InstructionId, DispatchError), + /// An instruction has been automatically affirmed. + /// Parameters: [`IdentityId`] of the caller, [`PortfolioId`] of the receiver, and [`InstructionId`] of the instruction. + InstructionAutomaticallyAffirmed(IdentityId, PortfolioId, InstructionId), + /// An instruction has affirmed by a mediator. + /// Parameters: [`IdentityId`] of the mediator and [`InstructionId`] of the instruction. + MediatorAffirmationReceived(IdentityId, InstructionId, Option), + /// An instruction affirmation has been withdrawn by a mediator. + /// Parameters: [`IdentityId`] of the mediator and [`InstructionId`] of the instruction. + MediatorAffirmationWithdrawn(IdentityId, InstructionId), + /// An instruction with mediators has been created. + /// Parameters: [`InstructionId`] of the instruction and the [`IdentityId`] of all mediators. + InstructionMediators(InstructionId, BTreeSet), + } +); + +pub trait WeightInfo { + fn create_venue(d: u32, u: u32) -> Weight; + fn update_venue_details(d: u32) -> Weight; + fn update_venue_type() -> Weight; + fn update_venue_signers(u: u32) -> Weight; + fn affirm_with_receipts(f: u32, n: u32, o: u32) -> Weight; + fn set_venue_filtering() -> Weight; + fn allow_venues(u: u32) -> Weight; + fn disallow_venues(u: u32) -> Weight; + fn execute_manual_instruction(f: u32, n: u32, o: u32) -> Weight; + fn add_instruction(f: u32, n: u32, o: u32) -> Weight; + fn add_and_affirm_instruction(f: u32, n: u32, o: u32) -> Weight; + fn affirm_instruction(f: u32, n: u32) -> Weight; + fn withdraw_affirmation(f: u32, n: u32, o: u32) -> Weight; + fn reject_instruction(f: u32, n: u32, o: u32) -> Weight; + fn execute_instruction_paused(f: u32, n: u32, o: u32) -> Weight; + fn execute_scheduled_instruction(f: u32, n: u32, o: u32) -> Weight; + fn ensure_root_origin() -> Weight; + fn affirm_with_receipts_rcv(f: u32, n: u32, o: u32) -> Weight; + fn affirm_instruction_rcv(f: u32, n: u32) -> Weight; + fn withdraw_affirmation_rcv(f: u32, n: u32, o: u32) -> Weight; + fn add_instruction_with_mediators(f: u32, n: u32, o: u32, m: u32) -> Weight; + fn add_and_affirm_with_mediators(f: u32, n: u32, o: u32, m: u32) -> Weight; + fn affirm_instruction_as_mediator() -> Weight; + fn withdraw_affirmation_as_mediator() -> Weight; + fn reject_instruction_as_mediator(f: u32, n: u32, o: u32) -> Weight; + + fn add_and_affirm_with_mediators_legs( + legs: &[Leg], + portfolios: u32, + n_mediators: u32, + ) -> Weight { + let (f, n, o) = Self::get_transfer_by_asset(legs, portfolios); + Self::add_and_affirm_with_mediators(f, n, o, n_mediators) + } + fn add_instruction_with_mediators_legs(legs: &[Leg], n_mediators: u32) -> Weight { + let (f, n, o) = Self::get_transfer_by_asset(legs, 0); + Self::add_instruction_with_mediators(f, n, o, n_mediators) + } + fn add_instruction_legs(legs: &[Leg]) -> Weight { + let (f, n, o) = Self::get_transfer_by_asset(legs, 0); + Self::add_instruction(f, n, o) + } + fn add_and_affirm_instruction_legs(legs: &[Leg], portfolios: u32) -> Weight { + let (f, n, o) = Self::get_transfer_by_asset(legs, portfolios); + Self::add_and_affirm_instruction(f, n, o) + } + fn execute_manual_weight_limit( + weight_limit: &Option, + f: &u32, + n: &u32, + o: &u32, + ) -> Weight { + if let Some(weight_limit) = weight_limit { + return *weight_limit; + } + Self::execute_manual_instruction(*f, *n, *o) + } + fn get_transfer_by_asset(legs: &[Leg], portfolios: u32) -> (u32, u32, u32) { + let asset_count = + AssetCount::try_from_legs(legs).unwrap_or(AssetCount::new(1024, 1024, 1024)); + let f = asset_count.fungible(); + let n = asset_count.non_fungible(); + let max_portfolios = (f.saturating_add(n)).saturating_mul(2); // 2 portfolios per leg. (f+n = max legs). + if portfolios > max_portfolios { + // Too many portfolios, return worse-case count based on portfolio count. + return (portfolios, portfolios, 1024); + } + (f, n, asset_count.off_chain()) + } + fn affirm_with_receipts_input( + affirmation_count: Option, + portfolios: u32, + ) -> Weight { + match affirmation_count { + Some(affirmation_count) => { + let max_portfolios = affirmation_count.max_portfolios(); + if portfolios > max_portfolios { + // Too many portfolios, return worse-case weight based on portfolio count. + return Self::affirm_with_receipts(portfolios, portfolios, 10); + } + // The weight for the assets being sent + let sender_asset_count = affirmation_count.sender_asset_count(); + let sender_side_weight = Self::affirm_with_receipts( + sender_asset_count.fungible(), + sender_asset_count.non_fungible(), + affirmation_count.offchain_count(), + ); + // The weight for the assets being received + let receiver_asset_count = affirmation_count.receiver_asset_count(); + let receiver_side_weight = Self::affirm_with_receipts_rcv( + receiver_asset_count.fungible(), + receiver_asset_count.non_fungible(), + 0, + ); + // Common reads/writes are being added twice + let duplicated_weight = Self::affirm_with_receipts_rcv(0, 0, 0); + // The actual weight is the sum of the sender and receiver weights subtracted by the duplicated weight + sender_side_weight + .saturating_add(receiver_side_weight) + .saturating_sub(duplicated_weight) + } + None => { + if portfolios > (10 + 100) * 2 { + // Too many portfolios, return worse-case weight based on portfolio count. + Self::affirm_with_receipts(portfolios, portfolios, 10) + } else { + Self::affirm_with_receipts(10, 100, 10) + } + } + } + } + fn affirm_instruction_input( + affirmation_count: Option, + portfolios: u32, + ) -> Weight { + match affirmation_count { + Some(affirmation_count) => { + let max_portfolios = affirmation_count.max_portfolios(); + if portfolios > max_portfolios { + // Too many portfolios, return worse-case weight based on portfolio count. + return Self::affirm_instruction(portfolios, portfolios); + } + // The weight for the assets being sent + let sender_asset_count = affirmation_count.sender_asset_count(); + let sender_side_weight = Self::affirm_instruction( + sender_asset_count.fungible(), + sender_asset_count.non_fungible(), + ); + // The weight for the assets being received + let receiver_asset_count = affirmation_count.receiver_asset_count(); + let receiver_side_weight = Self::affirm_instruction_rcv( + receiver_asset_count.fungible(), + receiver_asset_count.non_fungible(), + ); + // Common reads/writes are being added twice + let duplicated_weight = Self::affirm_instruction_rcv(0, 0); + // The actual weight is the sum of the sender and receiver weights subtracted by the duplicated weight + sender_side_weight + .saturating_add(receiver_side_weight) + .saturating_sub(duplicated_weight) + } + None => { + if portfolios > (10 + 100) * 2 { + // Too many portfolios, return worse-case weight based on portfolio count. + Self::affirm_instruction(portfolios, portfolios) + } else { + Self::affirm_instruction(10, 100) + } + } + } + } + fn withdraw_affirmation_input( + affirmation_count: Option, + portfolios: u32, + ) -> Weight { + match affirmation_count { + Some(affirmation_count) => { + let max_portfolios = affirmation_count.max_portfolios(); + if portfolios > max_portfolios { + // Too many portfolios, return worse-case weight based on portfolio count. + return Self::withdraw_affirmation(portfolios, portfolios, 10); + } + // The weight for the assets being sent + let sender_asset_count = affirmation_count.sender_asset_count(); + let sender_side_weight = Self::withdraw_affirmation( + sender_asset_count.fungible(), + sender_asset_count.non_fungible(), + affirmation_count.offchain_count(), + ); + // The weight for the assets being received + let receiver_asset_count = affirmation_count.receiver_asset_count(); + let receiver_side_weight = Self::withdraw_affirmation_rcv( + receiver_asset_count.fungible(), + receiver_asset_count.non_fungible(), + 0, + ); + // Common reads/writes are being added twice + let duplicated_weight = Self::withdraw_affirmation_rcv(0, 0, 0); + // The actual weight is the sum of the sender and receiver weights subtracted by the duplicated weight + sender_side_weight + .saturating_add(receiver_side_weight) + .saturating_sub(duplicated_weight) + } + None => { + if portfolios > (10 + 100) * 2 { + // Too many portfolios, return worse-case weight based on portfolio count. + Self::withdraw_affirmation(portfolios, portfolios, 10) + } else { + Self::withdraw_affirmation(10, 100, 10) + } + } + } + } + fn reject_instruction_input(asset_count: Option, as_mediator: bool) -> Weight { + match asset_count { + Some(asset_count) => { + if as_mediator { + return Self::reject_instruction_as_mediator( + asset_count.fungible(), + asset_count.non_fungible(), + asset_count.off_chain(), + ); + } + Self::reject_instruction( + asset_count.fungible(), + asset_count.non_fungible(), + asset_count.off_chain(), + ) + } + None => { + let (f, n, o) = (10, 100, 10); + if as_mediator { + return Self::reject_instruction_as_mediator(f, n, o); + } + Self::reject_instruction(f, n, o) + } + } + } +} + pub trait Config: asset::Config - + CommonConfig + + frame_system::Config + compliance_manager::Config + frame_system::Config + pallet_identity::Config + + pallet_permissions::Config + pallet_nft::Config + pallet_timestamp::Config { From 0ce879551b8f938eb90227667bad050ee8e2fb16 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 04:04:33 +0800 Subject: [PATCH 29/45] Move WeightInfo, Config, Event into Compliance Manager pallet. --- Cargo.lock | 3 - pallets/common/src/lib.rs | 2 +- .../common/src/traits/compliance_manager.rs | 134 ------------------ pallets/common/src/traits/mod.rs | 1 - pallets/compliance-manager/Cargo.toml | 7 - pallets/compliance-manager/src/lib.rs | 119 +++++++++++++++- pallets/settlement/src/lib.rs | 4 +- 7 files changed, 116 insertions(+), 154 deletions(-) delete mode 100644 pallets/common/src/traits/compliance_manager.rs diff --git a/Cargo.lock b/Cargo.lock index 961c14b04e..121d757a64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4907,15 +4907,12 @@ dependencies = [ "frame-support", "frame-system", "log", - "pallet-asset", - "pallet-balances 0.1.0", "pallet-base", "pallet-external-agents", "pallet-identity", "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index c8ac068686..9792ec01fd 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -16,4 +16,4 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod traits; -pub use traits::{asset, balances, compliance_manager, CommonConfig}; +pub use traits::{asset, balances, CommonConfig}; diff --git a/pallets/common/src/traits/compliance_manager.rs b/pallets/common/src/traits/compliance_manager.rs deleted file mode 100644 index 773f0cd40a..0000000000 --- a/pallets/common/src/traits/compliance_manager.rs +++ /dev/null @@ -1,134 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use frame_support::decl_event; -use frame_support::traits::Get; -use frame_support::weights::Weight; -use sp_std::prelude::*; - -use pallet_external_agents::Config as EAConfig; -use polymesh_primitives::asset::AssetId; -use polymesh_primitives::compliance_manager::ComplianceRequirement; -use polymesh_primitives::condition::{conditions_total_counts, Condition}; -use polymesh_primitives::traits::AssetFnConfig; -use polymesh_primitives::{IdentityId, TrustedIssuer}; - -use crate::balances::Config as BalancesConfig; - -/// The module's configuration trait. -pub trait Config: - pallet_timestamp::Config - + frame_system::Config - + pallet_permissions::Config - + BalancesConfig - + pallet_identity::Config - + EAConfig - + AssetFnConfig -{ - /// The overarching event type. - type RuntimeEvent: From + Into<::RuntimeEvent>; - - /// Weight details of all extrinsic - type WeightInfo: WeightInfo; - - /// The maximum claim reads that are allowed to happen in worst case of a condition resolution - type MaxConditionComplexity: Get; -} - -decl_event!( - pub enum Event { - /// Emitted when new compliance requirement is created. - /// (caller DID, AssetId, ComplianceRequirement). - ComplianceRequirementCreated(IdentityId, AssetId, ComplianceRequirement), - /// Emitted when a compliance requirement is removed. - /// (caller DID, AssetId, requirement_id). - ComplianceRequirementRemoved(IdentityId, AssetId, u32), - /// Emitted when an asset compliance is replaced. - /// Parameters: caller DID, AssetId, new asset compliance. - AssetComplianceReplaced(IdentityId, AssetId, Vec), - /// Emitted when an asset compliance of a asset_id is reset. - /// (caller DID, AssetId). - AssetComplianceReset(IdentityId, AssetId), - /// Emitted when an asset compliance for a given asset_id gets resume. - /// (caller DID, AssetId). - AssetComplianceResumed(IdentityId, AssetId), - /// Emitted when an asset compliance for a given asset_id gets paused. - /// (caller DID, AssetId). - AssetCompliancePaused(IdentityId, AssetId), - /// Emitted when compliance requirement get modified/change. - /// (caller DID, AssetId, ComplianceRequirement). - ComplianceRequirementChanged(IdentityId, AssetId, ComplianceRequirement), - /// Emitted when default claim issuer list for a given asset_id gets added. - /// (caller DID, AssetId, Added TrustedIssuer). - TrustedDefaultClaimIssuerAdded(IdentityId, AssetId, TrustedIssuer), - /// Emitted when default claim issuer list for a given asset_id get removed. - /// (caller DID, AssetId, Removed TrustedIssuer). - TrustedDefaultClaimIssuerRemoved(IdentityId, AssetId, IdentityId), - } -); - -pub trait WeightInfo { - fn add_compliance_requirement(c: u32) -> Weight; - fn remove_compliance_requirement() -> Weight; - fn pause_asset_compliance() -> Weight; - fn resume_asset_compliance() -> Weight; - fn add_default_trusted_claim_issuer() -> Weight; - fn remove_default_trusted_claim_issuer() -> Weight; - fn change_compliance_requirement(c: u32) -> Weight; - fn replace_asset_compliance(c: u32) -> Weight; - fn reset_asset_compliance() -> Weight; - fn is_condition_satisfied(c: u32, t: u32) -> Weight; - fn is_identity_condition(e: u32) -> Weight; - fn is_any_requirement_compliant(i: u32) -> Weight; - - fn condition_costs(conditions: u32, claims: u32, issuers: u32, claim_types: u32) -> Weight; - - fn add_compliance_requirement_full(sender: &[Condition], receiver: &[Condition]) -> Weight { - let (condtions, claims, issuers, claim_types) = - conditions_total_counts(sender.iter().chain(receiver.iter())); - Self::add_compliance_requirement(condtions).saturating_add(Self::condition_costs( - 0, - claims, - issuers, - claim_types, - )) - } - - fn change_compliance_requirement_full(req: &ComplianceRequirement) -> Weight { - let (conditions, claims, issuers, claim_types) = req.counts(); - Self::change_compliance_requirement(conditions).saturating_add(Self::condition_costs( - 0, - claims, - issuers, - claim_types, - )) - } - - fn replace_asset_compliance_full(reqs: &[ComplianceRequirement]) -> Weight { - let (conditions, claims, issuers, claim_types) = - conditions_total_counts(reqs.iter().flat_map(|req| req.conditions())); - Self::replace_asset_compliance(reqs.len() as u32).saturating_add(Self::condition_costs( - conditions, - claims, - issuers, - claim_types, - )) - } - - fn is_any_requirement_compliant_loop(i: u32) -> Weight { - Self::is_any_requirement_compliant(i) - .saturating_sub(Self::is_identity_condition(0).saturating_mul(i.into())) - } -} diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 75dfd6c6f7..6c25933721 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -25,4 +25,3 @@ pub use imbalances::{NegativeImbalance, PositiveImbalance}; pub mod asset; pub mod balances; pub mod checkpoint; -pub mod compliance_manager; diff --git a/pallets/compliance-manager/Cargo.toml b/pallets/compliance-manager/Cargo.toml index 10a56d9231..843b96ff48 100644 --- a/pallets/compliance-manager/Cargo.toml +++ b/pallets/compliance-manager/Cargo.toml @@ -7,16 +7,12 @@ edition = "2021" [dependencies] # Common polymesh-primitives = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } # Our pallets pallet-base = { workspace = true, default-features = false } pallet-external-agents = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } -## Only for benchmarks -pallet-asset = { workspace = true, optional = true, default-features = false } -pallet-balances = { workspace = true, optional = true, default-features = false } # Other serde = { version = "1.0.104", default-features = false } @@ -61,12 +57,9 @@ std = [ "pallet-base/std", "pallet-external-agents/std", "pallet-timestamp/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", ] runtime-benchmarks = [ "frame-benchmarking", - "pallet-asset/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", ] diff --git a/pallets/compliance-manager/src/lib.rs b/pallets/compliance-manager/src/lib.rs index b60a4f29f1..ad5c78ceeb 100644 --- a/pallets/compliance-manager/src/lib.rs +++ b/pallets/compliance-manager/src/lib.rs @@ -80,27 +80,134 @@ use core::result::Result; use frame_support::dispatch::{DispatchError, DispatchResult}; use frame_support::traits::Get; use frame_support::weights::Weight; -use frame_support::{decl_error, decl_module, decl_storage, ensure}; -use sp_std::{convert::From, prelude::*}; - +use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure}; use pallet_base::ensure_length_ok; -pub use polymesh_common_utilities::traits::compliance_manager::{Config, Event, WeightInfo}; +use pallet_external_agents::Config as EAConfig; use polymesh_primitives::asset::AssetId; use polymesh_primitives::compliance_manager::{ AssetCompliance, AssetComplianceResult, ComplianceReport, ComplianceRequirement, ConditionReport, ConditionResult, RequirementReport, }; +use polymesh_primitives::condition::{conditions_total_counts, Condition}; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::{ - proposition, storage_migration_ver, traits::ComplianceFnConfig, Claim, Condition, - ConditionType, Context, IdentityId, TargetIdentity, TrustedFor, TrustedIssuer, WeightMeter, + proposition, storage_migration_ver, + traits::{AssetFnConfig, ComplianceFnConfig}, + Claim, ConditionType, Context, IdentityId, TargetIdentity, TrustedFor, TrustedIssuer, + WeightMeter, }; +use sp_std::{convert::From, prelude::*}; type ExternalAgents = pallet_external_agents::Module; type Identity = pallet_identity::Module; storage_migration_ver!(1); +/// The module's configuration trait. +pub trait Config: + pallet_timestamp::Config + + frame_system::Config + + pallet_permissions::Config + + pallet_identity::Config + + EAConfig + + AssetFnConfig +{ + /// The overarching event type. + type RuntimeEvent: From + Into<::RuntimeEvent>; + + /// Weight details of all extrinsic + type WeightInfo: WeightInfo; + + /// The maximum claim reads that are allowed to happen in worst case of a condition resolution + type MaxConditionComplexity: Get; +} + +decl_event!( + pub enum Event { + /// Emitted when new compliance requirement is created. + /// (caller DID, AssetId, ComplianceRequirement). + ComplianceRequirementCreated(IdentityId, AssetId, ComplianceRequirement), + /// Emitted when a compliance requirement is removed. + /// (caller DID, AssetId, requirement_id). + ComplianceRequirementRemoved(IdentityId, AssetId, u32), + /// Emitted when an asset compliance is replaced. + /// Parameters: caller DID, AssetId, new asset compliance. + AssetComplianceReplaced(IdentityId, AssetId, Vec), + /// Emitted when an asset compliance of a asset_id is reset. + /// (caller DID, AssetId). + AssetComplianceReset(IdentityId, AssetId), + /// Emitted when an asset compliance for a given asset_id gets resume. + /// (caller DID, AssetId). + AssetComplianceResumed(IdentityId, AssetId), + /// Emitted when an asset compliance for a given asset_id gets paused. + /// (caller DID, AssetId). + AssetCompliancePaused(IdentityId, AssetId), + /// Emitted when compliance requirement get modified/change. + /// (caller DID, AssetId, ComplianceRequirement). + ComplianceRequirementChanged(IdentityId, AssetId, ComplianceRequirement), + /// Emitted when default claim issuer list for a given asset_id gets added. + /// (caller DID, AssetId, Added TrustedIssuer). + TrustedDefaultClaimIssuerAdded(IdentityId, AssetId, TrustedIssuer), + /// Emitted when default claim issuer list for a given asset_id get removed. + /// (caller DID, AssetId, Removed TrustedIssuer). + TrustedDefaultClaimIssuerRemoved(IdentityId, AssetId, IdentityId), + } +); + +pub trait WeightInfo { + fn add_compliance_requirement(c: u32) -> Weight; + fn remove_compliance_requirement() -> Weight; + fn pause_asset_compliance() -> Weight; + fn resume_asset_compliance() -> Weight; + fn add_default_trusted_claim_issuer() -> Weight; + fn remove_default_trusted_claim_issuer() -> Weight; + fn change_compliance_requirement(c: u32) -> Weight; + fn replace_asset_compliance(c: u32) -> Weight; + fn reset_asset_compliance() -> Weight; + fn is_condition_satisfied(c: u32, t: u32) -> Weight; + fn is_identity_condition(e: u32) -> Weight; + fn is_any_requirement_compliant(i: u32) -> Weight; + + fn condition_costs(conditions: u32, claims: u32, issuers: u32, claim_types: u32) -> Weight; + + fn add_compliance_requirement_full(sender: &[Condition], receiver: &[Condition]) -> Weight { + let (condtions, claims, issuers, claim_types) = + conditions_total_counts(sender.iter().chain(receiver.iter())); + Self::add_compliance_requirement(condtions).saturating_add(Self::condition_costs( + 0, + claims, + issuers, + claim_types, + )) + } + + fn change_compliance_requirement_full(req: &ComplianceRequirement) -> Weight { + let (conditions, claims, issuers, claim_types) = req.counts(); + Self::change_compliance_requirement(conditions).saturating_add(Self::condition_costs( + 0, + claims, + issuers, + claim_types, + )) + } + + fn replace_asset_compliance_full(reqs: &[ComplianceRequirement]) -> Weight { + let (conditions, claims, issuers, claim_types) = + conditions_total_counts(reqs.iter().flat_map(|req| req.conditions())); + Self::replace_asset_compliance(reqs.len() as u32).saturating_add(Self::condition_costs( + conditions, + claims, + issuers, + claim_types, + )) + } + + fn is_any_requirement_compliant_loop(i: u32) -> Weight { + Self::is_any_requirement_compliant(i) + .saturating_sub(Self::is_identity_condition(0).saturating_mul(i.into())) + } +} + decl_storage! { trait Store for Module as ComplianceManager { /// Compliance for an asset ([`AssetId`] -> [`AssetCompliance`]) diff --git a/pallets/settlement/src/lib.rs b/pallets/settlement/src/lib.rs index 4727ccaa09..ac7180f301 100644 --- a/pallets/settlement/src/lib.rs +++ b/pallets/settlement/src/lib.rs @@ -70,7 +70,7 @@ use sp_std::vec; use pallet_asset::MandatoryMediators; use pallet_base::{ensure_string_limited, try_next_post}; -use polymesh_common_utilities::traits::{asset, compliance_manager}; +use polymesh_common_utilities::traits::asset; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::queue_priority::SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY; use polymesh_primitives::settlement::{ @@ -402,7 +402,7 @@ pub trait WeightInfo { pub trait Config: asset::Config + frame_system::Config - + compliance_manager::Config + + pallet_compliance_manager::Config + frame_system::Config + pallet_identity::Config + pallet_permissions::Config From e9d8d0f88610d2c862d6b0e4efeffdb6f0511df6 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 04:24:39 +0800 Subject: [PATCH 30/45] Remove unneeded deps. --- Cargo.lock | 9 --------- pallets/asset/Cargo.toml | 2 -- pallets/bridge/Cargo.toml | 2 -- pallets/committee/Cargo.toml | 1 - pallets/common/src/traits/asset.rs | 6 +----- pallets/common/src/traits/mod.rs | 2 +- pallets/contracts/Cargo.toml | 2 -- pallets/corporate-actions/Cargo.toml | 2 -- pallets/corporate-actions/src/lib.rs | 6 ++---- pallets/multisig/Cargo.toml | 5 ----- pallets/nft/Cargo.toml | 3 +-- pallets/pips/src/lib.rs | 7 +------ pallets/staking/Cargo.toml | 3 --- pallets/sto/Cargo.toml | 2 -- 14 files changed, 6 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 121d757a64..84a0432226 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4711,7 +4711,6 @@ dependencies = [ "frame-system", "hex-literal 0.2.2", "log", - "pallet-balances 0.1.0", "pallet-base", "pallet-external-agents", "pallet-identity", @@ -4865,7 +4864,6 @@ dependencies = [ "pallet-multisig", "pallet-scheduler", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -4885,7 +4883,6 @@ dependencies = [ "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -4986,7 +4983,6 @@ dependencies = [ "frame-system", "log", "pallet-asset", - "pallet-balances 0.1.0", "pallet-base", "pallet-compliance-manager", "pallet-external-agents", @@ -5235,7 +5231,6 @@ dependencies = [ "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -5259,7 +5254,6 @@ dependencies = [ "pallet-identity", "pallet-portfolio", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "sp-runtime", @@ -5520,7 +5514,6 @@ dependencies = [ "pallet-session", "pallet-staking-reward-curve", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "rand_chacha 0.2.2", "scale-info", @@ -5619,7 +5612,6 @@ dependencies = [ "pallet-settlement", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "polymesh-primitives-derive", "scale-info", @@ -6293,7 +6285,6 @@ dependencies = [ "pallet-identity", "pallet-permissions", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", diff --git a/pallets/asset/Cargo.toml b/pallets/asset/Cargo.toml index e2c60f74be..2de3e05107 100644 --- a/pallets/asset/Cargo.toml +++ b/pallets/asset/Cargo.toml @@ -11,7 +11,6 @@ polymesh-primitives-derive = { workspace = true, default-features = false } polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets -pallet-balances = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } pallet-external-agents = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } @@ -54,7 +53,6 @@ std = [ "frame-support/std", "frame-system/std", "pallet-base/std", - "pallet-balances/std", "pallet-identity/std", "pallet-portfolio/std", "pallet-timestamp/std", diff --git a/pallets/bridge/Cargo.toml b/pallets/bridge/Cargo.toml index 5c2090e95d..fd745688e3 100644 --- a/pallets/bridge/Cargo.toml +++ b/pallets/bridge/Cargo.toml @@ -5,7 +5,6 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } @@ -43,7 +42,6 @@ std = [ "pallet-identity/std", "pallet-multisig/std", "pallet-scheduler/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "serde/std", "sp-core/std", diff --git a/pallets/committee/Cargo.toml b/pallets/committee/Cargo.toml index fbb2200e7a..183a8fdf9a 100644 --- a/pallets/committee/Cargo.toml +++ b/pallets/committee/Cargo.toml @@ -5,7 +5,6 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } diff --git a/pallets/common/src/traits/asset.rs b/pallets/common/src/traits/asset.rs index 25efe51d36..4f61ef9f99 100644 --- a/pallets/common/src/traits/asset.rs +++ b/pallets/common/src/traits/asset.rs @@ -37,11 +37,7 @@ use crate::traits::checkpoint; /// The module's configuration trait. pub trait Config: - crate::balances::Config - + EAConfig - + pallet_statistics::Config - + pallet_portfolio::Config - + AssetFnConfig + EAConfig + pallet_statistics::Config + pallet_portfolio::Config + AssetFnConfig { /// The overarching event type. type RuntimeEvent: From> diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index 6c25933721..f62576962a 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -15,7 +15,7 @@ use polymesh_primitives::traits::BlockRewardsReserveCurrency; -pub trait CommonConfig: frame_system::Config + pallet_permissions::Config { +pub trait CommonConfig: Sized { type BlockRewardsReserve: BlockRewardsReserveCurrency>; } diff --git a/pallets/contracts/Cargo.toml b/pallets/contracts/Cargo.toml index 100d54dbac..49c04bc5c8 100644 --- a/pallets/contracts/Cargo.toml +++ b/pallets/contracts/Cargo.toml @@ -25,7 +25,6 @@ pallet-base = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true } @@ -44,7 +43,6 @@ std = [ "pallet-identity/std", "pallet-contracts/std", "polymesh-primitives/std", - "polymesh-common-utilities/std", "wasm-instrument?/std", ] runtime-benchmarks = [ diff --git a/pallets/corporate-actions/Cargo.toml b/pallets/corporate-actions/Cargo.toml index d51a142c3a..d3287b0549 100644 --- a/pallets/corporate-actions/Cargo.toml +++ b/pallets/corporate-actions/Cargo.toml @@ -11,7 +11,6 @@ polymesh-primitives-derive = { workspace = true, default-features = false } polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets -pallet-balances = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } pallet-external-agents = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } @@ -49,7 +48,6 @@ std = [ "frame-system/std", "pallet-asset/std", "pallet-base/std", - "pallet-balances/std", "pallet-external-agents/std", "pallet-identity/std", "pallet-portfolio/std", diff --git a/pallets/corporate-actions/src/lib.rs b/pallets/corporate-actions/src/lib.rs index 8e3633aa3a..3a301b9079 100644 --- a/pallets/corporate-actions/src/lib.rs +++ b/pallets/corporate-actions/src/lib.rs @@ -104,9 +104,7 @@ use frame_system::ensure_root; use pallet_asset::checkpoint; use pallet_base::try_next_post; use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; -use polymesh_common_utilities::{ - balances::Config as BalancesConfig, traits::asset, traits::checkpoint::ScheduleId, -}; +use polymesh_common_utilities::{traits::asset, traits::checkpoint::ScheduleId}; use polymesh_primitives::asset::AssetId; use polymesh_primitives::{ asset::CheckpointId, impl_checked_inc, storage_migration_ver, with_transaction, Balance, @@ -317,7 +315,7 @@ pub trait WeightInfo { } /// The module's configuration trait. -pub trait Config: frame_system::Config + BalancesConfig + IdentityConfig + asset::Config { +pub trait Config: frame_system::Config + IdentityConfig + asset::Config { /// The overarching event type. type RuntimeEvent: From + From diff --git a/pallets/multisig/Cargo.toml b/pallets/multisig/Cargo.toml index 30f2ffc813..be097a2484 100644 --- a/pallets/multisig/Cargo.toml +++ b/pallets/multisig/Cargo.toml @@ -9,9 +9,7 @@ edition = "2021" [dependencies] pallet-identity = { workspace = true, default-features = false} pallet-permissions = { workspace = true, default-features = false } -polymesh-common-utilities = {workspace = true, default-features = false} polymesh-primitives = { workspace = true, default-features = false} -#polymesh-runtime-common = { workspace = true, default-features = false } # General log = "0.4.8" @@ -46,13 +44,10 @@ std = [ "frame-system/std", "frame-support/std", "polymesh-primitives/std", - "polymesh-common-utilities/std", -# "polymesh-runtime-common/std", "pallet-identity/std", ] runtime-benchmarks = [ "frame-benchmarking", "polymesh-primitives/runtime-benchmarks", - "polymesh-common-utilities/runtime-benchmarks", ] try-runtime = [] diff --git a/pallets/nft/Cargo.toml b/pallets/nft/Cargo.toml index 5c5ab47157..ff07515da2 100644 --- a/pallets/nft/Cargo.toml +++ b/pallets/nft/Cargo.toml @@ -11,8 +11,8 @@ pallet-base = { workspace = true, default-features = false } pallet-external-agents = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-portfolio = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } + # Substrate codec = { workspace = true, default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false } @@ -37,7 +37,6 @@ std = [ "pallet-external-agents/std", "pallet-identity/std", "pallet-portfolio/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "sp-std/std" ] diff --git a/pallets/pips/src/lib.rs b/pallets/pips/src/lib.rs index 1ca9326a13..5a8893e91e 100644 --- a/pallets/pips/src/lib.rs +++ b/pallets/pips/src/lib.rs @@ -109,7 +109,6 @@ use sp_version::RuntimeVersion; use pallet_base::{ensure_opt_string_limited, try_next_post}; use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; use polymesh_common_utilities::traits::balances::LockableCurrencyExt; -use polymesh_common_utilities::CommonConfig; use polymesh_primitives::constants::PIP_MAX_REPORTING_SIZE; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::traits::group::GroupTrait; @@ -279,11 +278,7 @@ pub mod pallet { #[pallet::config] pub trait Config: - frame_system::Config - + pallet_timestamp::Config - + IdentityConfig - + CommonConfig - + pallet_base::Config + frame_system::Config + pallet_timestamp::Config + IdentityConfig + pallet_base::Config { /// Currency type for this module. type Currency: LockableCurrencyExt; diff --git a/pallets/staking/Cargo.toml b/pallets/staking/Cargo.toml index d75a504a81..d081526f64 100644 --- a/pallets/staking/Cargo.toml +++ b/pallets/staking/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] polymesh-primitives = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false} # General @@ -44,7 +43,6 @@ sp-tracing = "6.0.0" default = ["std"] no_std = [] std = [ - "polymesh-common-utilities/std", "polymesh-primitives/std", "serde", "codec/std", @@ -65,7 +63,6 @@ std = [ "frame-benchmarking", ] runtime-benchmarks = [ - "polymesh-common-utilities/runtime-benchmarks", "frame-benchmarking", "rand_chacha", ] diff --git a/pallets/sto/Cargo.toml b/pallets/sto/Cargo.toml index 665e30c936..04182ed301 100644 --- a/pallets/sto/Cargo.toml +++ b/pallets/sto/Cargo.toml @@ -14,7 +14,6 @@ pallet-identity = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } pallet-portfolio = { workspace = true, default-features = false } pallet-settlement = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } polymesh-primitives-derive = { workspace = true, default-features = false } @@ -56,7 +55,6 @@ std = [ "frame-system/std", "frame-support/std", "frame-benchmarking/std", - "polymesh-common-utilities/std", "pallet-base/std", "pallet-balances/std", "polymesh-primitives/std", From 7abd22de2ffaddf8028f1d0e4b9b56b38ed2481a Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 04:30:07 +0800 Subject: [PATCH 31/45] Remove unused trait. --- pallets/balances/src/lib.rs | 16 +--------------- pallets/common/src/traits/balances.rs | 15 +++------------ 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/pallets/balances/src/lib.rs b/pallets/balances/src/lib.rs index f12ad85b10..e51c82b04d 100644 --- a/pallets/balances/src/lib.rs +++ b/pallets/balances/src/lib.rs @@ -178,7 +178,7 @@ use frame_support::{ use frame_system::{self as system, ensure_root, ensure_signed}; pub use polymesh_common_utilities::traits::balances::WeightInfo; use polymesh_common_utilities::traits::{ - balances::{AccountData, BalancesTrait, CheckCdd, RawEvent, Reasons}, + balances::{AccountData, CheckCdd, RawEvent, Reasons}, NegativeImbalance, PositiveImbalance, }; use polymesh_primitives::traits::{BlockRewardsReserveCurrency, IdentityFnTrait}; @@ -690,20 +690,6 @@ impl Module { } } -impl BalancesTrait> for Module -where - T: Config, -{ - fn withdraw( - who: &T::AccountId, - value: Balance, - reasons: WithdrawReasons, - liveness: ExistenceRequirement, - ) -> sp_std::result::Result, DispatchError> { - >::withdraw(who, value, reasons, liveness) - } -} - // Polymesh modified code. Managed BRR related functions. impl BlockRewardsReserveCurrency> for Module { // Polymesh modified code. Drop behavious modified to reduce BRR balance instead of inflating total supply. diff --git a/pallets/common/src/traits/balances.rs b/pallets/common/src/traits/balances.rs index fd376add1a..fa2b8dd977 100644 --- a/pallets/common/src/traits/balances.rs +++ b/pallets/common/src/traits/balances.rs @@ -17,10 +17,10 @@ use crate::traits::{CommonConfig, NegativeImbalance}; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ decl_event, - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchResult, traits::{ - BalanceStatus as Status, ExistenceRequirement, Get, LockIdentifier, LockableCurrency, - OnUnbalanced, StoredMap, WithdrawReasons, + BalanceStatus as Status, Get, LockIdentifier, LockableCurrency, OnUnbalanced, StoredMap, + WithdrawReasons, }, weights::Weight, }; @@ -176,15 +176,6 @@ pub trait Config: CommonConfig + pallet_identity::Config { type MaxLocks: Get; } -pub trait BalancesTrait { - fn withdraw( - who: &A, - value: Balance, - reasons: WithdrawReasons, - _liveness: ExistenceRequirement, - ) -> sp_std::result::Result; -} - pub trait CheckCdd { fn check_key_cdd(key: &AccountId) -> bool; fn get_key_cdd_did(key: &AccountId) -> Option; From 1dd788467c0687290433d07571a55921ca946542 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 04:34:00 +0800 Subject: [PATCH 32/45] Move CheckCdd trait to primitives. --- pallets/balances/src/lib.rs | 4 ++-- pallets/common/src/traits/balances.rs | 7 +------ pallets/runtime/common/src/cdd_check.rs | 2 +- pallets/runtime/tests/src/staking/mock.rs | 4 ++-- pallets/utility/src/lib.rs | 4 ++-- primitives/src/traits.rs | 5 +++++ 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pallets/balances/src/lib.rs b/pallets/balances/src/lib.rs index e51c82b04d..80becfdfb7 100644 --- a/pallets/balances/src/lib.rs +++ b/pallets/balances/src/lib.rs @@ -178,10 +178,10 @@ use frame_support::{ use frame_system::{self as system, ensure_root, ensure_signed}; pub use polymesh_common_utilities::traits::balances::WeightInfo; use polymesh_common_utilities::traits::{ - balances::{AccountData, CheckCdd, RawEvent, Reasons}, + balances::{AccountData, RawEvent, Reasons}, NegativeImbalance, PositiveImbalance, }; -use polymesh_primitives::traits::{BlockRewardsReserveCurrency, IdentityFnTrait}; +use polymesh_primitives::traits::{BlockRewardsReserveCurrency, CheckCdd, IdentityFnTrait}; use polymesh_primitives::{Balance, Memo, SystematicIssuers, GC_DID}; use scale_info::TypeInfo; use sp_runtime::{ diff --git a/pallets/common/src/traits/balances.rs b/pallets/common/src/traits/balances.rs index fa2b8dd977..12cfde3cda 100644 --- a/pallets/common/src/traits/balances.rs +++ b/pallets/common/src/traits/balances.rs @@ -24,7 +24,7 @@ use frame_support::{ }, weights::Weight, }; -use polymesh_primitives::{Balance, IdentityId, Memo}; +use polymesh_primitives::{traits::CheckCdd, Balance, IdentityId, Memo}; use scale_info::TypeInfo; use sp_runtime::RuntimeDebug; use sp_std::ops::BitOr; @@ -176,11 +176,6 @@ pub trait Config: CommonConfig + pallet_identity::Config { type MaxLocks: Get; } -pub trait CheckCdd { - fn check_key_cdd(key: &AccountId) -> bool; - fn get_key_cdd_did(key: &AccountId) -> Option; -} - /// Additional functionality atop `LockableCurrency` allowing a local, /// per-id, stacking layer atop the overlay. pub trait LockableCurrencyExt: LockableCurrency { diff --git a/pallets/runtime/common/src/cdd_check.rs b/pallets/runtime/common/src/cdd_check.rs index df62585ccb..b32fc936cf 100644 --- a/pallets/runtime/common/src/cdd_check.rs +++ b/pallets/runtime/common/src/cdd_check.rs @@ -14,7 +14,7 @@ // along with this program. If not, see . use pallet_identity::{Config as IdentityConfig, Module as Identity}; -use polymesh_common_utilities::traits::balances::CheckCdd; +use polymesh_primitives::traits::CheckCdd; use polymesh_primitives::IdentityId; pub struct CddChecker(sp_std::marker::PhantomData); diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index 554fe5b45e..2e185e6eda 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -41,7 +41,7 @@ use sp_staking::{EraIndex, SessionIndex}; use pallet_staking::types::SlashingSwitch; use pallet_staking::{self as pallet_staking, *}; -use polymesh_common_utilities::traits::balances::{AccountData, CheckCdd}; +use polymesh_common_utilities::traits::balances::AccountData; use polymesh_common_utilities::traits::CommonConfig; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::currency::POLY; @@ -49,7 +49,7 @@ use polymesh_primitives::identity_id::GenesisIdentityRecord; use polymesh_primitives::{ traits::{ group::{GroupTrait, InactiveMember}, - PortfolioSubTrait, SubsidiserTrait, + CheckCdd, PortfolioSubTrait, SubsidiserTrait, }, Authorization, AuthorizationData, Claim, IdentityId, Moment, NFTId, Permissions, PortfolioId, SecondaryKey, Signatory, diff --git a/pallets/utility/src/lib.rs b/pallets/utility/src/lib.rs index 33708a2114..81e6e816c5 100644 --- a/pallets/utility/src/lib.rs +++ b/pallets/utility/src/lib.rs @@ -86,8 +86,8 @@ use sp_std::prelude::*; use pallet_identity::{Config as IdentityConfig, Context}; use pallet_permissions::with_call_metadata; -use polymesh_common_utilities::balances::{CheckCdd, Config as BalancesConfig}; -use polymesh_primitives::{identity::AuthorizationNonce, IdentityId}; +use polymesh_common_utilities::balances::Config as BalancesConfig; +use polymesh_primitives::{identity::AuthorizationNonce, traits::CheckCdd, IdentityId}; type Identity = pallet_identity::Module; diff --git a/primitives/src/traits.rs b/primitives/src/traits.rs index 36db568c2c..7f92eb084f 100644 --- a/primitives/src/traits.rs +++ b/primitives/src/traits.rs @@ -40,6 +40,11 @@ pub trait CddAndFeeDetails { fn get_payer_from_context() -> Option; } +pub trait CheckCdd { + fn check_key_cdd(key: &AccountId) -> bool; + fn get_key_cdd_did(key: &AccountId) -> Option; +} + pub trait IdentityFnTrait { fn get_identity(key: &AccountId) -> Option; fn current_payer() -> Option; From 99520ef3f0d07d256d9999de82e34bd447ef0e27 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 04:51:24 +0800 Subject: [PATCH 33/45] Move WeightInfo, Config, Event, LockableCurrencyExt, AccountData into Balances pallet. --- Cargo.lock | 5 +- pallets/balances/Cargo.toml | 5 +- .../src/traits => balances/src}/imbalances.rs | 26 +-- pallets/balances/src/lib.rs | 199 ++++++++++++++++-- pallets/common/src/lib.rs | 2 +- pallets/common/src/traits/balances.rs | 198 ----------------- pallets/common/src/traits/mod.rs | 10 - pallets/pips/Cargo.toml | 2 - pallets/pips/src/lib.rs | 2 +- pallets/runtime/common/src/runtime.rs | 4 +- pallets/runtime/tests/src/balances_test.rs | 3 +- pallets/runtime/tests/src/staking/mock.rs | 6 +- pallets/treasury/Cargo.toml | 3 - pallets/treasury/src/lib.rs | 2 +- pallets/utility/Cargo.toml | 3 - pallets/utility/src/lib.rs | 2 +- 16 files changed, 210 insertions(+), 262 deletions(-) rename pallets/{common/src/traits => balances/src}/imbalances.rs (85%) delete mode 100644 pallets/common/src/traits/balances.rs diff --git a/Cargo.lock b/Cargo.lock index 84a0432226..2c5e49ca59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4803,12 +4803,12 @@ dependencies = [ "pallet-permissions", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", "serde_derive", "sp-api", + "sp-arithmetic", "sp-core", "sp-io", "sp-runtime", @@ -5309,7 +5309,6 @@ dependencies = [ "pallet-timestamp", "pallet-treasury", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "polymesh-primitives-derive", "polymesh-runtime-common", @@ -5687,7 +5686,6 @@ dependencies = [ "pallet-identity", "pallet-permissions", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "serde", @@ -5711,7 +5709,6 @@ dependencies = [ "pallet-identity", "pallet-permissions", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "scale-info", "sp-core", diff --git a/pallets/balances/Cargo.toml b/pallets/balances/Cargo.toml index c8a919b018..39dc4280a4 100644 --- a/pallets/balances/Cargo.toml +++ b/pallets/balances/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" # Our pallets pallet-permissions = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } log = "0.4.8" @@ -23,6 +22,7 @@ sp-io = { version = "7.0.0", default-features = false } sp-runtime = { version = "7.0.0", default-features = false } sp-version = { version = "5.0.0", default-features = false } sp-api = { version = "4.0.0-dev", default-features = false } +sp-arithmetic = { version = "6.0.0", default-features = false } frame-system = { version = "4.0.0-dev", default-features = false } frame-support = { version = "4.0.0-dev", default-features = false } @@ -46,17 +46,16 @@ std = [ "sp-runtime/std", "sp-version/std", "sp-api/std", + "sp-arithmetic/std", "frame-system/std", "frame-support/std", "pallet-timestamp/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "pallet-permissions/std", "pallet-identity/std", ] runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks", "pallet-permissions/runtime-benchmarks", "pallet-identity/runtime-benchmarks", ] diff --git a/pallets/common/src/traits/imbalances.rs b/pallets/balances/src/imbalances.rs similarity index 85% rename from pallets/common/src/traits/imbalances.rs rename to pallets/balances/src/imbalances.rs index 196d9ead07..de981826b8 100644 --- a/pallets/common/src/traits/imbalances.rs +++ b/pallets/balances/src/imbalances.rs @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::traits::CommonConfig; +use crate::BlockRewardConfig; use core::marker::PhantomData; use frame_support::traits::{Imbalance, SameOrOther, TryDrop}; use polymesh_primitives::traits::BlockRewardsReserveCurrency; @@ -27,28 +27,28 @@ use sp_std::{mem, result}; /// Opaque, move-only struct with private fields that serves as a token denoting that /// funds have been created without any equal and opposite accounting. #[must_use] -pub struct PositiveImbalance(Balance, PhantomData); +pub struct PositiveImbalance(Balance, PhantomData); -impl Default for PositiveImbalance { +impl Default for PositiveImbalance { fn default() -> Self { Self::new(<_>::default()) } } -impl PositiveImbalance { +impl PositiveImbalance { /// Create a new positive imbalance from a balance. pub fn new(amount: Balance) -> Self { PositiveImbalance(amount, PhantomData) } } -impl TryDrop for PositiveImbalance { +impl TryDrop for PositiveImbalance { fn try_drop(self) -> result::Result<(), Self> { self.drop_zero() } } -impl Imbalance for PositiveImbalance { +impl Imbalance for PositiveImbalance { type Opposite = NegativeImbalance; fn zero() -> Self { @@ -101,7 +101,7 @@ impl Imbalance for PositiveImbalance { } } -impl Drop for PositiveImbalance { +impl Drop for PositiveImbalance { /// Basic drop handler will just square up the total issuance. fn drop(&mut self) { T::BlockRewardsReserve::drop_positive_imbalance(self.0); @@ -111,28 +111,28 @@ impl Drop for PositiveImbalance { /// Opaque, move-only struct with private fields that serves as a token denoting that /// funds have been destroyed without any equal and opposite accounting. #[must_use] -pub struct NegativeImbalance(Balance, PhantomData); +pub struct NegativeImbalance(Balance, PhantomData); -impl Default for NegativeImbalance { +impl Default for NegativeImbalance { fn default() -> Self { Self::new(<_>::default()) } } -impl NegativeImbalance { +impl NegativeImbalance { /// Create a new negative imbalance from a balance. pub fn new(amount: Balance) -> Self { NegativeImbalance(amount, PhantomData) } } -impl TryDrop for NegativeImbalance { +impl TryDrop for NegativeImbalance { fn try_drop(self) -> result::Result<(), Self> { self.drop_zero() } } -impl Imbalance for NegativeImbalance { +impl Imbalance for NegativeImbalance { type Opposite = PositiveImbalance; fn zero() -> Self { @@ -185,7 +185,7 @@ impl Imbalance for NegativeImbalance { } } -impl Drop for NegativeImbalance { +impl Drop for NegativeImbalance { /// Basic drop handler will just square up the total issuance. fn drop(&mut self) { T::BlockRewardsReserve::drop_negative_imbalance(self.0); diff --git a/pallets/balances/src/lib.rs b/pallets/balances/src/lib.rs index 80becfdfb7..c6d7144906 100644 --- a/pallets/balances/src/lib.rs +++ b/pallets/balances/src/lib.rs @@ -164,37 +164,206 @@ #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; -use codec::{Decode, Encode}; -use frame_support::traits::Get; +pub mod imbalances; +pub use imbalances::{NegativeImbalance, PositiveImbalance}; + +use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - decl_error, decl_module, decl_storage, ensure, + decl_error, decl_event, decl_module, decl_storage, + dispatch::{DispatchError, DispatchResult}, + ensure, traits::{ tokens::{fungible, BalanceStatus as Status, DepositConsequence, WithdrawConsequence}, - Currency, ExistenceRequirement, Imbalance, LockIdentifier, LockableCurrency, - ReservableCurrency, SignedImbalance, StoredMap, WithdrawReasons, + Currency, ExistenceRequirement, Get, Imbalance, LockIdentifier, LockableCurrency, + OnUnbalanced, ReservableCurrency, SignedImbalance, StoredMap, WithdrawReasons, }, + weights::Weight, StorageValue, }; use frame_system::{self as system, ensure_root, ensure_signed}; -pub use polymesh_common_utilities::traits::balances::WeightInfo; -use polymesh_common_utilities::traits::{ - balances::{AccountData, RawEvent, Reasons}, - NegativeImbalance, PositiveImbalance, -}; use polymesh_primitives::traits::{BlockRewardsReserveCurrency, CheckCdd, IdentityFnTrait}; -use polymesh_primitives::{Balance, Memo, SystematicIssuers, GC_DID}; +use polymesh_primitives::{Balance, IdentityId, Memo, SystematicIssuers, GC_DID}; use scale_info::TypeInfo; use sp_runtime::{ traits::{AccountIdConversion, StaticLookup, Zero}, - DispatchError, DispatchResult, RuntimeDebug, + RuntimeDebug, }; +use sp_std::ops::BitOr; use sp_std::{cmp, mem, prelude::*, result}; -pub use polymesh_common_utilities::traits::balances::{Config, LockableCurrencyExt}; - -pub type Event = polymesh_common_utilities::traits::balances::Event; type CallPermissions = pallet_permissions::Module; +pub trait BlockRewardConfig: Sized { + type BlockRewardsReserve: BlockRewardsReserveCurrency>; +} + +// POLYMESH-NOTE: Make `AccountData` public to access it from the outside module. +/// All balance information for an account. +#[derive( + Encode, + Decode, + Clone, + PartialEq, + Eq, + Default, + RuntimeDebug, + MaxEncodedLen, + TypeInfo +)] +pub struct AccountData { + /// Non-reserved part of the balance. There may still be restrictions on this, but it is the + /// total pool what may in principle be transferred, reserved and used for tipping. + /// + /// This is the only balance that matters in terms of most operations on tokens. It + /// alone is used to determine the balance when in the contract execution environment. + pub free: Balance, + /// Balance which is reserved and may not be used at all. + /// + /// This can still get slashed, but gets slashed last of all. + /// + /// This balance is a 'reserve' balance that other subsystems use in order to set aside tokens + /// that are still 'owned' by the account holder, but which are suspendable. + pub reserved: Balance, + /// The amount that `free` may not drop below when withdrawing for *anything except transaction + /// fee payment*. + pub misc_frozen: Balance, + /// The amount that `free` may not drop below when withdrawing specifically for transaction + /// fee payment. + pub fee_frozen: Balance, +} + +impl AccountData { + /// How much this account's balance can be reduced for the given `reasons`. + pub fn usable(&self, reasons: Reasons) -> Balance { + self.free.saturating_sub(self.frozen(reasons)) + } + /// The amount that this account's free balance may not be reduced beyond for the given + /// `reasons`. + pub fn frozen(&self, reasons: Reasons) -> Balance { + match reasons { + Reasons::All => self.misc_frozen.max(self.fee_frozen), + Reasons::Misc => self.misc_frozen, + Reasons::Fee => self.fee_frozen, + } + } + /// The total balance in this account including any that is reserved and ignoring any frozen. + pub fn total(&self) -> Balance { + self.free.saturating_add(self.reserved) + } +} + +/// Simplified reasons for withdrawing balance. +#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] +#[allow(clippy::unnecessary_cast)] +pub enum Reasons { + /// Paying system transaction fees. + Fee = 0, + /// Any reason other than paying system transaction fees. + Misc = 1, + /// Any reason at all. + All = 2, +} + +impl From for Reasons { + fn from(r: WithdrawReasons) -> Reasons { + if r == WithdrawReasons::TRANSACTION_PAYMENT { + Reasons::Fee + } else if r.contains(WithdrawReasons::TRANSACTION_PAYMENT) { + Reasons::All + } else { + Reasons::Misc + } + } +} + +impl BitOr for Reasons { + type Output = Reasons; + fn bitor(self, other: Reasons) -> Reasons { + if self == other { + return self; + } + Reasons::All + } +} + +decl_event!( + pub enum Event where + ::AccountId + { + /// An account was created with some free balance. \[did, account, free_balance] + Endowed(Option, AccountId, Balance), + /// Transfer succeeded (from_did, from, to_did, to, value, memo). + Transfer(Option, AccountId, Option, AccountId, Balance, Option), + /// A balance was set by root (did, who, free, reserved). + BalanceSet(IdentityId, AccountId, Balance, Balance), + /// The account and the amount of unlocked balance of that account that was burned. + /// (caller Id, caller account, amount) + AccountBalanceBurned(IdentityId, AccountId, Balance), + /// Some balance was reserved (moved from free to reserved). \[who, value] + Reserved(AccountId, Balance), + /// Some balance was unreserved (moved from reserved to free). \[who, value] + Unreserved(AccountId, Balance), + /// Some balance was moved from the reserve of the first account to the second account. + /// Final argument indicates the destination balance type. + /// \[from, to, balance, destination_status] + ReserveRepatriated(AccountId, AccountId, Balance, Status), + } +); + +pub trait WeightInfo { + fn transfer() -> Weight; + fn transfer_with_memo() -> Weight; + fn deposit_block_reward_reserve_balance() -> Weight; + fn set_balance() -> Weight; + fn force_transfer() -> Weight; + fn burn_account_balance() -> Weight; +} + +pub trait Config: BlockRewardConfig + pallet_identity::Config { + /// The means of storing the balances of an account. + type AccountStore: StoredMap; + + /// Handler for the unbalanced reduction when removing a dust account. + type DustRemoval: OnUnbalanced>; + + /// The overarching event type. + type RuntimeEvent: From> + Into<::RuntimeEvent>; + + /// This type is no longer needed but kept for compatibility reasons. + /// The minimum amount required to keep an account open. + type ExistentialDeposit: Get; + + /// Used to check if an account is linked to a CDD'd identity + type CddChecker: CheckCdd; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; + + /// The maximum number of locks that should exist on an account. + /// Not strictly enforced, but used for weight estimation. + type MaxLocks: Get; +} + +/// Additional functionality atop `LockableCurrency` allowing a local, +/// per-id, stacking layer atop the overlay. +pub trait LockableCurrencyExt: LockableCurrency { + /// Reduce the locked amount under `id` for `who`. + /// If less than `amount` was locked, then `InsufficientBalance` is raised. + /// If the whole locked amount is reduced, then the lock is removed. + fn reduce_lock(id: LockIdentifier, who: &AccountId, amount: Balance) -> DispatchResult; + + /// Increase the locked amount under `id` for `who` or raises `Overflow`. + /// If there's no lock already, it will be made, unless `amount.is_zero()`. + /// Before committing to storage, `check_sum` is called with the lock total, + /// allowing the transaction to be aborted. + fn increase_lock( + id: LockIdentifier, + who: &AccountId, + amount: Balance, + reasons: WithdrawReasons, + check_sum: impl FnOnce(Balance) -> DispatchResult, + ) -> DispatchResult; +} decl_error! { pub enum Error for Module { /// Account liquidity restrictions prevent withdrawal diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index 9792ec01fd..b4cc62160f 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -16,4 +16,4 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod traits; -pub use traits::{asset, balances, CommonConfig}; +pub use traits::asset; diff --git a/pallets/common/src/traits/balances.rs b/pallets/common/src/traits/balances.rs deleted file mode 100644 index 12cfde3cda..0000000000 --- a/pallets/common/src/traits/balances.rs +++ /dev/null @@ -1,198 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use crate::traits::{CommonConfig, NegativeImbalance}; -use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::{ - decl_event, - dispatch::DispatchResult, - traits::{ - BalanceStatus as Status, Get, LockIdentifier, LockableCurrency, OnUnbalanced, StoredMap, - WithdrawReasons, - }, - weights::Weight, -}; -use polymesh_primitives::{traits::CheckCdd, Balance, IdentityId, Memo}; -use scale_info::TypeInfo; -use sp_runtime::RuntimeDebug; -use sp_std::ops::BitOr; - -// POLYMESH-NOTE: Make `AccountData` public to access it from the outside module. -/// All balance information for an account. -#[derive( - Encode, - Decode, - Clone, - PartialEq, - Eq, - Default, - RuntimeDebug, - MaxEncodedLen, - TypeInfo -)] -pub struct AccountData { - /// Non-reserved part of the balance. There may still be restrictions on this, but it is the - /// total pool what may in principle be transferred, reserved and used for tipping. - /// - /// This is the only balance that matters in terms of most operations on tokens. It - /// alone is used to determine the balance when in the contract execution environment. - pub free: Balance, - /// Balance which is reserved and may not be used at all. - /// - /// This can still get slashed, but gets slashed last of all. - /// - /// This balance is a 'reserve' balance that other subsystems use in order to set aside tokens - /// that are still 'owned' by the account holder, but which are suspendable. - pub reserved: Balance, - /// The amount that `free` may not drop below when withdrawing for *anything except transaction - /// fee payment*. - pub misc_frozen: Balance, - /// The amount that `free` may not drop below when withdrawing specifically for transaction - /// fee payment. - pub fee_frozen: Balance, -} - -impl AccountData { - /// How much this account's balance can be reduced for the given `reasons`. - pub fn usable(&self, reasons: Reasons) -> Balance { - self.free.saturating_sub(self.frozen(reasons)) - } - /// The amount that this account's free balance may not be reduced beyond for the given - /// `reasons`. - pub fn frozen(&self, reasons: Reasons) -> Balance { - match reasons { - Reasons::All => self.misc_frozen.max(self.fee_frozen), - Reasons::Misc => self.misc_frozen, - Reasons::Fee => self.fee_frozen, - } - } - /// The total balance in this account including any that is reserved and ignoring any frozen. - pub fn total(&self) -> Balance { - self.free.saturating_add(self.reserved) - } -} - -/// Simplified reasons for withdrawing balance. -#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] -#[allow(clippy::unnecessary_cast)] -pub enum Reasons { - /// Paying system transaction fees. - Fee = 0, - /// Any reason other than paying system transaction fees. - Misc = 1, - /// Any reason at all. - All = 2, -} - -impl From for Reasons { - fn from(r: WithdrawReasons) -> Reasons { - if r == WithdrawReasons::TRANSACTION_PAYMENT { - Reasons::Fee - } else if r.contains(WithdrawReasons::TRANSACTION_PAYMENT) { - Reasons::All - } else { - Reasons::Misc - } - } -} - -impl BitOr for Reasons { - type Output = Reasons; - fn bitor(self, other: Reasons) -> Reasons { - if self == other { - return self; - } - Reasons::All - } -} - -decl_event!( - pub enum Event where - ::AccountId - { - /// An account was created with some free balance. \[did, account, free_balance] - Endowed(Option, AccountId, Balance), - /// Transfer succeeded (from_did, from, to_did, to, value, memo). - Transfer(Option, AccountId, Option, AccountId, Balance, Option), - /// A balance was set by root (did, who, free, reserved). - BalanceSet(IdentityId, AccountId, Balance, Balance), - /// The account and the amount of unlocked balance of that account that was burned. - /// (caller Id, caller account, amount) - AccountBalanceBurned(IdentityId, AccountId, Balance), - /// Some balance was reserved (moved from free to reserved). \[who, value] - Reserved(AccountId, Balance), - /// Some balance was unreserved (moved from reserved to free). \[who, value] - Unreserved(AccountId, Balance), - /// Some balance was moved from the reserve of the first account to the second account. - /// Final argument indicates the destination balance type. - /// \[from, to, balance, destination_status] - ReserveRepatriated(AccountId, AccountId, Balance, Status), - } -); - -pub trait WeightInfo { - fn transfer() -> Weight; - fn transfer_with_memo() -> Weight; - fn deposit_block_reward_reserve_balance() -> Weight; - fn set_balance() -> Weight; - fn force_transfer() -> Weight; - fn burn_account_balance() -> Weight; -} - -pub trait Config: CommonConfig + pallet_identity::Config { - /// The means of storing the balances of an account. - type AccountStore: StoredMap; - - /// Handler for the unbalanced reduction when removing a dust account. - type DustRemoval: OnUnbalanced>; - - /// The overarching event type. - type RuntimeEvent: From> + Into<::RuntimeEvent>; - - /// This type is no longer needed but kept for compatibility reasons. - /// The minimum amount required to keep an account open. - type ExistentialDeposit: Get; - - /// Used to check if an account is linked to a CDD'd identity - type CddChecker: CheckCdd; - - /// Weight information for extrinsics in this pallet. - type WeightInfo: WeightInfo; - - /// The maximum number of locks that should exist on an account. - /// Not strictly enforced, but used for weight estimation. - type MaxLocks: Get; -} - -/// Additional functionality atop `LockableCurrency` allowing a local, -/// per-id, stacking layer atop the overlay. -pub trait LockableCurrencyExt: LockableCurrency { - /// Reduce the locked amount under `id` for `who`. - /// If less than `amount` was locked, then `InsufficientBalance` is raised. - /// If the whole locked amount is reduced, then the lock is removed. - fn reduce_lock(id: LockIdentifier, who: &AccountId, amount: Balance) -> DispatchResult; - - /// Increase the locked amount under `id` for `who` or raises `Overflow`. - /// If there's no lock already, it will be made, unless `amount.is_zero()`. - /// Before committing to storage, `check_sum` is called with the lock total, - /// allowing the transaction to be aborted. - fn increase_lock( - id: LockIdentifier, - who: &AccountId, - amount: Balance, - reasons: WithdrawReasons, - check_sum: impl FnOnce(Balance) -> DispatchResult, - ) -> DispatchResult; -} diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index f62576962a..e04d07792e 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -13,15 +13,5 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use polymesh_primitives::traits::BlockRewardsReserveCurrency; - -pub trait CommonConfig: Sized { - type BlockRewardsReserve: BlockRewardsReserveCurrency>; -} - -pub mod imbalances; -pub use imbalances::{NegativeImbalance, PositiveImbalance}; - pub mod asset; -pub mod balances; pub mod checkpoint; diff --git a/pallets/pips/Cargo.toml b/pallets/pips/Cargo.toml index b46d83eafc..608328cf27 100644 --- a/pallets/pips/Cargo.toml +++ b/pallets/pips/Cargo.toml @@ -5,7 +5,6 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } polymesh-primitives-derive = { workspace = true, default-features = false } polymesh-runtime-common = { workspace = true, default-features = false } @@ -60,7 +59,6 @@ std = [ "pallet-identity/std", "pallet-timestamp/std", "pallet-treasury/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "polymesh-runtime-common/std", "serde/std", diff --git a/pallets/pips/src/lib.rs b/pallets/pips/src/lib.rs index 5a8893e91e..0b92a645a7 100644 --- a/pallets/pips/src/lib.rs +++ b/pallets/pips/src/lib.rs @@ -106,9 +106,9 @@ use sp_std::convert::From; use sp_std::vec::Vec; use sp_version::RuntimeVersion; +use pallet_balances::LockableCurrencyExt; use pallet_base::{ensure_opt_string_limited, try_next_post}; use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; -use polymesh_common_utilities::traits::balances::LockableCurrencyExt; use polymesh_primitives::constants::PIP_MAX_REPORTING_SIZE; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::traits::group::GroupTrait; diff --git a/pallets/runtime/common/src/runtime.rs b/pallets/runtime/common/src/runtime.rs index 6374a2e188..c87f1f9a91 100644 --- a/pallets/runtime/common/src/runtime.rs +++ b/pallets/runtime/common/src/runtime.rs @@ -91,7 +91,7 @@ macro_rules! misc_pallet_impls { /// What to do if an account is fully reaped from the system. type OnKilledAccount = (); /// The data to be stored in an account. - type AccountData = polymesh_common_utilities::traits::balances::AccountData; + type AccountData = pallet_balances::AccountData; type SystemWeightInfo = polymesh_weights::frame_system::SubstrateWeight; type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; @@ -177,7 +177,7 @@ macro_rules! misc_pallet_impls { type WeightToFeeConst = polymesh_runtime_common::WeightToFee; } - impl polymesh_common_utilities::traits::CommonConfig for Runtime { + impl pallet_balances::BlockRewardConfig for Runtime { type BlockRewardsReserve = pallet_balances::Pallet; } diff --git a/pallets/runtime/tests/src/balances_test.rs b/pallets/runtime/tests/src/balances_test.rs index 67de91cb70..19e55bae2c 100644 --- a/pallets/runtime/tests/src/balances_test.rs +++ b/pallets/runtime/tests/src/balances_test.rs @@ -2,9 +2,8 @@ use super::{ storage::{register_keyring_account, EventTest, TestStorage}, ExtBuilder, }; -use pallet_balances as balances; +use pallet_balances::{self as balances, RawEvent as BalancesRawEvent}; use pallet_identity as identity; -use polymesh_common_utilities::traits::balances::RawEvent as BalancesRawEvent; use polymesh_runtime_develop::{runtime, Runtime}; use frame_support::{ diff --git a/pallets/runtime/tests/src/staking/mock.rs b/pallets/runtime/tests/src/staking/mock.rs index 2e185e6eda..cd4a3dd6c0 100644 --- a/pallets/runtime/tests/src/staking/mock.rs +++ b/pallets/runtime/tests/src/staking/mock.rs @@ -39,10 +39,10 @@ use sp_runtime::{KeyTypeId, Perbill}; use sp_staking::offence::{DisableStrategy, OffenceDetails, OnOffenceHandler}; use sp_staking::{EraIndex, SessionIndex}; +use pallet_balances::AccountData; +use pallet_balances::BlockRewardConfig; use pallet_staking::types::SlashingSwitch; use pallet_staking::{self as pallet_staking, *}; -use polymesh_common_utilities::traits::balances::AccountData; -use polymesh_common_utilities::traits::CommonConfig; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::currency::POLY; use polymesh_primitives::identity_id::GenesisIdentityRecord; @@ -190,7 +190,7 @@ impl pallet_base::Config for Test { type MaxLen = MaxLen; } -impl CommonConfig for Test { +impl BlockRewardConfig for Test { type BlockRewardsReserve = pallet_balances::Module; } diff --git a/pallets/treasury/Cargo.toml b/pallets/treasury/Cargo.toml index 8c6946b8b0..9622035f7c 100644 --- a/pallets/treasury/Cargo.toml +++ b/pallets/treasury/Cargo.toml @@ -5,7 +5,6 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } @@ -48,7 +47,6 @@ std = [ "sp-api/std", "frame-system/std", "frame-support/std", - "polymesh-common-utilities/std", "pallet-balances/std", "polymesh-primitives/std", "pallet-identity/std", @@ -56,5 +54,4 @@ std = [ runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks", ] diff --git a/pallets/treasury/src/lib.rs b/pallets/treasury/src/lib.rs index 187fab69db..a171ae5c2a 100644 --- a/pallets/treasury/src/lib.rs +++ b/pallets/treasury/src/lib.rs @@ -45,8 +45,8 @@ use frame_support::{ weights::Weight, }; use frame_system::ensure_root; +use pallet_balances::Config as BalancesConfig; use pallet_identity as identity; -use polymesh_common_utilities::traits::balances::Config as BalancesConfig; use polymesh_primitives::{constants::TREASURY_PALLET_ID, Beneficiary, IdentityId, GC_DID}; use sp_runtime::traits::{AccountIdConversion, Saturating}; use sp_std::prelude::*; diff --git a/pallets/utility/Cargo.toml b/pallets/utility/Cargo.toml index cb655300f8..b8be8e126d 100644 --- a/pallets/utility/Cargo.toml +++ b/pallets/utility/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" # Out Pallets pallet-balances = { workspace = true, default-features = false } pallet-permissions = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } @@ -35,7 +34,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "pallet-balances/std", "pallet-identity/std", @@ -45,6 +43,5 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "polymesh-common-utilities/runtime-benchmarks", ] try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/utility/src/lib.rs b/pallets/utility/src/lib.rs index 81e6e816c5..5009ec2011 100644 --- a/pallets/utility/src/lib.rs +++ b/pallets/utility/src/lib.rs @@ -84,9 +84,9 @@ use sp_runtime::traits::{BadOrigin, Dispatchable}; use sp_runtime::{traits::Verify, DispatchError, RuntimeDebug}; use sp_std::prelude::*; +use pallet_balances::Config as BalancesConfig; use pallet_identity::{Config as IdentityConfig, Context}; use pallet_permissions::with_call_metadata; -use polymesh_common_utilities::balances::Config as BalancesConfig; use polymesh_primitives::{identity::AuthorizationNonce, traits::CheckCdd, IdentityId}; type Identity = pallet_identity::Module; From 994ec25b3c4f6ffea54675ec5eca03c9160d5f66 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 20:40:26 +0800 Subject: [PATCH 34/45] Remove some unused deps. --- Cargo.lock | 8 -------- pallets/common/Cargo.toml | 8 -------- pallets/group/rpc/runtime-api/Cargo.toml | 2 -- pallets/runtime/common/Cargo.toml | 3 --- pallets/runtime/develop/Cargo.toml | 3 --- pallets/runtime/mainnet/Cargo.toml | 2 -- pallets/runtime/testnet/Cargo.toml | 2 -- 7 files changed, 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c5e49ca59..405f30bc03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5133,7 +5133,6 @@ name = "pallet-group-rpc-runtime-api" version = "2.0.0" dependencies = [ "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "serde", "sp-api", @@ -6245,10 +6244,7 @@ dependencies = [ "frame-support", "frame-system", "lazy_static", - "pallet-base", "pallet-external-agents", - "pallet-identity", - "pallet-permissions", "pallet-portfolio", "pallet-statistics", "pallet-timestamp", @@ -6388,7 +6384,6 @@ dependencies = [ "pallet-multisig", "pallet-relayer", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "smallvec", "sp-io", @@ -6457,7 +6452,6 @@ dependencies = [ "pallet-utility", "parity-scale-codec 3.6.9", "polymesh-build-tool", - "polymesh-common-utilities", "polymesh-contracts", "polymesh-primitives", "polymesh-runtime-common", @@ -6540,7 +6534,6 @@ dependencies = [ "pallet-utility", "parity-scale-codec 3.6.9", "polymesh-build-tool", - "polymesh-common-utilities", "polymesh-contracts", "polymesh-primitives", "polymesh-runtime-common", @@ -6625,7 +6618,6 @@ dependencies = [ "pallet-utility", "parity-scale-codec 3.6.9", "polymesh-build-tool", - "polymesh-common-utilities", "polymesh-contracts", "polymesh-primitives", "polymesh-runtime-common", diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml index 4e4f52adaf..0d711a5231 100644 --- a/pallets/common/Cargo.toml +++ b/pallets/common/Cargo.toml @@ -9,9 +9,6 @@ polymesh-primitives = { workspace = true, default-features = false } polymesh-primitives-derive = { workspace = true, default-features = false } # Our Pallets -pallet-base = { workspace = true, default-features = false } -pallet-permissions = { workspace = true, default-features = false } -pallet-identity = { workspace = true, default-features = false } pallet-external-agents = { workspace = true, default-features = false } pallet-portfolio = { workspace = true, default-features = false } pallet-statistics = { workspace = true, default-features = false } @@ -58,9 +55,6 @@ std = [ "frame-support/std", "frame-system/std", "pallet-timestamp/std", - "pallet-base/std", - "pallet-permissions/std", - "pallet-identity/std", "pallet-external-agents/std", "pallet-portfolio/std", "pallet-statistics/std", @@ -76,8 +70,6 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking", - "pallet-permissions/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", "pallet-external-agents/runtime-benchmarks", "pallet-portfolio/runtime-benchmarks", "pallet-statistics/runtime-benchmarks", diff --git a/pallets/group/rpc/runtime-api/Cargo.toml b/pallets/group/rpc/runtime-api/Cargo.toml index d2b85d471e..aed64f03e0 100644 --- a/pallets/group/rpc/runtime-api/Cargo.toml +++ b/pallets/group/rpc/runtime-api/Cargo.toml @@ -10,7 +10,6 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # Common polymesh-primitives = { workspace = true, default-features = false} -polymesh-common-utilities = { workspace = true, default-features = false } # Others serde = { version = "1.0.104", optional = true, features = ["derive"] } @@ -28,5 +27,4 @@ std = [ "codec/std", "sp-std/std", "polymesh-primitives/std", - "polymesh-common-utilities/std" ] diff --git a/pallets/runtime/common/Cargo.toml b/pallets/runtime/common/Cargo.toml index 003ca2233b..b18a174e6b 100644 --- a/pallets/runtime/common/Cargo.toml +++ b/pallets/runtime/common/Cargo.toml @@ -5,7 +5,6 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } pallet-balances = { workspace = true, default-features = false } @@ -45,7 +44,6 @@ std = [ "pallet-group-rpc-runtime-api/std", "pallet-identity/std", "pallet-multisig/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "sp-runtime/std", "sp-std/std", @@ -59,7 +57,6 @@ runtime-benchmarks = [ "pallet-identity/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-relayer/runtime-benchmarks", - "polymesh-common-utilities/runtime-benchmarks", "polymesh-primitives/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", diff --git a/pallets/runtime/develop/Cargo.toml b/pallets/runtime/develop/Cargo.toml index e2eee56160..18a531095b 100644 --- a/pallets/runtime/develop/Cargo.toml +++ b/pallets/runtime/develop/Cargo.toml @@ -9,7 +9,6 @@ build = "build.rs" [dependencies] # Common -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-runtime-common = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } polymesh-weights = { workspace = true, default-features = false } @@ -175,7 +174,6 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "pallet-utility/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "polymesh-runtime-common/std", "polymesh-weights/std", @@ -234,7 +232,6 @@ runtime-benchmarks = [ "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-staking/runtime-benchmarks", - "polymesh-common-utilities/runtime-benchmarks", "polymesh-contracts/runtime-benchmarks", "polymesh-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", diff --git a/pallets/runtime/mainnet/Cargo.toml b/pallets/runtime/mainnet/Cargo.toml index ef04d74d2c..37897f64e5 100644 --- a/pallets/runtime/mainnet/Cargo.toml +++ b/pallets/runtime/mainnet/Cargo.toml @@ -9,7 +9,6 @@ build = "build.rs" [dependencies] # Common -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } polymesh-runtime-common = { workspace = true, default-features = false} polymesh-weights = { workspace = true, default-features = false } @@ -162,7 +161,6 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "pallet-utility/std", - "polymesh-common-utilities/std", "polymesh-contracts/std", "polymesh-primitives/std", "polymesh-runtime-common/std", diff --git a/pallets/runtime/testnet/Cargo.toml b/pallets/runtime/testnet/Cargo.toml index 41f0ca1943..20a701d1f3 100644 --- a/pallets/runtime/testnet/Cargo.toml +++ b/pallets/runtime/testnet/Cargo.toml @@ -9,7 +9,6 @@ build = "build.rs" [dependencies] # Common -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-runtime-common = { workspace = true, default-features = false} polymesh-primitives = { workspace = true, default-features = false } polymesh-weights = { workspace = true, default-features = false } @@ -165,7 +164,6 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "pallet-utility/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "polymesh-runtime-common/std", "polymesh-weights/std", From 76a60e78156dbfe5e7124e18a6380751b687df08 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 21:02:03 +0800 Subject: [PATCH 35/45] Move WeightInfo, Config, Event into Asset/Checkpoint pallet. --- Cargo.lock | 4 - pallets/asset/Cargo.toml | 3 - pallets/asset/src/checkpoint/mod.rs | 42 +++- pallets/asset/src/error.rs | 4 +- pallets/asset/src/lib.rs | 191 ++++++++++++++- pallets/common/src/lib.rs | 3 - pallets/common/src/traits/asset.rs | 220 ------------------ pallets/common/src/traits/mod.rs | 2 - pallets/corporate-actions/Cargo.toml | 2 - pallets/corporate-actions/src/lib.rs | 4 +- pallets/runtime/tests/Cargo.toml | 4 +- pallets/runtime/tests/src/asset_test.rs | 4 +- .../tests/src/corporate_actions_test.rs | 2 +- pallets/settlement/Cargo.toml | 2 - pallets/settlement/src/lib.rs | 3 +- .../traits => primitives/src}/checkpoint.rs | 41 +--- primitives/src/lib.rs | 3 + 17 files changed, 237 insertions(+), 297 deletions(-) delete mode 100644 pallets/common/src/traits/asset.rs rename {pallets/common/src/traits => primitives/src}/checkpoint.rs (78%) diff --git a/Cargo.lock b/Cargo.lock index 405f30bc03..9072a6356d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4719,7 +4719,6 @@ dependencies = [ "pallet-statistics", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "polymesh-primitives-derive", "polymesh-runtime-common", @@ -4990,7 +4989,6 @@ dependencies = [ "pallet-portfolio", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "polymesh-primitives-derive", "scale-info", @@ -5483,7 +5481,6 @@ dependencies = [ "pallet-scheduler", "pallet-timestamp", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-primitives", "polymesh-primitives-derive", "scale-info", @@ -6708,7 +6705,6 @@ dependencies = [ "pallet-utility", "parity-scale-codec 3.6.9", "parking_lot 0.12.1", - "polymesh-common-utilities", "polymesh-contracts", "polymesh-exec-macro", "polymesh-primitives", diff --git a/pallets/asset/Cargo.toml b/pallets/asset/Cargo.toml index 2de3e05107..7b5edd8aad 100644 --- a/pallets/asset/Cargo.toml +++ b/pallets/asset/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" # Common polymesh-primitives = { workspace = true, default-features = false } polymesh-primitives-derive = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets pallet-base = { workspace = true, default-features = false } @@ -57,7 +56,6 @@ std = [ "pallet-portfolio/std", "pallet-timestamp/std", "pallet-external-agents/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "polymesh-runtime-common/std", "rustc-hex/std", @@ -73,6 +71,5 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking", - "polymesh-common-utilities/runtime-benchmarks", "pallet-identity/runtime-benchmarks", ] diff --git a/pallets/asset/src/checkpoint/mod.rs b/pallets/asset/src/checkpoint/mod.rs index d1cb75a5ef..002ec54b5a 100644 --- a/pallets/asset/src/checkpoint/mod.rs +++ b/pallets/asset/src/checkpoint/mod.rs @@ -44,7 +44,7 @@ pub mod benchmarking; use codec::{Decode, Encode}; use frame_support::{ - decl_error, decl_module, decl_storage, + decl_error, decl_event, decl_module, decl_storage, dispatch::{DispatchError, DispatchResult}, ensure, traits::UnixTime, @@ -56,14 +56,11 @@ use sp_std::prelude::*; use sp_std::vec; use pallet_base::try_next_pre; -pub use polymesh_common_utilities::traits::checkpoint::{Event, WeightInfo}; -use polymesh_common_utilities::traits::checkpoint::{ - NextCheckpoints, ScheduleCheckpoints, ScheduleId, -}; -use polymesh_primitives::asset::AssetId; +use polymesh_primitives::asset::{AssetId, CheckpointId}; +use polymesh_primitives::checkpoint::{NextCheckpoints, ScheduleCheckpoints, ScheduleId}; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::GC_DID; -use polymesh_primitives::{asset::CheckpointId, storage_migration_ver, IdentityId, Moment}; +use polymesh_primitives::{storage_migration_ver, IdentityId, Moment}; use crate::Config; @@ -72,6 +69,37 @@ type ExternalAgents = pallet_external_agents::Module; storage_migration_ver!(2); +pub trait WeightInfo { + fn create_checkpoint() -> Weight; + fn set_schedules_max_complexity() -> Weight; + fn create_schedule() -> Weight; + fn remove_schedule() -> Weight; +} + +decl_event! { + pub enum Event { + /// A checkpoint was created. + /// + /// (caller DID, AssetId, checkpoint ID, total supply, checkpoint timestamp) + CheckpointCreated(Option, AssetId, CheckpointId, polymesh_primitives::Balance, Moment), + + /// The maximum complexity for an arbitrary asset's schedule set was changed. + /// + /// (GC DID, the new maximum) + MaximumSchedulesComplexityChanged(IdentityId, u64), + + /// A checkpoint schedule was created. + /// + /// (caller DID, AssetId, schedule id, schedule) + ScheduleCreated(IdentityId, AssetId, ScheduleId, ScheduleCheckpoints), + + /// A checkpoint schedule was removed. + /// + /// (caller DID, AssetId, schedule id, schedule) + ScheduleRemoved(IdentityId, AssetId, ScheduleId, ScheduleCheckpoints), + } +} + decl_storage! { trait Store for Module as Checkpoint { // --------------------- Supply / Balance storage ---------------------- diff --git a/pallets/asset/src/error.rs b/pallets/asset/src/error.rs index 782aa4408f..38c1d9338b 100644 --- a/pallets/asset/src/error.rs +++ b/pallets/asset/src/error.rs @@ -1,8 +1,6 @@ use frame_support::decl_error; -use polymesh_common_utilities::traits::asset::Config; - -use crate::Module; +use crate::{Config, Module}; decl_error! { pub enum Error for Module { diff --git a/pallets/asset/src/lib.rs b/pallets/asset/src/lib.rs index c4316393be..b36620207b 100644 --- a/pallets/asset/src/lib.rs +++ b/pallets/asset/src/lib.rs @@ -91,10 +91,10 @@ use codec::{Decode, Encode}; use core::mem; use currency::*; use frame_support::dispatch::{DispatchError, DispatchResult}; -use frame_support::traits::Get; +use frame_support::traits::{Currency, Get, UnixTime}; use frame_support::weights::Weight; use frame_support::BoundedBTreeSet; -use frame_support::{decl_module, decl_storage, ensure}; +use frame_support::{decl_event, decl_module, decl_storage, ensure}; use frame_system::ensure_root; use sp_io::hashing::blake2_128; use sp_runtime::traits::Zero; @@ -104,9 +104,9 @@ use sp_std::prelude::*; use pallet_base::{ ensure_opt_string_limited, ensure_string_limited, try_next_pre, Error::CounterOverflow, }; +use pallet_external_agents::Config as EAConfig; use pallet_identity::PermissionedCallOriginData; use pallet_portfolio::{Error as PortfolioError, PortfolioAssetBalances}; -pub use polymesh_common_utilities::traits::asset::{Config, Event, RawEvent, WeightInfo}; use polymesh_primitives::agent::AgentGroup; use polymesh_primitives::asset::{ AssetId, AssetName, AssetType, CheckpointId, CustomAssetTypeId, FundingRoundName, @@ -118,7 +118,7 @@ use polymesh_primitives::asset_metadata::{ use polymesh_primitives::constants::*; use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp}; use polymesh_primitives::settlement::InstructionId; -use polymesh_primitives::traits::{AssetFnTrait, ComplianceFnConfig, NFTTrait}; +use polymesh_primitives::traits::{AssetFnConfig, AssetFnTrait, ComplianceFnConfig, NFTTrait}; use polymesh_primitives::{ extract_auth, storage_migrate_on, storage_migration_ver, AssetIdentifier, Balance, Document, DocumentId, IdentityId, Memo, PortfolioId, PortfolioKind, PortfolioUpdateReason, SecondaryKey, @@ -139,6 +139,189 @@ type Statistics = pallet_statistics::Module; storage_migration_ver!(6); +/// The module's configuration trait. +pub trait Config: + EAConfig + pallet_statistics::Config + pallet_portfolio::Config + AssetFnConfig +{ + /// The overarching event type. + type RuntimeEvent: From> + + From + + Into<::RuntimeEvent>; + + type Currency: Currency; + + type ComplianceManager: ComplianceFnConfig; + + /// Time used in computation of checkpoints. + type UnixTime: UnixTime; + + /// Max length for the name of an asset. + type AssetNameMaxLength: Get; + + /// Max length of the funding round name. + type FundingRoundNameMaxLength: Get; + + /// Max length for the Asset Metadata type name. + type AssetMetadataNameMaxLength: Get; + + /// Max length for the Asset Metadata value. + type AssetMetadataValueMaxLength: Get; + + /// Max length for the Asset Metadata type definition. + type AssetMetadataTypeDefMaxLength: Get; + + type WeightInfo: WeightInfo; + + type CPWeightInfo: checkpoint::WeightInfo; + + type NFTFn: NFTTrait; + + /// Maximum number of mediators for an asset. + type MaxAssetMediators: Get; +} + +decl_event! { + pub enum Event + where + Moment = ::Moment, + { + /// Event for creation of the asset. + /// caller DID/ owner DID, AssetId, divisibility, asset type, beneficiary DID, asset name, identifiers, funding round + AssetCreated(IdentityId, AssetId, bool, AssetType, IdentityId, AssetName, Vec, Option), + /// Event emitted when any token identifiers are updated. + /// caller DID, AssetId, a vector of (identifier type, identifier value) + IdentifiersUpdated(IdentityId, AssetId, Vec), + /// Event for change in divisibility. + /// caller DID, AssetId, divisibility + DivisibilityChanged(IdentityId, AssetId, bool), + /// Emit when ticker is registered. + /// caller DID / ticker owner did, ticker, ticker owner, expiry + TickerRegistered(IdentityId, Ticker, Option), + /// Emit when ticker is transferred. + /// caller DID / ticker transferred to DID, ticker, from + TickerTransferred(IdentityId, Ticker, IdentityId), + /// Emit when token ownership is transferred. + /// caller DID / token ownership transferred to DID, AssetId, from + AssetOwnershipTransferred(IdentityId, AssetId, IdentityId), + /// An event emitted when an asset is frozen. + /// Parameter: caller DID, AssetId. + AssetFrozen(IdentityId, AssetId), + /// An event emitted when an asset is unfrozen. + /// Parameter: caller DID, AssetId. + AssetUnfrozen(IdentityId, AssetId), + /// An event emitted when a token is renamed. + /// Parameters: caller DID, AssetId, new token name. + AssetRenamed(IdentityId, AssetId, AssetName), + /// An event carrying the name of the current funding round of an asset. + /// Parameters: caller DID, AssetId, funding round name. + FundingRoundSet(IdentityId, AssetId, FundingRoundName), + /// A new document attached to an asset + DocumentAdded(IdentityId, AssetId, DocumentId, Document), + /// A document removed from an asset + DocumentRemoved(IdentityId, AssetId, DocumentId), + /// Event for when a forced transfer takes place. + /// caller DID/ controller DID, ExtensionRemoved, Portfolio of token holder, value. + ControllerTransfer(IdentityId, AssetId, PortfolioId, Balance), + /// A custom asset type already exists on-chain. + /// caller DID, the ID of the custom asset type, the string contents registered. + CustomAssetTypeExists(IdentityId, CustomAssetTypeId, Vec), + /// A custom asset type was registered on-chain. + /// caller DID, the ID of the custom asset type, the string contents registered. + CustomAssetTypeRegistered(IdentityId, CustomAssetTypeId, Vec), + /// Set asset metadata value. + /// (Caller DID, AssetId, metadata value, optional value details) + SetAssetMetadataValue(IdentityId, AssetId, AssetMetadataValue, Option>), + /// Set asset metadata value details (expire, lock status). + /// (Caller DID, AssetId, value details) + SetAssetMetadataValueDetails(IdentityId, AssetId, AssetMetadataValueDetail), + /// Register asset metadata local type. + /// (Caller DID, AssetId, Local type name, Local type key, type specs) + RegisterAssetMetadataLocalType(IdentityId, AssetId, AssetMetadataName, AssetMetadataLocalKey, AssetMetadataSpec), + /// Register asset metadata global type. + /// (Global type name, Global type key, type specs) + RegisterAssetMetadataGlobalType(AssetMetadataName, AssetMetadataGlobalKey, AssetMetadataSpec), + /// An event emitted when the type of an asset changed. + /// Parameters: caller DID, AssetId, new token type. + AssetTypeChanged(IdentityId, AssetId, AssetType), + /// An event emitted when a local metadata key has been removed. + /// Parameters: caller AssetId, Local type name + LocalMetadataKeyDeleted(IdentityId, AssetId, AssetMetadataLocalKey), + /// An event emitted when a local metadata value has been removed. + /// Parameters: caller AssetId, Local type name + MetadataValueDeleted(IdentityId, AssetId, AssetMetadataKey), + /// Emitted when Tokens were issued, redeemed or transferred. + /// Contains the [`IdentityId`] of the receiver/issuer/redeemer, the [`AssetId`] for the token, the balance that was issued/transferred/redeemed, + /// the [`PortfolioId`] of the source, the [`PortfolioId`] of the destination and the [`PortfolioUpdateReason`]. + AssetBalanceUpdated( + IdentityId, + AssetId, + Balance, + Option, + Option, + PortfolioUpdateReason, + ), + /// An asset has been added to the list of pre aprroved receivement (valid for all identities). + /// Parameters: [`AssetId`] of the pre approved asset. + AssetAffirmationExemption(AssetId), + /// An asset has been removed from the list of pre aprroved receivement (valid for all identities). + /// Parameters: [`AssetId`] of the asset. + RemoveAssetAffirmationExemption(AssetId), + /// An identity has added an asset to the list of pre aprroved receivement. + /// Parameters: [`IdentityId`] of caller, [`AssetId`] of the pre approved asset. + PreApprovedAsset(IdentityId, AssetId), + /// An identity has removed an asset to the list of pre aprroved receivement. + /// Parameters: [`IdentityId`] of caller, [`AssetId`] of the asset. + RemovePreApprovedAsset(IdentityId, AssetId), + /// An identity has added mandatory mediators to an asset. + /// Parameters: [`IdentityId`] of caller, [`AssetId`] of the asset, the identity of all mediators added. + AssetMediatorsAdded(IdentityId, AssetId, BTreeSet), + /// An identity has removed mediators from an asset. + /// Parameters: [`IdentityId`] of caller, [`AssetId`] of the asset, the identity of all mediators removed. + AssetMediatorsRemoved(IdentityId, AssetId, BTreeSet), + /// An identity has linked a ticker to an asset. + /// Parameters: [`IdentityId`] of caller, [`Ticker`] of the asset, the asset identifier [`AssetId`]. + TickerLinkedToAsset(IdentityId, Ticker, AssetId), + /// An identity has unlinked a ticker from an asset. + /// Parameters: [`IdentityId`] of caller, unlinked [`Ticker`], the asset identifier [`AssetId`]. + TickerUnlinkedFromAsset(IdentityId, Ticker, AssetId), + } +} + +pub trait WeightInfo { + fn register_unique_ticker() -> Weight; + fn accept_ticker_transfer() -> Weight; + fn accept_asset_ownership_transfer() -> Weight; + fn create_asset(n: u32, i: u32, f: u32) -> Weight; + fn freeze() -> Weight; + fn unfreeze() -> Weight; + fn rename_asset(n: u32) -> Weight; + fn issue() -> Weight; + fn redeem() -> Weight; + fn make_divisible() -> Weight; + fn add_documents(d: u32) -> Weight; + fn remove_documents(d: u32) -> Weight; + fn set_funding_round(f: u32) -> Weight; + fn update_identifiers(i: u32) -> Weight; + fn controller_transfer() -> Weight; + fn register_custom_asset_type(n: u32) -> Weight; + fn set_asset_metadata() -> Weight; + fn set_asset_metadata_details() -> Weight; + fn register_and_set_local_asset_metadata() -> Weight; + fn register_asset_metadata_local_type() -> Weight; + fn register_asset_metadata_global_type() -> Weight; + fn update_asset_type() -> Weight; + fn remove_local_metadata_key() -> Weight; + fn remove_metadata_value() -> Weight; + fn base_transfer() -> Weight; + fn exempt_asset_affirmation() -> Weight; + fn remove_asset_affirmation_exemption() -> Weight; + fn pre_approve_asset() -> Weight; + fn remove_asset_pre_approval() -> Weight; + fn add_mandatory_mediators(n: u32) -> Weight; + fn remove_mandatory_mediators(n: u32) -> Weight; + fn link_ticker_to_asset_id() -> Weight; + fn unlink_ticker_from_asset_id() -> Weight; +} decl_storage! { trait Store for Module as Asset { /// Maps each [`Ticker`] to its registration details ([`TickerRegistration`]). diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs index b4cc62160f..656e684df2 100644 --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -14,6 +14,3 @@ // along with this program. If not, see . #![cfg_attr(not(feature = "std"), no_std)] - -pub mod traits; -pub use traits::asset; diff --git a/pallets/common/src/traits/asset.rs b/pallets/common/src/traits/asset.rs deleted file mode 100644 index 4f61ef9f99..0000000000 --- a/pallets/common/src/traits/asset.rs +++ /dev/null @@ -1,220 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -use frame_support::decl_event; -use frame_support::traits::{Currency, Get, UnixTime}; -use frame_support::weights::Weight; -use sp_std::collections::btree_set::BTreeSet; -use sp_std::prelude::Vec; - -use pallet_external_agents::Config as EAConfig; -use polymesh_primitives::asset::{ - AssetId, AssetName, AssetType, CustomAssetTypeId, FundingRoundName, -}; -use polymesh_primitives::asset_metadata::{ - AssetMetadataGlobalKey, AssetMetadataKey, AssetMetadataLocalKey, AssetMetadataName, - AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, -}; -use polymesh_primitives::traits::{AssetFnConfig, ComplianceFnConfig, NFTTrait}; -use polymesh_primitives::{ - AssetIdentifier, Balance, Document, DocumentId, IdentityId, PortfolioId, PortfolioUpdateReason, - Ticker, -}; - -use crate::traits::checkpoint; - -/// The module's configuration trait. -pub trait Config: - EAConfig + pallet_statistics::Config + pallet_portfolio::Config + AssetFnConfig -{ - /// The overarching event type. - type RuntimeEvent: From> - + From - + Into<::RuntimeEvent>; - - type Currency: Currency; - - type ComplianceManager: ComplianceFnConfig; - - /// Time used in computation of checkpoints. - type UnixTime: UnixTime; - - /// Max length for the name of an asset. - type AssetNameMaxLength: Get; - - /// Max length of the funding round name. - type FundingRoundNameMaxLength: Get; - - /// Max length for the Asset Metadata type name. - type AssetMetadataNameMaxLength: Get; - - /// Max length for the Asset Metadata value. - type AssetMetadataValueMaxLength: Get; - - /// Max length for the Asset Metadata type definition. - type AssetMetadataTypeDefMaxLength: Get; - - type WeightInfo: WeightInfo; - - type CPWeightInfo: crate::traits::checkpoint::WeightInfo; - - type NFTFn: NFTTrait; - - /// Maximum number of mediators for an asset. - type MaxAssetMediators: Get; -} - -decl_event! { - pub enum Event - where - Moment = ::Moment, - { - /// Event for creation of the asset. - /// caller DID/ owner DID, AssetId, divisibility, asset type, beneficiary DID, asset name, identifiers, funding round - AssetCreated(IdentityId, AssetId, bool, AssetType, IdentityId, AssetName, Vec, Option), - /// Event emitted when any token identifiers are updated. - /// caller DID, AssetId, a vector of (identifier type, identifier value) - IdentifiersUpdated(IdentityId, AssetId, Vec), - /// Event for change in divisibility. - /// caller DID, AssetId, divisibility - DivisibilityChanged(IdentityId, AssetId, bool), - /// Emit when ticker is registered. - /// caller DID / ticker owner did, ticker, ticker owner, expiry - TickerRegistered(IdentityId, Ticker, Option), - /// Emit when ticker is transferred. - /// caller DID / ticker transferred to DID, ticker, from - TickerTransferred(IdentityId, Ticker, IdentityId), - /// Emit when token ownership is transferred. - /// caller DID / token ownership transferred to DID, AssetId, from - AssetOwnershipTransferred(IdentityId, AssetId, IdentityId), - /// An event emitted when an asset is frozen. - /// Parameter: caller DID, AssetId. - AssetFrozen(IdentityId, AssetId), - /// An event emitted when an asset is unfrozen. - /// Parameter: caller DID, AssetId. - AssetUnfrozen(IdentityId, AssetId), - /// An event emitted when a token is renamed. - /// Parameters: caller DID, AssetId, new token name. - AssetRenamed(IdentityId, AssetId, AssetName), - /// An event carrying the name of the current funding round of an asset. - /// Parameters: caller DID, AssetId, funding round name. - FundingRoundSet(IdentityId, AssetId, FundingRoundName), - /// A new document attached to an asset - DocumentAdded(IdentityId, AssetId, DocumentId, Document), - /// A document removed from an asset - DocumentRemoved(IdentityId, AssetId, DocumentId), - /// Event for when a forced transfer takes place. - /// caller DID/ controller DID, ExtensionRemoved, Portfolio of token holder, value. - ControllerTransfer(IdentityId, AssetId, PortfolioId, Balance), - /// A custom asset type already exists on-chain. - /// caller DID, the ID of the custom asset type, the string contents registered. - CustomAssetTypeExists(IdentityId, CustomAssetTypeId, Vec), - /// A custom asset type was registered on-chain. - /// caller DID, the ID of the custom asset type, the string contents registered. - CustomAssetTypeRegistered(IdentityId, CustomAssetTypeId, Vec), - /// Set asset metadata value. - /// (Caller DID, AssetId, metadata value, optional value details) - SetAssetMetadataValue(IdentityId, AssetId, AssetMetadataValue, Option>), - /// Set asset metadata value details (expire, lock status). - /// (Caller DID, AssetId, value details) - SetAssetMetadataValueDetails(IdentityId, AssetId, AssetMetadataValueDetail), - /// Register asset metadata local type. - /// (Caller DID, AssetId, Local type name, Local type key, type specs) - RegisterAssetMetadataLocalType(IdentityId, AssetId, AssetMetadataName, AssetMetadataLocalKey, AssetMetadataSpec), - /// Register asset metadata global type. - /// (Global type name, Global type key, type specs) - RegisterAssetMetadataGlobalType(AssetMetadataName, AssetMetadataGlobalKey, AssetMetadataSpec), - /// An event emitted when the type of an asset changed. - /// Parameters: caller DID, AssetId, new token type. - AssetTypeChanged(IdentityId, AssetId, AssetType), - /// An event emitted when a local metadata key has been removed. - /// Parameters: caller AssetId, Local type name - LocalMetadataKeyDeleted(IdentityId, AssetId, AssetMetadataLocalKey), - /// An event emitted when a local metadata value has been removed. - /// Parameters: caller AssetId, Local type name - MetadataValueDeleted(IdentityId, AssetId, AssetMetadataKey), - /// Emitted when Tokens were issued, redeemed or transferred. - /// Contains the [`IdentityId`] of the receiver/issuer/redeemer, the [`AssetId`] for the token, the balance that was issued/transferred/redeemed, - /// the [`PortfolioId`] of the source, the [`PortfolioId`] of the destination and the [`PortfolioUpdateReason`]. - AssetBalanceUpdated( - IdentityId, - AssetId, - Balance, - Option, - Option, - PortfolioUpdateReason, - ), - /// An asset has been added to the list of pre aprroved receivement (valid for all identities). - /// Parameters: [`AssetId`] of the pre approved asset. - AssetAffirmationExemption(AssetId), - /// An asset has been removed from the list of pre aprroved receivement (valid for all identities). - /// Parameters: [`AssetId`] of the asset. - RemoveAssetAffirmationExemption(AssetId), - /// An identity has added an asset to the list of pre aprroved receivement. - /// Parameters: [`IdentityId`] of caller, [`AssetId`] of the pre approved asset. - PreApprovedAsset(IdentityId, AssetId), - /// An identity has removed an asset to the list of pre aprroved receivement. - /// Parameters: [`IdentityId`] of caller, [`AssetId`] of the asset. - RemovePreApprovedAsset(IdentityId, AssetId), - /// An identity has added mandatory mediators to an asset. - /// Parameters: [`IdentityId`] of caller, [`AssetId`] of the asset, the identity of all mediators added. - AssetMediatorsAdded(IdentityId, AssetId, BTreeSet), - /// An identity has removed mediators from an asset. - /// Parameters: [`IdentityId`] of caller, [`AssetId`] of the asset, the identity of all mediators removed. - AssetMediatorsRemoved(IdentityId, AssetId, BTreeSet), - /// An identity has linked a ticker to an asset. - /// Parameters: [`IdentityId`] of caller, [`Ticker`] of the asset, the asset identifier [`AssetId`]. - TickerLinkedToAsset(IdentityId, Ticker, AssetId), - /// An identity has unlinked a ticker from an asset. - /// Parameters: [`IdentityId`] of caller, unlinked [`Ticker`], the asset identifier [`AssetId`]. - TickerUnlinkedFromAsset(IdentityId, Ticker, AssetId), - } -} - -pub trait WeightInfo { - fn register_unique_ticker() -> Weight; - fn accept_ticker_transfer() -> Weight; - fn accept_asset_ownership_transfer() -> Weight; - fn create_asset(n: u32, i: u32, f: u32) -> Weight; - fn freeze() -> Weight; - fn unfreeze() -> Weight; - fn rename_asset(n: u32) -> Weight; - fn issue() -> Weight; - fn redeem() -> Weight; - fn make_divisible() -> Weight; - fn add_documents(d: u32) -> Weight; - fn remove_documents(d: u32) -> Weight; - fn set_funding_round(f: u32) -> Weight; - fn update_identifiers(i: u32) -> Weight; - fn controller_transfer() -> Weight; - fn register_custom_asset_type(n: u32) -> Weight; - fn set_asset_metadata() -> Weight; - fn set_asset_metadata_details() -> Weight; - fn register_and_set_local_asset_metadata() -> Weight; - fn register_asset_metadata_local_type() -> Weight; - fn register_asset_metadata_global_type() -> Weight; - fn update_asset_type() -> Weight; - fn remove_local_metadata_key() -> Weight; - fn remove_metadata_value() -> Weight; - fn base_transfer() -> Weight; - fn exempt_asset_affirmation() -> Weight; - fn remove_asset_affirmation_exemption() -> Weight; - fn pre_approve_asset() -> Weight; - fn remove_asset_pre_approval() -> Weight; - fn add_mandatory_mediators(n: u32) -> Weight; - fn remove_mandatory_mediators(n: u32) -> Weight; - fn link_ticker_to_asset_id() -> Weight; - fn unlink_ticker_from_asset_id() -> Weight; -} diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs index e04d07792e..dae32c8c57 100644 --- a/pallets/common/src/traits/mod.rs +++ b/pallets/common/src/traits/mod.rs @@ -13,5 +13,3 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -pub mod asset; -pub mod checkpoint; diff --git a/pallets/corporate-actions/Cargo.toml b/pallets/corporate-actions/Cargo.toml index d3287b0549..530147147e 100644 --- a/pallets/corporate-actions/Cargo.toml +++ b/pallets/corporate-actions/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" # Common polymesh-primitives = { workspace = true, default-features = false } polymesh-primitives-derive = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } # Our Pallets pallet-base = { workspace = true, default-features = false } @@ -52,7 +51,6 @@ std = [ "pallet-identity/std", "pallet-portfolio/std", "pallet-timestamp/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "serde/std", "serde_derive", diff --git a/pallets/corporate-actions/src/lib.rs b/pallets/corporate-actions/src/lib.rs index 3a301b9079..954b041b0f 100644 --- a/pallets/corporate-actions/src/lib.rs +++ b/pallets/corporate-actions/src/lib.rs @@ -104,8 +104,8 @@ use frame_system::ensure_root; use pallet_asset::checkpoint; use pallet_base::try_next_post; use pallet_identity::{Config as IdentityConfig, PermissionedCallOriginData}; -use polymesh_common_utilities::{traits::asset, traits::checkpoint::ScheduleId}; use polymesh_primitives::asset::AssetId; +use polymesh_primitives::checkpoint::ScheduleId; use polymesh_primitives::{ asset::CheckpointId, impl_checked_inc, storage_migration_ver, with_transaction, Balance, DocumentId, EventDid, IdentityId, Moment, PortfolioNumber, GC_DID, @@ -315,7 +315,7 @@ pub trait WeightInfo { } /// The module's configuration trait. -pub trait Config: frame_system::Config + IdentityConfig + asset::Config { +pub trait Config: frame_system::Config + IdentityConfig + pallet_asset::Config { /// The overarching event type. type RuntimeEvent: From + From diff --git a/pallets/runtime/tests/Cargo.toml b/pallets/runtime/tests/Cargo.toml index 6558185109..431219b810 100644 --- a/pallets/runtime/tests/Cargo.toml +++ b/pallets/runtime/tests/Cargo.toml @@ -34,7 +34,6 @@ pallet-sudo = { workspace = true, default-features = false } pallet-transaction-payment = { workspace = true, default-features = false } pallet-treasury = { workspace = true, default-features = false } pallet-utility = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-contracts = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } polymesh-runtime-common = { workspace = true, default-features = false, features = ["testing"] } @@ -108,7 +107,7 @@ sp-tracing = { version = "6.0.0", default-features = false, features = ["std"] } [features] default = ["std", "testing", "equalize"] -default_identity = [ "polymesh-common-utilities/default_identity" ] +default_identity = [] testing = [] equalize = [] @@ -160,7 +159,6 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "pallet-sudo/std", - "polymesh-common-utilities/std", "polymesh-primitives/std", "polymesh-runtime-common/std", "polymesh-contracts/std", diff --git a/pallets/runtime/tests/src/asset_test.rs b/pallets/runtime/tests/src/asset_test.rs index cd181b4719..ff3a219f14 100644 --- a/pallets/runtime/tests/src/asset_test.rs +++ b/pallets/runtime/tests/src/asset_test.rs @@ -22,9 +22,6 @@ use pallet_portfolio::{ NextPortfolioNumber, PortfolioAssetBalances, PortfolioAssetCount, PortfolioLockedAssets, }; use pallet_statistics::AssetStats; -use polymesh_common_utilities::traits::checkpoint::{ - NextCheckpoints, ScheduleCheckpoints, ScheduleId, -}; use polymesh_primitives::agent::AgentGroup; use polymesh_primitives::asset::{ AssetId, AssetName, AssetType, CheckpointId, CustomAssetTypeId, FundingRoundName, @@ -35,6 +32,7 @@ use polymesh_primitives::asset_metadata::{ AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail, }; use polymesh_primitives::calendar::{CalendarPeriod, CalendarUnit, FixedOrVariableCalendarUnit}; +use polymesh_primitives::checkpoint::{NextCheckpoints, ScheduleCheckpoints, ScheduleId}; use polymesh_primitives::constants::currency::ONE_UNIT; use polymesh_primitives::settlement::{ InstructionId, Leg, SettlementType, VenueDetails, VenueId, VenueType, diff --git a/pallets/runtime/tests/src/corporate_actions_test.rs b/pallets/runtime/tests/src/corporate_actions_test.rs index 9382524360..7d1e1891fc 100644 --- a/pallets/runtime/tests/src/corporate_actions_test.rs +++ b/pallets/runtime/tests/src/corporate_actions_test.rs @@ -20,8 +20,8 @@ use pallet_corporate_actions::{ TargetTreatment::{Exclude, Include}, Tax, }; -use polymesh_common_utilities::traits::checkpoint::{ScheduleCheckpoints, ScheduleId}; use polymesh_primitives::asset::AssetId; +use polymesh_primitives::checkpoint::{ScheduleCheckpoints, ScheduleId}; use polymesh_primitives::{ agent::AgentGroup, asset::CheckpointId, constants::currency::ONE_UNIT, AuthorizationData, Claim, ClaimType, Condition, ConditionType, CountryCode, Document, DocumentId, IdentityId, diff --git a/pallets/settlement/Cargo.toml b/pallets/settlement/Cargo.toml index 8a34acbfdd..b05fdb211a 100644 --- a/pallets/settlement/Cargo.toml +++ b/pallets/settlement/Cargo.toml @@ -5,7 +5,6 @@ authors = ["PolymeshAssociation"] edition = "2021" [dependencies] -polymesh-common-utilities = { workspace = true, default-features = false } pallet-base = { workspace = true, default-features = false } pallet-identity = { workspace = true, default-features = false } pallet-asset = { workspace = true, default-features = false } @@ -53,7 +52,6 @@ std = [ "pallet-identity/std", "pallet-timestamp/std", "pallet-permissions/std", - "polymesh-common-utilities/std", "pallet-compliance-manager/std", "polymesh-primitives/std", "serde/std", diff --git a/pallets/settlement/src/lib.rs b/pallets/settlement/src/lib.rs index ac7180f301..092501a980 100644 --- a/pallets/settlement/src/lib.rs +++ b/pallets/settlement/src/lib.rs @@ -70,7 +70,6 @@ use sp_std::vec; use pallet_asset::MandatoryMediators; use pallet_base::{ensure_string_limited, try_next_post}; -use polymesh_common_utilities::traits::asset; use polymesh_primitives::asset::AssetId; use polymesh_primitives::constants::queue_priority::SETTLEMENT_INSTRUCTION_EXECUTION_PRIORITY; use polymesh_primitives::settlement::{ @@ -400,7 +399,7 @@ pub trait WeightInfo { } pub trait Config: - asset::Config + pallet_asset::Config + frame_system::Config + pallet_compliance_manager::Config + frame_system::Config diff --git a/pallets/common/src/traits/checkpoint.rs b/primitives/src/checkpoint.rs similarity index 78% rename from pallets/common/src/traits/checkpoint.rs rename to primitives/src/checkpoint.rs index 2de92d7d5e..7a3cfa6c69 100644 --- a/pallets/common/src/traits/checkpoint.rs +++ b/primitives/src/checkpoint.rs @@ -1,14 +1,14 @@ +#![allow(missing_docs)] + use codec::{Decode, Encode}; -use frame_support::decl_event; -use frame_support::weights::Weight; -use polymesh_primitives::asset::AssetId; -use polymesh_primitives::calendar::{CalendarPeriod, CheckpointSchedule}; -use polymesh_primitives::{asset::CheckpointId, impl_checked_inc, Balance, IdentityId, Moment}; use scale_info::TypeInfo; use sp_std::collections::btree_map::BTreeMap; use sp_std::collections::btree_set::BTreeSet; use sp_std::prelude::Vec; +use crate::calendar::{CalendarPeriod, CheckpointSchedule}; +use crate::{impl_checked_inc, Moment}; + /// ID of a `StoredSchedule`. #[derive(Encode, Decode, TypeInfo)] #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Default)] @@ -181,34 +181,3 @@ impl NextCheckpoints { } } } - -pub trait WeightInfo { - fn create_checkpoint() -> Weight; - fn set_schedules_max_complexity() -> Weight; - fn create_schedule() -> Weight; - fn remove_schedule() -> Weight; -} - -decl_event! { - pub enum Event { - /// A checkpoint was created. - /// - /// (caller DID, AssetId, checkpoint ID, total supply, checkpoint timestamp) - CheckpointCreated(Option, AssetId, CheckpointId, Balance, Moment), - - /// The maximum complexity for an arbitrary asset's schedule set was changed. - /// - /// (GC DID, the new maximum) - MaximumSchedulesComplexityChanged(IdentityId, u64), - - /// A checkpoint schedule was created. - /// - /// (caller DID, AssetId, schedule id, schedule) - ScheduleCreated(IdentityId, AssetId, ScheduleId, ScheduleCheckpoints), - - /// A checkpoint schedule was removed. - /// - /// (caller DID, AssetId, schedule id, schedule) - ScheduleRemoved(IdentityId, AssetId, ScheduleId, ScheduleCheckpoints), - } -} diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 6eda7278a9..7ffb4d8bd9 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -218,6 +218,9 @@ pub use authorization::{Authorization, AuthorizationData, AuthorizationError, Au /// Pub Traits pub mod traits; +/// Checkpoint types. +pub mod checkpoint; + /// Benchmarking helpers. #[cfg(feature = "runtime-benchmarks")] pub mod bench; From c78705cba93935ad58936b7cdc56d9b0a37b5c96 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 21:37:25 +0800 Subject: [PATCH 36/45] Remove polymesh-common-utilities. --- Cargo.lock | 29 ------------ Cargo.toml | 6 +-- pallets/common/Cargo.toml | 77 -------------------------------- pallets/common/src/lib.rs | 16 ------- pallets/common/src/traits/mod.rs | 15 ------- 5 files changed, 1 insertion(+), 142 deletions(-) delete mode 100644 pallets/common/Cargo.toml delete mode 100644 pallets/common/src/lib.rs delete mode 100644 pallets/common/src/traits/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 9072a6356d..ad9f0ff0d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6177,7 +6177,6 @@ dependencies = [ "pallet-sudo", "pallet-transaction-payment", "parity-scale-codec 3.6.9", - "polymesh-common-utilities", "polymesh-contracts", "polymesh-node-rpc", "polymesh-primitives", @@ -6233,34 +6232,6 @@ dependencies = [ "substrate-wasm-builder", ] -[[package]] -name = "polymesh-common-utilities" -version = "0.1.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "lazy_static", - "pallet-external-agents", - "pallet-portfolio", - "pallet-statistics", - "pallet-timestamp", - "parity-scale-codec 3.6.9", - "polymesh-primitives", - "polymesh-primitives-derive", - "scale-info", - "schnorrkel 0.11.4", - "serde", - "serde_derive", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-std", -] - [[package]] name = "polymesh-contracts" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 8c1c9b2bbf..5e4d57e9db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,7 +109,6 @@ members = [ "pallets/base", "pallets/bridge", "pallets/committee", - "pallets/common", "pallets/compliance-manager", "pallets/contracts", "pallets/corporate-actions", @@ -185,7 +184,6 @@ pallet-sudo = { path = "pallets/sudo", default-features = false } polymesh-contracts = { path = "pallets/contracts", default-features = false } # Common -polymesh-common-utilities = { path = "pallets/common", default-features = false } polymesh-runtime-common = { path = "pallets/runtime/common", default-features = false } polymesh-primitives = { path = "primitives", default-features = false } polymesh-primitives-derive = { path = "primitives_derive", default-features = false } @@ -278,7 +276,6 @@ pallet-staking = { workspace = true, default-features = false } pallet-sudo = { workspace = true, default-features = false } pallet-transaction-payment = { workspace = true, default-features = false } polymesh-contracts = { workspace = true, default-features = false } -polymesh-common-utilities = { workspace = true, default-features = false } polymesh-primitives = { workspace = true, default-features = false } polymesh-runtime-common = { workspace = true, default-features = false } @@ -369,7 +366,7 @@ disable_fees = [ "polymesh-runtime-testnet/disable_fees", ] running-ci = [ "polymesh-runtime-develop/running-ci" ] -default_identity = [ "polymesh-common-utilities/default_identity" ] +default_identity = [] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks", @@ -381,6 +378,5 @@ runtime-benchmarks = [ ci-runtime = [ "polymesh-runtime-develop/ci-runtime" ] std = [ - "polymesh-common-utilities/std", "serde/std" ] diff --git a/pallets/common/Cargo.toml b/pallets/common/Cargo.toml deleted file mode 100644 index 0d711a5231..0000000000 --- a/pallets/common/Cargo.toml +++ /dev/null @@ -1,77 +0,0 @@ -[package] -name = "polymesh-common-utilities" -version = "0.1.0" -authors = ["PolymeshAssociation"] -edition = "2021" - -[dependencies] -polymesh-primitives = { workspace = true, default-features = false } -polymesh-primitives-derive = { workspace = true, default-features = false } - -# Our Pallets -pallet-external-agents = { workspace = true, default-features = false } -pallet-portfolio = { workspace = true, default-features = false } -pallet-statistics = { workspace = true, default-features = false } - -# Other -serde = { version = "1.0.112", default-features = false } -serde_derive = { version = "1.0.112", optional = true, default-features = false} - -# Substrate -codec = { workspace = true, default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false } -frame-system = { version = "4.0.0-dev", default-features = false } -pallet-timestamp = { version = "4.0.0-dev", default-features = false } -scale-info = { version = "2.0", default-features = false, features = ["derive"] } -sp-api = { version = "4.0.0-dev", default-features = false } -sp-arithmetic = { version = "6.0.0", default-features = false } -sp-core = { version = "7.0.0", default-features = false } -sp-io = { version = "7.0.0", default-features = false } -sp-runtime = { version = "7.0.0", default-features = false } -sp-std = { version = "5.0.0", default-features = false } - -# Benchmarks -frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true } -schnorrkel = { version = "0.11", default-features = false, optional = true } - -[dev-dependencies] -lazy_static = { version = "1.4.0", default-features = false } -sp-keyring = { version = "7.0.0" } - -[features] -default = ["std", "equalize"] - -# Backends -u32_backend = [] -u64_backend = [] - -equalize = [] -default_identity = [] -no_std = ["u64_backend"] -only-staking = [] -std = [ - "u64_backend", - "codec/std", - "frame-support/std", - "frame-system/std", - "pallet-timestamp/std", - "pallet-external-agents/std", - "pallet-portfolio/std", - "pallet-statistics/std", - "polymesh-primitives/std", - "serde/std", - "serde_derive", - "sp-api/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", -] -runtime-benchmarks = [ - "frame-benchmarking", - "pallet-external-agents/runtime-benchmarks", - "pallet-portfolio/runtime-benchmarks", - "pallet-statistics/runtime-benchmarks", - "schnorrkel", -] diff --git a/pallets/common/src/lib.rs b/pallets/common/src/lib.rs deleted file mode 100644 index 656e684df2..0000000000 --- a/pallets/common/src/lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#![cfg_attr(not(feature = "std"), no_std)] diff --git a/pallets/common/src/traits/mod.rs b/pallets/common/src/traits/mod.rs deleted file mode 100644 index dae32c8c57..0000000000 --- a/pallets/common/src/traits/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh). -// Copyright (c) 2020 Polymesh Association - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. - -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - From 9194831f8ff1133cc70a8d43a4333245e2f6bd9f Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 21:37:44 +0800 Subject: [PATCH 37/45] Bump polymesh-api deps. --- integration/Cargo.lock | 894 +++++++++++++++++++++++++++-------------- integration/Cargo.toml | 4 +- 2 files changed, 601 insertions(+), 297 deletions(-) diff --git a/integration/Cargo.lock b/integration/Cargo.lock index 614916bde5..3d5cb3ad51 100644 --- a/integration/Cargo.lock +++ b/integration/Cargo.lock @@ -23,11 +23,11 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ - "gimli 0.31.0", + "gimli 0.31.1", ] [[package]] @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "android-tzdata" @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.88" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "ark-bls12-377" @@ -258,9 +258,9 @@ checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" @@ -314,8 +314,8 @@ checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" dependencies = [ "async-task", "concurrent-queue", - "fastrand 2.1.1", - "futures-lite 2.3.0", + "fastrand 2.3.0", + "futures-lite 2.5.0", "slab", ] @@ -353,18 +353,18 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.4" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" +checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" dependencies = [ "async-lock 3.4.0", "cfg-if", "concurrent-queue", "futures-io", - "futures-lite 2.3.0", + "futures-lite 2.5.0", "parking", - "polling 3.7.3", - "rustix 0.38.37", + "polling 3.7.4", + "rustix 0.38.42", "slab", "tracing", "windows-sys 0.59.0", @@ -414,7 +414,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.37", + "rustix 0.38.42", "windows-sys 0.48.0", ] @@ -424,13 +424,13 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" dependencies = [ - "async-io 2.3.4", + "async-io 2.4.0", "async-lock 3.4.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.37", + "rustix 0.38.42", "signal-hook-registry", "slab", "windows-sys 0.59.0", @@ -438,9 +438,9 @@ dependencies = [ [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -449,13 +449,13 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -466,13 +466,13 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -509,9 +509,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" @@ -519,11 +519,11 @@ version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ - "addr2line 0.24.1", + "addr2line 0.24.2", "cfg-if", "libc", "miniz_oxide", - "object 0.36.4", + "object 0.36.5", "rustc-demangle", "windows-targets 0.52.6", ] @@ -572,9 +572,9 @@ dependencies = [ [[package]] name = "bip39" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" +checksum = "33415e24172c1b7d6066f6d999545375ab8e1d95421d6784bdfff9496f292387" dependencies = [ "bitcoin_hashes", "rand 0.8.5", @@ -583,11 +583,21 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "bitcoin-internals" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" + [[package]] name = "bitcoin_hashes" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +dependencies = [ + "bitcoin-internals", + "hex-conservative", +] [[package]] name = "bitflags" @@ -691,7 +701,7 @@ dependencies = [ "async-channel 2.3.1", "async-task", "futures-io", - "futures-lite 2.3.0", + "futures-lite 2.5.0", "piper", ] @@ -742,15 +752,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" -version = "1.1.18" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" dependencies = [ "shlex", ] @@ -774,9 +784,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -860,9 +870,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -902,18 +912,18 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" @@ -1002,7 +1012,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -1050,7 +1060,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -1072,7 +1082,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -1106,7 +1116,27 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.77", + "syn 2.0.90", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] @@ -1138,6 +1168,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -1279,12 +1320,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1317,9 +1358,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" dependencies = [ "event-listener 5.3.1", "pin-project-lite", @@ -1348,9 +1389,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fiat-crypto" @@ -1372,9 +1413,9 @@ dependencies = [ [[package]] name = "flume" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" dependencies = [ "futures-core", "futures-sink", @@ -1387,6 +1428,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1443,9 +1490,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1458,9 +1505,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1468,15 +1515,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1497,9 +1544,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" @@ -1518,11 +1565,11 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +checksum = "cef40d21ae2c515b51041df9ed313ed21e572df340ea58a922a0aefe7e8891a1" dependencies = [ - "fastrand 2.1.1", + "fastrand 2.3.0", "futures-core", "futures-io", "parking", @@ -1531,26 +1578,26 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" @@ -1564,9 +1611,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1644,9 +1691,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "gloo-net" @@ -1706,7 +1753,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.5.0", + "indexmap 2.7.0", "slab", "tokio", "tokio-util", @@ -1757,6 +1804,17 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + [[package]] name = "hashlink" version = "0.9.1" @@ -1808,6 +1866,12 @@ dependencies = [ "serde", ] +[[package]] +name = "hex-conservative" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" + [[package]] name = "hmac" version = "0.8.1" @@ -1872,9 +1936,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -1890,9 +1954,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" dependencies = [ "bytes", "futures-channel", @@ -1905,7 +1969,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.7", + "socket2 0.5.8", "tokio", "tower-service", "tracing", @@ -1930,9 +1994,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1951,6 +2015,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1959,12 +2141,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -1996,13 +2189,13 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.90", ] [[package]] @@ -2018,12 +2211,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.2", ] [[package]] @@ -2038,7 +2231,7 @@ version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9fd4f77d66c94aa7f27a7cf41cd2edbc2229afe34ec475c3f32b6e8fdf561a0" dependencies = [ - "derive_more", + "derive_more 0.99.18", "ink_env", "ink_macro", "ink_metadata", @@ -2064,7 +2257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22d79057b2565df31a10af6510a44b161093f110c5f9c22ad02c20af9cea4c29" dependencies = [ "blake2", - "derive_more", + "derive_more 0.99.18", "either", "env_logger 0.10.2", "heck 0.4.1", @@ -2078,7 +2271,7 @@ dependencies = [ "quote", "serde", "serde_json", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -2088,7 +2281,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "722ec3a5eb557124b001c60ff8f961079f6d566af643edea579f152b15822fe5" dependencies = [ "blake2", - "derive_more", + "derive_more 0.99.18", "ink_primitives", "parity-scale-codec", "secp256k1 0.27.0", @@ -2105,7 +2298,7 @@ dependencies = [ "arrayref", "blake2", "cfg-if", - "derive_more", + "derive_more 0.99.18", "ink_allocator", "ink_engine", "ink_prelude", @@ -2135,7 +2328,7 @@ dependencies = [ "itertools 0.10.5", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -2150,7 +2343,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", "synstructure", ] @@ -2160,7 +2353,7 @@ version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fddff95ce3e01f42002fdaf96edda691dbccb08c9ae76d7101daa1fa634e601" dependencies = [ - "derive_more", + "derive_more 0.99.18", "impl-serde 0.4.0", "ink_prelude", "ink_primitives", @@ -2183,7 +2376,7 @@ version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6414bcad12ebf0c3abbbb192a09e4d06e22f662cf3e19545204e1b0684be12a1" dependencies = [ - "derive_more", + "derive_more 0.99.18", "ink_prelude", "parity-scale-codec", "scale-decode 0.9.0", @@ -2200,7 +2393,7 @@ checksum = "bd728409de235de0489f71ee2d1beb320613fdb50dda9fa1c564825f4ad06daa" dependencies = [ "array-init", "cfg-if", - "derive_more", + "derive_more 0.99.18", "ink_env", "ink_metadata", "ink_prelude", @@ -2308,16 +2501,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -2456,15 +2650,15 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libsecp256k1" @@ -2543,6 +2737,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "lock_api" version = "0.4.12" @@ -2561,11 +2761,11 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.14.5", + "hashbrown 0.15.2", ] [[package]] @@ -2598,7 +2798,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.37", + "rustix 0.38.42", ] [[package]] @@ -2651,20 +2851,19 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi 0.3.9", "libc", "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", @@ -2788,18 +2987,18 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -2815,9 +3014,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -2836,7 +3035,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -2847,9 +3046,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -2945,29 +3144,29 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -2982,7 +3181,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" dependencies = [ "atomic-waker", - "fastrand 2.1.1", + "fastrand 2.3.0", "futures-io", ] @@ -2998,9 +3197,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "polling" @@ -3020,15 +3219,15 @@ dependencies = [ [[package]] name = "polling" -version = "3.7.3" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" +checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.37", + "rustix 0.38.42", "tracing", "windows-sys 0.59.0", ] @@ -3046,9 +3245,9 @@ dependencies = [ [[package]] name = "polymesh-api" -version = "3.8.1" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1f1242aca2f9e4d29bd6369250769adbbb56d9797c66787a1c63fd54f666ce" +checksum = "975666bf3077ef7540833649adec88c58eddc6e68ee51d8e9eed75cbb0bd4e2a" dependencies = [ "async-trait", "ink", @@ -3065,9 +3264,9 @@ dependencies = [ [[package]] name = "polymesh-api-client" -version = "3.7.1" +version = "3.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eda1ebfa288f984c2a332d7e0c3714623a788557a668b42446fad3a5b3da015" +checksum = "82ba16ca03a45e606e62871c89f66aa676c2c1472e36c5d2744d1fca0c757850" dependencies = [ "async-stream", "async-trait", @@ -3094,13 +3293,14 @@ dependencies = [ "subxt-signer", "thiserror", "tokio", + "uuid", ] [[package]] name = "polymesh-api-client-extras" -version = "3.4.1" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac514e14c057b5b35b12212662a597dfdea5c9d69652c946d20b178936268a2" +checksum = "8a337f8927c2026c3bd2d5e7e52a76731ba98091177de4eab9dbd988062591f3" dependencies = [ "parity-scale-codec", "polymesh-api", @@ -3111,9 +3311,9 @@ dependencies = [ [[package]] name = "polymesh-api-codegen" -version = "3.5.2" +version = "3.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca758383c09cdca43ca252a6ec24b0535f1262a34bb2648c26ac93712746e539" +checksum = "c561c4e41c52bc822ae3fbb8fcdeadad3dfb9ee1c95e180b9fa893c66ebdd6e5" dependencies = [ "frame-metadata 15.1.0", "heck 0.4.1", @@ -3131,9 +3331,9 @@ dependencies = [ [[package]] name = "polymesh-api-codegen-macro" -version = "3.5.2" +version = "3.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50ed4f91e2639099ac0c62b84c5a157ad094375bef04ab5277b774360ead6106" +checksum = "b4f29d6e08ff01c399678ff599abf0a0348028e2df2c06077ec4f610d9fff96a" dependencies = [ "darling 0.14.4", "parity-scale-codec", @@ -3146,9 +3346,9 @@ dependencies = [ [[package]] name = "polymesh-api-ink" -version = "1.3.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d889e12cf9f93543654cfd8d1269f6ce76e64682e54e94c48b3265a1973a83e" +checksum = "fef72aba71c295abec42ec3f1b645be12ae2295316c4f8098584dc48d6c5a814" dependencies = [ "hex", "ink", @@ -3161,9 +3361,9 @@ dependencies = [ [[package]] name = "polymesh-api-tester" -version = "0.7.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dfb4f4bcb95bb2a87c428752b390ef8f44901d47a2d6ee8a3eb3b44b42a19df" +checksum = "44561e7df2511887f847a76ea6b0d5d48a62c915b38225d98423668a01507954" dependencies = [ "async-trait", "env_logger 0.9.3", @@ -3219,7 +3419,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.22.20", + "toml_edit 0.22.22", ] [[package]] @@ -3248,18 +3448,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "psm" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810" dependencies = [ "cc", ] @@ -3352,9 +3552,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ "bitflags 2.6.0", ] @@ -3376,19 +3576,19 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", ] [[package]] @@ -3402,13 +3602,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -3419,9 +3619,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "ring" @@ -3501,15 +3701,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys 0.4.14", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3557,9 +3757,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "ruzstd" @@ -3568,7 +3768,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58c4eb8a81997cf040a091d1f7e1938aeab6749d3a0dfa73af43cdc32393483d" dependencies = [ "byteorder", - "derive_more", + "derive_more 0.99.18", "twox-hash", ] @@ -3595,7 +3795,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7789f5728e4e954aaa20cadcc370b99096fb8645fca3c9333ace44bb18f30095" dependencies = [ - "derive_more", + "derive_more 0.99.18", "parity-scale-codec", "scale-bits", "scale-decode-derive 0.9.0", @@ -3609,7 +3809,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7caaf753f8ed1ab4752c6afb20174f03598c664724e0e32628e161c21000ff76" dependencies = [ - "derive_more", + "derive_more 0.99.18", "parity-scale-codec", "primitive-types", "scale-bits", @@ -3650,7 +3850,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d70cb4b29360105483fac1ed567ff95d65224a14dd275b6303ed0a654c78de5" dependencies = [ - "derive_more", + "derive_more 0.99.18", "parity-scale-codec", "primitive-types", "scale-bits", @@ -3674,13 +3874,13 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.3" +version = "2.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" +checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" dependencies = [ "bitvec", "cfg-if", - "derive_more", + "derive_more 1.0.0", "parity-scale-codec", "scale-info-derive", "serde", @@ -3688,14 +3888,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.3" +version = "2.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" +checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.90", ] [[package]] @@ -3706,7 +3906,7 @@ checksum = "58223c7691bf0bd46b43c9aea6f0472d1067f378d574180232358d7c6e0a8089" dependencies = [ "base58", "blake2", - "derive_more", + "derive_more 0.99.18", "either", "frame-metadata 15.1.0", "parity-scale-codec", @@ -3720,9 +3920,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -3869,9 +4069,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" dependencies = [ "core-foundation-sys", "libc", @@ -3879,9 +4079,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" [[package]] name = "send_wrapper" @@ -3891,9 +4091,9 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] @@ -3918,22 +4118,22 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.7.0", "itoa", "memchr", "ryu", @@ -4097,12 +4297,12 @@ dependencies = [ "bs58", "chacha20", "crossbeam-queue", - "derive_more", + "derive_more 0.99.18", "ed25519-zebra 4.0.3", "either", "event-listener 3.1.0", "fnv", - "futures-lite 2.3.0", + "futures-lite 2.5.0", "futures-util", "hashbrown 0.14.5", "hex", @@ -4147,12 +4347,12 @@ dependencies = [ "async-lock 3.4.0", "base64 0.21.7", "blake2-rfc", - "derive_more", + "derive_more 0.99.18", "either", "event-listener 3.1.0", "fnv", "futures-channel", - "futures-lite 2.3.0", + "futures-lite 2.5.0", "futures-util", "hashbrown 0.14.5", "hex", @@ -4185,9 +4385,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -4307,7 +4507,7 @@ checksum = "50535e1a5708d3ba5c1195b59ebefac61cc8679c2c24716b87a86e8b7ed2e4a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -4435,7 +4635,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -4609,7 +4809,7 @@ dependencies = [ "hashbrown 0.14.5", "hashlink", "hex", - "indexmap 2.5.0", + "indexmap 2.7.0", "log", "memchr", "native-tls", @@ -4637,7 +4837,7 @@ dependencies = [ "quote", "sqlx-core", "sqlx-macros-core", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -4658,7 +4858,7 @@ dependencies = [ "sha2 0.10.8", "sqlx-core", "sqlx-sqlite", - "syn 2.0.77", + "syn 2.0.90", "tempfile", "tokio", "url", @@ -4689,9 +4889,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.50.0" +version = "1.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43fce22ed1df64d04b262351c8f9d5c6da4f76f79f25ad15529792f893fad25d" +checksum = "19409f13998e55816d1c728395af0b52ec066206341d939e22e7766df9b494b8" dependencies = [ "Inflector", "num-format", @@ -4815,7 +5015,7 @@ dependencies = [ "quote", "scale-info", "subxt-metadata", - "syn 2.0.77", + "syn 2.0.90", "thiserror", "tokio", ] @@ -4847,7 +5047,7 @@ dependencies = [ "parity-scale-codec", "proc-macro-error", "subxt-codegen", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -4898,9 +5098,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -4915,7 +5115,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -4932,14 +5132,14 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", - "fastrand 2.1.1", + "fastrand 2.3.0", "once_cell", - "rustix 0.38.37", + "rustix 0.38.42", "windows-sys 0.59.0", ] @@ -4954,22 +5154,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -4982,6 +5182,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -4999,9 +5209,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -5010,7 +5220,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.7", + "socket2 0.5.8", "tokio-macros", "windows-sys 0.52.0", ] @@ -5023,7 +5233,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] @@ -5038,9 +5248,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", @@ -5049,9 +5259,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -5073,20 +5283,20 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.7.0", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.7.0", "toml_datetime", - "winnow 0.6.18", + "winnow 0.6.20", ] [[package]] @@ -5118,9 +5328,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -5130,20 +5340,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -5250,17 +5460,11 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-normalization" @@ -5273,9 +5477,9 @@ dependencies = [ [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "unicode_categories" @@ -5301,15 +5505,36 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +dependencies = [ + "serde", +] + [[package]] name = "valuable" version = "0.1.0" @@ -5330,9 +5555,9 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "w3f-bls" -version = "0.1.4" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c5da5fa2c6afa2c9158eaa7cd9aee249765eb32b5fb0c63ad8b9e79336a47ec" +checksum = "70a3028804c8bbae2a97a15b71ffc0e308c4b01a520994aafa77d56e94e19024" dependencies = [ "ark-bls12-377", "ark-bls12-381", @@ -5381,9 +5606,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -5392,36 +5617,36 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5429,22 +5654,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "wasmi" @@ -5630,9 +5855,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", @@ -5909,13 +6134,25 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "wyz" version = "0.5.1" @@ -5949,6 +6186,30 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff4524214bc4629eba08d78ceb1d6507070cc0bcbbed23af74e19e6e924a24cf" +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -5967,7 +6228,28 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", + "synstructure", ] [[package]] @@ -5987,5 +6269,27 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.90", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", ] diff --git a/integration/Cargo.toml b/integration/Cargo.toml index e1889e6073..62f3a48985 100644 --- a/integration/Cargo.toml +++ b/integration/Cargo.toml @@ -27,5 +27,5 @@ sp-runtime = "29.0" sp-keyring = "29.0" sp-weights = "25.0" -polymesh-api = { version = "3.8.1", features = ["download_metadata"] } -polymesh-api-tester = { version = "0.7.3", default-features = false, features = ["download_metadata", "polymesh_v7"] } +polymesh-api = { version = "3.10.0", features = ["download_metadata"] } +polymesh-api-tester = { version = "0.9.0", features = ["download_metadata"] } From 1e88b5fbed6a7c00a0c3e4e7562a5816600f9029 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Thu, 19 Dec 2024 23:54:09 +0800 Subject: [PATCH 38/45] Remove unused feature 'default_identity'. --- .circleci/config.yml | 1 - Cargo.toml | 1 - README.md | 2 +- pallets/runtime/tests/Cargo.toml | 2 -- pallets/runtime/tests/src/identity_test.rs | 9 ++++----- scripts/coverage.sh | 2 +- scripts/receipt.sh | 2 +- scripts/test.sh | 2 +- 8 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1a2ce5056b..5a6ce12492 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -426,7 +426,6 @@ jobs: --package polymesh-runtime-tests --package pallet-balances:0.1.0 --package asset-metadata - --features default_identity no_output_timeout: 30m - save-sccache-cache coverage: diff --git a/Cargo.toml b/Cargo.toml index 5e4d57e9db..255511edc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -366,7 +366,6 @@ disable_fees = [ "polymesh-runtime-testnet/disable_fees", ] running-ci = [ "polymesh-runtime-develop/running-ci" ] -default_identity = [] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-benchmarking-cli/runtime-benchmarks", diff --git a/README.md b/README.md index 5fda11d6b4..23265fcff4 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ and to display log files you can use: Unit tests are packaged with the Rust code. To run these, you can execute: ```bash -cargo test --package polymesh-runtime-tests --features default_identity +cargo test --package polymesh-runtime-tests cargo test --package pallet-staking cargo test --package pallet-balances cargo test --package polymesh-primitives diff --git a/pallets/runtime/tests/Cargo.toml b/pallets/runtime/tests/Cargo.toml index 431219b810..16f82fdc6a 100644 --- a/pallets/runtime/tests/Cargo.toml +++ b/pallets/runtime/tests/Cargo.toml @@ -107,8 +107,6 @@ sp-tracing = { version = "6.0.0", default-features = false, features = ["std"] } [features] default = ["std", "testing", "equalize"] -default_identity = [] - testing = [] equalize = [] only-staking = [] diff --git a/pallets/runtime/tests/src/identity_test.rs b/pallets/runtime/tests/src/identity_test.rs index 9fa4fd57d7..a35589da3d 100644 --- a/pallets/runtime/tests/src/identity_test.rs +++ b/pallets/runtime/tests/src/identity_test.rs @@ -368,11 +368,10 @@ fn freeze_secondary_keys_with_externalities() { )); // unfreeze all - // commenting this because `default_identity` feature is not allowing to access None identity. - // assert_noop!( - // Identity::unfreeze_secondary_keys(bob.clone()), - // DispatchError::Other("Current identity is none and key is not linked to any identity") - // ); + assert_noop!( + Identity::unfreeze_secondary_keys(bob.origin()), + Error::KeyNotAllowed + ); assert_ok!(Identity::unfreeze_secondary_keys(alice.origin())); assert_eq!(is_auth(dave.acc()), true); diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 82fa22243c..575d5624cd 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -16,7 +16,7 @@ function run_tests() { --package polymesh-runtime-tests \ --package pallet-balances:0.1.0 \ --package asset-metadata \ - --features default_identity $* + $* } function get_tests_filenames() { diff --git a/scripts/receipt.sh b/scripts/receipt.sh index a491624533..26d9485907 100755 --- a/scripts/receipt.sh +++ b/scripts/receipt.sh @@ -1 +1 @@ -SKIP_WASM_BUILD=true cargo test --package polymesh-runtime-common --features default_identity encode_receipt -- --nocapture +SKIP_WASM_BUILD=true cargo test --package polymesh-runtime-common encode_receipt -- --nocapture diff --git a/scripts/test.sh b/scripts/test.sh index 60bd1c13c1..be4e52833b 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -13,4 +13,4 @@ SKIP_WASM_BUILD=1 RUST_BACKTRACE=1 \ --package polymesh-runtime-tests \ --package pallet-balances:0.1.0 \ --package asset-metadata \ - --features default_identity "$@" + "$@" From bfb440b222436172cf36592758d81f0d7158e96e Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 20 Dec 2024 00:03:06 +0800 Subject: [PATCH 39/45] Update 7.1 metadata. --- .metadata/polymesh_dev/7001000.meta | Bin 369478 -> 380573 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.metadata/polymesh_dev/7001000.meta b/.metadata/polymesh_dev/7001000.meta index 6b030c009df3a89a863221802b3de5eb7024c974..6ad487c64f3e2aac25733f7a8fce8d5bd45a8449 100644 GIT binary patch delta 15341 zcmds8Yiu0Xb>?0!6)}}4lN28-Qq<^S>S1amI#R8tqm8HsC6W@U)q|lVa=1H7jxcZGVxwd+(idzH{z(9{0|-zg_*MFV#H%LFwW>DJ79mt=@Z&1==co zAIFw|u*moEcHK)WOBZjo2WO8Q+I%mwvwLZ_^Ji7rA0K?$`{~}1Lr0c+ANj~1MONm2 z)!F~^wceg?#(*NT7s>g)Y* zw=uZ#-kE!!Yb;&7&lUe4|Gunraf|bD(T~4U?)&)W&qtP*E^e}a1#MYi9A1tEYsb4D z3v4caZ1E2J7gJ3rqpF$R{HdDp`;~$1xa0==r}5e~f#;e%NXGyAL_pmFNr-^;>~&m1ggRmXH7Jxxj_{Y~N~#cCf}`Yfy#HbTDbGs67xF)Y4Ksqem^x&?SW5 z7*0z#K#GznOvy4NQytLK7XGhDx;iXbTJ$1*Fic4uu~a?AM~gA0LaT%WMqE;K{28Zd z`hYz{mLj;UJ^PZ9&|>iC9c(Flr-RjvpJsQ{~^%T+tpt{tL3*+J`Q%fr5D9M&qqlO-X^TUDaG5L91PCVFI&KAR`om?cX zl@45@#|P-~5w2#Jt-BhdnWqO;#K_SBflFtiQ8k^8XA+4~7bi6))-p}QOqT{WF{ux} zxhz<-n3iZo1>l`!!Br8t*?UaHFxm`#z!~7-lu-2nYY?G~s%lIaCaH{Q$xKq%N{vZk zh`f?kgU^P7)$+t;5DQDu^t7bu9C;}^sF+F=jhdF>kB_m9fj#i{G4`N!ZjrB$Ih0Dq z8tm0Lf?-(E$(ql3SR+0T))7t-H zh+4VSV)g7>w=27GA0Ws!r^$Tt+cWu`Ru?pTS1UTk23I(g%?GQbn5w%Jw4GuNffl%k ze@>$wswEfQ2uv9(`3Mvxoe_bN2R|fNT}epF09ua1XxvoQ%NVC@;!4B6-es%i*pJuA z&mwwU9Gh^-i-mZu2=K~vR_mjScOBO_Xd0JQ9&tsWbGR;_7UF!Ik9PkISLiTKWTJy% z!ph@N`_VB2H!;yIPYLAj;_#1!6X;yAQSX_a*N|aw(~AL!8%ZTg86DbBvHC?NEiazb z##tf1IF)grth;!f&m=!_OoE!u&?uw>2a3l5o_oyFEKRR+ zGg?!dghx#A6nOtMd%E=S8z)mSqGDtTb+z@WEYH5C785 zu9k4LVepgeFMObKat{-`d_qYmdQ=sT=YeZS9ORCEF8I4PU`ANO2u3_ z)?w%eGx`9<@(2mmH)bd7E{75=A(82uG3fGfNbERJPWpn@Atd-rLNPUK)K7#-49`3c z@Gv2{l$caeWD&3~a<&|DF$YV>gc=S_d+S1#Q_p{>;KC}O16LhAFE7yy54!MxMI#uRTB6_L=Y?j6j%V&Dofxr%UvzIlTwb9QM zh`y;N@d56GZH`^Q{HR7K!doX~1GmBRQXkvnn&FIR2Hx&+%+STf_oDYSh7g*@co6Z7 z0YB|y8`D(UrIm-;c7V zU7zvJ$ovzohMMROAH#>e2WoKEW6VAq1T_6p^F}7>$ z`vn>hZ4|{c!EJZ&zKfmhV>T!mI=1T#(~27j%@8zeptVgqbvQmRCjnEX4$FmwKSTrb zG>*1G1dgff$y&}@l)v`6(u!a2uP?5JyDAI&%*~tG`?1$<8gzK#G+mv|h-&h3hdNC; z_H}wfm^%9Q z^YVI@cAIOGb0qY3TJSfirnFmKzO}eCyo9D{=d*|-{LyIm+w;lOeoVU7~9u$C*)x40{e*2Q!cp4espe{>SvR0&*MHhLD06z7S)<>Ww?_Zen`<@+(3Xqri!2h$K69tGtMI}Kvok5FS_(E+ z72X7ggTBiomS|+f*gKFCk|1g~$g9wyky}eHlZ6wFIxkj-}`pfRcdJ z5H^?I9AZyWgS5%x*PS#0lhiP^^V)4qPf`EG;aj*~6Eg#_l<7st8<2vz^Nd;0T{%JVz^M zzjvp>>k&{fD1hK(2|%H&oqQS%E`@Tb+mrHcfOz?NZFQ{^Ub zyvvvV^{~wnlbM0zFlMsG{;$rN1LnIP$9jPa@Y(oZ8^xN*{HT)*#?Q5XWk2$A@>%%8 zD?GUTV0m!OVSnUt;yXXtoOw)nhp+bDj*^w9rwdiwN-;IA=^DS+H}eNP3rkH_3*Sp) z$8sO6w%GcX)l)l@Y2cy0eKn6CeYiIT2NDLJ!?}AD!WOH1!ooeBd#%s606!gnB){w` zbF=Nw@eTPmFRbdyF|GaNS#pGDTYhGced~ovSX2{y>|;Ko<>@3*j^UJU_RgO#YoDAK zYeQLvwe+-EqAew^7joC}oq`l}jt{GAgCWo|tZI(y_o+HLA#V1`Zd<`GGkC!4q#(Yg z%~EnB9{M8~MN|A+ss3DzC* zIjMJ>%Mn=9qee1?HwW=tTU7fb4R=_&o$F~Q!;VYX$!&w%m)Ndkp>1^gghI)WAbi(g zUZdf4N|92}Q#h%V%L!YqpK}|EU+sWx!>qEF+nwhVy-ulvu=Mn0Da5CT*%n_E5qvMd zDDLp`G?fDXh6!0mOvU@_IbA%SBJn!KpE8usxH#b%GF+(*Hm>qn*-b+U&3-k3mxt5v zi`&6!`0_A2&JKSUp1;KE;9-(2f~pZ#+4J1gBrY7_5x3V|Yr0RKSKC$a{#>r4gxvXqs*6z&hJ?Fsj(<&~98}J^Eu}0YQ4680564V*f z6boNWK}UzZ*V*In-tOW$`0_Js-6qe6c*V>er(Lzj=UkkC8_%#%Pnp?r$%t-Kb9YVhg{jHYm0g{PZfj$QpLQt}&K4@P)aEW-v6y zs^RypVTinSlP#ZfWAIQl!5DkX-d{s6Yv*MAp^aBoqYmt z^nG}p?LJ=UJ)eZ8U!;Rv@!Hq?-18}yR}(1W8RRMv7`wrCRg}`Vxey}T)x-NY*k)e} z&)rqLkz2PwI(_K5mZg^WZQEAXe@$EbkOAV(f>$`e4aZKEL)J zK=-7*{u9M)T3ftPXTPZRYDF-#b>d_(OT0%X4Jz1O97*9t(3p6+0p{?{rY3&Tgu~RD zwofTt@Px*mc<`6?_%77)o7fa+gHPUM&5@x3cVI@(^(%fwbRG^m%Eb+CVH;A2dsZF% z`%SjCf|mf3xEKCd21jl&$yWk&lP6>!zFc#ZR&isgXY`yCeW9L{7)|L}aHKw1_bd3& z<0K6ChEtxAoGqH;L+I}O);`?}l6hJzY}=Yfe|GF08C2c)-Fcsxd1mIBcTb%vee=zdz8h7AQe2C6#$+Sn4{5QOruq}65>-q^He9A2 zR7``7e6V45Hg=Do#iL^@4>?`;im-oQLwzMWh$t(<4Cx4tTtQNDdoR|E#NZ6cB zI(f;hOgLJX1tv@0Y!>9DQ1 zl45o;EzE){llLixsi^JDR6@ID-CHCyuJy4N>kpf-l{DF4s%Elw86VyV6^q8rzvQW6 z^?G|ECab3Lwy=Z+G+k*|)PRpECI;RU37Ei}N=@ zjll4+O>m{~Q-KOTBA{TxjQACakb+pa8H({(6I9^YW_Vz=>mMx<#bDut8Zs44W%N5? z$P)Jx429&l$%6EIx2!U)LzQ(SqQn`gm}-P&9e=n9wtl+X!aAPSU4Ba)77}_k!$REB z0hlNg9dWF5)W4RJnt)tv3wWd{j1rO4JCnd02;HMwl6qnPM4R%u{q)LZ$Ew z;>@t4^CH^6;me%J~tU}Y6Hd&RP8uCOl4UAX3) zSbAR$>uuowWCMk5P?9Qu77@#_uU2H}m!K~7@a(gq3-^2-*i1ICMYS-pJe9XhmpQ9` z9xWDK2Nw=)hq>VXGrqbVY6{q7zPyt#(|x&3d&MM|c7-@8_(>ah)8d<6tQbZ@&g*~r z_F{a}4+{kkcKKl|el-AxQ+96z;Ab;jx-7|Zj2o6G)QB6x8on2U`zelDD%8%+2%95Jhzy?jr?|$deNCE!FwK)hqUP86kJOx`TC+jJ z0~$2o(Kxi`y5HRrmx3mBNAuUH);W8iC^b77!d9E^bJAtXG;MZxd*9XF^HI`)rKfo1 zUt$T$1~hffuI;5bB~sM!6~Zk@uOpq8dub zdyA|nF&`sTl3g{WQ~WjF>3}MHuoJE}t^5Myx_QQ+(5RWRkKx$&#qu570vk0c5hZFu zl)q_mZvm9QK?IRrIUvMCwuqkP6!177Qe zGG`HYWyIx>MSyx39-8%kXI*v#blNJtN1*!iI>%*4iQh~TKR5OkB|s$c^)e9sWXs=ZGRDF=8WGFt8m9Iahj##sfxcvY}glu@!JRCL?K!Rm>W(a1N=5kV_8p(t|)mprF0x0+$b8u`3mSXS( zG=cjqY#O9)eCGruHUTBvvXTD&ZE()9?tn3BGFleFaWLMeO}O?uungEO{Pk&Ixb76p z$J#C-4-Z5{XL?BUvG6q9hdVrUUm1P@3Z}c3uqQOl#2eoQAKiNwpMq7Nak3hho`w90 zLl;k5m*s1x;lZgqm15Nyr~@{D^|hiKyUsv9Iy|B`MU@qoggOb%V5GQajRG|=G> zUxqrnuO?_Ou=ZjmLOCuRhAI%!VdBG(i~EOZMArNPVoB)-@OaNXKc$|#vRq7FS)TL9 zvZ=qyo*QkhpyWe1E&68vnE^r+8-SO1)kRv?W=aqtQ`3!0KrQXI?CmojV=w G=zjs&zc85q From 45246a103189fbaeef70a7113ff0ade1faa21091 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 20 Dec 2024 00:14:41 +0800 Subject: [PATCH 40/45] Bump anstream. --- Cargo.lock | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad9f0ff0d2..a34e4ca0a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -206,15 +206,16 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.5" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] @@ -3179,6 +3180,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" From 1ea45ae6adfa53a0693bf58ba6e6b9543bd000ad Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 20 Dec 2024 00:18:15 +0800 Subject: [PATCH 41/45] Bump yarn deps. --- yarn.lock | 605 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 357 insertions(+), 248 deletions(-) diff --git a/yarn.lock b/yarn.lock index dd76f1e59e..e5e46a6430 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4,286 +4,390 @@ "@cloudflare/kv-asset-handler@^0.2.0": version "0.2.0" - resolved "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.2.0.tgz" + resolved "https://registry.yarnpkg.com/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.2.0.tgz#c9959bbd7a1c40bd7c674adae98aa8c8d0e5ca68" integrity sha512-MVbXLbTcAotOPUj0pAMhVtJ+3/kFkwJqc5qNOleOZTv6QkZZABDMS21dSrSlVswEHwrpWC03e4fWytjqKvuE2A== dependencies: mime "^3.0.0" "@esbuild-plugins/node-globals-polyfill@^0.1.1": version "0.1.1" - resolved "https://registry.npmjs.org/@esbuild-plugins/node-globals-polyfill/-/node-globals-polyfill-0.1.1.tgz" + resolved "https://registry.yarnpkg.com/@esbuild-plugins/node-globals-polyfill/-/node-globals-polyfill-0.1.1.tgz#a313ab3efbb2c17c8ce376aa216c627c9b40f9d7" integrity sha512-MR0oAA+mlnJWrt1RQVQ+4VYuRJW/P2YmRTv1AsplObyvuBMnPHiizUF95HHYiSsMGLhyGtWufaq2XQg6+iurBg== "@esbuild-plugins/node-modules-polyfill@^0.1.4": version "0.1.4" - resolved "https://registry.npmjs.org/@esbuild-plugins/node-modules-polyfill/-/node-modules-polyfill-0.1.4.tgz" + resolved "https://registry.yarnpkg.com/@esbuild-plugins/node-modules-polyfill/-/node-modules-polyfill-0.1.4.tgz#eb2f55da11967b2986c913f1a7957d1c868849c0" integrity sha512-uZbcXi0zbmKC/050p3gJnne5Qdzw8vkXIv+c2BW0Lsc1ji1SkrxbKPUy5Efr0blbTu1SL8w4eyfpnSdPg3G0Qg== dependencies: escape-string-regexp "^4.0.0" rollup-plugin-node-polyfills "^0.2.1" +"@esbuild/android-arm64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.16.3.tgz#6af6d16be6d534d776a51fc215bfd81a68906d2c" + integrity sha512-RolFVeinkeraDvN/OoRf1F/lP0KUfGNb5jxy/vkIMeRRChkrX/HTYN6TYZosRJs3a1+8wqpxAo5PI5hFmxyPRg== + +"@esbuild/android-arm@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.16.3.tgz#2a091222f3b1928e3246fb3c5202eaca88baab67" + integrity sha512-mueuEoh+s1eRbSJqq9KNBQwI4QhQV6sRXIfTyLXSHGMpyew61rOK4qY21uKbXl1iBoMb0AdL1deWFCQVlN2qHA== + +"@esbuild/android-x64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.16.3.tgz#a6d749c58b022d371dc40d50ac1bb4aebd1eb953" + integrity sha512-SFpTUcIT1bIJuCCBMCQWq1bL2gPTjWoLZdjmIhjdcQHaUfV41OQfho6Ici5uvvkMmZRXIUGpM3GxysP/EU7ifQ== + +"@esbuild/darwin-arm64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.16.3.tgz#92d1826ed2f21dcac5830b70d7215c6afbb744e2" + integrity sha512-DO8WykMyB+N9mIDfI/Hug70Dk1KipavlGAecxS3jDUwAbTpDXj0Lcwzw9svkhxfpCagDmpaTMgxWK8/C/XcXvw== + +"@esbuild/darwin-x64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.16.3.tgz#7fc3570c2b16e9ff4fc178593a0a4adb1ae8ea57" + integrity sha512-uEqZQ2omc6BvWqdCiyZ5+XmxuHEi1SPzpVxXCSSV2+Sh7sbXbpeNhHIeFrIpRjAs0lI1FmA1iIOxFozKBhKgRQ== + +"@esbuild/freebsd-arm64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.16.3.tgz#16735ce16f8c9a4e7289e9e259aa01a8d9874307" + integrity sha512-nJansp3sSXakNkOD5i5mIz2Is/HjzIhFs49b1tjrPrpCmwgBmH9SSzhC/Z1UqlkivqMYkhfPwMw1dGFUuwmXhw== + +"@esbuild/freebsd-x64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.16.3.tgz#f4edd1464cb072799ed6b8ab5178478e71c13459" + integrity sha512-TfoDzLw+QHfc4a8aKtGSQ96Wa+6eimljjkq9HKR0rHlU83vw8aldMOUSJTUDxbcUdcgnJzPaX8/vGWm7vyV7ug== + +"@esbuild/linux-arm64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.16.3.tgz#4b7ae6fe3618d9a40d6ca39c6edc991ac1447203" + integrity sha512-7I3RlsnxEFCHVZNBLb2w7unamgZ5sVwO0/ikE2GaYvYuUQs9Qte/w7TqWcXHtCwxvZx/2+F97ndiUQAWs47ZfQ== + +"@esbuild/linux-arm@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.16.3.tgz#4b3e9f849822e16a76a70844c4db68075b259a58" + integrity sha512-VwswmSYwVAAq6LysV59Fyqk3UIjbhuc6wb3vEcJ7HEJUtFuLK9uXWuFoH1lulEbE4+5GjtHi3MHX+w1gNHdOWQ== + +"@esbuild/linux-ia32@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.16.3.tgz#2ff3936b91bfff62f9ecf7f6411ef399b29ed22d" + integrity sha512-X8FDDxM9cqda2rJE+iblQhIMYY49LfvW4kaEjoFbTTQ4Go8G96Smj2w3BRTwA8IHGoi9dPOPGAX63dhuv19UqA== + +"@esbuild/linux-loong64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.16.3.tgz#ff8aa59f49d9ccbc1ff952ba1f5cd01a534562df" + integrity sha512-hIbeejCOyO0X9ujfIIOKjBjNAs9XD/YdJ9JXAy1lHA+8UXuOqbFe4ErMCqMr8dhlMGBuvcQYGF7+kO7waj2KHw== + +"@esbuild/linux-mips64el@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.16.3.tgz#5dd5e118071c3912df69beedbfd11fb117f0fe5e" + integrity sha512-znFRzICT/V8VZQMt6rjb21MtAVJv/3dmKRMlohlShrbVXdBuOdDrGb+C2cZGQAR8RFyRe7HS6klmHq103WpmVw== + +"@esbuild/linux-ppc64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.16.3.tgz#36c62e24eae7fa3f0d921506da8fc1e6098a1364" + integrity sha512-EV7LuEybxhXrVTDpbqWF2yehYRNz5e5p+u3oQUS2+ZFpknyi1NXxr8URk4ykR8Efm7iu04//4sBg249yNOwy5Q== + +"@esbuild/linux-riscv64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.16.3.tgz#f0fec8e7affb5bcc817fefc61a21cbb95539e393" + integrity sha512-uDxqFOcLzFIJ+r/pkTTSE9lsCEaV/Y6rMlQjUI9BkzASEChYL/aSQjZjchtEmdnVxDKETnUAmsaZ4pqK1eE5BQ== + +"@esbuild/linux-s390x@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.16.3.tgz#22e10edd6e91f53c2e1f60e46abd453d7794409b" + integrity sha512-NbeREhzSxYwFhnCAQOQZmajsPYtX71Ufej3IQ8W2Gxskfz9DK58ENEju4SbpIj48VenktRASC52N5Fhyf/aliQ== + "@esbuild/linux-x64@0.16.3": version "0.16.3" - resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.16.3.tgz" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.16.3.tgz#38388b73fd9eebe45b073d7d8099b9c2e54f7139" integrity sha512-SDiG0nCixYO9JgpehoKgScwic7vXXndfasjnD5DLbp1xltANzqZ425l7LSdHynt19UWOcDjG9wJJzSElsPvk0w== +"@esbuild/netbsd-x64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.16.3.tgz#e0270569567f1530b8dbe6d11d5b4930b9cc71ae" + integrity sha512-AzbsJqiHEq1I/tUvOfAzCY15h4/7Ivp3ff/o1GpP16n48JMNAtbW0qui2WCgoIZArEHD0SUQ95gvR0oSO7ZbdA== + +"@esbuild/openbsd-x64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.16.3.tgz#3b16642d443848bca605f33ee3978a1890911e6d" + integrity sha512-gSABi8qHl8k3Cbi/4toAzHiykuBuWLZs43JomTcXkjMZVkp0gj3gg9mO+9HJW/8GB5H89RX/V0QP4JGL7YEEVg== + +"@esbuild/sunos-x64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.16.3.tgz#a838f247867380f0ae25ce1936dc5ab6f57b7734" + integrity sha512-SF9Kch5Ete4reovvRO6yNjMxrvlfT0F0Flm+NPoUw5Z4Q3r1d23LFTgaLwm3Cp0iGbrU/MoUI+ZqwCv5XJijCw== + +"@esbuild/win32-arm64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.16.3.tgz#bedd9bef5fb41f89ce2599f1761973cf6d6a67b6" + integrity sha512-u5aBonZIyGopAZyOnoPAA6fGsDeHByZ9CnEzyML9NqntK6D/xl5jteZUKm/p6nD09+v3pTM6TuUIqSPcChk5gg== + +"@esbuild/win32-ia32@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.16.3.tgz#49800aa812d8cc35ceef61e8d3b01224684cc0b1" + integrity sha512-GlgVq1WpvOEhNioh74TKelwla9KDuAaLZrdxuuUgsP2vayxeLgVc+rbpIv0IYF4+tlIzq2vRhofV+KGLD+37EQ== + +"@esbuild/win32-x64@0.16.3": + version "0.16.3" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.16.3.tgz#94047dae921949cfb308117d993c4b941291ae10" + integrity sha512-5/JuTd8OWW8UzEtyf19fbrtMJENza+C9JoPIkvItgTBQ1FO2ZLvjbPO6Xs54vk0s5JB5QsfieUEshRQfu7ZHow== + "@fastify/busboy@^2.0.0": version "2.1.1" - resolved "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz" + resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA== "@iarna/toml@^2.2.5": version "2.2.5" - resolved "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz" + resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c" integrity sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg== -"@miniflare/cache@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/cache/-/cache-2.14.2.tgz" - integrity sha512-XH218Y2jxSOfxG8EyuprBKhI/Fn6xLrb9A39niJBlzpiKXqr8skl/sy/sUL5tfvqEbEnqDagGne8zEcjM+1fBg== +"@miniflare/cache@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/cache/-/cache-2.14.4.tgz#3b3e6b2fba9055d8e0deacc175aacef33c402765" + integrity sha512-ayzdjhcj+4mjydbNK7ZGDpIXNliDbQY4GPcY2KrYw0v1OSUdj5kZUkygD09fqoGRfAks0d91VelkyRsAXX8FQA== dependencies: - "@miniflare/core" "2.14.2" - "@miniflare/shared" "2.14.2" + "@miniflare/core" "2.14.4" + "@miniflare/shared" "2.14.4" http-cache-semantics "^4.1.0" - undici "5.28.2" + undici "5.28.4" -"@miniflare/cli-parser@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/cli-parser/-/cli-parser-2.14.2.tgz" - integrity sha512-CzC7OnPWuMWSJrmnn0PUToMFDkMEnsFFE+ybA+Gqpgcdb/gaLz+yP0/Hagb5YN4JMxh5SBG7NCktsjZKaO94ig== +"@miniflare/cli-parser@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/cli-parser/-/cli-parser-2.14.4.tgz#282197bc3611d5354ffe3f4d8cbfb046bde2a677" + integrity sha512-ltc6DDg0Sb1ZI6zbaPf9+CJbpRQXOLoCZqUdwtQyWCdZpAYQCT3tOeN19/tJC/uuL8NHj+EWKQIQriDYwp6uYQ== dependencies: - "@miniflare/shared" "2.14.2" + "@miniflare/shared" "2.14.4" kleur "^4.1.4" -"@miniflare/core@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/core/-/core-2.14.2.tgz" - integrity sha512-n/smm5ZTg7ilGM4fxO7Gxhbe573oc8Za06M3b2fO+lPWqF6NJcEKdCC+sJntVFbn3Cbbd2G1ChISmugPfmlCkQ== +"@miniflare/core@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/core/-/core-2.14.4.tgz#2088e4e99b698a0434f0ee720af86f1122a334da" + integrity sha512-FMmZcC1f54YpF4pDWPtdQPIO8NXfgUxCoR9uyrhxKJdZu7M6n8QKopPVNuaxR40jcsdxb7yKoQoFWnHfzJD9GQ== dependencies: "@iarna/toml" "^2.2.5" - "@miniflare/queues" "2.14.2" - "@miniflare/shared" "2.14.2" - "@miniflare/watcher" "2.14.2" + "@miniflare/queues" "2.14.4" + "@miniflare/shared" "2.14.4" + "@miniflare/watcher" "2.14.4" busboy "^1.6.0" dotenv "^10.0.0" kleur "^4.1.4" set-cookie-parser "^2.4.8" - undici "5.28.2" + undici "5.28.4" urlpattern-polyfill "^4.0.3" -"@miniflare/d1@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/d1/-/d1-2.14.2.tgz" - integrity sha512-3NPJyBLbFfzz9VAAdIZrDRdRpyslVCJoZHQk0/0CX3z2mJIfcQzjZhox2cYCFNH8NMJ7pRg6AeSMPYAnDKECDg== +"@miniflare/d1@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/d1/-/d1-2.14.4.tgz#41c36ec5fd6cd4a5dbde0fcf2933bf45322fa9ff" + integrity sha512-pMBVq9XWxTDdm+RRCkfXZP+bREjPg1JC8s8C0JTovA9OGmLQXqGTnFxIaS9vf1d8k3uSUGhDzPTzHr0/AUW1gA== dependencies: - "@miniflare/core" "2.14.2" - "@miniflare/shared" "2.14.2" + "@miniflare/core" "2.14.4" + "@miniflare/shared" "2.14.4" -"@miniflare/durable-objects@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/durable-objects/-/durable-objects-2.14.2.tgz" - integrity sha512-BfK+ZkJABoi7gd/O6WbpsO4GrgW+0dmOBWJDlNBxQ7GIpa+w3n9+SNnrYUxKzWlPSvz+TfTTk381B1z/Z87lPw== +"@miniflare/durable-objects@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/durable-objects/-/durable-objects-2.14.4.tgz#a303a754a7f9141f757a409cefddaadf85e83333" + integrity sha512-+JrmHP6gHHrjxV8S3axVw5lGHLgqmAGdcO/1HJUPswAyJEd3Ah2YnKhpo+bNmV4RKJCtEq9A2hbtVjBTD2YzwA== dependencies: - "@miniflare/core" "2.14.2" - "@miniflare/shared" "2.14.2" - "@miniflare/storage-memory" "2.14.2" - undici "5.28.2" + "@miniflare/core" "2.14.4" + "@miniflare/shared" "2.14.4" + "@miniflare/storage-memory" "2.14.4" + undici "5.28.4" -"@miniflare/html-rewriter@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/html-rewriter/-/html-rewriter-2.14.2.tgz" - integrity sha512-tu0kd9bj38uZ04loHb3sMI8kzUzZPgPOAJEdS9zmdSPh0uOkjCDf/TEkKsDdv2OFysyb0DRsIrwhPqCTIrPf1Q== +"@miniflare/html-rewriter@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/html-rewriter/-/html-rewriter-2.14.4.tgz#58984bcbf287cb1eeb896dafd73d8bbc7fc072e3" + integrity sha512-GB/vZn7oLbnhw+815SGF+HU5EZqSxbhIa3mu2L5MzZ2q5VOD5NHC833qG8c2GzDPhIaZ99ITY+ZJmbR4d+4aNQ== dependencies: - "@miniflare/core" "2.14.2" - "@miniflare/shared" "2.14.2" + "@miniflare/core" "2.14.4" + "@miniflare/shared" "2.14.4" html-rewriter-wasm "^0.4.1" - undici "5.28.2" + undici "5.28.4" -"@miniflare/http-server@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/http-server/-/http-server-2.14.2.tgz" - integrity sha512-cc8OfZahdPd7pDER3xR1Io29g4pLrVhhxYnoT7t2TbhLoxOl93tRjxdUPX/UEjmy0MCYS4mutpSoWx49FB9OcA== +"@miniflare/http-server@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/http-server/-/http-server-2.14.4.tgz#105576933960174d10f48b0b5957d0ee6a63f6f2" + integrity sha512-2YrJi4o5Jf1FdT2XvdPCgaYpxuai7jn6Z1k5pgL1+s2qIaXr/uShceBLjJjEf3jz+daDxwmB1+BP0xyO/Cu4+g== dependencies: - "@miniflare/core" "2.14.2" - "@miniflare/shared" "2.14.2" - "@miniflare/web-sockets" "2.14.2" + "@miniflare/core" "2.14.4" + "@miniflare/shared" "2.14.4" + "@miniflare/web-sockets" "2.14.4" kleur "^4.1.4" selfsigned "^2.0.0" - undici "5.28.2" + undici "5.28.4" ws "^8.2.2" youch "^2.2.2" -"@miniflare/kv@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/kv/-/kv-2.14.2.tgz" - integrity sha512-3rs4cJOGACT/U7NH7j4KD29ugXRYUiM0aGkvOEdFQtChXLsYClJljXpezTfJJxBwZjdS4F2UFTixtFcHp74UfA== +"@miniflare/kv@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/kv/-/kv-2.14.4.tgz#e59247d9a466eae53d7ebde092424ba42f517a34" + integrity sha512-QlERH0Z+klwLg0xw+/gm2yC34Nnr/I0GcQ+ASYqXeIXBwjqOtMBa3YVQnocaD+BPy/6TUtSpOAShHsEj76R2uw== dependencies: - "@miniflare/shared" "2.14.2" + "@miniflare/shared" "2.14.4" -"@miniflare/queues@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/queues/-/queues-2.14.2.tgz" - integrity sha512-OylkRs4lOWKvGnX+Azab3nx+1qwC87M36/hkgAU1RRvVDCOxOrYLvNLUczFfgmgMBwpYsmmW8YOIASlI3p4Qgw== +"@miniflare/queues@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/queues/-/queues-2.14.4.tgz#021d5e5c6a8700c42c9d9294dd36084650ebe9c4" + integrity sha512-aXQ5Ik8Iq1KGMBzGenmd6Js/jJgqyYvjom95/N9GptCGpiVWE5F0XqC1SL5rCwURbHN+aWY191o8XOFyY2nCUA== dependencies: - "@miniflare/shared" "2.14.2" + "@miniflare/shared" "2.14.4" -"@miniflare/r2@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/r2/-/r2-2.14.2.tgz" - integrity sha512-uuc7dx6OqSQT8i0F2rsigfizXmInssRvvJAjoi1ltaNZNJCHH9l1PwHfaNc/XAuDjYmiCjtHDaPdRvZU9g9F3g== +"@miniflare/r2@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/r2/-/r2-2.14.4.tgz#ad37b8ca3dac0e8812eb90a1252534a66ace19dd" + integrity sha512-4ctiZWh7Ty7LB3brUjmbRiGMqwyDZgABYaczDtUidblo2DxX4JZPnJ/ZAyxMPNJif32kOJhcg6arC2hEthR9Sw== dependencies: - "@miniflare/core" "2.14.2" - "@miniflare/shared" "2.14.2" - undici "5.28.2" + "@miniflare/core" "2.14.4" + "@miniflare/shared" "2.14.4" + undici "5.28.4" -"@miniflare/runner-vm@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/runner-vm/-/runner-vm-2.14.2.tgz" - integrity sha512-WlyxAQ+bv/9Pm/xnbpgAg7RNX4pz/q3flytUoo4z4OrRmNEuXrbMUsJZnH8dziqzrZ2gCLkYIEzeaTmSQKp5Jg== +"@miniflare/runner-vm@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/runner-vm/-/runner-vm-2.14.4.tgz#c319d52b1fd1893482a88b616f3f80770d012ac6" + integrity sha512-Nog0bB9SVhPbZAkTWfO4lpLAUsBXKEjlb4y+y66FJw77mPlmPlVdpjElCvmf8T3VN/pqh83kvELGM+/fucMf4g== dependencies: - "@miniflare/shared" "2.14.2" + "@miniflare/shared" "2.14.4" -"@miniflare/scheduler@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/scheduler/-/scheduler-2.14.2.tgz" - integrity sha512-gJejGz9F2hZl8NHfQd2iNwDnuNsK27DkWpLHiPkIqlrbz8tglN/kUKAa0rbTOKipsdo2+h6KRqLRq5PxvJ3T8w== +"@miniflare/scheduler@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/scheduler/-/scheduler-2.14.4.tgz#668261443e08bcaeea9da403910b47ceb4ca9d98" + integrity sha512-tBgQGFiRoqDSSuWyJDPbk6sNvGYrjE7O6Fhsx1d7h7/2ThofSqPxOnlttTTzeqnGc7Nt4Rf/s/JjQnzXOVXmqQ== dependencies: - "@miniflare/core" "2.14.2" - "@miniflare/shared" "2.14.2" + "@miniflare/core" "2.14.4" + "@miniflare/shared" "2.14.4" cron-schedule "^3.0.4" -"@miniflare/shared@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/shared/-/shared-2.14.2.tgz" - integrity sha512-dDnYIztz10zDQjaFJ8Gy9UaaBWZkw3NyhFdpX6tAeyPA/2lGvkftc42MYmNi8s5ljqkZAtKgWAJnSf2K75NCJw== +"@miniflare/shared@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/shared/-/shared-2.14.4.tgz#b807add75fa2706ea6cac02876cd958488f05b8e" + integrity sha512-upl4RSB3hyCnITOFmRZjJj4A72GmkVrtfZTilkdq5Qe5TTlzsjVeDJp7AuNUM9bM8vswRo+N5jOiot6O4PVwwQ== dependencies: "@types/better-sqlite3" "^7.6.0" kleur "^4.1.4" npx-import "^1.1.4" picomatch "^2.3.1" -"@miniflare/sites@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/sites/-/sites-2.14.2.tgz" - integrity sha512-jFOx1G5kD+kTubsga6jcFbMdU2nSuNG2/EkojwuhYT8hYp3qd8duvPyh1V+OR2tMvM4FWu6jXPXNZNBHXHQaUQ== +"@miniflare/sites@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/sites/-/sites-2.14.4.tgz#21245563d5b9fa36cf0eedffabf78a96a9095714" + integrity sha512-O5npWopi+fw9W9Ki0gy99nuBbgDva/iXy8PDC4dAXDB/pz45nISDqldabk0rL2t4W2+lY6LXKzdOw+qJO1GQTA== dependencies: - "@miniflare/kv" "2.14.2" - "@miniflare/shared" "2.14.2" - "@miniflare/storage-file" "2.14.2" + "@miniflare/kv" "2.14.4" + "@miniflare/shared" "2.14.4" + "@miniflare/storage-file" "2.14.4" -"@miniflare/storage-file@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/storage-file/-/storage-file-2.14.2.tgz" - integrity sha512-tn8rqMBeTtN+ICHQAMKQ0quHGYIkcyDK0qKW+Ic14gdfGDZx45BqXExQM9wTVqKtwAt85zp5eKVUYQCFfUx46Q== +"@miniflare/storage-file@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/storage-file/-/storage-file-2.14.4.tgz#8f967ef66d9a729e3524c8a61ea0d3cf2af2ed91" + integrity sha512-JxcmX0hXf4cB0cC9+s6ZsgYCq+rpyUKRPCGzaFwymWWplrO3EjPVxKCcMxG44jsdgsII6EZihYUN2J14wwCT7A== dependencies: - "@miniflare/shared" "2.14.2" - "@miniflare/storage-memory" "2.14.2" + "@miniflare/shared" "2.14.4" + "@miniflare/storage-memory" "2.14.4" -"@miniflare/storage-memory@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/storage-memory/-/storage-memory-2.14.2.tgz" - integrity sha512-9Wtz9mayHIY0LDsfpMGx+/sfKCq3eAQJzYY+ju1tTEaKR0sVAuO51wu0wbyldsjj9OcBcd2X32iPbIa7KcSZQQ== +"@miniflare/storage-memory@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/storage-memory/-/storage-memory-2.14.4.tgz#4d39f5178aa146c5128ce98782f06d1ff133ae6a" + integrity sha512-9jB5BqNkMZ3SFjbPFeiVkLi1BuSahMhc/W1Y9H0W89qFDrrD+z7EgRgDtHTG1ZRyi9gIlNtt9qhkO1B6W2qb2A== dependencies: - "@miniflare/shared" "2.14.2" + "@miniflare/shared" "2.14.4" -"@miniflare/watcher@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/watcher/-/watcher-2.14.2.tgz" - integrity sha512-/TL0np4uYDl+6MdseDApZmDdlJ6Y7AY5iDY0TvUQJG9nyBoCjX6w0Zn4SiKDwO6660rPtSqZ5c7HzbPhGb5vsA== +"@miniflare/watcher@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/watcher/-/watcher-2.14.4.tgz#1dd672697c8ef055f45b5e46e58bf7e6477f5b04" + integrity sha512-PYn05ET2USfBAeXF6NZfWl0O32KVyE8ncQ/ngysrh3hoIV7l3qGGH7ubeFx+D8VWQ682qYhwGygUzQv2j1tGGg== dependencies: - "@miniflare/shared" "2.14.2" + "@miniflare/shared" "2.14.4" -"@miniflare/web-sockets@2.14.2": - version "2.14.2" - resolved "https://registry.npmjs.org/@miniflare/web-sockets/-/web-sockets-2.14.2.tgz" - integrity sha512-kpbVlznPuxNQahssQvZiNPQo/iPme7qV3WMQeg6TYNCkYD7n6vEqeFZ5E/eQgB59xCanpvw4Ci8y/+SdMK6BUg== +"@miniflare/web-sockets@2.14.4": + version "2.14.4" + resolved "https://registry.yarnpkg.com/@miniflare/web-sockets/-/web-sockets-2.14.4.tgz#a0b6dda2d56fc695dabe7420954c7003e9f69ecf" + integrity sha512-stTxvLdJ2IcGOs76AnvGYAzGvx8JvQPRxC5DW0P5zdAAnhL33noqb5LKdPt3P37BKp9FzBKZHuihQI9oVqwm0g== dependencies: - "@miniflare/core" "2.14.2" - "@miniflare/shared" "2.14.2" - undici "5.28.2" + "@miniflare/core" "2.14.4" + "@miniflare/shared" "2.14.4" + undici "5.28.4" ws "^8.2.2" "@polymeshassociation/polymesh-rust-docs@./workers-site/": version "1.0.0" - resolved "file:workers-site" dependencies: "@cloudflare/kv-asset-handler" "^0.2.0" wrangler "^2.20.1" "@types/better-sqlite3@^7.6.0": - version "7.6.11" - resolved "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.11.tgz" - integrity sha512-i8KcD3PgGtGBLl3+mMYA8PdKkButvPyARxA7IQAd6qeslht13qxb1zzO8dRCtE7U3IoJS782zDBAeoKiM695kg== + version "7.6.12" + resolved "https://registry.yarnpkg.com/@types/better-sqlite3/-/better-sqlite3-7.6.12.tgz#e5712d46d71097dcc2775c0b068072eadc15deb7" + integrity sha512-fnQmj8lELIj7BSrZQAdBMHEHX8OZLYIHXqAKT1O7tDfLxaINzf00PMjw22r3N/xXh0w/sGHlO6SVaCQ2mj78lg== dependencies: "@types/node" "*" "@types/node-forge@^1.3.0": version "1.3.11" - resolved "https://registry.npmjs.org/@types/node-forge/-/node-forge-1.3.11.tgz" + resolved "https://registry.yarnpkg.com/@types/node-forge/-/node-forge-1.3.11.tgz#0972ea538ddb0f4d9c2fa0ec5db5724773a604da" integrity sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ== dependencies: "@types/node" "*" "@types/node@*": - version "22.5.4" - resolved "https://registry.npmjs.org/@types/node/-/node-22.5.4.tgz" - integrity sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg== + version "22.10.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.10.2.tgz#a485426e6d1fdafc7b0d4c7b24e2c78182ddabb9" + integrity sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ== dependencies: - undici-types "~6.19.2" + undici-types "~6.20.0" "@types/stack-trace@0.0.29": version "0.0.29" - resolved "https://registry.npmjs.org/@types/stack-trace/-/stack-trace-0.0.29.tgz" + resolved "https://registry.yarnpkg.com/@types/stack-trace/-/stack-trace-0.0.29.tgz#eb7a7c60098edb35630ed900742a5ecb20cfcb4d" integrity sha512-TgfOX+mGY/NyNxJLIbDWrO9DjGoVSW9+aB8H2yy1fy32jsvxijhmyJI9fDFgvz3YP4lvJaq9DzdR/M1bOgVc9g== anymatch@~3.1.2: version "3.1.3" - resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== dependencies: normalize-path "^3.0.0" picomatch "^2.0.4" binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + version "2.3.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" + integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== blake3-wasm@^2.1.5: version "2.1.5" - resolved "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz" + resolved "https://registry.yarnpkg.com/blake3-wasm/-/blake3-wasm-2.1.5.tgz#b22dbb84bc9419ed0159caa76af4b1b132e6ba52" integrity sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g== braces@~3.0.2: version "3.0.3" - resolved "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== dependencies: fill-range "^7.1.1" buffer-from@^1.0.0: version "1.1.2" - resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== builtins@^5.0.0: version "5.1.0" - resolved "https://registry.npmjs.org/builtins/-/builtins-5.1.0.tgz" + resolved "https://registry.yarnpkg.com/builtins/-/builtins-5.1.0.tgz#6d85eeb360c4ebc166c3fdef922a15aa7316a5e8" integrity sha512-SW9lzGTLvWTP1AY8xeAMZimqDrIaSdLQUcVr9DMef51niJ022Ri87SwRRKYm4A6iHfkPaiVUu/Duw2Wc4J7kKg== dependencies: semver "^7.0.0" busboy@^1.6.0: version "1.6.0" - resolved "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893" integrity sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA== dependencies: streamsearch "^1.1.0" chokidar@^3.5.3: - version "3.5.3" - resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + version "3.6.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" + integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== dependencies: anymatch "~3.1.2" braces "~3.0.2" @@ -297,18 +401,18 @@ chokidar@^3.5.3: cookie@^0.4.1: version "0.4.2" - resolved "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== cron-schedule@^3.0.4: version "3.0.6" - resolved "https://registry.npmjs.org/cron-schedule/-/cron-schedule-3.0.6.tgz" + resolved "https://registry.yarnpkg.com/cron-schedule/-/cron-schedule-3.0.6.tgz#7d0a3ad9154112fc3720fe43238a43d50e8465e7" integrity sha512-izfGgKyzzIyLaeb1EtZ3KbglkS6AKp9cv7LxmiyoOu+fXfol1tQDC0Cof0enVZGNtudTHW+3lfuW9ZkLQss4Wg== cross-spawn@^7.0.3: - version "7.0.3" - resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + version "7.0.6" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" + integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== dependencies: path-key "^3.1.0" shebang-command "^2.0.0" @@ -316,12 +420,12 @@ cross-spawn@^7.0.3: dotenv@^10.0.0: version "10.0.0" - resolved "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81" integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q== -esbuild@*, esbuild@0.16.3: +esbuild@0.16.3: version "0.16.3" - resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.16.3.tgz" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.16.3.tgz#5868632fa23f7a8547f2a4ea359c44e946515c94" integrity sha512-71f7EjPWTiSguen8X/kxEpkAS7BFHwtQKisCDDV3Y4GLGWBaoSCyD5uXkaUew6JDzA9FEN1W23mdnSwW9kqCeg== optionalDependencies: "@esbuild/android-arm" "0.16.3" @@ -349,17 +453,17 @@ esbuild@*, esbuild@0.16.3: escape-string-regexp@^4.0.0: version "4.0.0" - resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== estree-walker@^0.6.1: version "0.6.1" - resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== execa@^6.1.0: version "6.1.0" - resolved "https://registry.npmjs.org/execa/-/execa-6.1.0.tgz" + resolved "https://registry.yarnpkg.com/execa/-/execa-6.1.0.tgz#cea16dee211ff011246556388effa0818394fb20" integrity sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA== dependencies: cross-spawn "^7.0.3" @@ -374,156 +478,161 @@ execa@^6.1.0: fill-range@^7.1.1: version "7.1.1" - resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== dependencies: to-regex-range "^5.0.1" +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + get-stream@^6.0.1: version "6.0.1" - resolved "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== glob-parent@~5.1.2: version "5.1.2" - resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" html-rewriter-wasm@^0.4.1: version "0.4.1" - resolved "https://registry.npmjs.org/html-rewriter-wasm/-/html-rewriter-wasm-0.4.1.tgz" + resolved "https://registry.yarnpkg.com/html-rewriter-wasm/-/html-rewriter-wasm-0.4.1.tgz#235e3d96c1aa4bfd2182661ee13881e290ff5ff2" integrity sha512-lNovG8CMCCmcVB1Q7xggMSf7tqPCijZXaH4gL6iE8BFghdQCbaY5Met9i1x2Ex8m/cZHDUtXK9H6/znKamRP8Q== http-cache-semantics@^4.1.0: version "4.1.1" - resolved "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz" + resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== human-signals@^3.0.1: version "3.0.1" - resolved "https://registry.npmjs.org/human-signals/-/human-signals-3.0.1.tgz" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-3.0.1.tgz#c740920859dafa50e5a3222da9d3bf4bb0e5eef5" integrity sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ== is-binary-path@~2.1.0: version "2.1.0" - resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== dependencies: binary-extensions "^2.0.0" is-extglob@^2.1.1: version "2.1.1" - resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== is-glob@^4.0.1, is-glob@~4.0.1: version "4.0.3" - resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== dependencies: is-extglob "^2.1.1" is-number@^7.0.0: version "7.0.0" - resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== is-stream@^3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-3.0.0.tgz#e6bfd7aa6bef69f4f472ce9bb681e3e57b4319ac" integrity sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA== isexe@^2.0.0: version "2.0.0" - resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== kleur@^4.1.4: version "4.1.5" - resolved "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-4.1.5.tgz#95106101795f7050c6c650f350c683febddb1780" integrity sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ== magic-string@^0.25.3: version "0.25.9" - resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== dependencies: sourcemap-codec "^1.4.8" merge-stream@^2.0.0: version "2.0.0" - resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== mime@^3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz" + resolved "https://registry.yarnpkg.com/mime/-/mime-3.0.0.tgz#b374550dca3a0c18443b0c950a6a58f1931cf7a7" integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A== mimic-fn@^4.0.0: version "4.0.0" - resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc" integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== -miniflare@2.14.2: - version "2.14.2" - resolved "https://registry.npmjs.org/miniflare/-/miniflare-2.14.2.tgz" - integrity sha512-s2gruuOFT0o3cmQW+EX3k2EaLe1iHZ4OVXRmcNLj5ivrxxRHcK4Hy0LMd6bUOVDcT5KSKs7ylBkHqzp0zmUKCg== - dependencies: - "@miniflare/cache" "2.14.2" - "@miniflare/cli-parser" "2.14.2" - "@miniflare/core" "2.14.2" - "@miniflare/d1" "2.14.2" - "@miniflare/durable-objects" "2.14.2" - "@miniflare/html-rewriter" "2.14.2" - "@miniflare/http-server" "2.14.2" - "@miniflare/kv" "2.14.2" - "@miniflare/queues" "2.14.2" - "@miniflare/r2" "2.14.2" - "@miniflare/runner-vm" "2.14.2" - "@miniflare/scheduler" "2.14.2" - "@miniflare/shared" "2.14.2" - "@miniflare/sites" "2.14.2" - "@miniflare/storage-file" "2.14.2" - "@miniflare/storage-memory" "2.14.2" - "@miniflare/web-sockets" "2.14.2" +miniflare@2.14.4: + version "2.14.4" + resolved "https://registry.yarnpkg.com/miniflare/-/miniflare-2.14.4.tgz#75900b78894ea2f0b93346c77dc98b1295a33b29" + integrity sha512-sMV8oJRWwqxPsgg7EOMizkv7pLxd1HOzqv055PcsM4kcRECPhnJSaCtAUc+ZfpOgR4musgfooM6kQo8o+ifZ+w== + dependencies: + "@miniflare/cache" "2.14.4" + "@miniflare/cli-parser" "2.14.4" + "@miniflare/core" "2.14.4" + "@miniflare/d1" "2.14.4" + "@miniflare/durable-objects" "2.14.4" + "@miniflare/html-rewriter" "2.14.4" + "@miniflare/http-server" "2.14.4" + "@miniflare/kv" "2.14.4" + "@miniflare/queues" "2.14.4" + "@miniflare/r2" "2.14.4" + "@miniflare/runner-vm" "2.14.4" + "@miniflare/scheduler" "2.14.4" + "@miniflare/shared" "2.14.4" + "@miniflare/sites" "2.14.4" + "@miniflare/storage-file" "2.14.4" + "@miniflare/storage-memory" "2.14.4" + "@miniflare/web-sockets" "2.14.4" kleur "^4.1.4" semiver "^1.1.0" source-map-support "^0.5.20" - undici "5.28.2" + undici "5.28.4" mustache@^4.2.0: version "4.2.0" - resolved "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz" + resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64" integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== nanoid@^3.3.3: - version "3.3.4" - resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz" - integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== + version "3.3.8" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.8.tgz#b1be3030bee36aaff18bacb375e5cce521684baf" + integrity sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w== node-forge@^1: version "1.3.1" - resolved "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz" + resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== npm-run-path@^5.1.0: version "5.3.0" - resolved "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-5.3.0.tgz#e23353d0ebb9317f174e93417e4a4d82d0249e9f" integrity sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ== dependencies: path-key "^4.0.0" npx-import@^1.1.4: version "1.1.4" - resolved "https://registry.npmjs.org/npx-import/-/npx-import-1.1.4.tgz" + resolved "https://registry.yarnpkg.com/npx-import/-/npx-import-1.1.4.tgz#0ee9a27484c633255528f7ec2e4c2adeaa1fcda3" integrity sha512-3ShymTWOgqGyNlh5lMJAejLuIv3W1K3fbI5Ewc6YErZU3Sp0PqsNs8UIU1O8z5+KVl/Du5ag56Gza9vdorGEoA== dependencies: execa "^6.1.0" @@ -533,46 +642,46 @@ npx-import@^1.1.4: onetime@^6.0.0: version "6.0.0" - resolved "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-6.0.0.tgz#7c24c18ed1fd2e9bca4bd26806a33613c77d34b4" integrity sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ== dependencies: mimic-fn "^4.0.0" parse-package-name@^1.0.0: version "1.0.0" - resolved "https://registry.npmjs.org/parse-package-name/-/parse-package-name-1.0.0.tgz" + resolved "https://registry.yarnpkg.com/parse-package-name/-/parse-package-name-1.0.0.tgz#1a108757e4ffc6889d5e78bcc4932a97c097a5a7" integrity sha512-kBeTUtcj+SkyfaW4+KBe0HtsloBJ/mKTPoxpVdA57GZiPerREsUWJOhVj9anXweFiJkm5y8FG1sxFZkZ0SN6wg== path-key@^3.1.0: version "3.1.1" - resolved "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== path-key@^4.0.0: version "4.0.0" - resolved "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-4.0.0.tgz#295588dc3aee64154f877adb9d780b81c554bf18" integrity sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ== path-to-regexp@^6.2.0: version "6.3.0" - resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.3.0.tgz#2b6a26a337737a8e1416f9272ed0766b1c0389f4" integrity sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ== picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: version "2.3.1" - resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== readdirp@~3.6.0: version "3.6.0" - resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== dependencies: picomatch "^2.2.1" rollup-plugin-inject@^3.0.0: version "3.0.2" - resolved "https://registry.npmjs.org/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz" + resolved "https://registry.yarnpkg.com/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz#e4233855bfba6c0c12a312fd6649dff9a13ee9f4" integrity sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w== dependencies: estree-walker "^0.6.1" @@ -581,21 +690,21 @@ rollup-plugin-inject@^3.0.0: rollup-plugin-node-polyfills@^0.2.1: version "0.2.1" - resolved "https://registry.npmjs.org/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz" + resolved "https://registry.yarnpkg.com/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz#53092a2744837164d5b8a28812ba5f3ff61109fd" integrity sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA== dependencies: rollup-plugin-inject "^3.0.0" rollup-pluginutils@^2.8.1: version "2.8.2" - resolved "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz" + resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== dependencies: estree-walker "^0.6.1" selfsigned@^2.0.0, selfsigned@^2.0.1: version "2.4.1" - resolved "https://registry.npmjs.org/selfsigned/-/selfsigned-2.4.1.tgz" + resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.4.1.tgz#560d90565442a3ed35b674034cec4e95dceb4ae0" integrity sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q== dependencies: "@types/node-forge" "^1.3.0" @@ -603,39 +712,39 @@ selfsigned@^2.0.0, selfsigned@^2.0.1: semiver@^1.1.0: version "1.1.0" - resolved "https://registry.npmjs.org/semiver/-/semiver-1.1.0.tgz" + resolved "https://registry.yarnpkg.com/semiver/-/semiver-1.1.0.tgz#9c97fb02c21c7ce4fcf1b73e2c7a24324bdddd5f" integrity sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg== semver@^7.0.0, semver@^7.3.7: version "7.6.3" - resolved "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== set-cookie-parser@^2.4.8: - version "2.7.0" - resolved "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.0.tgz" - integrity sha512-lXLOiqpkUumhRdFF3k1osNXCy9akgx/dyPZ5p8qAg9seJzXr5ZrlqZuWIMuY6ejOsVLE6flJ5/h3lsn57fQ/PQ== + version "2.7.1" + resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz#3016f150072202dfbe90fadee053573cc89d2943" + integrity sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ== shebang-command@^2.0.0: version "2.0.0" - resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== dependencies: shebang-regex "^3.0.0" shebang-regex@^3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== signal-exit@^3.0.7: version "3.0.7" - resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== source-map-support@^0.5.20: version "0.5.21" - resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== dependencies: buffer-from "^1.0.0" @@ -643,87 +752,87 @@ source-map-support@^0.5.20: source-map@^0.6.0: version "0.6.1" - resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== source-map@^0.7.4: version "0.7.4" - resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656" integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA== sourcemap-codec@^1.4.8: version "1.4.8" - resolved "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz" + resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== stack-trace@0.0.10: version "0.0.10" - resolved "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" integrity sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg== streamsearch@^1.1.0: version "1.1.0" - resolved "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== strip-final-newline@^3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-3.0.0.tgz#52894c313fbff318835280aed60ff71ebf12b8fd" integrity sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw== to-regex-range@^5.0.1: version "5.0.1" - resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== dependencies: is-number "^7.0.0" -undici-types@~6.19.2: - version "6.19.8" - resolved "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz" - integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== +undici-types@~6.20.0: + version "6.20.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.20.0.tgz#8171bf22c1f588d1554d55bf204bc624af388433" + integrity sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg== -undici@5.28.2: - version "5.28.2" - resolved "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz" - integrity sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w== +undici@5.28.4: + version "5.28.4" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068" + integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g== dependencies: "@fastify/busboy" "^2.0.0" urlpattern-polyfill@^4.0.3: version "4.0.3" - resolved "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-4.0.3.tgz" + resolved "https://registry.yarnpkg.com/urlpattern-polyfill/-/urlpattern-polyfill-4.0.3.tgz#c1fa7a73eb4e6c6a1ffb41b24cf31974f7392d3b" integrity sha512-DOE84vZT2fEcl9gqCUTcnAw5ZY5Id55ikUcziSUntuEFL3pRvavg5kwDmTEUJkeCHInTlV/HexFomgYnzO5kdQ== validate-npm-package-name@^4.0.0: version "4.0.0" - resolved "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-4.0.0.tgz" + resolved "https://registry.yarnpkg.com/validate-npm-package-name/-/validate-npm-package-name-4.0.0.tgz#fe8f1c50ac20afdb86f177da85b3600f0ac0d747" integrity sha512-mzR0L8ZDktZjpX4OB46KT+56MAhl4EIazWP/+G/HPGuvfdaqg4YsCdtOm6U9+LOFyYDoh4dpnpxZRB9MQQns5Q== dependencies: builtins "^5.0.0" which@^2.0.1: version "2.0.2" - resolved "https://registry.npmjs.org/which/-/which-2.0.2.tgz" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== dependencies: isexe "^2.0.0" wrangler@^2.20.1: - version "2.21.1" - resolved "https://registry.npmjs.org/wrangler/-/wrangler-2.21.1.tgz" - integrity sha512-gPLqLHUvIR1TVLc2fARtIJ4UNVpTTMbxXKCZyLqGuLmbYPFQhvNKlct2eyfAYuYaTOr8g7VxswMn2mFab1Gu5A== + version "2.21.2" + resolved "https://registry.yarnpkg.com/wrangler/-/wrangler-2.21.2.tgz#77bd420540fbcde6e7e0f459188bd3ee9b4ead98" + integrity sha512-2vD2dXjGa1zWnv+0o2esVIYvWA0zupiHitZNhWL3WyQrAyRMvWKzFK3XSag9Cgbjxv3WbuOXMx8EroM704Vy3A== dependencies: "@cloudflare/kv-asset-handler" "^0.2.0" "@esbuild-plugins/node-globals-polyfill" "^0.1.1" "@esbuild-plugins/node-modules-polyfill" "^0.1.4" - "@miniflare/core" "2.14.2" - "@miniflare/d1" "2.14.2" - "@miniflare/durable-objects" "2.14.2" + "@miniflare/core" "2.14.4" + "@miniflare/d1" "2.14.4" + "@miniflare/durable-objects" "2.14.4" blake3-wasm "^2.1.5" chokidar "^3.5.3" esbuild "0.16.3" - miniflare "2.14.2" + miniflare "2.14.4" nanoid "^3.3.3" path-to-regexp "^6.2.0" selfsigned "^2.0.1" @@ -734,17 +843,17 @@ wrangler@^2.20.1: ws@^8.2.2: version "8.18.0" - resolved "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== xxhash-wasm@^1.0.1: - version "1.0.2" - resolved "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-1.0.2.tgz" - integrity sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A== + version "1.1.0" + resolved "https://registry.yarnpkg.com/xxhash-wasm/-/xxhash-wasm-1.1.0.tgz#ffe7f0b98220a4afac171e3fb9b6d1f8771f015e" + integrity sha512-147y/6YNh+tlp6nd/2pWq38i9h6mz/EuQ6njIrmW8D1BS5nCqs0P6DG+m6zTGnNz5I+uhZ0SHxBs9BsPrwcKDA== youch@^2.2.2: version "2.2.2" - resolved "https://registry.npmjs.org/youch/-/youch-2.2.2.tgz" + resolved "https://registry.yarnpkg.com/youch/-/youch-2.2.2.tgz#cb87a359a5c524ebd35eb07ca3a1521dbc7e1a3e" integrity sha512-/FaCeG3GkuJwaMR34GHVg0l8jCbafZLHiFowSjqLlqhC6OMyf2tPJBu8UirF7/NI9X/R5ai4QfEKUCOxMAGxZQ== dependencies: "@types/stack-trace" "0.0.29" From 3f32576a4cd9d284fb55a18fb6fcc131ff29a38a Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 20 Dec 2024 00:23:51 +0800 Subject: [PATCH 42/45] Update v7.1 testnet/mainnet metadata. --- .metadata/polymesh_mainnet/7001000.meta | Bin 367325 -> 378420 bytes .metadata/polymesh_testnet/7001000.meta | Bin 367325 -> 378420 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/.metadata/polymesh_mainnet/7001000.meta b/.metadata/polymesh_mainnet/7001000.meta index c16aadf217c7c1d0a32b725d28104c4ccb38ed36..b47fbb44d2a4b17a4c7cd71ae1c782c4f06bb187 100644 GIT binary patch delta 15135 zcmds8du$xXdDjk)7HNu<$fNiONogsCw5X70QnFm@Wr^lPI*X+EIO=JOTHfvPHoV(C z?(R{dWS3SD*KsSyG%nFp23l800z+uxLRK0^aS%s=fub)oMp2+f?Kln!^p7;C3$%cZ z)@{FUW?y$aQja4UqkoaNJM+!V_xOE}`Syc9uloMw>bc((7wt<*@wjY`-P|B-^?QCE ztNhIao}baWD-Fd(?bhIQb5(*?8#5Quikt`c|kR`_Z=X zzuQvg5R?o3{oPNJyrKTK#0to}1lo{Dja~9`{wHn{I67 z|4iN(rw{)Tsk=$uq|L=e2kn#m_#gkithlJ#{`uy=e5ah=-e2Iq`PEO=%HpC{>jm9d zCd||SjTO|)|4*6FR#05@nDu6Uph6e{65H(G?})-n9WFQK&0#@)IDMmaBmJ*S!guhW z`Ja77_>1E7N3T`Rf9taFpSQ@tM*3xorYY)# zH6tK~fUGrpT8b-?62+VmBbsc8s&?fNX*eEO)4Emc)F)C2Sv8FrVY_%%)0GKDJu9}c z+5DFX^zALSisxcVI0oBQ#c?1HOC)tAA?Y)?LqiU0YJ^^T*H=9|2h{lLHZ^N6o+Ad< zh+D;;X*YY5t0bP{^_5t^=;l2=x~<_X%nOHB*dg zDK!%4VcdGg@7wgC%Pso4-`7mP5+pk+_RV#IFq5W%3d|57ExqWc&4JN$EG8RGJoDkWrO0%FSPvz_>C03SVVg9Abp-^vtnEuu^- zhB6*!lSb(Naq?J@y+(dHF9YrZ=1eksfe=2*vA{3sNBv}@4|dZ@-ybKN>v!Xd0ICr{ zzcC#Z&)qMr3X@&!4$OQEBiZgb6TJxIoB+0%e)zrWGMvQl#>4I$iV3fW#PO2Xbb|Z5v=m?;Z+0)pBU<7bdi7K*g zZ9-B3bfZ^JlbUt9?98j7Lq|z{rLX&PuP)0MKu>IqG-%^>;vc*uEb4@82^lHwahO*D z^irj`C{4if=%1pDY$nys%dB~|m*MbiHx{Cy-m%~GcLxi$%(^!EJ`7~+>D9FhGV@&A zP%S)JV4qPo&Vyz@1PTM%NGcp-bQVb1@|Y%fuz|mU;q9Gqu))ZTyC%9AdyBZF#0LPg za9063aFmEbH`U+|ZM#m^4!@YE6jJJH$f4;Qi^%~s!QKPCt&tj!O#aoD$tY~{?xcdG z7^j$InbqB+Tw1@&rH zd|{a_qZ}1J!!l_3DbmP|gNHZ#trxKY+Gza{3Hb08efK)49dRw_pKWOk%Q(jaiHn(# z&IfvI=>8CLpM{Y3DCtVY0Dz*>2&qm#_elkPafCFIwIONTmg%1)$VR$pm^@R+I80v~CU1GPo&k0zdd4TDxTJ>VQKk(pKV5(r=K~gC zQ;N^y$i{)8!oWbn<4z7i zRF{fNI^+Xhv`c{JWC+jrYiA0kn2=?73@c2y^C0k^N-4U0fTa$BPNW{vOesE+N+#no zN2g^y3b~Dkyoqlic*oaSvGoISC83xBdTN9W2_gF35n^%`53G4MPm6>oSC$i;2Ovyc zOJqp%58`By9z0GuERo&{kyrm8i4>BM6u=SYl#C6ID_b>@j*OD#^@pDoy#A4XZIpy& z^L2m;X%a#L72+Nzoa7+r2``t(Z};Y#;4T8hF2s8DXb8=tn}@_o9L%mOCaDu1s733t zj=|nzRBdNO3s3@*N}TLLiJSmB%WRfGm21naND#Oas@yH8d}6x}D;~0r$fN!(UYUDi zB1c{U`qg7(|7`bjoskG^G0f`_9>{eZvy>+cNEr)&LDAj@{0&VOLO5kxWwx$7Cq;Xpa1t$M&cb6Q4a1c;`_h$>HMywE-S*vhLZP3{!@kzLI$SD7V1M1-0DFed&ZvWZrODIoo`5?{^M?D7m8(gU0~a7|j?URYb&!^(Z! zl!Ek)5?}3xoN4`9D`=(HPLX54`cF=gj(&cEHP`Z#0FVD5qpvPlT@kG12T0M|r%9Dl zS=mHCIZZ@Yom*VSvuc`Kkub7iT`WpG2}OyFTJ6H<_FifnC7v1wo%(4(6+QA4>D?3> z5_&Zq3c?WA*@X^PlVagJed8&zXXJxC#R9Sj12TK*(*yrO>Llh!G;rSfN|w?Wi8Ly? z%>ElRn8kUh_aXXwPm>)r3~Vsi9ZPDu8P(#7#@~K)yP$^t+9YLE93?wFE`=3{yP$ln zYj_V4vg*FJE!hFIlr2-6t(Qqdc?-Uaz_yh*ON)-ueKHxK z&mAMam>YHM#!(RBbz+sR-#X+mEOIz_=N8!mZsYjArX30${lw3hnHw=X_p>4@`+Or9Zw@296; zuA!|_BA&>%*qNa#7WY3VI#bJa1{vqoixAhEopfx%8<|$PI>JH*&=LCZ1gR-y%ET^& zKrzy7bDOp<2w{K;p3vp~6(OhQWGe!YN6pzDG#V)HS%;s?81I;z+X{MdlGK)MM6nxC^F~t%(QA`r zclmw7hbKIG38|)EnAqT0HX{yGQfO-Nj({J-x>W%$E9^9?3<3Nhcyl6;)xKZA&|{PbbM4;UGN` zClAdwF0L`U28~2k4;rM}E_jI(aSiU!GOaZ;1vkNlGMm{v)B-N#6d=AVf;oGtoW7B7 z;_>b5Cw=1;e|qi}-*ARxtv%f%j<}*_mjpn%ivClXuXLw}%h{*RVf&v8`PzwFPl9v{ zef0MeWb@Hwyi!LUTg5ANp0X{{qJ%fZRv%P|wJFif(*=zT13XogQq-DG3|4Vau1g=T zEzEkd1Jt{`<`Lb9mlr--!Du|!Ja^G~H8)9Qj*lsU#VnMZ@$H9UKdXvOjng-ETcdRArG8Z$VF6? zqb%8(?3N_fctIyM;`cK_GY>uHWIl5m2`1dQlp%K?hFkqs;&Mcu>6W4K+H-w_49wx^ zvsEL)r+LCw7BH~{rp+U>+@x}*F*)6W6N&;MOk-GVP5U?anm2n^al8oP(zqOlrdosk z`~_bXeNQ8U!eP2SNp_unX>pwAn!>scSfevsP+_lgX4@GTI23)HGlsR@Bh5D^kb9M&t``jc$az)hkghyK-`0Y{aEbDQRqd=kw7=>e9V#<)F0^y z=v5=F-=>KvBBnq4;6eJw23fbv7l64y)R8!SwxM7>6<;SsW3CPLqwEKDxs$6_gmL69 zMD9^X5Igj6>2g?xCN3=d2k1_dbdc6>(2F{$Pw)G1HP6bVy~C3yuoI>a{9)Ceg~tM+ zx(9)HHya$d9!3ImONt~P=)NV4K;2{J9N9*Hnj$+#bo?5`1+l=ICCu5joF!X-rAT`0 zYSl{JO;)gLE4C5G#a?@>pep^74@;;zP3p?0IPOLixOvmDv_r2>lgM^gU07DmbfjOl zMrHIz(DFwLYELXE0kPHyk2k%6>kOn4i>;U>n1fqH5{J)|`to;kNur5fJx`9ey5e9lPbU9{Sp$dD z`oIKIyFeh0Vt;&|JOP#Qoik)_-j(sVqE6y1F8`p))K;R!VM8M_#`E11eefcLyzkDC z%@xJ?DwC-IenG|M7gJyU5mX;+R*r-;#=Q(=u=byg1$es5wjpm>vlG{*@L53Jqe#pu zaJ!_iH`>mxT`K&eH1^FC|K4ZrLEqZU?|nAJBm=xn5_&-+?3;yrKMZPReIV@ELBqOs zbeO?;$x0w}d!?`R zKJ=&wHoKU5{0``|``s7|o%y0c1D3TFAQa;k$@YZB-j`G93Qdo%-uO8 z6bch#R4hO?1CJk@3LUJpr4lGq)-?75X`4VTY|H`LTWs&DuJXS$7Dm6bf=+- zvZ1rfpViF#S`K#IVoX#*l8%=Og_7Zx;#*U5K_7OO9k0m2usF3$oHu-@X|u!mu#i*h zd@VU6{n}UI$k}+7KR4syW#SjJb3q+${nmxKvnMAt_4&nsP(G}_`7@}V)H>C2sWu0z zotMHngt&6}!%MH#_|fEM>05h+>yJKk4AK`43jh8w zxQg&>E7alJtxz?sNLc%{m-%t)a&WfxNCpdunl`{9sF4>q*8X#n5jG4J@c?a*wP8y-YR`Kd?#FgY?j{riWXCe)C|kiy11R^~kz` zMZbqqd~OBQ3k>(HfNO;h1Sw!&rs%Qy8z3zu6!F2~e@;xItg_g)NVvNd{EqBV zY{V6vupF;$f+g9m_lxjkwQFxnILyLo$eLO{;MB1_av#ly1;>4U)k^6XyouBhFIO1v zc0*M*+^<5gTySAt7%H=(ecU?PV)h>$9hukV5;SL@{!D^;+v!9!RK~5m95ZN}AA8XDh|)acIFUD!3`%msDVT ze(NVH5}MjaafeBh2ZAI>u^8)?SU0DR5@e#nR<)8mG2Ku#u}AV;<%j4|h~7{$E8N=D zRbgTQutN4Vr&t1ez@m3$46y~Q+9WKQs zop89wg6DzsO1yFg?%f3qnVuK;K#nxMf!B6H3Et_4ijrDWT{5fH%hUv4{9+7$(+`g! zdjY26pLc;1R}VmOeh-alc>^=IF{XFIF1!0Si4AVs4VBpO0zrB^;m|_@$*9@+@&3$E zo*NtX2~M`X2yY7uaq%9gH?cEfIz-8gECzgWFU-m-;;?!`3enWw9fD$fYCp`G@&C`d zZ69dh9>PNhU{-3~P#(Ujf&+b>@Xh}zG_NC@%Ry}4M;!YO&=zpw-~pI}7gWgSuxvw^KwRRdkez)L3s$KdOeom@D2=)L1m59}Pikphl)^9eTbGu4z$CimQDR{^ca}POo&G7uH+<+fTtV<#&5PSr);2eEg@NS$yQh~W|$73x8Aq!>(-;YX6R(cs<%Xs@NUC-BChj{w* ztMKgphklS9xaYQ|@42T8%$oe$?!bQEl=Oa|ed-M1G7kFfbyb$K(?F;pnRbo2$}`vZ dRpDS)I_bc((7wt<*@wjY`-P|B-^?QCE ztNhIao}baWD-Fd(?bhIQb5(*?8#5Quikt`c|kR`_Z=X zzuQvg5R?o3{oPNJyrKTK#0to}1lo{Dja~9`{wHn{I67 z|4iN(rw{)Tsk=$uq|L=e2kn#m_#gkithlJ#{`uy=e5ah=-e2Iq`PEO=%HpC{>jm9d zCd||SjTO|)|4*6FR#05@nDu6Uph6e{65H(G?})-n9WFQK&0#@)IDMmaBmJ*S!guhW z`Ja77_>1E7N3T`Rf9taFpSQ@tM*3xorYY)# zH6tK~fUGrpT8b-?62+VmBbsc8s&?fNX*eEO)4Emc)F)C2Sv8FrVY_%%)0GKDJu9}c z+5DFX^zALSisxcVI0oBQ#c?1HOC)tAA?Y)?LqiU0YJ^^T*H=9|2h{lLHZ^N6o+Ad< zh+D;;X*YY5t0bP{^_5t^=;l2=x~<_X%nOHB*dg zDK!%4VcdGg@7wgC%Pso4-`7mP5+pk+_RV#IFq5W%3d|57ExqWc&4JN$EG8RGJoDkWrO0%FSPvz_>C03SVVg9Abp-^vtnEuu^- zhB6*!lSb(Naq?J@y+(dHF9YrZ=1eksfe=2*vA{3sNBv}@4|dZ@-ybKN>v!Xd0ICr{ zzcC#Z&)qMr3X@&!4$OQEBiZgb6TJxIoB+0%e)zrWGMvQl#>4I$iV3fW#PO2Xbb|Z5v=m?;Z+0)pBU<7bdi7K*g zZ9-B3bfZ^JlbUt9?98j7Lq|z{rLX&PuP)0MKu>IqG-%^>;vc*uEb4@82^lHwahO*D z^irj`C{4if=%1pDY$nys%dB~|m*MbiHx{Cy-m%~GcLxi$%(^!EJ`7~+>D9FhGV@&A zP%S)JV4qPo&Vyz@1PTM%NGcp-bQVb1@|Y%fuz|mU;q9Gqu))ZTyC%9AdyBZF#0LPg za9063aFmEbH`U+|ZM#m^4!@YE6jJJH$f4;Qi^%~s!QKPCt&tj!O#aoD$tY~{?xcdG z7^j$InbqB+Tw1@&rH zd|{a_qZ}1J!!l_3DbmP|gNHZ#trxKY+Gza{3Hb08efK)49dRw_pKWOk%Q(jaiHn(# z&IfvI=>8CLpM{Y3DCtVY0Dz*>2&qm#_elkPafCFIwIONTmg%1)$VR$pm^@R+I80v~CU1GPo&k0zdd4TDxTJ>VQKk(pKV5(r=K~gC zQ;N^y$i{)8!oWbn<4z7i zRF{fNI^+Xhv`c{JWC+jrYiA0kn2=?73@c2y^C0k^N-4U0fTa$BPNW{vOesE+N+#no zN2g^y3b~Dkyoqlic*oaSvGoISC83xBdTN9W2_gF35n^%`53G4MPm6>oSC$i;2Ovyc zOJqp%58`By9z0GuERo&{kyrm8i4>BM6u=SYl#C6ID_b>@j*OD#^@pDoy#A4XZIpy& z^L2m;X%a#L72+Nzoa7+r2``t(Z};Y#;4T8hF2s8DXb8=tn}@_o9L%mOCaDu1s733t zj=|nzRBdNO3s3@*N}TLLiJSmB%WRfGm21naND#Oas@yH8d}6x}D;~0r$fN!(UYUDi zB1c{U`qg7(|7`bjoskG^G0f`_9>{eZvy>+cNEr)&LDAj@{0&VOLO5kxWwx$7Cq;Xpa1t$M&cb6Q4a1c;`_h$>HMywE-S*vhLZP3{!@kzLI$SD7V1M1-0DFed&ZvWZrODIoo`5?{^M?D7m8(gU0~a7|j?URYb&!^(Z! zl!Ek)5?}3xoN4`9D`=(HPLX54`cF=gj(&cEHP`Z#0FVD5qpvPlT@kG12T0M|r%9Dl zS=mHCIZZ@Yom*VSvuc`Kkub7iT`WpG2}OyFTJ6H<_FifnC7v1wo%(4(6+QA4>D?3> z5_&Zq3c?WA*@X^PlVagJed8&zXXJxC#R9Sj12TK*(*yrO>Llh!G;rSfN|w?Wi8Ly? z%>ElRn8kUh_aXXwPm>)r3~Vsi9ZPDu8P(#7#@~K)yP$^t+9YLE93?wFE`=3{yP$ln zYj_V4vg*FJE!hFIlr2-6t(Qqdc?-Uaz_yh*ON)-ueKHxK z&mAMam>YHM#!(RBbz+sR-#X+mEOIz_=N8!mZsYjArX30${lw3hnHw=X_p>4@`+Or9Zw@296; zuA!|_BA&>%*qNa#7WY3VI#bJa1{vqoixAhEopfx%8<|$PI>JH*&=LCZ1gR-y%ET^& zKrzy7bDOp<2w{K;p3vp~6(OhQWGe!YN6pzDG#V)HS%;s?81I;z+X{MdlGK)MM6nxC^F~t%(QA`r zclmw7hbKIG38|)EnAqT0HX{yGQfO-Nj({J-x>W%$E9^9?3<3Nhcyl6;)xKZA&|{PbbM4;UGN` zClAdwF0L`U28~2k4;rM}E_jI(aSiU!GOaZ;1vkNlGMm{v)B-N#6d=AVf;oGtoW7B7 z;_>b5Cw=1;e|qi}-*ARxtv%f%j<}*_mjpn%ivClXuXLw}%h{*RVf&v8`PzwFPl9v{ zef0MeWb@Hwyi!LUTg5ANp0X{{qJ%fZRv%P|wJFif(*=zT13XogQq-DG3|4Vau1g=T zEzEkd1Jt{`<`Lb9mlr--!Du|!Ja^G~H8)9Qj*lsU#VnMZ@$H9UKdXvOjng-ETcdRArG8Z$VF6? zqb%8(?3N_fctIyM;`cK_GY>uHWIl5m2`1dQlp%K?hFkqs;&Mcu>6W4K+H-w_49wx^ zvsEL)r+LCw7BH~{rp+U>+@x}*F*)6W6N&;MOk-GVP5U?anm2n^al8oP(zqOlrdosk z`~_bXeNQ8U!eP2SNp_unX>pwAn!>scSfevsP+_lgX4@GTI23)HGlsR@Bh5D^kb9M&t``jc$az)hkghyK-`0Y{aEbDQRqd=kw7=>e9V#<)F0^y z=v5=F-=>KvBBnq4;6eJw23fbv7l64y)R8!SwxM7>6<;SsW3CPLqwEKDxs$6_gmL69 zMD9^X5Igj6>2g?xCN3=d2k1_dbdc6>(2F{$Pw)G1HP6bVy~C3yuoI>a{9)Ceg~tM+ zx(9)HHya$d9!3ImONt~P=)NV4K;2{J9N9*Hnj$+#bo?5`1+l=ICCu5joF!X-rAT`0 zYSl{JO;)gLE4C5G#a?@>pep^74@;;zP3p?0IPOLixOvmDv_r2>lgM^gU07DmbfjOl zMrHIz(DFwLYELXE0kPHyk2k%6>kOn4i>;U>n1fqH5{J)|`to;kNur5fJx`9ey5e9lPbU9{Sp$dD z`oIKIyFeh0Vt;&|JOP#Qoik)_-j(sVqE6y1F8`p))K;R!VM8M_#`E11eefcLyzkDC z%@xJ?DwC-IenG|M7gJyU5mX;+R*r-;#=Q(=u=byg1$es5wjpm>vlG{*@L53Jqe#pu zaJ!_iH`>mxT`K&eH1^FC|K4ZrLEqZU?|nAJBm=xn5_&-+?3;yrKMZPReIV@ELBqOs zbeO?;$x0w}d!?`R zKJ=&wHoKU5{0``|``s7|o%y0c1D3TFAQa;k$@YZB-j`G93Qdo%-uO8 z6bch#R4hO?1CJk@3LUJpr4lGq)-?75X`4VTY|H`LTWs&DuJXS$7Dm6bf=+- zvZ1rfpViF#S`K#IVoX#*l8%=Og_7Zx;#*U5K_7OO9k0m2usF3$oHu-@X|u!mu#i*h zd@VU6{n}UI$k}+7KR4syW#SjJb3q+${nmxKvnMAt_4&nsP(G}_`7@}V)H>C2sWu0z zotMHngt&6}!%MH#_|fEM>05h+>yJKk4AK`43jh8w zxQg&>E7alJtxz?sNLc%{m-%t)a&WfxNCpdunl`{9sF4>q*8X#n5jG4J@c?a*wP8y-YR`Kd?#FgY?j{riWXCe)C|kiy11R^~kz` zMZbqqd~OBQ3k>(HfNO;h1Sw!&rs%Qy8z3zu6!F2~e@;xItg_g)NVvNd{EqBV zY{V6vupF;$f+g9m_lxjkwQFxnILyLo$eLO{;MB1_av#ly1;>4U)k^6XyouBhFIO1v zc0*M*+^<5gTySAt7%H=(ecU?PV)h>$9hukV5;SL@{!D^;+v!9!RK~5m95ZN}AA8XDh|)acIFUD!3`%msDVT ze(NVH5}MjaafeBh2ZAI>u^8)?SU0DR5@e#nR<)8mG2Ku#u}AV;<%j4|h~7{$E8N=D zRbgTQutN4Vr&t1ez@m3$46y~Q+9WKQs zop89wg6DzsO1yFg?%f3qnVuK;K#nxMf!B6H3Et_4ijrDWT{5fH%hUv4{9+7$(+`g! zdjY26pLc;1R}VmOeh-alc>^=IF{XFIF1!0Si4AVs4VBpO0zrB^;m|_@$*9@+@&3$E zo*NtX2~M`X2yY7uaq%9gH?cEfIz-8gECzgWFU-m-;;?!`3enWw9fD$fYCp`G@&C`d zZ69dh9>PNhU{-3~P#(Ujf&+b>@Xh}zG_NC@%Ry}4M;!YO&=zpw-~pI}7gWgSuxvw^KwRRdkez)L3s$KdOeom@D2=)L1m59}Pikphl)^9eTbGu4z$CimQDR{^ca}POo&G7uH+<+fTtV<#&5PSr);2eEg@NS$yQh~W|$73x8Aq!>(-;YX6R(cs<%Xs@NUC-BChj{w* ztMKgphklS9xaYQ|@42T8%$oe$?!bQEl=Oa|ed-M1G7kFfbyb$K(?F;pnRbo2$}`vZ dRpDS)I_ Date: Fri, 20 Sep 2024 11:32:17 +0200 Subject: [PATCH 43/45] Remove bridge from readme --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 23265fcff4..fccc3fa14f 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,7 @@ For more details on monitoring infrastructure for nodes and running an operator ## Polymesh Testnet -The Testnet does not offer incentives to users to participate and test with it. It has a simple onboarding process (no-KYC required) and a bridge allowing test KOVAN based POLY to be bridged to testnet POLYX. - +The Testnet does not offer incentives to users to participate and test with it. It has a simple onboarding process (no-KYC required). The testnet also includes the `testUtils` pallet that allows easier onboarding for testing, and in addition each new account will receive 100,000 POLYX for testing purposes. To run a node which connects to the Testnet, you can start your node with: @@ -52,8 +51,6 @@ To run a node which connects to the Testnet, you can start your node with: The public mainnet is the official Polymesh blockchain. Onboarding requires users to go through a simple KYC process (called Customer Due Diligence or CDD) in order to access the network. -ERC20 POLY can be bridged from Ethereum to the Polymesh Mainnet. - To run a node which connects to the Mainnet, you can start your node with: ```bash From 244b050361a51769d7f6125b253d771230d698c9 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 20 Dec 2024 01:27:46 +0800 Subject: [PATCH 44/45] Remove useless `Context` test. --- pallets/identity/Cargo.toml | 34 ++++++++++++++-------------- pallets/identity/src/context.rs | 39 --------------------------------- 2 files changed, 17 insertions(+), 56 deletions(-) diff --git a/pallets/identity/Cargo.toml b/pallets/identity/Cargo.toml index 3939958e4f..bb6d79dbfb 100644 --- a/pallets/identity/Cargo.toml +++ b/pallets/identity/Cargo.toml @@ -12,7 +12,7 @@ polymesh-primitives = { workspace = true, default-features = false } # Others log = "0.4.8" serde = { version = "1.0.104", default-features = false } -serde_derive = { version = "1.0.104", optional = true, default-features = false } +serde_derive = { version = "1.0.104", optional = true, default-features = false } either = { version = "1.6.1", default-features = false } hex-literal = "0.3.0" @@ -21,20 +21,24 @@ schnorrkel = { version = "0.11", default-features = false, optional = true } # Substrate codec = { workspace = true, default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false } -scale-info = { version = "2.0", default-features = false, features = ["derive"] } -frame-system = { version = "4.0.0-dev", default-features = false } -pallet-timestamp = { version = "4.0.0-dev", default-features = false } -sp-api = { version = "4.0.0-dev", default-features = false } -sp-core = { version = "7.0.0", default-features = false } -sp-io = { version = "7.0.0", default-features = false } -sp-runtime = { version = "7.0.0", default-features = false } -sp-std = { version = "5.0.0", default-features = false } -sp-version = { version = "5.0.0", default-features = false } +frame-support = { workspace = true, default-features = false } +scale-info = { version = "2.0", default-features = false, features = [ + "derive", +] } +frame-system = { workspace = true, default-features = false } +pallet-timestamp = { workspace = true, default-features = false } +sp-api = { 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-std = { workspace = true, default-features = false } +sp-version = { workspace = true, default-features = false } # Only Benchmarking frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true } -hex = { version = "^0.4.0", default-features = false, features = ["alloc"], optional = true } +hex = { version = "^0.4.0", default-features = false, features = [ + "alloc", +], optional = true } [features] equalize = [] @@ -60,8 +64,4 @@ std = [ "sp-std/std", "sp-version/std", ] -runtime-benchmarks = [ - "frame-benchmarking", - "schnorrkel", - "hex", -] +runtime-benchmarks = ["frame-benchmarking", "schnorrkel", "hex"] diff --git a/pallets/identity/src/context.rs b/pallets/identity/src/context.rs index 03876a40db..392d8bd2c3 100644 --- a/pallets/identity/src/context.rs +++ b/pallets/identity/src/context.rs @@ -20,42 +20,3 @@ impl Context { I::set_current_payer(payer) } } - -#[cfg(test)] -mod test { - use super::*; - use polymesh_primitives::{AccountId, IdentityId}; - - use sp_keyring::AccountKeyring; - use std::{collections::BTreeMap, convert::From}; - - struct IdentityTest {} - - impl IdentityFnTrait for IdentityTest { - fn get_identity(key: &AccountId) -> Option { - let keys: BTreeMap = vec![ - (AccountId::from(AccountKeyring::Alice.public().0), 1u128), - (AccountId::from(AccountKeyring::Bob.public().0), 2u128), - (AccountId::from(AccountKeyring::Charlie.public().0), 3u128), - ] - .into_iter() - .collect(); - - if let Some(id) = keys.get(key) { - Some(IdentityId::from(*id)) - } else { - None - } - } - - fn current_payer() -> Option { - None - } - - fn set_current_payer(_payer: Option) {} - - fn has_valid_cdd(_target_did: IdentityId) -> bool { - true - } - } -} From 86928795913937b289bcd0a5a89df8ec5215cad2 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Tue, 14 Jan 2025 18:06:11 +0800 Subject: [PATCH 45/45] Update metadata-tool to detect storage prefix changes. --- metadata-tools/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata-tools/Cargo.lock b/metadata-tools/Cargo.lock index 60e5de96b5..3225d0e1d8 100644 --- a/metadata-tools/Cargo.lock +++ b/metadata-tools/Cargo.lock @@ -3329,7 +3329,7 @@ dependencies = [ [[package]] name = "substrate-differ" version = "0.21.3" -source = "git+https://github.com/PolymeshAssociation/subwasm.git?branch=polymesh#ee52a00d74a5dc6a444f5b8a2d96f0231a36489b" +source = "git+https://github.com/PolymeshAssociation/subwasm.git?branch=polymesh#dd073b20a410e6d1444e7f022ed84b5b57eb1c73" dependencies = [ "blake3", "comparable",