All files / tools/consolidator/interactions mintNFT.ts

75% Statements 6/8
66.67% Branches 4/6
100% Functions 1/1
75% Lines 6/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30          1x         133x 32x         101x 101x           101x            
import { Remark } from "../remark";
import { NFT } from "../../..";
import { OP_TYPES } from "../../constants";
import { Collection } from "../../..";
 
export const validateMintNFT = (
  remark: Remark,
  nft: NFT,
  nftParentCollection?: Collection
) => {
  if (!nftParentCollection) {
    throw new Error(
      `NFT referencing non-existant parent collection ${nft.collection}`
    );
  }
 
  nft.owner = nftParentCollection.issuer;
  Iif (remark.caller != nft.owner) {
    throw new Error(
      `Attempted issue of NFT in non-owned collection. Issuer: ${nftParentCollection.issuer}, caller: ${remark.caller}`
    );
  }
 
  Iif (nft.owner === "") {
    throw new Error(
      `[${OP_TYPES.MINTNFT}] Somehow this NFT still doesn't have an owner.`
    );
  }
};