Skip to content

Commit

Permalink
Bunch of tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Oct 19, 2023
1 parent 7fe6112 commit be46409
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 107 deletions.
20 changes: 11 additions & 9 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions pallets/core/src/common/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::util::btree_set;
use crate::{
did,
did::{
AuthorizeAction, Did, DidKey, DidMethodKey, DidOrDidMethodKey, DidOrDidMethodKeySignature,
AuthorizeTarget, Did, DidKey, DidMethodKey, DidOrDidMethodKey, DidOrDidMethodKeySignature,
Signed, SignedActionWithNonce,
},
util::{Action, ActionWithNonce, NonceError, UpdateWithNonceError, WithNonce},
Expand Down Expand Up @@ -144,8 +144,8 @@ impl<T: Limits> Policy<T> {
V: HasPolicy<T>,
F: FnOnce(S, &mut Option<V>) -> Result<R, E>,
WithNonce<T, S>: ActionWithNonce<T> + ToStateChange<T>,
Did: AuthorizeAction<<WithNonce<T, S> as Action>::Target, DidKey>,
DidMethodKey: AuthorizeAction<<WithNonce<T, S> as Action>::Target, DidMethodKey>,
Did: AuthorizeTarget<<WithNonce<T, S> as Action>::Target, DidKey>,
DidMethodKey: AuthorizeTarget<<WithNonce<T, S> as Action>::Target, DidMethodKey>,
E: From<PolicyExecutionError>
+ From<did::Error<T>>
+ From<NonceError>
Expand Down Expand Up @@ -178,8 +178,8 @@ fn rec_update<T: did::Config, A, R, E, D>(
where
E: From<UpdateWithNonceError> + From<NonceError> + From<did::Error<T>>,
WithNonce<T, A>: ActionWithNonce<T> + ToStateChange<T>,
Did: AuthorizeAction<<WithNonce<T, A> as Action>::Target, DidKey>,
DidMethodKey: AuthorizeAction<<WithNonce<T, A> as Action>::Target, DidMethodKey>,
Did: AuthorizeTarget<<WithNonce<T, A> as Action>::Target, DidKey>,
DidMethodKey: AuthorizeTarget<<WithNonce<T, A> as Action>::Target, DidMethodKey>,
{
if let Some(sig_with_nonce) = proof.next() {
let action_with_nonce = WithNonce::new_with_nonce(action, sig_with_nonce.nonce);
Expand All @@ -202,8 +202,8 @@ pub struct PolicyExecutor(pub DidOrDidMethodKey);

crate::impl_wrapper!(PolicyExecutor(DidOrDidMethodKey));

impl<T> AuthorizeAction<T, DidKey> for PolicyExecutor {}
impl<T> AuthorizeAction<T, DidMethodKey> for PolicyExecutor {}
impl<T> AuthorizeTarget<T, DidKey> for PolicyExecutor {}
impl<T> AuthorizeTarget<T, DidMethodKey> for PolicyExecutor {}

/// `DID`s signature along with the nonce.
pub type DidSignatureWithNonce<T> = WithNonce<T, DidOrDidMethodKeySignature<PolicyExecutor>>;
Expand Down
6 changes: 3 additions & 3 deletions pallets/core/src/modules/accumulator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use frame_support::{CloneNoBound, DebugNoBound, EqNoBound, PartialEqNoBound};
use super::*;
use crate::{
common::{Limits, TypesAndLimits},
did::{AuthorizeAction, DidKey, DidMethodKey, DidOrDidMethodKey},
did::{AuthorizeTarget, DidKey, DidMethodKey, DidOrDidMethodKey},
util::BoundedBytes,
};

Expand Down Expand Up @@ -32,8 +32,8 @@ pub struct AccumulatorOwner(pub DidOrDidMethodKey);

crate::impl_wrapper!(AccumulatorOwner(DidOrDidMethodKey));

impl AuthorizeAction<(), DidKey> for AccumulatorOwner {}
impl AuthorizeAction<(), DidMethodKey> for AccumulatorOwner {}
impl AuthorizeTarget<(), DidKey> for AccumulatorOwner {}
impl AuthorizeTarget<(), DidMethodKey> for AccumulatorOwner {}

#[derive(
scale_info_derive::TypeInfo,
Expand Down
6 changes: 3 additions & 3 deletions pallets/core/src/modules/attest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::{
common::{signatures::ForSigType, Limits, TypesAndLimits},
did::{
self, AuthorizeAction, DidKey, DidMethodKey, DidOrDidMethodKey, DidOrDidMethodKeySignature,
self, AuthorizeTarget, DidKey, DidMethodKey, DidOrDidMethodKey, DidOrDidMethodKeySignature,
SignedActionWithNonce,
},
util::BoundedBytes,
Expand Down Expand Up @@ -37,8 +37,8 @@ pub type Iri<T> = BoundedBytes<<T as Limits>::MaxIriSize>;
#[scale_info(omit_prefix)]
pub struct Attester(pub DidOrDidMethodKey);

impl AuthorizeAction<(), DidKey> for Attester {}
impl AuthorizeAction<(), DidMethodKey> for Attester {}
impl AuthorizeTarget<(), DidKey> for Attester {}
impl AuthorizeTarget<(), DidMethodKey> for Attester {}

crate::impl_wrapper!(Attester(DidOrDidMethodKey));

Expand Down
6 changes: 3 additions & 3 deletions pallets/core/src/modules/blob/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
common::{signatures::ForSigType, Limits, TypesAndLimits},
did,
did::{
AuthorizeAction, Did, DidKey, DidMethodKey, DidOrDidMethodKey, DidOrDidMethodKeySignature,
AuthorizeTarget, Did, DidKey, DidMethodKey, DidOrDidMethodKey, DidOrDidMethodKeySignature,
SignedActionWithNonce,
},
util::BoundedBytes,
Expand Down Expand Up @@ -35,8 +35,8 @@ mod weights;
#[scale_info(omit_prefix)]
pub struct BlobOwner(pub DidOrDidMethodKey);

impl AuthorizeAction<(), DidKey> for BlobOwner {}
impl AuthorizeAction<(), DidMethodKey> for BlobOwner {}
impl AuthorizeTarget<(), DidKey> for BlobOwner {}
impl AuthorizeTarget<(), DidMethodKey> for BlobOwner {}

crate::impl_wrapper!(BlobOwner(DidOrDidMethodKey));

Expand Down
2 changes: 1 addition & 1 deletion pallets/core/src/modules/did/base/did_method_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<T: crate::did::Config> StorageMapRef<T, WithNonce<T, ()>> for DidMethodKey
type Storage = DidMethodKeys<T>;
}

impl<Target> AuthorizeAction<Target, Self> for DidMethodKey {}
impl<Target> AuthorizeTarget<Target, Self> for DidMethodKey {}

impl Index<RangeFull> for DidMethodKey {
type Output = [u8];
Expand Down
4 changes: 2 additions & 2 deletions pallets/core/src/modules/did/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ impl TryFrom<DidOrDidMethodKey> for DidMethodKey {
#[scale_info(omit_prefix)]
pub struct Did(#[cfg_attr(feature = "serde", serde(with = "hex"))] pub RawDid);

impl<Target> AuthorizeAction<Target, DidKey> for Did {
fn ensure_can_perform_action<T, A>(&self, key: &DidKey, _: &A) -> Result<(), Error<T>>
impl<Target> AuthorizeTarget<Target, DidKey> for Did {
fn ensure_authorizes_target<T, A>(&self, key: &DidKey, _: &A) -> Result<(), Error<T>>
where
T: crate::did::Config,
A: Action<Target = Target>,
Expand Down
Loading

0 comments on commit be46409

Please sign in to comment.