@@ -13,6 +13,7 @@ use sp_std::convert::TryInto;
1313use rmrk_traits:: {
1414 primitives:: * , AccountIdOrCollectionNftTuple , Collection , CollectionInfo , Nft , NftInfo ,
1515 Priority , Property , Resource , ResourceInfo , RoyaltyInfo ,
16+ ResourceTypes , BasicResource , SlotResource , ComposableResource
1617} ;
1718use sp_std:: result:: Result ;
1819
@@ -574,21 +575,15 @@ pub mod pallet {
574575 Ok ( ( ) )
575576 }
576577
577- /// Create resource
578+ /// Create basic resource
578579 #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . reads_writes( 1 , 1 ) ) ]
579580 #[ transactional]
580- pub fn add_resource (
581+ pub fn add_basic_resource (
581582 origin : OriginFor < T > ,
582583 collection_id : CollectionId ,
583584 nft_id : NftId ,
584585 resource_id : BoundedResource < T :: ResourceSymbolLimit > ,
585- base : Option < BaseId > ,
586- src : Option < BoundedVec < u8 , T :: StringLimit > > ,
587- metadata : Option < BoundedVec < u8 , T :: StringLimit > > ,
588- slot : Option < SlotId > ,
589- license : Option < BoundedVec < u8 , T :: StringLimit > > ,
590- thumb : Option < BoundedVec < u8 , T :: StringLimit > > ,
591- parts : Option < BoundedVec < PartId , T :: PartsLimit > > ,
586+ resource : BasicResource < StringLimitOf < T > > ,
592587 ) -> DispatchResult {
593588 let sender = ensure_signed ( origin. clone ( ) ) ?;
594589
@@ -597,13 +592,55 @@ pub mod pallet {
597592 collection_id,
598593 nft_id,
599594 resource_id. clone ( ) ,
600- base,
601- src,
602- metadata,
603- slot,
604- license,
605- thumb,
606- parts,
595+ ResourceTypes :: Basic ( resource) ,
596+ ) ?;
597+
598+ Self :: deposit_event ( Event :: ResourceAdded { nft_id, resource_id } ) ;
599+ Ok ( ( ) )
600+ }
601+
602+ /// Create composable resource
603+ #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . reads_writes( 1 , 1 ) ) ]
604+ #[ transactional]
605+ pub fn add_composable_resource (
606+ origin : OriginFor < T > ,
607+ collection_id : CollectionId ,
608+ nft_id : NftId ,
609+ resource_id : BoundedResource < T :: ResourceSymbolLimit > ,
610+ resource : ComposableResource < StringLimitOf < T > , BoundedVec < PartId , T :: PartsLimit > > ,
611+ ) -> DispatchResult {
612+ let sender = ensure_signed ( origin. clone ( ) ) ?;
613+
614+ Self :: resource_add (
615+ sender,
616+ collection_id,
617+ nft_id,
618+ resource_id. clone ( ) ,
619+ ResourceTypes :: Composable ( resource) ,
620+ ) ?;
621+
622+ Self :: deposit_event ( Event :: ResourceAdded { nft_id, resource_id } ) ;
623+ Ok ( ( ) )
624+ }
625+
626+ /// Create slot resource
627+ #[ pallet:: weight( 10_000 + T :: DbWeight :: get( ) . reads_writes( 1 , 1 ) ) ]
628+ #[ transactional]
629+ pub fn add_slot_resource (
630+ origin : OriginFor < T > ,
631+ collection_id : CollectionId ,
632+ nft_id : NftId ,
633+ resource_id : BoundedResource < T :: ResourceSymbolLimit > ,
634+ resource : SlotResource < StringLimitOf < T > > ,
635+ ) -> DispatchResult {
636+ let sender = ensure_signed ( origin. clone ( ) ) ?;
637+
638+ Self :: resource_add (
639+ sender,
640+ collection_id,
641+ nft_id,
642+ resource_id. clone ( ) ,
643+ ResourceTypes :: Slot ( resource) ,
607644 ) ?;
608645
609646 Self :: deposit_event ( Event :: ResourceAdded { nft_id, resource_id } ) ;
0 commit comments