UNPKG

meta-contract-debug

Version:

Meta Contract SDK

44 lines (43 loc) 2.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ContractUtil = void 0; const scryptlib_1 = require("../scryptlib"); const nft_1 = require("./contract-factory/nft"); const nftGenesis_1 = require("./contract-factory/nftGenesis"); const nftSell_1 = require("./contract-factory/nftSell"); const nftUnlockContractCheck_1 = require("./contract-factory/nftUnlockContractCheck"); function getNftUnlockContractCheckCodeHashArray() { let contractArray = [ nftUnlockContractCheck_1.NftUnlockContractCheckFactory.createContract(nftUnlockContractCheck_1.NFT_UNLOCK_CONTRACT_TYPE.OUT_3), nftUnlockContractCheck_1.NftUnlockContractCheckFactory.createContract(nftUnlockContractCheck_1.NFT_UNLOCK_CONTRACT_TYPE.OUT_6), nftUnlockContractCheck_1.NftUnlockContractCheckFactory.createContract(nftUnlockContractCheck_1.NFT_UNLOCK_CONTRACT_TYPE.OUT_10), nftUnlockContractCheck_1.NftUnlockContractCheckFactory.createContract(nftUnlockContractCheck_1.NFT_UNLOCK_CONTRACT_TYPE.OUT_20), nftUnlockContractCheck_1.NftUnlockContractCheckFactory.createContract(nftUnlockContractCheck_1.NFT_UNLOCK_CONTRACT_TYPE.OUT_100), ]; return contractArray.map((v) => v.getCodeHash()); } class ContractUtil { static init(config) { if (config) { this.unlockContractCodeHashArray = config.unlockContractCodeHashArray.map((v) => new scryptlib_1.Bytes(v)); nftGenesis_1.NftGenesisFactory.lockingScriptSize = config.tokenGenesisSize; nft_1.NftFactory.lockingScriptSize = config.tokenSize; nftSell_1.NftSellFactory.lockingScriptSize = config.nftSellSize; nftUnlockContractCheck_1.NftUnlockContractCheckFactory.unlockContractTypeInfos.forEach((v, idx) => { v.lockingScriptSize = config.unlockContractSizes[idx]; }); } else { this.unlockContractCodeHashArray = getNftUnlockContractCheckCodeHashArray().map((v) => new scryptlib_1.Bytes(v)); nftGenesis_1.NftGenesisFactory.lockingScriptSize = nftGenesis_1.NftGenesisFactory.calLockingScriptSize(); nft_1.NftFactory.lockingScriptSize = nft_1.NftFactory.calLockingScriptSize(); nftSell_1.NftSellFactory.lockingScriptSize = nftSell_1.NftSellFactory.calLockingScriptSize(); nftUnlockContractCheck_1.NftUnlockContractCheckFactory.unlockContractTypeInfos.forEach((v, idx) => { v.lockingScriptSize = nftUnlockContractCheck_1.NftUnlockContractCheckFactory.calLockingScriptSize(v.type); }); } let tokenContract = nft_1.NftFactory.getDummyInstance(); this.tokenCodeHash = tokenContract.getCodeHash(); } } exports.ContractUtil = ContractUtil;