Skip to content

Ids contradiction #138

@mrshiposha

Description

@mrshiposha

Resource Id

There are different representations of the Resource Id.

1) u32 representation

One is in the rmrk-traits:

pub type ResourceId = u32;

It is used in NextResourceId storage:

pub type NextResourceId<T: Config> = StorageValue<_, ResourceId, ValueQuery>;

And it is used in the priorities:

pub type Priorities<T: Config> = StorageNMap<
_,
(
NMapKey<Blake2_128Concat, CollectionId>,
NMapKey<Blake2_128Concat, NftId>,
NMapKey<Blake2_128Concat, ResourceId>,


2) string representation

Another representation of the resource Id is BoundedVec<u8, ResourceSymbolLimit>:

pub type ResourceOf<T, R, P> = ResourceInfo::<
BoundedVec<u8, R>,
BoundedVec<u8, <T as pallet_uniques::Config>::StringLimit>,
BoundedVec<PartId, P>
>;

Unused resource Id generation

The NextResourceId used only in get_next_resource_id function which is never used:

pub fn get_next_resource_id() -> Result<ResourceId, Error<T>> {
NextResourceId::<T>::try_mutate(|id| {
let current_id = *id;
*id = id.checked_add(1).ok_or(Error::<T>::NoAvailableCollectionId)?;
Ok(current_id)
})
}

Part Id

Unused Id generation. The Id is taken from the create_base extrinsic input.
Storage NextPartId and the function get_next_part_id are unused.

Observation about IDs

In the RMRK spec, parts and resources obtain their IDs from some external generator (like the nanoid).
It seems it is intended to generate IDs internally in the rmrk-substrate (as far as I can understand from the code).
But ids are still expected from the inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions