-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some types back to polymesh-common-utilities. (#1787)
* Move some types back to polymesh-common-utilities. * Move types to traits module.
- Loading branch information
1 parent
63af899
commit c42b18b
Showing
50 changed files
with
199 additions
and
104 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
pub mod traits { | ||
pub mod checkpoint; | ||
pub mod identity; | ||
} | ||
pub use traits::*; | ||
|
||
pub mod protocol_fee; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.