Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into trust-registry-did-method-key
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Oct 19, 2023
2 parents a07a231 + ebb264b commit a3a0dd7
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 27 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
# rustup directory
ENV PATH /root/.cargo/bin:$PATH

ARG stable='stable-2023-03-09'
ARG nightly='nightly-2023-03-09'

# setup rust nightly channel, pinning specific version as newer versions have a regression
# setup rust stable and nightly channels, pinning specific version as newer versions have a regression
RUN rustup install $stable
RUN rustup install $nightly

RUN rustup install stable

# install wasm toolchain for substrate
RUN rustup target add wasm32-unknown-unknown --toolchain $nightly

Expand All @@ -45,11 +45,11 @@ ARG release

RUN if [ "$release" = "Y" ] ; then \
echo 'Building in release mode.' ; \
cargo +$nightly build --profile=release $features ; \
WASM_BUILD_TOOLCHAIN=$nightly cargo +$stable build --profile=release $features ; \
mv /dock-node/target/release/dock-node /dock-node/target/; \
else \
echo 'Building in production mode.' ; \
cargo +$nightly build --profile=production $features ; \
WASM_BUILD_TOOLCHAIN=$nightly cargo +$stable build --profile=production $features ; \
mv /dock-node/target/production/dock-node /dock-node/target/; \
fi

Expand Down
4 changes: 2 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Dock.io"]
build = "build.rs"
edition = "2021"
name = "dock-node"
version = "0.24.0"
version = "0.25.0"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand All @@ -28,7 +28,7 @@ optional = true

[dependencies.dock-runtime]
path = "../runtime"
version = "0.24.0"
version = "0.25.0"

[dependencies.beefy-primitives]
git = "https://github.com/paritytech/substrate.git"
Expand Down
8 changes: 7 additions & 1 deletion pallets/core/src/modules/accumulator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ crate::impl_wrapper!(AccumulatorId([u8; 32]), with tests as acc_tests);
/// Accumulator owner - DID with the ability to control given accumulator keys, params, etc.
#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[derive(scale_info_derive::TypeInfo)]
#[scale_info(omit_prefix)]
pub struct AccumulatorOwner(pub DidOrDidMethodKey);
Expand All @@ -47,6 +46,7 @@ impl AuthorizeAction<(), DidMethodKey> for AccumulatorOwner {}
MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -71,6 +71,7 @@ pub struct AccumulatorParameters<T: Limits> {
MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -88,6 +89,7 @@ pub struct AccumulatorPublicKey<T: Limits> {
Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound, MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -110,6 +112,7 @@ pub enum Accumulator<T: Limits> {
MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -132,6 +135,7 @@ pub struct AccumulatorCommon<T: Limits> {
MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down Expand Up @@ -185,6 +189,7 @@ impl<T: Limits> Accumulator<T> {
scale_info_derive::TypeInfo, Encode, Decode, Clone, PartialEq, Eq, Debug, Default, MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[scale_info(omit_prefix)]
pub struct StoredAccumulatorOwnerCounters {
pub params_counter: IncId,
Expand All @@ -195,6 +200,7 @@ pub struct StoredAccumulatorOwnerCounters {
scale_info_derive::TypeInfo, Encode, Decode, Clone, PartialEq, Eq, Debug, MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down
2 changes: 2 additions & 0 deletions pallets/core/src/modules/attest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ crate::impl_wrapper!(Attester(DidOrDidMethodKey));
MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -70,6 +71,7 @@ pub struct Attestation<T: Limits> {
Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound, Default,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down
2 changes: 2 additions & 0 deletions pallets/core/src/modules/blob/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub type BlobId = [u8; ID_BYTE_SIZE];
/// When a new blob is being registered, the following object is sent.
#[derive(Encode, Decode, CloneNoBound, PartialEqNoBound, DebugNoBound, EqNoBound)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -63,6 +64,7 @@ pub struct Blob<T: Limits> {

#[derive(Encode, Decode, scale_info_derive::TypeInfo, DebugNoBound, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down
6 changes: 3 additions & 3 deletions pallets/core/src/modules/did/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl TryFrom<DidOrDidMethodKey> for DidMethodKey {
}
}

/// The type of the Dock DID.
/// The type of the Dock `DID`.
#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Copy, Ord, PartialOrd, MaxEncodedLen)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(scale_info_derive::TypeInfo)]
Expand Down Expand Up @@ -102,7 +102,7 @@ impl Index<RangeFull> for Did {
}

/// Contains underlying DID describing its storage type.
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, MaxEncodedLen)]
#[derive(Encode, Decode, DebugNoBound, Clone, PartialEq, Eq, MaxEncodedLen)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "serde",
Expand All @@ -118,7 +118,7 @@ pub enum StoredDidDetails<T: TypesAndLimits> {
OnChain(StoredOnChainDidDetails<T>),
}

impl<T: Config> StoredDidDetails<T> {
impl<T: TypesAndLimits> StoredDidDetails<T> {
pub fn is_onchain(&self) -> bool {
matches!(self, StoredDidDetails::OnChain(_))
}
Expand Down
10 changes: 5 additions & 5 deletions pallets/core/src/modules/did/base/offchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{common::TypesAndLimits, deposit_indexed_event};
/// Off-chain DID has no need of nonce as the signature is made on the whole transaction by
/// the caller account and Substrate takes care of replay protection. Thus it stores the data
/// about off-chain DID Doc (hash, URI or any other reference) and the account that owns it.
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, MaxEncodedLen)]
#[derive(Encode, Decode, DebugNoBound, Clone, PartialEq, Eq, MaxEncodedLen)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
Expand All @@ -20,13 +20,13 @@ pub struct OffChainDidDetails<T: TypesAndLimits> {
pub doc_ref: OffChainDidDocRef<T>,
}

impl<T: Config> From<OffChainDidDetails<T>> for StoredDidDetails<T> {
impl<T: TypesAndLimits> From<OffChainDidDetails<T>> for StoredDidDetails<T> {
fn from(details: OffChainDidDetails<T>) -> Self {
Self::OffChain(details)
}
}

impl<T: Config> TryFrom<StoredDidDetails<T>> for OffChainDidDetails<T> {
impl<T: TypesAndLimits> TryFrom<StoredDidDetails<T>> for OffChainDidDetails<T> {
type Error = Error<T>;

fn try_from(details: StoredDidDetails<T>) -> Result<Self, Self::Error> {
Expand All @@ -36,7 +36,7 @@ impl<T: Config> TryFrom<StoredDidDetails<T>> for OffChainDidDetails<T> {
}
}

impl<T: Config> OffChainDidDetails<T> {
impl<T: TypesAndLimits> OffChainDidDetails<T> {
/// Constructs new off-chain DID details using supplied params.
pub fn new(account_id: T::AccountId, doc_ref: OffChainDidDocRef<T>) -> Self {
Self {
Expand Down Expand Up @@ -71,7 +71,7 @@ pub enum OffChainDidDocRef<T: Limits> {
Custom(BoundedBytes<T::MaxDidDocRefSize>),
}

impl<T: Config> OffChainDidDocRef<T> {
impl<T: Limits> OffChainDidDocRef<T> {
pub fn len(&self) -> u32 {
match self {
OffChainDidDocRef::CID(v) => v.len() as u32,
Expand Down
1 change: 1 addition & 0 deletions pallets/core/src/modules/did/base/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub trait AuthorizeSigned<Key, Target>: Signed {
) -> Result<Option<Authorization<Self::Signer, Key>>, Error<T>>;
}

/// `DID`'s signature along with the used `DID`s key reference.
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, MaxEncodedLen)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
Expand Down
6 changes: 4 additions & 2 deletions pallets/core/src/modules/did/details_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ use crate::{
};

/// Aggregated details for the given DID.
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq)]
#[derive(Encode, Decode, DebugNoBound, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
)]
#[derive(scale_info_derive::TypeInfo)]
#[scale_info(skip_type_params(T))]
#[scale_info(omit_prefix)]
pub struct AggregatedDidDetailsResponse<T: TypesAndLimits> {
did: Did,
Expand All @@ -39,13 +40,14 @@ pub struct DidKeyWithId {
}

/// `ServiceEndpoint` with its identifier.
#[derive(Encode, Decode, scale_info_derive::TypeInfo, Debug, Clone, PartialEq, Eq)]
#[derive(Encode, Decode, scale_info_derive::TypeInfo, DebugNoBound, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
)]
#[scale_info(skip_type_params(T))]
#[scale_info(omit_prefix)]
pub struct ServiceEndpointWithId<T: Limits> {
id: ServiceEndpointId<T>,
Expand Down
8 changes: 6 additions & 2 deletions pallets/core/src/modules/did/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,14 @@ pub mod pallet {
Self::new_did_method_key_(did_key).map_err(Into::into)
}

/// Adds `StateChange` to the metadata.
/// Adds `StateChange` and `AggregatedDidDetailsResponse` to the metadata.
#[doc(hidden)]
#[pallet::weight(<T as frame_system::Config>::DbWeight::get().writes(10))]
pub fn noop(_o: OriginFor<T>, _s: common::StateChange<'static, T>) -> DispatchResult {
pub fn noop(
_o: OriginFor<T>,
_s: common::StateChange<'static, T>,
_d: AggregatedDidDetailsResponse<T>,
) -> DispatchResult {
Err(DispatchError::BadOrigin)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/core/src/modules/did/service_endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bitflags::bitflags! {
impl_bits_conversion! { ServiceEndpointType from u16 }
impl_wrapper_type_info! { ServiceEndpointType(u16) }

impl<T: Config> ServiceEndpoint<T> {
impl<T: Limits> ServiceEndpoint<T> {
pub fn is_valid(&self) -> bool {
!self.types.is_empty()
&& !self.origins.is_empty()
Expand Down
2 changes: 2 additions & 0 deletions pallets/core/src/modules/master/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ mod tests;
Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -117,6 +118,7 @@ impl<T: Limits> Default for Membership<T> {
Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound, Default,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down
4 changes: 4 additions & 0 deletions pallets/core/src/modules/offchain_signatures/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::*;

#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -18,6 +19,7 @@ pub struct AddOffchainSignatureParams<T: TypesAndLimits> {

#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -32,6 +34,7 @@ pub struct AddOffchainSignaturePublicKey<T: TypesAndLimits> {

#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand All @@ -45,6 +48,7 @@ pub struct RemoveOffchainSignatureParams<T: Types> {

#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, PartialEq, Eq, DebugNoBound)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down
2 changes: 2 additions & 0 deletions pallets/core/src/modules/offchain_signatures/schemes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ macro_rules! def_signature_scheme_key_and_params {
$(#[$key_meta])*
#[derive(scale_info_derive::TypeInfo, Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down Expand Up @@ -116,6 +117,7 @@ macro_rules! def_signature_scheme_key_and_params {
$(#[$params_meta])*
#[derive(scale_info_derive::TypeInfo, Encode, Decode, CloneNoBound, PartialEqNoBound, EqNoBound, DebugNoBound, MaxEncodedLen)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down
1 change: 1 addition & 0 deletions pallets/core/src/util/with_nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::common::Types;
/// Initial nonce will be equal to the current block number provided by the system.
#[derive(Encode, Decode, scale_info_derive::TypeInfo, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(
Expand Down
1 change: 1 addition & 0 deletions pallets/token-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod tests;
DefaultNoBound,
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
feature = "serde",
serde(bound(serialize = "T: Sized", deserialize = "T: Sized"))
Expand Down
Loading

0 comments on commit a3a0dd7

Please sign in to comment.