-
Notifications
You must be signed in to change notification settings - Fork 0
example: add Dip origin checks to NFT marketplace place #1
Conversation
@@ -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; |
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
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:
pallet_dip_consumer.dispatchAs
extrinsic on the Xcavate chain with the right call.