Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 32 additions & 0 deletions rpc/did/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub type RawDidLinkedInfo<DidIdentifier, AccountId, LinkableAccountId, Balance,
>;

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<DidIdentifier, AccountId, LinkableAccountId, Balance, Key: Ord, BlockNumber> where
Expand Down Expand Up @@ -142,4 +143,35 @@ sp_api::decl_runtime_apis! {
fn query_did(did: DidIdentifier) -> Option<RawDidLinkedInfo<DidIdentifier, AccountId, AccountId, Balance, Key, BlockNumber>>;
fn query_did(did: DidIdentifier) -> Option<RawDidLinkedInfo<DidIdentifier, AccountId, LinkableAccountId, Balance, Key, BlockNumber>>;
}

pub trait Did<DidIdentifier, AccountId, LinkableAccountId, Balance, Key: Ord, BlockNumber> 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
fn query_by_web3_name(name: Vec<u8>) -> Option<RawDidLinkedInfo<DidIdentifier, AccountId, LinkableAccountId, Balance, Key, BlockNumber>>;
/// Given an account address this returns:
/// * the DID
/// * public keys stored for the did
/// * the web3name (optional)
/// * associated accounts
/// * service endpoints
fn query_by_account(account: LinkableAccountId) -> Option<RawDidLinkedInfo<DidIdentifier, AccountId, LinkableAccountId, Balance, Key, BlockNumber>>;
/// Given a did this returns:
/// * the DID
/// * public keys stored for the did
/// * the web3name (optional)
/// * associated accounts
/// * service endpoints
fn query(did: DidIdentifier) -> Option<RawDidLinkedInfo<DidIdentifier, AccountId, LinkableAccountId, Balance, Key, BlockNumber>>;
}
}
49 changes: 49 additions & 0 deletions runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use sp_version::RuntimeVersion;
use xcm_executor::XcmExecutor;

use delegation::DelegationAc;
use did_rpc_runtime_api::runtime_decl_for_DidApi::DidApiV2;
use pallet_did_lookup::{linkable_account::LinkableAccountId, migrations::EthereumMigration};
pub use parachain_staking::InflationInfo;
pub use public_credentials;
Expand Down Expand Up @@ -1240,6 +1241,54 @@ 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<u8>) -> Option<did_rpc_runtime_api::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
Balance,
Hash,
BlockNumber
>
> {
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::PublicCredentialsApi<Block, AssetDid, Hash, public_credentials::CredentialEntry<Hash, DidIdentifier, BlockNumber, AccountId, Balance, AuthorizationId<<Runtime as delegation::Config>::DelegationNodeId>>> for Runtime {
fn get_credential(credential_id: Hash) -> Option<public_credentials::CredentialEntry<Hash, DidIdentifier, BlockNumber, AccountId, Balance, AuthorizationId<<Runtime as delegation::Config>::DelegationNodeId>>> {
let subject = public_credentials::CredentialSubjects::<Runtime>::get(&credential_id)?;
Expand Down
49 changes: 49 additions & 0 deletions runtimes/spiritnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use sp_version::RuntimeVersion;
use xcm_executor::XcmExecutor;

use delegation::DelegationAc;
use did_rpc_runtime_api::runtime_decl_for_DidApi::DidApiV2;
use pallet_did_lookup::{linkable_account::LinkableAccountId, migrations::EthereumMigration};
pub use parachain_staking::InflationInfo;
pub use public_credentials;
Expand Down Expand Up @@ -1234,6 +1235,54 @@ 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<u8>) -> Option<did_rpc_runtime_api::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
Balance,
Hash,
BlockNumber
>
> {
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::PublicCredentialsApi<Block, AssetDid, Hash, public_credentials::CredentialEntry<Hash, DidIdentifier, BlockNumber, AccountId, Balance, AuthorizationId<<Runtime as delegation::Config>::DelegationNodeId>>> for Runtime {
fn get_credential(credential_id: Hash) -> Option<public_credentials::CredentialEntry<Hash, DidIdentifier, BlockNumber, AccountId, Balance, AuthorizationId<<Runtime as delegation::Config>::DelegationNodeId>>> {
let subject = public_credentials::CredentialSubjects::<Runtime>::get(&credential_id)?;
Expand Down
49 changes: 49 additions & 0 deletions runtimes/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use sp_std::prelude::*;
use sp_version::RuntimeVersion;

use delegation::DelegationAc;
use did_rpc_runtime_api::runtime_decl_for_DidApi::DidApiV2;
use pallet_did_lookup::{linkable_account::LinkableAccountId, migrations::EthereumMigration};
use runtime_common::{
assets::AssetDid,
Expand Down Expand Up @@ -992,6 +993,54 @@ 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<u8>) -> Option<did_rpc_runtime_api::RawDidLinkedInfo<
DidIdentifier,
AccountId,
LinkableAccountId,
Balance,
Hash,
BlockNumber
>
> {
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::PublicCredentialsApi<Block, AssetDid, Hash, public_credentials::CredentialEntry<Hash, DidIdentifier, BlockNumber, AccountId, Balance, AuthorizationId<<Runtime as delegation::Config>::DelegationNodeId>>> for Runtime {
fn get_credential(credential_id: Hash) -> Option<public_credentials::CredentialEntry<Hash, DidIdentifier, BlockNumber, AccountId, Balance, AuthorizationId<<Runtime as delegation::Config>::DelegationNodeId>>> {
let subject = public_credentials::CredentialSubjects::<Runtime>::get(&credential_id)?;
Expand Down