pub type Module<T> = Pallet<T>;
Pallet
insteadExpand description
Type alias to Pallet
, to be used by construct_runtime
.
Generated by pallet
attribute macro.
Aliased Type§
struct Module<T>(/* private fields */);
Implementations§
source§impl<T: Config> Pallet<T>where
T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
impl<T: Config> Pallet<T>where T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
sourcepub fn create(
origin: OriginFor<T>,
details: Box<DidCreationDetails<DidIdentifierOf<T>, AccountIdOf<T>, <T as Config>::MaxNewKeyAgreementKeys, DidEndpoint<T>>>,
signature: DidSignature
) -> DispatchResult
pub fn create( origin: OriginFor<T>, details: Box<DidCreationDetails<DidIdentifierOf<T>, AccountIdOf<T>, <T as Config>::MaxNewKeyAgreementKeys, DidEndpoint<T>>>, signature: DidSignature ) -> DispatchResult
Store a new DID on chain, after verifying that the creation operation has been signed by the KILT account associated with the identifier of the DID being created and that a DID with the same identifier has not previously existed on (and then deleted from) the chain.
There must be no DID information stored on chain under the same DID identifier.
The new keys added with this operation are stored under the DID identifier along with the block number in which the operation was executed.
The dispatch origin can be any KILT account with enough funds to execute the extrinsic and it does not have to be tied in any way to the KILT account identifying the DID subject.
Emits DidCreated
.
- The transaction’s complexity is mainly dependent on the number of new key agreement keys and the number of new service endpoints included in the operation.
Weight: O(K) + O(N) where K is the number of new key agreement
keys bounded by MaxNewKeyAgreementKeys
, while N is the number of
new service endpoints bounded by MaxNumberOfServicesPerDid
.
- Reads: [Origin Account], Did, DidBlacklist
- Writes: Did (with K new key agreement keys), ServiceEndpoints (with N new service endpoints), DidEndpointsCount
sourcepub fn set_authentication_key(
origin: OriginFor<T>,
new_key: DidVerificationKey<AccountIdOf<T>>
) -> DispatchResult
pub fn set_authentication_key( origin: OriginFor<T>, new_key: DidVerificationKey<AccountIdOf<T>> ) -> DispatchResult
Update the DID authentication key.
The old key is deleted from the set of public keys if it is not used in any other part of the DID. The new key is added to the set of public keys.
The dispatch origin must be a DID origin proxied via the
submit_did_call
extrinsic.
Emits DidUpdated
.
Weight: O(1)
- Reads: [Origin Account], Did
- Writes: Did
sourcepub fn set_delegation_key(
origin: OriginFor<T>,
new_key: DidVerificationKey<AccountIdOf<T>>
) -> DispatchResult
pub fn set_delegation_key( origin: OriginFor<T>, new_key: DidVerificationKey<AccountIdOf<T>> ) -> DispatchResult
Set or update the DID delegation key.
If an old key existed, it is deleted from the set of public keys if it is not used in any other part of the DID. The new key is added to the set of public keys.
The dispatch origin must be a DID origin proxied via the
submit_did_call
extrinsic.
Emits DidUpdated
.
Weight: O(1)
- Reads: [Origin Account], Did
- Writes: Did
sourcepub fn remove_delegation_key(origin: OriginFor<T>) -> DispatchResult
pub fn remove_delegation_key(origin: OriginFor<T>) -> DispatchResult
sourcepub fn set_attestation_key(
origin: OriginFor<T>,
new_key: DidVerificationKey<AccountIdOf<T>>
) -> DispatchResult
pub fn set_attestation_key( origin: OriginFor<T>, new_key: DidVerificationKey<AccountIdOf<T>> ) -> DispatchResult
Set or update the DID attestation key.
If an old key existed, it is deleted from the set of public keys if it is not used in any other part of the DID. The new key is added to the set of public keys.
The dispatch origin must be a DID origin proxied via the
submit_did_call
extrinsic.
Emits DidUpdated
.
Weight: O(1)
- Reads: [Origin Account], Did
- Writes: Did
sourcepub fn remove_attestation_key(origin: OriginFor<T>) -> DispatchResult
pub fn remove_attestation_key(origin: OriginFor<T>) -> DispatchResult
sourcepub fn add_key_agreement_key(
origin: OriginFor<T>,
new_key: DidEncryptionKey
) -> DispatchResult
pub fn add_key_agreement_key( origin: OriginFor<T>, new_key: DidEncryptionKey ) -> DispatchResult
sourcepub fn remove_key_agreement_key(
origin: OriginFor<T>,
key_id: KeyIdOf<T>
) -> DispatchResult
pub fn remove_key_agreement_key( origin: OriginFor<T>, key_id: KeyIdOf<T> ) -> DispatchResult
sourcepub fn add_service_endpoint(
origin: OriginFor<T>,
service_endpoint: DidEndpoint<T>
) -> DispatchResult
pub fn add_service_endpoint( origin: OriginFor<T>, service_endpoint: DidEndpoint<T> ) -> DispatchResult
sourcepub fn remove_service_endpoint(
origin: OriginFor<T>,
service_id: ServiceEndpointId<T>
) -> DispatchResult
pub fn remove_service_endpoint( origin: OriginFor<T>, service_id: ServiceEndpointId<T> ) -> DispatchResult
sourcepub fn delete(origin: OriginFor<T>, endpoints_to_remove: u32) -> DispatchResult
pub fn delete(origin: OriginFor<T>, endpoints_to_remove: u32) -> DispatchResult
Delete a DID from the chain and all information associated with it, after verifying that the delete operation has been signed by the DID subject using the authentication key currently stored on chain.
The referenced DID identifier must be present on chain before the delete operation is evaluated.
After it is deleted, a DID with the same identifier cannot be re-created ever again.
As the result of the deletion, all traces of the DID are removed from the storage, which results in the invalidation of all attestations issued by the DID subject.
The dispatch origin must be a DID origin proxied via the
submit_did_call
extrinsic.
Emits DidDeleted
.
Weight: O(1)
- Reads: [Origin Account], Did
- Kills: Did entry associated to the DID identifier
sourcepub fn reclaim_deposit(
origin: OriginFor<T>,
did_subject: DidIdentifierOf<T>,
endpoints_to_remove: u32
) -> DispatchResult
pub fn reclaim_deposit( origin: OriginFor<T>, did_subject: DidIdentifierOf<T>, endpoints_to_remove: u32 ) -> DispatchResult
Reclaim a deposit for a DID. This will delete the DID and all information associated with it, after verifying that the caller is the owner of the deposit.
The referenced DID identifier must be present on chain before the delete operation is evaluated.
After it is deleted, a DID with the same identifier cannot be re-created ever again.
As the result of the deletion, all traces of the DID are removed from the storage, which results in the invalidation of all attestations issued by the DID subject.
Emits DidDeleted
.
Weight: O(1)
- Reads: [Origin Account], Did
- Kills: Did entry associated to the DID identifier
sourcepub fn submit_did_call(
origin: OriginFor<T>,
did_call: Box<DidAuthorizedCallOperation<DidIdentifierOf<T>, DidCallableOf<T>, BlockNumberFor<T>, AccountIdOf<T>, u64>>,
signature: DidSignature
) -> DispatchResultWithPostInfo
pub fn submit_did_call( origin: OriginFor<T>, did_call: Box<DidAuthorizedCallOperation<DidIdentifierOf<T>, DidCallableOf<T>, BlockNumberFor<T>, AccountIdOf<T>, u64>>, signature: DidSignature ) -> DispatchResultWithPostInfo
Proxy a dispatchable call of another runtime extrinsic that supports a DID origin.
The referenced DID identifier must be present on chain before the operation is dispatched.
A call submitted through this extrinsic must be signed with the
right DID key, depending on the call. This information is provided
by the DidAuthorizedCallOperation
parameter, which specifies the
DID subject acting as the origin of the call, the DID’s tx counter
(nonce), the dispatchable to call in case signature verification
succeeds, the type of DID key to use to verify the operation
signature, and the block number the operation was targeting for
inclusion, when it was created and signed.
In case the signature is incorrect, the nonce is not valid, the
required key is not present for the specified DID, or the block
specified is too old the verification fails and the call is not
dispatched. Otherwise, the call is properly dispatched with a
DidOrigin
origin indicating the DID subject.
A successful dispatch operation results in the tx counter associated with the given DID to be incremented, to mitigate replay attacks.
The dispatch origin can be any KILT account with enough funds to execute the extrinsic and it does not have to be tied in any way to the KILT account identifying the DID subject.
Emits DidCallDispatched
.
Weight: O(1) + weight of the dispatched call
- Reads: [Origin Account], Did
- Writes: Did
sourcepub fn change_deposit_owner(origin: OriginFor<T>) -> DispatchResult
pub fn change_deposit_owner(origin: OriginFor<T>) -> DispatchResult
Changes the deposit owner.
The balance that is reserved by the current deposit owner will be freed and balance of the new deposit owner will get reserved.
The subject of the call must be the did owner. The sender of the call will be the new deposit owner.
sourcepub fn update_deposit(
origin: OriginFor<T>,
did: DidIdentifierOf<T>
) -> DispatchResult
pub fn update_deposit( origin: OriginFor<T>, did: DidIdentifierOf<T> ) -> DispatchResult
Updates the deposit amount to the current deposit rate.
The sender must be the deposit owner.
sourcepub fn dispatch_as(
origin: OriginFor<T>,
did_identifier: DidIdentifierOf<T>,
call: Box<DidCallableOf<T>>
) -> DispatchResultWithPostInfo
pub fn dispatch_as( origin: OriginFor<T>, did_identifier: DidIdentifierOf<T>, call: Box<DidCallableOf<T>> ) -> DispatchResultWithPostInfo
Proxy a dispatchable call of another runtime extrinsic that supports a DID origin.
The referenced DID identifier must be present on chain before the operation is dispatched.
A call submitted through this extrinsic must be signed with the
right DID key, depending on the call. In contrast to the
submit_did_call
extrinsic, this call doesn’t separate the sender
from the DID subject. The key that must be used for this DID call
is required to also be a valid account with enough balance to pay
for fees.
The dispatch origin must be a KILT account with enough funds to execute the extrinsic and must correspond to the required DID Verification Key.
Emits DidCallDispatched
.
sourcepub fn create_from_account(
origin: OriginFor<T>,
authentication_key: DidVerificationKey<AccountIdOf<T>>
) -> DispatchResult
pub fn create_from_account( origin: OriginFor<T>, authentication_key: DidVerificationKey<AccountIdOf<T>> ) -> DispatchResult
Store a new DID on chain.
The DID identifier is derived from the account ID that submits this
call. The authentication key must correspond to the account ID that
submitted this call. For accounts that use the ed25519 and sr25519
schema, the authentication key must be of the
DidVerificationKey::Ed25519
or DidVerificationKey::Sr25519
variant and contains the public key. For Ecdsa accounts, the
DidVerificationKey::Ecdsa
variant is calculated by hashing the
Ecdsa public key.
If this call is dispatched by an account id that doesn’t correspond
to a public private key pair, the DidVerificationKey::Account
variant shall be used (Multisig, Pure Proxy, Governance origins).
The resulting DID can NOT be used for signing data and is therefore
limited to onchain activities.
There must be no DID information stored on chain under the same DID identifier. This call will fail if there exists a DID with the same identifier or if a DID with the same identifier existed and was deleted.
The origin for this account must be funded and provide the required deposit and fee.
Emits DidCreated
.
source§impl<T: Config> Pallet<T>where
T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
impl<T: Config> Pallet<T>where T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
sourcepub fn try_insert_did(
did_identifier: DidIdentifierOf<T>,
did_entry: DidDetails<T>,
sender: AccountIdOf<T>
) -> DispatchResult
pub fn try_insert_did( did_identifier: DidIdentifierOf<T>, did_entry: DidDetails<T>, sender: AccountIdOf<T> ) -> DispatchResult
Try creating a DID.
Errors
- When the DID was deleted, this function returns a
AlreadyDeleted
error. - When the DID already exists, this function returns a
AlreadyExists
error. - When the
sender
doesn’t have enough free balance, this function returns aUnableToPayFees
error.
sourcepub fn try_update_did(
did_identifier: &DidIdentifierOf<T>,
did_details: DidDetails<T>
) -> DispatchResult
pub fn try_update_did( did_identifier: &DidIdentifierOf<T>, did_details: DidDetails<T> ) -> DispatchResult
sourcepub fn verify_did_operation_signature_and_increase_nonce(
operation: &DidAuthorizedCallOperationWithVerificationRelationship<T>,
signature: &DidSignature
) -> Result<(), DidError>
pub fn verify_did_operation_signature_and_increase_nonce( operation: &DidAuthorizedCallOperationWithVerificationRelationship<T>, signature: &DidSignature ) -> Result<(), DidError>
Verify the validity (i.e., nonce, signature and mortality) of a DID-authorized operation and, if valid, update the DID state with the latest nonce.
Verify that account
is authorized to dispatch DID calls on behave
of did_identifier
.
Errors
This function returns an error if the did was not found, the verification key was not found or the account didn’t match the verification key.
sourcepub fn verify_payload_signature_with_did_key_type(
payload: &Payload,
signature: &DidSignature,
did_details: &DidDetails<T>,
key_type: DidVerificationKeyRelationship
) -> Result<(), DidError>
pub fn verify_payload_signature_with_did_key_type( payload: &Payload, signature: &DidSignature, did_details: &DidDetails<T>, key_type: DidVerificationKeyRelationship ) -> Result<(), DidError>
Verify a generic payload signature using a given DID verification key type.
sourcepub fn delete_did(
did_subject: DidIdentifierOf<T>,
endpoints_to_remove: u32
) -> DispatchResult
pub fn delete_did( did_subject: DidIdentifierOf<T>, endpoints_to_remove: u32 ) -> DispatchResult
Deletes DID details from storage, including its linked service endpoints, adds the identifier to the blacklisted DIDs and frees the deposit.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn get_did<KArg>(k: KArg) -> Option<DidDetails<T>>where
KArg: EncodeLike<DidIdentifierOf<T>>,
pub fn get_did<KArg>(k: KArg) -> Option<DidDetails<T>>where KArg: EncodeLike<DidIdentifierOf<T>>,
An auto-generated getter for Did
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn get_service_endpoints<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> Option<DidEndpoint<T>>where
KArg1: EncodeLike<DidIdentifierOf<T>>,
KArg2: EncodeLike<ServiceEndpointId<T>>,
pub fn get_service_endpoints<KArg1, KArg2>( k1: KArg1, k2: KArg2 ) -> Option<DidEndpoint<T>>where KArg1: EncodeLike<DidIdentifierOf<T>>, KArg2: EncodeLike<ServiceEndpointId<T>>,
An auto-generated getter for ServiceEndpoints
.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn get_deleted_did<KArg>(k: KArg) -> Option<()>where
KArg: EncodeLike<DidIdentifierOf<T>>,
pub fn get_deleted_did<KArg>(k: KArg) -> Option<()>where KArg: EncodeLike<DidIdentifierOf<T>>,
An auto-generated getter for DidBlacklist
.
Trait Implementations§
source§impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
impl<T: Config> BeforeAllRuntimeMigrations for Pallet<T>
source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
source§impl<T> Benchmarking for Pallet<T>where
T: Config + Config,
T::DidIdentifier: From<AccountId32>,
<T as Config>::RuntimeOrigin: From<RawOrigin<T::DidIdentifier>>,
<T as Config>::AccountId: From<AccountId32>,
<T as Config>::Currency: Mutate<T::AccountId>,
T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
impl<T> Benchmarking for Pallet<T>where T: Config + Config, T::DidIdentifier: From<AccountId32>, <T as Config>::RuntimeOrigin: From<RawOrigin<T::DidIdentifier>>, <T as Config>::AccountId: From<AccountId32>, <T as Config>::Currency: Mutate<T::AccountId>, T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
source§impl<T: Config> Callable<T> for Pallet<T>where
T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
impl<T: Config> Callable<T> for Pallet<T>where T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
type RuntimeCall = Call<T>
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
§type CurrentStorageVersion = StorageVersion
type CurrentStorageVersion = StorageVersion
source§fn current_storage_version() -> Self::CurrentStorageVersion
fn current_storage_version() -> Self::CurrentStorageVersion
source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
source§impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn try_state(_n: BlockNumberFor<T>) -> Result<(), TryRuntimeError>
fn try_state(_n: BlockNumberFor<T>) -> Result<(), TryRuntimeError>
§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
Hooks::on_finalize
]). Read more§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
§fn pre_upgrade() -> Result<Vec<u8, Global>, DispatchError>
fn pre_upgrade() -> Result<Vec<u8, Global>, DispatchError>
§fn post_upgrade(_state: Vec<u8, Global>) -> Result<(), DispatchError>
fn post_upgrade(_state: Vec<u8, Global>) -> Result<(), DispatchError>
§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
§fn integrity_test()
fn integrity_test()
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§fn integrity_test()
fn integrity_test()
Hooks::integrity_test
].source§impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn offchain_worker(n: BlockNumberFor<T>)
fn offchain_worker(n: BlockNumberFor<T>)
source§impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_finalize(n: BlockNumberFor<T>)
fn on_finalize(n: BlockNumberFor<T>)
Hooks::on_finalize
].source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
source§fn on_genesis()
fn on_genesis()
source§impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§fn on_initialize(n: BlockNumberFor<T>) -> Weight
fn on_initialize(n: BlockNumberFor<T>) -> Weight
Hooks::on_initialize
].source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Hooks::on_runtime_upgrade
].§fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, DispatchError>
pre_upgrade
->
on_runtime_upgrade
-> post_upgrade
hooks for a migration. Read moresource§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
source§fn module_name() -> &'static str
fn module_name() -> &'static str
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
source§impl<T> PartialEq<Pallet<T>> for Pallet<T>
impl<T> PartialEq<Pallet<T>> for Pallet<T>
source§impl<T: Config> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> TryState<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.