File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
src/rmrk2.0.0/tools/consolidator/interactions Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ export const validateMintNFT = async (
2323 `Attempted issue of NFT in non-owned collection. Issuer: ${ nftParentCollection . issuer } , caller: ${ remark . caller } `
2424 ) ;
2525 }
26+
27+ const nfts = await dbAdapter . getNFTsByCollection ( nftParentCollection . id ) ;
28+ const unburnedNfts = nfts ? nfts . filter ( ( nft ) => nft . burned === "" ) : [ ] ;
29+ if ( nftParentCollection . max <= unburnedNfts . length && nftParentCollection . max !== 0 ) {
30+ throw new Error (
31+ `Attempted to mint into maxed out collection ${ nftParentCollection . id } `
32+ ) ;
33+ }
2634
2735 if ( nft . owner ) {
2836 if ( ! isValidAddressPolkadotAddress ( nft . owner ) ) {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { Consolidator, NFT } from "../../../src/rmrk2.0.0";
22import {
33 createCollectionMock ,
44 getBlockCallsMock ,
5+ getAliceKey ,
56 getBobKey ,
67 getRemarksFromBlocksMock ,
78 mintNftMock ,
@@ -100,4 +101,20 @@ describe("rmrk2.0.0 Consolidator: MINT", () => {
100101 const consolidator = new Consolidator ( ) ;
101102 expect ( await consolidator . consolidate ( remarks ) ) . toMatchSnapshot ( ) ;
102103 } ) ;
104+
105+ it ( "Should prevent minting NFT into locked collection" , async ( ) => {
106+ const remarks = getRemarksFromBlocksMock ( [
107+ ...getSetupRemarks ( ) ,
108+ ...getBlockCallsMock (
109+ createCollectionMock ( 2 ) . lock ( ) ,
110+ getAliceKey ( ) . address
111+ ) ,
112+ ...getBlockCallsMock ( mintNftMock2 ( ) . mint ( ) ) ,
113+ ] ) ;
114+ const consolidator = new Consolidator ( ) ;
115+ const consolidated = await consolidator . consolidate ( remarks ) ;
116+ expect ( consolidated . invalid [ 0 ] . message ) . toEqual (
117+ "Attempted to mint into maxed out collection d43593c715a56da27d-KANARIABIRDS"
118+ ) ;
119+ } ) ;
103120} ) ;
You can’t perform that action at this time.
0 commit comments