diff --git a/Cargo.lock b/Cargo.lock index 739317646a..d5dedb345c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -339,7 +339,7 @@ checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" [[package]] name = "attestation" -version = "1.7.4" +version = "1.8.0" dependencies = [ "ctype", "frame-benchmarking", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "clone-runtime" -version = "1.7.4" +version = "1.8.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -1356,7 +1356,7 @@ dependencies = [ [[package]] name = "ctype" -version = "1.7.4" +version = "1.8.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -1927,7 +1927,7 @@ dependencies = [ [[package]] name = "delegation" -version = "1.7.4" +version = "1.8.0" dependencies = [ "attestation", "bitflags", @@ -1986,7 +1986,7 @@ dependencies = [ [[package]] name = "did" -version = "1.7.4" +version = "1.8.0" dependencies = [ "ctype", "env_logger", @@ -2008,22 +2008,9 @@ dependencies = [ "substrate-wasm-builder", ] -[[package]] -name = "did-rpc" -version = "1.7.4" -dependencies = [ - "did-rpc-runtime-api", - "jsonrpsee", - "parity-scale-codec", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-runtime", -] - [[package]] name = "did-rpc-runtime-api" -version = "1.7.4" +version = "1.8.0" dependencies = [ "did", "kilt-support", @@ -3626,7 +3613,7 @@ checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" [[package]] name = "kilt-asset-dids" -version = "1.7.2" +version = "1.8.0" dependencies = [ "base58", "frame-support", @@ -3641,7 +3628,7 @@ dependencies = [ [[package]] name = "kilt-parachain" -version = "1.7.4" +version = "1.8.0" dependencies = [ "clap", "clone-runtime", @@ -3657,7 +3644,6 @@ dependencies = [ "cumulus-relay-chain-interface", "cumulus-relay-chain-rpc-interface", "derive_more", - "did-rpc", "frame-benchmarking", "frame-benchmarking-cli", "futures 0.3.24", @@ -3665,7 +3651,6 @@ dependencies = [ "jsonrpsee", "log", "node-common", - "pallet-did-lookup", "pallet-transaction-payment-rpc", "parity-scale-codec", "parking_lot 0.12.1", @@ -3718,7 +3703,7 @@ dependencies = [ [[package]] name = "kilt-support" -version = "1.7.4" +version = "1.8.0" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -4635,10 +4620,9 @@ dependencies = [ [[package]] name = "mashnet-node" -version = "1.7.4" +version = "1.8.0" dependencies = [ "clap", - "did-rpc", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -4647,7 +4631,6 @@ dependencies = [ "log", "mashnet-node-runtime", "node-common", - "pallet-did-lookup", "pallet-transaction-payment", "pallet-transaction-payment-rpc", "public-credentials", @@ -4689,7 +4672,7 @@ dependencies = [ [[package]] name = "mashnet-node-runtime" -version = "1.7.4" +version = "1.8.0" dependencies = [ "attestation", "bitflags", @@ -5100,7 +5083,7 @@ dependencies = [ [[package]] name = "node-common" -version = "1.7.2" +version = "1.8.0" dependencies = [ "kilt-support", "public-credentials", @@ -5549,7 +5532,7 @@ dependencies = [ [[package]] name = "pallet-did-lookup" -version = "1.7.4" +version = "1.8.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5719,7 +5702,7 @@ dependencies = [ [[package]] name = "pallet-inflation" -version = "1.7.4" +version = "1.8.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -6198,7 +6181,7 @@ dependencies = [ [[package]] name = "pallet-web3-names" -version = "1.7.4" +version = "1.8.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -6265,7 +6248,7 @@ dependencies = [ [[package]] name = "parachain-staking" -version = "1.7.4" +version = "1.8.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -6473,7 +6456,7 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "peregrine-runtime" -version = "1.7.4" +version = "1.8.0" dependencies = [ "attestation", "ctype", @@ -8011,7 +7994,7 @@ dependencies = [ [[package]] name = "public-credentials" -version = "1.7.2" +version = "1.8.0" dependencies = [ "base58", "ctype", @@ -8033,7 +8016,7 @@ dependencies = [ [[package]] name = "public-credentials-rpc" -version = "1.7.2" +version = "1.8.0" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -8045,7 +8028,7 @@ dependencies = [ [[package]] name = "public-credentials-runtime-api" -version = "1.7.2" +version = "1.8.0" dependencies = [ "parity-scale-codec", "sp-api", @@ -8497,7 +8480,7 @@ dependencies = [ [[package]] name = "runtime-common" -version = "1.7.4" +version = "1.8.0" dependencies = [ "attestation", "frame-support", @@ -10844,7 +10827,7 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "spiritnet-runtime" -version = "1.7.4" +version = "1.8.0" dependencies = [ "attestation", "ctype", diff --git a/Cargo.toml b/Cargo.toml index a91307b735..16e6b28fb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ panic = "unwind" members = [ "nodes/*", "pallets/*", - "rpc/did", "rpc/did/runtime-api", "rpc/public-credentials", "rpc/public-credentials/runtime-api", diff --git a/crates/assets/Cargo.toml b/crates/assets/Cargo.toml index 95eafd9232..e62a30f858 100644 --- a/crates/assets/Cargo.toml +++ b/crates/assets/Cargo.toml @@ -4,7 +4,7 @@ description = "Asset DIDs and related structs, suitable for no_std environments. edition = "2021" name = "kilt-asset-dids" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.2" +version = "1.8.0" [dependencies] # External dependencies diff --git a/nodes/common/Cargo.toml b/nodes/common/Cargo.toml index ab97705e98..c61e4dce5c 100644 --- a/nodes/common/Cargo.toml +++ b/nodes/common/Cargo.toml @@ -3,7 +3,7 @@ authors = ["KILT "] edition = "2021" description = "Set of common utility types, functions, and traits that all node executables can tap into." name = "node-common" -version = "1.7.2" +version = "1.8.0" [dependencies] # Client dependencies diff --git a/nodes/parachain/Cargo.toml b/nodes/parachain/Cargo.toml index c34534827f..260944ecaa 100644 --- a/nodes/parachain/Cargo.toml +++ b/nodes/parachain/Cargo.toml @@ -4,7 +4,7 @@ build = "build.rs" description = "KILT parachain" edition = "2021" name = "kilt-parachain" -version = "1.7.4" +version = "1.8.0" [[bin]] name = "kilt-parachain" @@ -17,9 +17,7 @@ substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", # Internal dependencies clone-runtime = {path = "../../runtimes/clone"} -did-rpc = {path = "../../rpc/did"} node-common = {path = "../common"} -pallet-did-lookup = {path = "../../pallets/pallet-did-lookup"} peregrine-runtime = {path = "../../runtimes/peregrine"} public-credentials = {path = "../../pallets/public-credentials"} public-credentials-rpc = {path = "../../rpc/public-credentials"} @@ -106,7 +104,6 @@ fast-gov = [ "runtime-common/fast-gov", ] runtime-benchmarks = [ - "pallet-did-lookup/runtime-benchmarks", "polkadot-service/runtime-benchmarks", "peregrine-runtime/runtime-benchmarks", "public-credentials/runtime-benchmarks", diff --git a/nodes/parachain/src/rpc.rs b/nodes/parachain/src/rpc.rs index 26e189a3b5..8cc5ff4ca4 100644 --- a/nodes/parachain/src/rpc.rs +++ b/nodes/parachain/src/rpc.rs @@ -33,7 +33,6 @@ use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use pallet_did_lookup::linkable_account::LinkableAccountId; use public_credentials::CredentialEntry; use runtime_common::{ assets::AssetDid, authorization::AuthorizationId, AccountId, Balance, Block, BlockNumber, DidIdentifier, Hash, @@ -59,7 +58,6 @@ where C::Api: frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, - C::Api: did_rpc::DidRuntimeApi, C::Api: public_credentials_rpc::PublicCredentialsRuntimeApi< Block, AssetDid, @@ -68,7 +66,6 @@ where >, P: TransactionPool + 'static, { - use did_rpc::{DidApiServer, DidQuery}; use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use public_credentials_rpc::{PublicCredentialsApiServer, PublicCredentialsQuery}; @@ -87,7 +84,6 @@ where // to call into the runtime. // // `module.merge(YourRpcStruct::new(ReferenceToClient).into_rpc())?;` - module.merge(DidQuery::new(client.clone()).into_rpc())?; module.merge( PublicCredentialsQuery::< C, diff --git a/nodes/parachain/src/service.rs b/nodes/parachain/src/service.rs index 1e45b885b2..a103b7a40a 100644 --- a/nodes/parachain/src/service.rs +++ b/nodes/parachain/src/service.rs @@ -42,7 +42,6 @@ use sp_runtime::traits::BlakeTwo256; use std::{sync::Arc, time::Duration}; use substrate_prometheus_endpoint::Registry; -use pallet_did_lookup::linkable_account::LinkableAccountId; use public_credentials::CredentialEntry; use runtime_common::{ assets::AssetDid, authorization::AuthorizationId, AccountId, AuthorityId, Balance, BlockNumber, DidIdentifier, @@ -257,7 +256,6 @@ where + cumulus_primitives_core::CollectCollationInfo + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + frame_rpc_system::AccountNonceApi - + did_rpc::DidRuntimeApi + public_credentials_rpc::PublicCredentialsRuntimeApi< Block, AssetDid, @@ -502,7 +500,6 @@ where + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + sp_consensus_aura::AuraApi + cumulus_primitives_core::CollectCollationInfo - + did_rpc::DidRuntimeApi + public_credentials_rpc::PublicCredentialsRuntimeApi< Block, AssetDid, diff --git a/nodes/standalone/Cargo.toml b/nodes/standalone/Cargo.toml index 61feb9d608..709af490d8 100644 --- a/nodes/standalone/Cargo.toml +++ b/nodes/standalone/Cargo.toml @@ -3,7 +3,7 @@ authors = ["KILT "] build = "build.rs" edition = "2021" name = "mashnet-node" -version = "1.7.4" +version = "1.8.0" [[bin]] name = "mashnet-node" @@ -15,10 +15,8 @@ substrate-build-script-utils = {git = "https://github.com/paritytech/substrate", [dependencies] # Internal dependencies -did-rpc = {path = "../../rpc/did"} mashnet-node-runtime = {path = "../../runtimes/standalone"} node-common = {path = "../common"} -pallet-did-lookup = {path = "../../pallets/pallet-did-lookup"} public-credentials = {path = "../../pallets/public-credentials"} public-credentials-rpc = {path = "../../rpc/public-credentials"} runtime-common = {path = "../../runtimes/common"} @@ -77,7 +75,6 @@ try-runtime-cli = {git = "https://github.com/paritytech/substrate", branch = "po default = [] runtime-benchmarks = [ "mashnet-node-runtime/runtime-benchmarks", - "pallet-did-lookup/runtime-benchmarks", "public-credentials/runtime-benchmarks", "runtime-common/runtime-benchmarks", ] diff --git a/nodes/standalone/src/rpc.rs b/nodes/standalone/src/rpc.rs index d3cf5d45f0..a4174c8bc7 100644 --- a/nodes/standalone/src/rpc.rs +++ b/nodes/standalone/src/rpc.rs @@ -33,7 +33,6 @@ use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; -use pallet_did_lookup::linkable_account::LinkableAccountId; use public_credentials::CredentialEntry; use runtime_common::{ assets::AssetDid, authorization::AuthorizationId, AccountId, Balance, Block, BlockNumber, DidIdentifier, Hash, @@ -59,7 +58,6 @@ where C::Api: frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, - C::Api: did_rpc::DidRuntimeApi, C::Api: public_credentials_rpc::PublicCredentialsRuntimeApi< Block, AssetDid, @@ -68,7 +66,6 @@ where >, P: TransactionPool + 'static, { - use did_rpc::{DidApiServer, DidQuery}; use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use public_credentials_rpc::{PublicCredentialsApiServer, PublicCredentialsQuery}; @@ -88,7 +85,6 @@ where // to call into the runtime. // // `module.merge(YourRpcStruct::new(ReferenceToClient).into_rpc())?;` - module.merge(DidQuery::new(client.clone()).into_rpc())?; module.merge( PublicCredentialsQuery::< C, diff --git a/pallets/attestation/Cargo.toml b/pallets/attestation/Cargo.toml index 7c74c4d874..0a4a9e582c 100644 --- a/pallets/attestation/Cargo.toml +++ b/pallets/attestation/Cargo.toml @@ -4,7 +4,7 @@ description = "Enables adding and revoking attestations." edition = "2021" name = "attestation" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.4" +version = "1.8.0" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/ctype/Cargo.toml b/pallets/ctype/Cargo.toml index 7c220e9cda..d957e1bf6c 100644 --- a/pallets/ctype/Cargo.toml +++ b/pallets/ctype/Cargo.toml @@ -4,7 +4,7 @@ description = "Enables adding CTypes." edition = "2021" name = "ctype" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.4" +version = "1.8.0" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/delegation/Cargo.toml b/pallets/delegation/Cargo.toml index 71b81be282..a3dcff39b7 100644 --- a/pallets/delegation/Cargo.toml +++ b/pallets/delegation/Cargo.toml @@ -4,7 +4,7 @@ description = "Enables creating and revoking root nodes of delegation hierarchie edition = "2021" name = "delegation" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.4" +version = "1.8.0" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/did/Cargo.toml b/pallets/did/Cargo.toml index e0fa05655d..afc7290124 100644 --- a/pallets/did/Cargo.toml +++ b/pallets/did/Cargo.toml @@ -4,7 +4,7 @@ description = "Enables adding and removing decentralized identifiers (DIDs)." edition = "2021" name = "did" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.4" +version = "1.8.0" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/pallet-did-lookup/Cargo.toml b/pallets/pallet-did-lookup/Cargo.toml index 5a33391caa..cc748e04fd 100644 --- a/pallets/pallet-did-lookup/Cargo.toml +++ b/pallets/pallet-did-lookup/Cargo.toml @@ -4,7 +4,7 @@ description = "Lookup the DID for a blockchain account." edition = "2021" name = "pallet-did-lookup" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.4" +version = "1.8.0" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/pallet-inflation/Cargo.toml b/pallets/pallet-inflation/Cargo.toml index da8bf6b2bb..ab6f59d1b6 100644 --- a/pallets/pallet-inflation/Cargo.toml +++ b/pallets/pallet-inflation/Cargo.toml @@ -4,7 +4,7 @@ description = "Substrate pallet issueing a pre-configured amount of tokens to th edition = "2021" name = "pallet-inflation" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.4" +version = "1.8.0" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/pallet-web3-names/Cargo.toml b/pallets/pallet-web3-names/Cargo.toml index 9ac9c40200..b7d8430718 100644 --- a/pallets/pallet-web3-names/Cargo.toml +++ b/pallets/pallet-web3-names/Cargo.toml @@ -4,7 +4,7 @@ description = "Unique Web3 nicknames for KILT DIDs." edition = "2021" name = "pallet-web3-names" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.4" +version = "1.8.0" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index d17c1625ac..9239069cbf 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -3,7 +3,7 @@ authors = ["KILT "] description = "Parachain parachain-staking pallet for collator delegation and selection as well as reward distribution" edition = "2021" name = "parachain-staking" -version = "1.7.4" +version = "1.8.0" [dev-dependencies] pallet-aura = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29"} diff --git a/pallets/public-credentials/Cargo.toml b/pallets/public-credentials/Cargo.toml index 1ce0efb72b..c82ae15dc0 100644 --- a/pallets/public-credentials/Cargo.toml +++ b/pallets/public-credentials/Cargo.toml @@ -4,7 +4,7 @@ description = "Enables adding and revoking public credentials." edition = "2021" name = "public-credentials" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.2" +version = "1.8.0" [dev-dependencies] ctype = {features = ["mock"], path = "../ctype"} diff --git a/rpc/did/Cargo.toml b/rpc/did/Cargo.toml deleted file mode 100644 index b352459745..0000000000 --- a/rpc/did/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -edition = "2021" -name = "did-rpc" -version = "1.7.4" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5" } -jsonrpsee = { version = "0.15.1", features = ["server", "macros"] } - -did-rpc-runtime-api = {version = "1.7.2", path = "./runtime-api"} - -sp-api = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"} -sp-blockchain = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"} -sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"} -sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"} - -[features] -default = ["std"] -std = [ - "codec/std", - "did-rpc-runtime-api/std", - "sp-api/std", - "sp-core/std", - "sp-runtime/std", -] diff --git a/rpc/did/runtime-api/Cargo.toml b/rpc/did/runtime-api/Cargo.toml index 33abfc46bf..0106bfdbd5 100644 --- a/rpc/did/runtime-api/Cargo.toml +++ b/rpc/did/runtime-api/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "did-rpc-runtime-api" -version = "1.7.4" +version = "1.8.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/rpc/did/runtime-api/src/lib.rs b/rpc/did/runtime-api/src/lib.rs index 5f01ed0ea4..8aba8fd945 100644 --- a/rpc/did/runtime-api/src/lib.rs +++ b/rpc/did/runtime-api/src/lib.rs @@ -103,7 +103,9 @@ pub type RawDidLinkedInfo; sp_api::decl_runtime_apis! { - /// The API to query account nonce (aka transaction index). + // 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, @@ -118,6 +120,8 @@ sp_api::decl_runtime_apis! { /// * 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 @@ -125,6 +129,9 @@ sp_api::decl_runtime_apis! { /// * 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 @@ -132,6 +139,39 @@ sp_api::decl_runtime_apis! { /// * the web3name (optional) /// * associated accounts /// * service endpoints - fn query_did(did: DidIdentifier) -> Option>; + #[changed_in(2)] + fn query_did(did: DidIdentifier) -> Option>; + fn query_did(did: DidIdentifier) -> Option>; + } + + pub trait Did 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) -> Option>; + /// 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>; + /// 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>; } } diff --git a/rpc/did/src/lib.rs b/rpc/did/src/lib.rs deleted file mode 100644 index fc6e44ada5..0000000000 --- a/rpc/did/src/lib.rs +++ /dev/null @@ -1,261 +0,0 @@ -// KILT Blockchain – https://botlabs.org -// Copyright (C) 2019-2022 BOTLabs GmbH - -// The KILT Blockchain is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The KILT Blockchain is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// If you feel like getting in touch with us, you can do so at info@botlabs.org - -use std::{fmt::Display, str::FromStr, sync::Arc}; - -use codec::{Codec, MaxEncodedLen}; -use did_rpc_runtime_api::{DidLinkedInfo, ServiceEndpoint}; -use jsonrpsee::{ - core::{async_trait, RpcResult}, - proc_macros::rpc, - types::error::{CallError, ErrorObject}, -}; -use sp_api::ProvideRuntimeApi; -use sp_blockchain::HeaderBackend; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; - -pub use did_rpc_runtime_api::DidApi as DidRuntimeApi; - -pub type RpcDidLinkedInfo = DidLinkedInfo< - DidIdentifier, - AccountId, - LinkableAccountId, - String, - String, - String, - String, - Balance, - Key, - BlockNumber, ->; - -fn raw_did_endpoint_to_rpc( - raw: ServiceEndpoint, Vec, Vec>, -) -> Option> { - Some(ServiceEndpoint { - id: String::from_utf8(raw.id).ok()?, - service_types: raw - .service_types - .into_iter() - .filter_map(|st| String::from_utf8(st).ok()) - .collect(), - urls: raw - .urls - .into_iter() - .filter_map(|url| String::from_utf8(url).ok()) - .collect(), - }) -} - -pub type DidRpcResponse = - Option>; - -#[rpc(client, server)] -pub trait DidApi -where - BlockNumber: MaxEncodedLen, - Key: Ord, - Balance: FromStr + Display, -{ - /// Given a web3name this returns: - /// * the DID - /// * public keys stored for the did - /// * the web3name (optional) - /// * associated accounts - /// * service endpoints - #[method(name = "did_queryByWeb3Name")] - fn query_did_by_w3n( - &self, - web3name: String, - at: Option, - ) -> RpcResult>; - - /// Given an account this returns: - /// * the DID - /// * public keys stored for the did - /// * the web3name (optional) - /// * associated accounts - /// * service endpoints - #[method(name = "did_queryByAccount")] - fn query_did_by_account_id( - &self, - account: LinkableAccountId, - at: Option, - ) -> RpcResult>; - - /// Given a did this returns: - /// * the DID - /// * public keys stored for the did - /// * the web3name (optional) - /// * associated accounts - /// * service endpoints - #[method(name = "did_query")] - fn query_did( - &self, - account: DidIdentifier, - at: Option, - ) -> RpcResult>; -} - -/// A struct that implements the [`DidRuntimeApi`]. -pub struct DidQuery { - client: Arc, - _marker: std::marker::PhantomData, -} - -impl DidQuery { - /// Create new `DidQuery` with the given reference to the client. - pub fn new(client: Arc) -> Self { - Self { - client, - _marker: Default::default(), - } - } -} - -/// Error type of this RPC api. -pub enum Error { - /// The transaction was not decodable. - DecodeError, - /// The call to runtime failed. - RuntimeError, -} - -impl From for i32 { - fn from(e: Error) -> i32 { - match e { - Error::RuntimeError => 1, - Error::DecodeError => 2, - } - } -} - -#[async_trait] -impl - DidApiServer<::Hash, DidIdentifier, AccountId, LinkableAccountId, Balance, Key, BlockNumber> - for DidQuery -where - AccountId: Codec + Send + Sync + 'static, - LinkableAccountId: Codec + Send + Sync + 'static, - DidIdentifier: Codec + Send + Sync + 'static, - Key: Codec + Ord, - Balance: Codec + FromStr + Display, - BlockNumber: Codec + MaxEncodedLen, - Block: BlockT, - Client: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, - Client::Api: DidRuntimeApi, -{ - fn query_did_by_w3n( - &self, - web3name: String, - at: Option<::Hash>, - ) -> RpcResult>> { - let api = self.client.runtime_api(); - let at = BlockId::hash(at.unwrap_or_else(|| - // If the block hash is not provided, assume the best block. - self.client.info().best_hash)); - - match api.query_did_by_w3n(&at, web3name.into()) { - Err(e) => Err(CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - "Unable to query DID by web3name.", - Some(format!("{:?}", e)), - )) - .into()), - Ok(doc) => Ok(doc.map(|doc| RpcDidLinkedInfo { - // convert the w3n from a byte array to a string. if it's invalid utf-8 which should never happen, we - // ignore the w3n and pretend it doesn't exist. - w3n: doc.w3n.and_then(|w3n| String::from_utf8(w3n).ok()), - accounts: doc.accounts, - identifier: doc.identifier, - service_endpoints: doc - .service_endpoints - .into_iter() - .filter_map(raw_did_endpoint_to_rpc) - .collect(), - details: doc.details, - })), - } - } - - fn query_did_by_account_id( - &self, - account: LinkableAccountId, - at: Option<::Hash>, - ) -> RpcResult>> { - let api = self.client.runtime_api(); - let at = BlockId::hash(at.unwrap_or_else(|| - // If the block hash is not supplied assume the best block. - self.client.info().best_hash)); - - match api.query_did_by_account_id(&at, account) { - Err(e) => Err(CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - "Unable to query account by DID.", - Some(format!("{:?}", e)), - )) - .into()), - Ok(doc) => Ok(doc.map(|doc| RpcDidLinkedInfo { - // convert the w3n from a byte array to a string. if it's invalid utf-8 which should never happen, we - // ignore the w3n and pretend it doesn't exist. - w3n: doc.w3n.and_then(|w3n| String::from_utf8(w3n).ok()), - accounts: doc.accounts, - identifier: doc.identifier, - service_endpoints: doc - .service_endpoints - .into_iter() - .filter_map(raw_did_endpoint_to_rpc) - .collect(), - details: doc.details, - })), - } - } - - fn query_did( - &self, - did: DidIdentifier, - at: Option<::Hash>, - ) -> RpcResult>> { - let api = self.client.runtime_api(); - let at = BlockId::hash(at.unwrap_or_else(|| - // If the block hash is not supplied assume the best block. - self.client.info().best_hash)); - - match api.query_did(&at, did) { - Err(e) => Err(CallError::Custom(ErrorObject::owned( - Error::RuntimeError.into(), - "Unable to query DID details.", - Some(format!("{:?}", e)), - )) - .into()), - Ok(doc) => Ok(doc.map(|doc| RpcDidLinkedInfo { - // convert the w3n from a byte array to a string. if it's invalid utf-8 which should never happen, we - // ignore the w3n and pretend it doesn't exist. - w3n: doc.w3n.and_then(|w3n| String::from_utf8(w3n).ok()), - accounts: doc.accounts, - identifier: doc.identifier, - service_endpoints: doc - .service_endpoints - .into_iter() - .filter_map(raw_did_endpoint_to_rpc) - .collect(), - details: doc.details, - })), - } - } -} diff --git a/rpc/public-credentials/Cargo.toml b/rpc/public-credentials/Cargo.toml index 9fd1769c2f..5a4e7f8128 100644 --- a/rpc/public-credentials/Cargo.toml +++ b/rpc/public-credentials/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "public-credentials-rpc" -version = "1.7.2" +version = "1.8.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -18,7 +18,7 @@ sp-blockchain = {git = "https://github.com/paritytech/substrate", default-featur sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29"} # Internal runtime dependencies -public-credentials-runtime-api = {version = "1.7.2", path = "./runtime-api"} +public-credentials-runtime-api = {version = "1.8.0", path = "./runtime-api"} [features] default = ["std"] diff --git a/rpc/public-credentials/runtime-api/Cargo.toml b/rpc/public-credentials/runtime-api/Cargo.toml index 7252ac420c..6e5042b7ff 100644 --- a/rpc/public-credentials/runtime-api/Cargo.toml +++ b/rpc/public-credentials/runtime-api/Cargo.toml @@ -4,7 +4,7 @@ description = "Runtime APIs for dealing with public credentials." edition = "2021" name = "public-credentials-runtime-api" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.2" +version = "1.8.0" [dependencies] # External dependencies diff --git a/runtimes/clone/Cargo.toml b/runtimes/clone/Cargo.toml index 5686c2a358..55ea14f3ff 100644 --- a/runtimes/clone/Cargo.toml +++ b/runtimes/clone/Cargo.toml @@ -2,7 +2,7 @@ authors = ["KILT "] edition = "2021" name = "clone-runtime" -version = "1.7.4" +version = "1.8.0" [build-dependencies] substrate-wasm-builder = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29"} @@ -183,4 +183,4 @@ try-runtime = [ "pallet-xcm/try-runtime", "parachain-info/try-runtime", "runtime-common/try-runtime", -] \ No newline at end of file +] diff --git a/runtimes/clone/src/lib.rs b/runtimes/clone/src/lib.rs index 499e87dce1..9fbf43faae 100644 --- a/runtimes/clone/src/lib.rs +++ b/runtimes/clone/src/lib.rs @@ -78,7 +78,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("KILT"), impl_name: create_runtime_str!("KILT"), authoring_version: 0, - spec_version: 10740, + spec_version: 10800, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 0, diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 940f4ebefb..84286d8cc4 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -2,7 +2,7 @@ authors = ["KILT "] edition = "2021" name = "runtime-common" -version = "1.7.4" +version = "1.8.0" [dev-dependencies] sp-io = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29"} diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index 8e022f892e..1b8dd8f02d 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -2,7 +2,7 @@ authors = ["KILT "] edition = "2021" name = "peregrine-runtime" -version = "1.7.4" +version = "1.8.0" [build-dependencies] substrate-wasm-builder = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29"} diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 927383ec83..1e5050a3d0 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -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; @@ -87,7 +88,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("mashnet-node"), impl_name: create_runtime_str!("mashnet-node"), authoring_version: 4, - spec_version: 10740, + spec_version: 10800, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 4, @@ -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) -> 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::PublicCredentialsApi::DelegationNodeId>>> for Runtime { fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> { let subject = public_credentials::CredentialSubjects::::get(&credential_id)?; diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml index 6af3f14063..23676a00b6 100644 --- a/runtimes/spiritnet/Cargo.toml +++ b/runtimes/spiritnet/Cargo.toml @@ -2,7 +2,7 @@ authors = ["KILT "] edition = "2021" name = "spiritnet-runtime" -version = "1.7.4" +version = "1.8.0" [build-dependencies] substrate-wasm-builder = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29"} diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 44d5a596fd..ab4eda9b51 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -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; @@ -87,7 +88,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kilt-spiritnet"), impl_name: create_runtime_str!("kilt-spiritnet"), authoring_version: 1, - spec_version: 10740, + spec_version: 10800, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 3, @@ -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) -> 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::PublicCredentialsApi::DelegationNodeId>>> for Runtime { fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> { let subject = public_credentials::CredentialSubjects::::get(&credential_id)?; diff --git a/runtimes/standalone/Cargo.toml b/runtimes/standalone/Cargo.toml index 784e6c84be..eb64ae5ad2 100644 --- a/runtimes/standalone/Cargo.toml +++ b/runtimes/standalone/Cargo.toml @@ -2,7 +2,7 @@ authors = ["KILT "] edition = "2021" name = "mashnet-node-runtime" -version = "1.7.4" +version = "1.8.0" [build-dependencies] substrate-wasm-builder = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29"} diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs index 56749688f9..49b2836619 100644 --- a/runtimes/standalone/src/lib.rs +++ b/runtimes/standalone/src/lib.rs @@ -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, @@ -117,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("mashnet-node"), impl_name: create_runtime_str!("mashnet-node"), authoring_version: 4, - spec_version: 10740, + spec_version: 10800, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 4, @@ -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) -> 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::PublicCredentialsApi::DelegationNodeId>>> for Runtime { fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> { let subject = public_credentials::CredentialSubjects::::get(&credential_id)?; diff --git a/support/Cargo.toml b/support/Cargo.toml index 60f50c91a8..9b6d75b7ec 100644 --- a/support/Cargo.toml +++ b/support/Cargo.toml @@ -4,7 +4,7 @@ description = "Shared traits and structs used across the KILT pallets" edition = "2021" name = "kilt-support" repository = "https://github.com/KILTprotocol/kilt-node" -version = "1.7.4" +version = "1.8.0" [dependencies] # External dependencies