-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Resource Id
There are different representations of the Resource Id.
1) u32 representation
One is in the rmrk-traits:
rmrk-substrate/traits/src/lib.rs
Line 23 in 0bcc42a
| 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:
rmrk-substrate/pallets/rmrk-core/src/lib.rs
Lines 113 to 118 in 0bcc42a
| 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>:
rmrk-substrate/pallets/rmrk-core/src/lib.rs
Lines 31 to 35 in 0bcc42a
| 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:
rmrk-substrate/pallets/rmrk-core/src/functions.rs
Lines 657 to 663 in 0bcc42a
| 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.