import { MinespiderFacade } from "../../src/MinespiderBundle/Business/MinespiderFacade";
import { CertificateFile, CertificateEnvelope } from "@minespider/core-sdk";

export const splitAndSellCertificate = async (
  facade: MinespiderFacade,
  certificateEnvelope: CertificateEnvelope,
  amount: number,
  to: string
) => {
  const publicFileList = [
    new CertificateFile(
      Buffer.from("public file " + Math.random()),
      "public.txt",
      {
        type: "text/plain"
      }
    )
  ];
  const privateFileList = [
    new CertificateFile(
      Buffer.from("private file " + Math.random()),
      "private.txt",
      {
        type: "text/plain"
      }
    )
  ];

  return facade.sellCertification(
    certificateEnvelope.certificateUuid,
    amount,
    to,
    publicFileList,
    privateFileList
  );
};
