@@ -60,6 +60,7 @@ fn basic_mint() -> DispatchResult {
6060 Some ( Permill :: from_float ( 1.525 ) ) ,
6161 bvec ! [ 0u8 ; 20 ] ,
6262 true ,
63+ None ,
6364 )
6465}
6566
@@ -240,6 +241,7 @@ fn mint_nft_works() {
240241 Some ( Permill :: from_float( 20.525 ) ) ,
241242 bvec![ 0u8 ; 20 ] ,
242243 true ,
244+ None ,
243245 ) ) ;
244246 // BOB shouldn't be able to mint in ALICE's collection
245247 assert_noop ! (
@@ -251,6 +253,7 @@ fn mint_nft_works() {
251253 Some ( Permill :: from_float( 20.525 ) ) ,
252254 bvec![ 0u8 ; 20 ] ,
253255 true ,
256+ None ,
254257 ) ,
255258 Error :: <Test >:: NoPermission
256259 ) ;
@@ -264,6 +267,7 @@ fn mint_nft_works() {
264267 Some ( Permill :: from_float( 20.525 ) ) ,
265268 bvec![ 0u8 ; 20 ] ,
266269 true ,
270+ None ,
267271 ) ,
268272 Error :: <Test >:: CollectionUnknown
269273 ) ;
@@ -304,6 +308,7 @@ fn royalty_recipient_default_works() {
304308 Some ( Permill :: from_float( 20.525 ) ) ,
305309 bvec![ 0u8 ; 20 ] ,
306310 true ,
311+ None ,
307312 ) ) ;
308313 // Royalty recipient should default to issuer (ALICE)
309314 assert_eq ! ( RmrkCore :: nfts( 0 , 0 ) . unwrap( ) . royalty. unwrap( ) . recipient, ALICE ) ;
@@ -316,6 +321,7 @@ fn royalty_recipient_default_works() {
316321 Some ( Permill :: from_float( 20.525 ) ) ,
317322 bvec![ 0u8 ; 20 ] ,
318323 true ,
324+ None ,
319325 ) ) ;
320326 // Royalty recipient should be BOB
321327 assert_eq ! ( RmrkCore :: nfts( 0 , 1 ) . unwrap( ) . royalty. unwrap( ) . recipient, BOB ) ;
@@ -328,6 +334,7 @@ fn royalty_recipient_default_works() {
328334 None , // No royalty amount
329335 bvec![ 0u8 ; 20 ] ,
330336 true ,
337+ None ,
331338 ) ) ;
332339 // Royalty should not exist
333340 assert ! ( RmrkCore :: nfts( 0 , 2 ) . unwrap( ) . royalty. is_none( ) ) ;
@@ -340,6 +347,7 @@ fn royalty_recipient_default_works() {
340347 None , // No royalty amount
341348 bvec![ 0u8 ; 20 ] ,
342349 true ,
350+ None ,
343351 ) ) ;
344352 // Royalty should not exist
345353 assert ! ( RmrkCore :: nfts( 0 , 3 ) . unwrap( ) . royalty. is_none( ) ) ;
@@ -511,6 +519,7 @@ fn send_non_transferable_fail() {
511519 Some ( Permill :: from_float( 1.525 ) ) ,
512520 bvec![ 0u8 ; 20 ] ,
513521 false , // non-transferable
522+ None ,
514523 ) ) ;
515524 assert_noop ! (
516525 RMRKCore :: send(
@@ -581,6 +590,7 @@ fn reject_nft_removes_self_from_parents_children() {
581590 Some ( Permill :: from_float( 1.525 ) ) ,
582591 bvec![ 0u8 ; 20 ] ,
583592 true ,
593+ None
584594 ) ) ;
585595 // BOB sends NFT (0, 1) to ALICE's NFT (0, 0)
586596 assert_ok ! ( RMRKCore :: send(
@@ -986,6 +996,78 @@ fn create_resource_works() {
986996 } ) ;
987997}
988998
999+ /// Minting with resources works
1000+ #[ test]
1001+ fn add_resource_on_mint_works ( ) {
1002+ ExtBuilder :: default ( ) . build ( ) . execute_with ( || {
1003+ let basic_resource: BasicResource < BoundedVec < u8 , UniquesStringLimit > > =
1004+ BasicResource { src : None , metadata : None , license : None , thumb : None } ;
1005+
1006+ // Create a basic collection
1007+ assert_ok ! ( basic_collection( ) ) ;
1008+
1009+ let basic_resource =
1010+ BasicResource { src : None , metadata : None , license : None , thumb : None } ;
1011+
1012+ // Resources to add
1013+ let resources_to_add = bvec ! [
1014+ ResourceTypes :: Basic ( basic_resource. clone( ) ) ,
1015+ ResourceTypes :: Basic ( basic_resource) ,
1016+ ] ;
1017+
1018+ // Mint NFT
1019+ assert_ok ! ( RMRKCore :: mint_nft(
1020+ Origin :: signed( ALICE ) ,
1021+ ALICE ,
1022+ COLLECTION_ID_0 ,
1023+ Some ( ALICE ) ,
1024+ Some ( Permill :: from_float( 1.525 ) ) ,
1025+ bvec![ 0u8 ; 20 ] ,
1026+ true ,
1027+ Some ( resources_to_add) ,
1028+ ) ) ;
1029+
1030+ assert_eq ! ( RMRKCore :: resources( ( 0 , 0 , 0 ) ) . is_some( ) , true ) ;
1031+ assert_eq ! ( RMRKCore :: resources( ( 0 , 0 , 1 ) ) . is_some( ) , true ) ;
1032+ } ) ;
1033+ }
1034+
1035+ /// Minting with more than max resources (set to 3 in mock) should panic
1036+ #[ should_panic]
1037+ #[ test]
1038+ fn add_resource_on_mint_beyond_max_fails ( ) {
1039+ ExtBuilder :: default ( ) . build ( ) . execute_with ( || {
1040+ let basic_resource: BasicResource < BoundedVec < u8 , UniquesStringLimit > > =
1041+ BasicResource { src : None , metadata : None , license : None , thumb : None } ;
1042+
1043+ // Create a basic collection
1044+ assert_ok ! ( basic_collection( ) ) ;
1045+
1046+ let basic_resource =
1047+ BasicResource { src : None , metadata : None , license : None , thumb : None } ;
1048+
1049+ // Resources to add
1050+ let resources_to_add = bvec ! [
1051+ ResourceTypes :: Basic ( basic_resource. clone( ) ) ,
1052+ ResourceTypes :: Basic ( basic_resource. clone( ) ) ,
1053+ ResourceTypes :: Basic ( basic_resource. clone( ) ) ,
1054+ ResourceTypes :: Basic ( basic_resource) ,
1055+ ] ;
1056+
1057+ // Mint NFT
1058+ RMRKCore :: mint_nft (
1059+ Origin :: signed ( ALICE ) ,
1060+ ALICE ,
1061+ COLLECTION_ID_0 ,
1062+ Some ( ALICE ) ,
1063+ Some ( Permill :: from_float ( 1.525 ) ) ,
1064+ bvec ! [ 0u8 ; 20 ] ,
1065+ true ,
1066+ Some ( resources_to_add) ,
1067+ )
1068+ } ) ;
1069+ }
1070+
9891071/// Resource: Resource addition with pending and accept (RMRK2.0 spec: ACCEPT)
9901072#[ test]
9911073fn add_resource_pending_works ( ) {
@@ -1001,6 +1083,7 @@ fn add_resource_pending_works() {
10011083 Some ( Permill :: from_float( 1.525 ) ) ,
10021084 bvec![ 0u8 ; 20 ] ,
10031085 true ,
1086+ None
10041087 ) ) ;
10051088
10061089 let basic_resource = BasicResource {
@@ -1123,6 +1206,7 @@ fn resource_removal_pending_works() {
11231206 Some ( Permill :: from_float( 1.525 ) ) ,
11241207 bvec![ 0u8 ; 20 ] ,
11251208 true ,
1209+ None
11261210 ) ) ;
11271211
11281212 let basic_resource =
0 commit comments