Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

example: add Dip origin checks to NFT marketplace place #1

Closed
wants to merge 1 commit into from

Conversation

ntn-x2
Copy link

@ntn-x2 ntn-x2 commented Jul 29, 2024

An example of how the DIP consumer can be integrated into a pallet. With the origin check added to the pallet's config, it's possible to get access to the DID identifier of the submitter.

The flow would then be:

  1. Commit the identity on the KILT chain
  2. Call the pallet_dip_consumer.dispatchAs extrinsic on the Xcavate chain with the right call.

@@ -250,30 +241,25 @@ pub mod pallet {
/// The maximum length of data stored in for post codes.
#[pallet::constant]
type PostcodeLimit: Get<u32>;

type DidIdentifier: Parameter + MaxEncodedLen;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type could also be hardcoded somewhere else instead of being a type parameter of this crate.

@@ -250,30 +241,25 @@ pub mod pallet {
/// The maximum length of data stored in for post codes.
#[pallet::constant]
type PostcodeLimit: Get<u32>;

type DidIdentifier: Parameter + MaxEncodedLen;
type BuyTokenOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::DidIdentifier>;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will most likely be a more generic origin rather than an origin for a specific call. What's important is the trait it's required to implement, and the expected Success type, which will be a Kilt DID.

@@ -702,16 +656,15 @@ pub mod pallet {
#[pallet::call_index(3)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::buy_token())]
pub fn buy_token(origin: OriginFor<T>, listing_id: u32, amount: u32) -> DispatchResult {
let origin = ensure_signed(origin.clone())?;
// You have access to the DID origin now.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the other relevant change, which gives the extrinsic access to the DID of the submitter.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants