text: import { deployContractByName, executeScript, mintFlow, sendTransaction } from 'flow-js-testing';
  
  import { getMugenARTAddress } from './common';
  
  // MugenNFT types
  export const typeID1 = 1000;
  
  /*
   * Deploys NonFungibleToken and MugenNFT contracts to MugenART.
   * @throws Will throw an error if transaction is reverted.
   * @returns {Promise<*>}
   * */
  export const deployMugenNFT = async () => {
  	const MugenART = await getMugenARTAddress();
  	await mintFlow(MugenART, '10.0');
  
  	await deployContractByName({ to: MugenART, name: 'NonFungibleToken' });
  
  	const addressMap = { NonFungibleToken: MugenART };
  	return deployContractByName({ to: MugenART, name: 'MugenNFT', addressMap });
  };
  
  /*
   * Setups MugenNFT collection on account and exposes public capability.
   * @param {string} account - account address
   * @throws Will throw an error if transaction is reverted.
   * @returns {Promise<*>}
   * */
  export const setupMugenNFTOnAccount = async (account) => {
  	const name = 'setup_account';
  	const signers = [account];
  
  	return sendTransaction({ name, signers });
  };
  
  /*
   * Returns MugenNFT supply.
   * @throws Will throw an error if execution will be halted
   * @returns {UInt64} - number of NFT minted so far
   * */
  export const getMugenNFTSupply = async () => {
  	const name = 'get_total_supply';
  
  	return executeScript({ name });
  };
  
  /*
   * Mints MugenNFT of a specific **itemType** and sends it to **recipient**.
   * @param {UInt64} itemType - type of NFT to mint
   * @param {string} recipient - recipient account address
   * @throws Will throw an error if execution will be halted
   * @returns {Promise<*>}
   * */
  export const mintMugenNFT = async (itemType, recipient) => {
  	const MugenART = await getMugenARTAddress();
  
  	const name = 'mint_nft';
  	const args = [recipient, itemType];
  	const signers = [MugenART];
  
  	return sendTransaction({ name, args, signers });
  };
  
  /*
   * Transfers MugenNFT NFT with id equal **itemId** from **sender** account to **recipient**.
   * @param {string} sender - sender address
   * @param {string} recipient - recipient address
   * @param {UInt64} itemId - id of the item to transfer
   * @throws Will throw an error if execution will be halted
   * @returns {Promise<*>}
   * */
  export const transferNFT = async (sender, recipient, itemId) => {
  	const name = 'transfer_nft';
  	const args = [recipient, itemId];
  	const signers = [sender];
  
  	return sendTransaction({ name, args, signers });
  };
  
  /*
   * Returns the MugenNFT NFT with the provided **id** from an account collection.
   * @param {string} account - account address
   * @param {UInt64} itemID - NFT id
   * @throws Will throw an error if execution will be halted
   * @returns {Promise<*>}
   * */
  export const getMugenNFT = async (account, itemID) => {
  	const name = 'get_collection_item';
  	const args = [account, itemID];
  
  	return executeScript({ name, args });
  };
  
  /*
   * Returns the number of MugenNFT Items in an account's collection.
   * @param {string} account - account address
   * @throws Will throw an error if execution will be halted
   * @returns {Promise<Int>}
   * */
  export const getMugenNFTCount = async (account) => {
  	const name = 'get_collection_length';
  	const args = [account];
  
  	return executeScript({ name, args });
  };
  
  /*
   * Returns the MugenNFT Items in an account's collection.
   * @param {string} account - account address
   * @throws Will throw an error if execution will be halted
   * @returns {Promise<[UInt64]>}
   * */
  export const getMugenNFTIDs = async (account) => {
  	const name = 'get_collection_ids';
  	const args = [account];
  
  	return executeScript({ name, args });
  };
  