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
6 changes: 5 additions & 1 deletion dip-template/runtimes/dip-provider/src/dip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

// If you feel like getting in touch with us, you can do so at [email protected]

use did::EnsureDidOrigin;
use dip_support::IdentityDetailsAction;
use frame_support::traits::EitherOfDiverse;
use frame_system::EnsureRoot;
use pallet_dip_provider::traits::{TxBuilder, XcmRouterDispatcher};
use parity_scale_codec::{Decode, Encode};
use runtime_common::dip::{did::LinkedDidInfoProviderOf, merkle::DidMerkleRootGenerator};
use xcm::{latest::MultiLocation, DoubleEncoded};

use crate::{DidIdentifier, Hash, Runtime, RuntimeEvent, XcmRouter};
use crate::{AccountId, DidIdentifier, Hash, Runtime, RuntimeEvent, XcmRouter};

#[derive(Encode, Decode)]
enum ConsumerParachainCalls {
Expand Down Expand Up @@ -53,6 +56,7 @@ impl TxBuilder<DidIdentifier, Hash> for ConsumerParachainTxBuilder {
}

impl pallet_dip_provider::Config for Runtime {
type CommitOrigin = EitherOfDiverse<EnsureRoot<AccountId>, EnsureDidOrigin<DidIdentifier, AccountId>>;
type Identifier = DidIdentifier;
type IdentityProofDispatcher = XcmRouterDispatcher<XcmRouter, DidIdentifier, Hash>;
type IdentityProofGenerator = DidMerkleRootGenerator<Runtime>;
Expand Down
4 changes: 2 additions & 2 deletions dip-template/runtimes/xcm-tests/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use dip_consumer_runtime_template::{
BlockNumber, DidIdentifier, DidLookup, DipConsumer, Runtime as ConsumerRuntime, RuntimeCall as ConsumerRuntimeCall,
RuntimeEvent, System,
};
use dip_provider_runtime_template::{AccountId as ProviderAccountId, DipProvider, Runtime as ProviderRuntime};
use dip_provider_runtime_template::{DipProvider, Runtime as ProviderRuntime};

#[test]
fn commit_identity() {
Expand All @@ -57,7 +57,7 @@ fn commit_identity() {
// 1. Send identity commitment from DIP provider to DIP consumer.
ProviderParachain::execute_with(|| {
assert_ok!(DipProvider::commit_identity(
RawOrigin::Signed(ProviderAccountId::from([0u8; 32])).into(),
RawOrigin::Root.into(),
did.clone(),
Box::new(ParentThen(X1(Parachain(para::consumer::PARA_ID))).into()),
Box::new((Here, 1_000_000_000).into()),
Expand Down
5 changes: 3 additions & 2 deletions pallets/pallet-dip-provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use crate::pallet::*;
pub mod pallet {
use super::*;

use frame_support::{pallet_prelude::*, weights::Weight};
use frame_support::{pallet_prelude::*, traits::EnsureOrigin, weights::Weight};
use frame_system::pallet_prelude::*;
use sp_std::{boxed::Box, fmt::Debug};
use xcm::{latest::prelude::*, VersionedMultiAsset, VersionedMultiLocation};
Expand All @@ -44,6 +44,7 @@ pub mod pallet {

#[pallet::config]
pub trait Config: frame_system::Config {
type CommitOrigin: EnsureOrigin<Self::RuntimeOrigin>;
type Identifier: Parameter;
type IdentityProofGenerator: IdentityProofGenerator<
Self::Identifier,
Expand Down Expand Up @@ -90,7 +91,7 @@ pub mod pallet {
weight: Weight,
) -> DispatchResult {
// TODO: Charge the dispatcher based on the destination weight configuration
ensure_signed(origin)?;
T::CommitOrigin::ensure_origin(origin)?;

let destination: MultiLocation = (*destination).try_into().map_err(|_| Error::<T>::BadVersion)?;
let action: IdentityProofActionOf<T> = match T::IdentityProvider::retrieve(&identifier) {
Expand Down