All files / tools/consolidator/interactions mint.ts

90% Statements 9/10
75% Branches 3/4
100% Functions 2/2
90% Lines 9/10

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            1x 208x 208x 99x       109x     1x 95x 95x 95x            
import { decodeAddress } from "@polkadot/keyring";
import { Collection as C100 } from "../../..";
import { u8aToHex } from "@polkadot/util";
import { Remark } from "../remark";
import { OP_TYPES } from "../../constants";
 
export const getCollectionFromRemark = (remark: Remark) => {
  const collection = C100.fromRemark(remark.remark, remark.block);
  if (typeof collection === "string") {
    throw new Error(
      `[${OP_TYPES.MINT}] Dead before instantiation: ${collection}`
    );
  }
  return collection;
};
 
export const validateMintIds = (collection: C100, remark: Remark) => {
  const pubkey = decodeAddress(remark.caller);
  const id = C100.generateId(u8aToHex(pubkey), collection.symbol);
  Iif (id.toLowerCase() !== collection.id.toLowerCase()) {
    throw new Error(
      `Caller's pubkey ${u8aToHex(pubkey)} (${id}) does not match generated ID`
    );
  }
};