diff --git a/rpc/did/runtime-api/src/lib.rs b/rpc/did/runtime-api/src/lib.rs index 8aba8fd94..172c127cf 100644 --- a/rpc/did/runtime-api/src/lib.rs +++ b/rpc/did/runtime-api/src/lib.rs @@ -103,47 +103,7 @@ pub type RawDidLinkedInfo; sp_api::decl_runtime_apis! { - // TODO: Remove this runtime API when the SDK team agrees that it is time to introduce a breaking change. #[api_version(2)] - /// The API to query DID information. - pub trait DidApi where - DidIdentifier: Codec, - AccountId: Codec, - LinkableAccountId: Codec, - BlockNumber: Codec + MaxEncodedLen, - Key: Codec, - Balance: Codec, - { - /// Given a web3name this returns: - /// * the DID - /// * public keys stored for the did - /// * the web3name (optional) - /// * associated accounts - /// * service endpoints - #[changed_in(2)] - fn query_did_by_w3n(name: Vec) -> Option>; - fn query_did_by_w3n(name: Vec) -> Option>; - /// Given an account address this returns: - /// * the DID - /// * public keys stored for the did - /// * the web3name (optional) - /// * associated accounts - /// * service endpoints - // See https://paritytech.github.io/substrate/master/sp_api/macro.decl_runtime_apis.html#declaring-multiple-api-versions for more details - #[changed_in(2)] - fn query_did_by_account_id(account: AccountId) -> Option>; - fn query_did_by_account_id(account: LinkableAccountId) -> Option>; - /// Given a did this returns: - /// * the DID - /// * public keys stored for the did - /// * the web3name (optional) - /// * associated accounts - /// * service endpoints - #[changed_in(2)] - fn query_did(did: DidIdentifier) -> Option>; - fn query_did(did: DidIdentifier) -> Option>; - } - pub trait Did where DidIdentifier: Codec, AccountId: Codec, @@ -158,6 +118,8 @@ sp_api::decl_runtime_apis! { /// * the web3name (optional) /// * associated accounts /// * service endpoints + #[changed_in(2)] + fn query_by_web3_name(name: Vec) -> Option>; fn query_by_web3_name(name: Vec) -> Option>; /// Given an account address this returns: /// * the DID @@ -165,6 +127,8 @@ sp_api::decl_runtime_apis! { /// * the web3name (optional) /// * associated accounts /// * service endpoints + #[changed_in(2)] + fn query_by_account(account: AccountId) -> Option>; fn query_by_account(account: LinkableAccountId) -> Option>; /// Given a did this returns: /// * the DID @@ -172,6 +136,8 @@ sp_api::decl_runtime_apis! { /// * the web3name (optional) /// * associated accounts /// * service endpoints + #[changed_in(2)] + fn query(did: DidIdentifier) -> Option>; fn query(did: DidIdentifier) -> Option>; } } diff --git a/runtimes/clone/src/lib.rs b/runtimes/clone/src/lib.rs index 8b11d33c8..e98ea607e 100644 --- a/runtimes/clone/src/lib.rs +++ b/runtimes/clone/src/lib.rs @@ -531,7 +531,7 @@ impl_runtime_apis! { } // Solely required from parachain client - impl did_rpc_runtime_api::DidApi< + impl did_rpc_runtime_api::Did< Block, AccountId, AccountId, @@ -540,7 +540,7 @@ impl_runtime_apis! { Hash, BlockNumber > for Runtime { - fn query_did_by_w3n(_: Vec) -> Option) -> Option Option< + fn query_by_account(_: LinkableAccountId) -> Option< did_rpc_runtime_api::RawDidLinkedInfo< AccountId, AccountId, @@ -565,7 +565,7 @@ impl_runtime_apis! { None } - fn query_did(_: AccountId) -> Option< + fn query(_: AccountId) -> Option< did_rpc_runtime_api::RawDidLinkedInfo< AccountId, AccountId, diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 32c56ea1a..07a0bdd6b 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -46,7 +46,6 @@ use sp_version::RuntimeVersion; use xcm_executor::XcmExecutor; use delegation::DelegationAc; -use did_rpc_runtime_api::runtime_decl_for_DidApi::DidApiV2; use kilt_support::traits::ItemFilter; use pallet_did_lookup::{linkable_account::LinkableAccountId, migrations::EthereumMigration}; pub use parachain_staking::InflationInfo; @@ -1152,7 +1151,7 @@ impl_runtime_apis! { } } - impl did_rpc_runtime_api::DidApi< + impl did_rpc_runtime_api::Did< Block, DidIdentifier, AccountId, @@ -1161,7 +1160,7 @@ impl_runtime_apis! { Hash, BlockNumber > for Runtime { - fn query_did_by_w3n(name: Vec) -> Option) -> Option::get(&owner_info.owner).map(|details| (owner_info, details)) }) .map(|(owner_info, details)| { - let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(&owner_info.owner).collect(); + let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix( + &owner_info.owner, + ).collect(); let service_endpoints = did::ServiceEndpoints::::iter_prefix(&owner_info.owner).map(|e| From::from(e.1)).collect(); - did_rpc_runtime_api::RawDidLinkedInfo { + did_rpc_runtime_api::RawDidLinkedInfo{ identifier: owner_info.owner, w3n: Some(name.into()), accounts, @@ -1189,7 +1190,7 @@ impl_runtime_apis! { }) } - fn query_did_by_account_id(account: LinkableAccountId) -> Option< + fn query_by_account(account: LinkableAccountId) -> Option< did_rpc_runtime_api::RawDidLinkedInfo< DidIdentifier, AccountId, @@ -1218,7 +1219,7 @@ impl_runtime_apis! { }) } - fn query_did(did: DidIdentifier) -> Option< + fn query(did: DidIdentifier) -> Option< did_rpc_runtime_api::RawDidLinkedInfo< DidIdentifier, AccountId, @@ -1243,54 +1244,6 @@ impl_runtime_apis! { } } - impl did_rpc_runtime_api::Did< - Block, - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > for Runtime { - fn query_by_web3_name(name: Vec) -> Option - > { - Self::query_did_by_w3n(name) - } - - fn query_by_account(account: LinkableAccountId) -> Option< - did_rpc_runtime_api::RawDidLinkedInfo< - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > - > { - Self::query_did_by_account_id(account) - } - - fn query(did: DidIdentifier) -> Option< - did_rpc_runtime_api::RawDidLinkedInfo< - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > - > { - Self::query_did(did) - } - } - impl public_credentials_runtime_api::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime { fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> { let subject = public_credentials::CredentialSubjects::::get(&credential_id)?; diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 07c3c6ac7..74e0d95f9 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -46,7 +46,6 @@ use sp_version::RuntimeVersion; use xcm_executor::XcmExecutor; use delegation::DelegationAc; -use did_rpc_runtime_api::runtime_decl_for_DidApi::DidApiV2; use kilt_support::traits::ItemFilter; use pallet_did_lookup::{linkable_account::LinkableAccountId, migrations::EthereumMigration}; pub use parachain_staking::InflationInfo; @@ -1146,7 +1145,7 @@ impl_runtime_apis! { } } - impl did_rpc_runtime_api::DidApi< + impl did_rpc_runtime_api::Did< Block, DidIdentifier, AccountId, @@ -1155,7 +1154,7 @@ impl_runtime_apis! { Hash, BlockNumber > for Runtime { - fn query_did_by_w3n(name: Vec) -> Option) -> Option::get(&owner_info.owner).map(|details| (owner_info, details)) }) .map(|(owner_info, details)| { - let accounts: Vec = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(&owner_info.owner).collect(); + let accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix( + &owner_info.owner, + ).collect(); let service_endpoints = did::ServiceEndpoints::::iter_prefix(&owner_info.owner).map(|e| From::from(e.1)).collect(); - did_rpc_runtime_api::RawDidLinkedInfo { + did_rpc_runtime_api::RawDidLinkedInfo{ identifier: owner_info.owner, w3n: Some(name.into()), accounts, @@ -1183,7 +1184,7 @@ impl_runtime_apis! { }) } - fn query_did_by_account_id(account: LinkableAccountId) -> Option< + fn query_by_account(account: LinkableAccountId) -> Option< did_rpc_runtime_api::RawDidLinkedInfo< DidIdentifier, AccountId, @@ -1212,7 +1213,7 @@ impl_runtime_apis! { }) } - fn query_did(did: DidIdentifier) -> Option< + fn query(did: DidIdentifier) -> Option< did_rpc_runtime_api::RawDidLinkedInfo< DidIdentifier, AccountId, @@ -1237,54 +1238,6 @@ impl_runtime_apis! { } } - impl did_rpc_runtime_api::Did< - Block, - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > for Runtime { - fn query_by_web3_name(name: Vec) -> Option - > { - Self::query_did_by_w3n(name) - } - - fn query_by_account(account: LinkableAccountId) -> Option< - did_rpc_runtime_api::RawDidLinkedInfo< - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > - > { - Self::query_did_by_account_id(account) - } - - fn query(did: DidIdentifier) -> Option< - did_rpc_runtime_api::RawDidLinkedInfo< - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > - > { - Self::query_did(did) - } - } - impl public_credentials_runtime_api::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime { fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> { let subject = public_credentials::CredentialSubjects::::get(&credential_id)?; diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs index 0772469fe..6e020bc93 100644 --- a/runtimes/standalone/src/lib.rs +++ b/runtimes/standalone/src/lib.rs @@ -50,7 +50,6 @@ use sp_std::prelude::*; use sp_version::RuntimeVersion; use delegation::DelegationAc; -use did_rpc_runtime_api::runtime_decl_for_DidApi::DidApiV2; use kilt_support::traits::ItemFilter; use pallet_did_lookup::{linkable_account::LinkableAccountId, migrations::EthereumMigration}; use runtime_common::{ @@ -902,7 +901,7 @@ impl_runtime_apis! { } } - impl did_rpc_runtime_api::DidApi< + impl did_rpc_runtime_api::Did< Block, DidIdentifier, AccountId, @@ -911,7 +910,7 @@ impl_runtime_apis! { Hash, BlockNumber > for Runtime { - fn query_did_by_w3n(name: Vec) -> Option) -> Option Option< + fn query_by_account(account: LinkableAccountId) -> Option< did_rpc_runtime_api::RawDidLinkedInfo< DidIdentifier, AccountId, @@ -970,7 +969,7 @@ impl_runtime_apis! { }) } - fn query_did(did: DidIdentifier) -> Option< + fn query(did: DidIdentifier) -> Option< did_rpc_runtime_api::RawDidLinkedInfo< DidIdentifier, AccountId, @@ -995,54 +994,6 @@ impl_runtime_apis! { } } - impl did_rpc_runtime_api::Did< - Block, - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > for Runtime { - fn query_by_web3_name(name: Vec) -> Option - > { - Self::query_did_by_w3n(name) - } - - fn query_by_account(account: LinkableAccountId) -> Option< - did_rpc_runtime_api::RawDidLinkedInfo< - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > - > { - Self::query_did_by_account_id(account) - } - - fn query(did: DidIdentifier) -> Option< - did_rpc_runtime_api::RawDidLinkedInfo< - DidIdentifier, - AccountId, - LinkableAccountId, - Balance, - Hash, - BlockNumber - > - > { - Self::query_did(did) - } - } - impl public_credentials_runtime_api::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime { fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> { let subject = public_credentials::CredentialSubjects::::get(&credential_id)?;