Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ members = [
"primitives/asset-metadata",
"rpc",
"rpc/runtime-api",
"utils/permissions",
"utils/permissions", "pallets/common",
]
exclude = [
"contracts",
Expand Down Expand Up @@ -185,6 +185,7 @@ polymesh-contracts = { path = "pallets/contracts", default-features = false }

# Common
polymesh-runtime-common = { path = "pallets/runtime/common", default-features = false }
polymesh-common-utilities = { path = "pallets/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 }
Expand Down Expand Up @@ -276,6 +277,7 @@ 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 }

Expand Down
2 changes: 2 additions & 0 deletions pallets/asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"

[dependencies]
# Common
polymesh-common-utilities = { workspace = true, default-features = false }
polymesh-primitives = { workspace = true, default-features = false }
polymesh-primitives-derive = { workspace = true, default-features = false }

Expand Down Expand Up @@ -57,6 +58,7 @@ std = [
"pallet-timestamp/std",
"pallet-external-agents/std",
"polymesh-primitives/std",
"polymesh-common-utilities/std",
"polymesh-runtime-common/std",
"rustc-hex/std",
"serde/std",
Expand Down
4 changes: 2 additions & 2 deletions pallets/asset/src/checkpoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ use sp_std::prelude::*;
use sp_std::vec;

use pallet_base::try_next_pre;
use polymesh_common_utilities::checkpoint::{NextCheckpoints, ScheduleCheckpoints, ScheduleId};
use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp};
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::{storage_migration_ver, IdentityId, Moment};

Expand Down
2 changes: 1 addition & 1 deletion pallets/asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ use pallet_base::{
use pallet_external_agents::Config as EAConfig;
use pallet_identity::PermissionedCallOriginData;
use pallet_portfolio::{Error as PortfolioError, PortfolioAssetBalances};
use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp};
use polymesh_primitives::agent::AgentGroup;
use polymesh_primitives::asset::{
AssetId, AssetName, AssetType, CheckpointId, CustomAssetTypeId, FundingRoundName,
Expand All @@ -116,7 +117,6 @@ use polymesh_primitives::asset_metadata::{
AssetMetadataSpec, AssetMetadataValue, AssetMetadataValueDetail,
};
use polymesh_primitives::constants::*;
use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp};
use polymesh_primitives::settlement::InstructionId;
use polymesh_primitives::traits::{AssetFnConfig, AssetFnTrait, ComplianceFnConfig, NFTTrait};
use polymesh_primitives::{
Expand Down
28 changes: 28 additions & 0 deletions pallets/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "polymesh-common-utilities"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0.104", optional = true, default-features = false, features = ["derive"] }

polymesh-primitives = { workspace = true, default-features = false }

# Substrate
codec = { workspace = true, default-features = false, features = ["derive"] }
frame-support = { workspace = true, default-features = false }
scale-info = { workspace = true, default-features = false, features = ["derive"] }
sp-core = { workspace = true, default-features = false }
sp-std = { workspace = true, default-features = false }

[features]
default = ["std"]

std = [
"serde",
"codec/std",
"frame-support/std",
"polymesh-primitives/std",
"sp-core/std",
"sp-std/std",
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ 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};
use polymesh_primitives::calendar::{CalendarPeriod, CheckpointSchedule};
use polymesh_primitives::{impl_checked_inc, Moment};

/// ID of a `StoredSchedule`.
#[derive(Encode, Decode, TypeInfo)]
Expand Down
52 changes: 52 additions & 0 deletions pallets/common/src/identity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#![allow(missing_docs)]
// This file is part of the Polymesh distribution (https://github.com/PolymeshAssociation/Polymesh).
// Copyright (c) Polymesh Association

use codec::{Decode, Encode};
use polymesh_primitives::{secondary_key::SecondaryKey, IdentityId};
use scale_info::TypeInfo;
use sp_core::H512;

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<Moment> {
/// 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<AccountId> {
/// Secondary key to be added.
pub secondary_key: SecondaryKey<AccountId>,
/// 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<AccountId> {
/// 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,
}
5 changes: 5 additions & 0 deletions pallets/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod checkpoint;
pub mod identity;
pub mod protocol_fee;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use codec::{Decode, Encode};
use frame_support::dispatch::DispatchResult;
use scale_info::TypeInfo;
#[cfg(feature = "std")]
use sp_runtime::{Deserialize, Serialize};
use serde::{Deserialize, Serialize};

/// Protocol fee operations.
#[derive(Decode, Encode, TypeInfo)]
Expand Down
2 changes: 2 additions & 0 deletions pallets/compliance-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"

[dependencies]
# Common
polymesh-common-utilities = { workspace = true, default-features = false }
polymesh-primitives = { workspace = true, default-features = false }

# Our pallets
Expand Down Expand Up @@ -58,6 +59,7 @@ std = [
"pallet-external-agents/std",
"pallet-timestamp/std",
"polymesh-primitives/std",
"polymesh-common-utilities/std",
]

runtime-benchmarks = [
Expand Down
2 changes: 1 addition & 1 deletion pallets/compliance-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ use frame_support::weights::Weight;
use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure};
use pallet_base::ensure_length_ok;
use pallet_external_agents::Config as EAConfig;
use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp};
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::{AssetFnConfig, ComplianceFnConfig},
Expand Down
2 changes: 2 additions & 0 deletions pallets/corporate-actions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"

[dependencies]
# Common
polymesh-common-utilities = { workspace = true, default-features = false }
polymesh-primitives = { workspace = true, default-features = false }
polymesh-primitives-derive = { workspace = true, default-features = false }

Expand Down Expand Up @@ -52,6 +53,7 @@ std = [
"pallet-portfolio/std",
"pallet-timestamp/std",
"polymesh-primitives/std",
"polymesh-common-utilities/std",
"serde/std",
"serde_derive",
"sp-api/std",
Expand Down
2 changes: 1 addition & 1 deletion pallets/corporate-actions/src/ballot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ use frame_support::{
use pallet_asset::checkpoint;
use pallet_base::ensure_string_limited;
use pallet_identity as identity;
use polymesh_primitives::protocol_fee::{ChargeProtocolFee, ProtocolOp};
use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp};
use polymesh_primitives::{storage_migration_ver, Balance, EventDid, IdentityId, Moment};
use polymesh_primitives_derive::VecU8StrongTyped;
use scale_info::TypeInfo;
Expand Down
6 changes: 2 additions & 4 deletions pallets/corporate-actions/src/distribution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ use frame_support::{
};
use pallet_asset::{self as asset, checkpoint};
use pallet_identity::{self as identity, PermissionedCallOriginData};
use polymesh_common_utilities::protocol_fee::{ChargeProtocolFee, ProtocolOp};
use polymesh_primitives::asset::AssetId;
use polymesh_primitives::{
constants::currency::ONE_UNIT,
protocol_fee::{ChargeProtocolFee, ProtocolOp},
storage_migration_ver,
traits::PortfolioSubTrait,
constants::currency::ONE_UNIT, storage_migration_ver, traits::PortfolioSubTrait,
with_transaction, Balance, EventDid, IdentityId, Moment, PortfolioId, PortfolioNumber,
SecondaryKey, WeightMeter,
};
Expand Down
2 changes: 1 addition & 1 deletion pallets/corporate-actions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::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,
Expand Down
Loading