mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
feat(operator): 🏗️ Add Identity pallet (#25)
This commit is contained in:
parent
5616d9e449
commit
c9f3427ad5
6 changed files with 56 additions and 3 deletions
1
operator/Cargo.lock
generated
1
operator/Cargo.lock
generated
|
|
@ -1609,6 +1609,7 @@ dependencies = [
|
|||
"pallet-evm",
|
||||
"pallet-evm-chain-id",
|
||||
"pallet-grandpa",
|
||||
"pallet-identity",
|
||||
"pallet-im-online",
|
||||
"pallet-mmr",
|
||||
"pallet-multisig",
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch
|
|||
pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
|
||||
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
|
||||
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
|
||||
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
|
||||
pallet-im-online = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
|
||||
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
|
||||
pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ pallet-authorship.workspace = true
|
|||
pallet-babe.workspace = true
|
||||
pallet-balances.workspace = true
|
||||
pallet-grandpa.workspace = true
|
||||
pallet-identity.workspace = true
|
||||
pallet-im-online.workspace = true
|
||||
pallet-multisig.workspace = true
|
||||
pallet-offences.workspace = true
|
||||
|
|
@ -100,6 +101,7 @@ std = [
|
|||
"pallet-balances/std",
|
||||
"pallet-im-online/std",
|
||||
"pallet-grandpa/std",
|
||||
"pallet-identity/std",
|
||||
"pallet-multisig/std",
|
||||
"pallet-mmr/std",
|
||||
"pallet-offences/std",
|
||||
|
|
@ -153,6 +155,7 @@ runtime-benchmarks = [
|
|||
"pallet-balances/runtime-benchmarks",
|
||||
"pallet-im-online/runtime-benchmarks",
|
||||
"pallet-grandpa/runtime-benchmarks",
|
||||
"pallet-identity/runtime-benchmarks",
|
||||
"pallet-multisig/runtime-benchmarks",
|
||||
"pallet-offences/runtime-benchmarks",
|
||||
"pallet-preimage/runtime-benchmarks",
|
||||
|
|
@ -179,6 +182,7 @@ try-runtime = [
|
|||
"pallet-babe/try-runtime",
|
||||
"pallet-balances/try-runtime",
|
||||
"pallet-grandpa/try-runtime",
|
||||
"pallet-identity/try-runtime",
|
||||
"pallet-im-online/try-runtime",
|
||||
"pallet-multisig/try-runtime",
|
||||
"pallet-offences/try-runtime",
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ frame_benchmarking::define_benchmarks!(
|
|||
[frame_benchmarking, BaselineBench::<Runtime>]
|
||||
[frame_system, SystemBench::<Runtime>]
|
||||
[pallet_balances, Balances]
|
||||
[pallet_identity, Identity]
|
||||
[pallet_im_online, ImOnline]
|
||||
[pallet_multisig, Multisig]
|
||||
[pallet_preimage, Preimage]
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ use super::{
|
|||
deposit, AccountId, Babe, Balance, Balances, BeefyMmrLeaf, Block, BlockNumber, EvmChainId,
|
||||
Hash, Historical, ImOnline, Nonce, Offences, OriginCaller, PalletInfo, Preimage, Runtime,
|
||||
RuntimeCall, RuntimeEvent, RuntimeFreezeReason, RuntimeHoldReason, RuntimeOrigin, RuntimeTask,
|
||||
Session, SessionKeys, System, Timestamp, ValidatorSet, EXISTENTIAL_DEPOSIT, SLOT_DURATION,
|
||||
STORAGE_BYTE_FEE, SUPPLY_FACTOR, UNIT, VERSION,
|
||||
Session, SessionKeys, Signature, System, Timestamp, ValidatorSet, EXISTENTIAL_DEPOSIT,
|
||||
SLOT_DURATION, STORAGE_BYTE_FEE, SUPPLY_FACTOR, UNIT, VERSION,
|
||||
};
|
||||
// Substrate and Polkadot dependencies
|
||||
use codec::{Decode, Encode};
|
||||
use datahaven_runtime_common::{
|
||||
gas::WEIGHT_PER_GAS,
|
||||
time::{EpochDurationInBlocks, MILLISECS_PER_BLOCK, MINUTES},
|
||||
time::{EpochDurationInBlocks, DAYS, MILLISECS_PER_BLOCK, MINUTES},
|
||||
};
|
||||
use frame_support::{
|
||||
derive_impl,
|
||||
|
|
@ -357,6 +357,49 @@ impl pallet_sudo::Config for Runtime {
|
|||
type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxSubAccounts: u32 = 100;
|
||||
pub const MaxAdditionalFields: u32 = 100;
|
||||
pub const MaxRegistrars: u32 = 20;
|
||||
pub const PendingUsernameExpiration: u32 = 7 * DAYS;
|
||||
pub const MaxSuffixLength: u32 = 7;
|
||||
pub const MaxUsernameLength: u32 = 32;
|
||||
}
|
||||
|
||||
type IdentityForceOrigin = EnsureRoot<AccountId>;
|
||||
type IdentityRegistrarOrigin = EnsureRoot<AccountId>;
|
||||
// TODO: Add governance origin when available
|
||||
// type IdentityForceOrigin =
|
||||
// EitherOfDiverse<EnsureRoot<AccountId>, governance::custom_origins::GeneralAdmin>;
|
||||
// type IdentityRegistrarOrigin =
|
||||
// EitherOfDiverse<EnsureRoot<AccountId>, governance::custom_origins::GeneralAdmin>;
|
||||
|
||||
impl pallet_identity::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
// Add one item in storage and take 258 bytes
|
||||
type BasicDeposit = ConstU128<{ deposit(1, 258) }>;
|
||||
// Does not add any item to the storage but takes 1 bytes
|
||||
type ByteDeposit = ConstU128<{ deposit(0, 1) }>;
|
||||
// Add one item in storage and take 53 bytes
|
||||
type SubAccountDeposit = ConstU128<{ deposit(1, 53) }>;
|
||||
type MaxSubAccounts = MaxSubAccounts;
|
||||
type IdentityInformation = pallet_identity::legacy::IdentityInfo<MaxAdditionalFields>;
|
||||
type MaxRegistrars = MaxRegistrars;
|
||||
type Slashed = ();
|
||||
// TODO: Slashed funds should be sent to the treasury (when added to the runtime)
|
||||
// type Slashed = Treasury;
|
||||
type ForceOrigin = IdentityForceOrigin;
|
||||
type RegistrarOrigin = IdentityRegistrarOrigin;
|
||||
type OffchainSignature = Signature;
|
||||
type SigningPublicKey = <Signature as sp_runtime::traits::Verify>::Signer;
|
||||
type UsernameAuthorityOrigin = EnsureRoot<AccountId>;
|
||||
type PendingUsernameExpiration = PendingUsernameExpiration;
|
||||
type MaxSuffixLength = MaxSuffixLength;
|
||||
type MaxUsernameLength = MaxUsernameLength;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,6 +268,9 @@ mod runtime {
|
|||
#[runtime::pallet_index(22)]
|
||||
pub type Preimage = pallet_preimage;
|
||||
|
||||
#[runtime::pallet_index(23)]
|
||||
pub type Identity = pallet_identity;
|
||||
|
||||
#[runtime::pallet_index(24)]
|
||||
pub type Multisig = pallet_multisig;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue