Git Product home page Git Product logo

Comments (6)

sudipghimire533 avatar sudipghimire533 commented on September 12, 2024 1

Correct. My point is to control who can be the collection_issuer.

For this we take a type type Creators: EnsureOrigin<Self::Origin, Success = Self::AccountId>.

And current behaviour would be achieved by:

impl pallet_rmrk_core::Config for Runtime {
    type Creators = EnsureSigned
}

Then all signed origin can create collection ( & in turn nft inside it )

And if we want it to be controlled we do something like:

impl pallet_rmrk_core::Config for Runtime {
    type Creators = OneOfOrigin<[Account1, Account2, Account3]>
}

Then only Account1, Account2 and Account3 can create collection ( & in turn nft under it )

from rmrk-substrate.

HashWarlock avatar HashWarlock commented on September 12, 2024 1

With the Uniques pallet, we can set the team with function set_team. This function allows us to set

  • issuer: Issuer of NFTs for a given Collection
  • admin: Admin can thaw, force transfer and burn NFTs of a given Collection
  • freezer: Freezer to freeze NFTs for a given Collection

We could leverage this existing functionality to set the issuer account for a Collection then ensure the mint functions check if sender is the Collection's issuer

Example:

set_team in pallet_uniques & must be called by the Collection's owner:

#[pallet::weight(T::WeightInfo::set_team())]
pub fn set_team(
  origin: OriginFor<T>,
  collection: T::CollectionId,
  issuer: AccountIdLookupOf<T>,
  admin: AccountIdLookupOf<T>,
  freezer: AccountIdLookupOf<T>,
) -> DispatchResult {
  let origin = ensure_signed(origin)?;
  let issuer = T::Lookup::lookup(issuer)?;
  let admin = T::Lookup::lookup(admin)?;
  let freezer = T::Lookup::lookup(freezer)?;

  Collection::<T, I>::try_mutate(collection, |maybe_details| {
    let details = maybe_details.as_mut().ok_or(Error::<T, I>::UnknownCollection)?;
    ensure!(origin == details.owner, Error::<T, I>::NoPermission);

    details.issuer = issuer.clone();
    details.admin = admin.clone();
    details.freezer = freezer.clone();

    Self::deposit_event(Event::TeamChanged { collection, issuer, admin, freezer });
    Ok(())
  })
}

By default, these accounts are assigned to the Collection owner when a Collection is created. Having upstream uniques manage this account permissions logic can allow us to have the function change_collection_issuer in pallet_rmrk_core to remove the call to pallet_uniques::transfer_ownership and instead call pallet_uniques::set_team to change the issuer account. We can update permission checks to check our internal function for Collections called issuer to return the CollectionInfo field issuer from the Collections storage.

This can remove the need for adding a trait & won't require storage migrations downstream.

from rmrk-substrate.

ilionic avatar ilionic commented on September 12, 2024

I think it makes sense. @HashWarlock wdyt?

from rmrk-substrate.

sudipghimire533 avatar sudipghimire533 commented on September 12, 2024

If so. I am willinng to raise a PR. I mean work has already been done.

from rmrk-substrate.

Szegoo avatar Szegoo commented on September 12, 2024

Currently, anyone can do so. It might be more convinent to allow the runtime to configure this.

I am not entirely sure what you mean by this. Currently, only the collection_issuer is able to mint nfts.

// Collection must exist and sender must be issuer of collection
if let Some(collection_issuer) =
	pallet_uniques::Pallet::<T>::collection_owner(collection_id)
{
        ensure!(collection_issuer == sender, Error::<T>::NoPermission);
// -- snip

What would we exactly gain by using a custom origin? Sorry if I didn't understand you correctly.

from rmrk-substrate.

Szegoo avatar Szegoo commented on September 12, 2024

Ok, it makes sense to me now, thanks for the explanation.

from rmrk-substrate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.