2021-04-08 00:31:25 +08:00
|
|
|
const fs = require("fs");
|
|
|
|
|
const { deploySwitch } = require('../truffle-config.js')
|
|
|
|
|
const file = fs.createWriteStream("../deploy-nft.txt", { 'flags': 'a' });
|
|
|
|
|
let logger = new console.Console(file, file);
|
|
|
|
|
const { GetConfig } = require("../configAdapter.js")
|
|
|
|
|
|
|
|
|
|
const DODOApproveProxy = artifacts.require("DODOApproveProxy");
|
|
|
|
|
const NFTCollateralVault = artifacts.require("NFTCollateralVault");
|
2021-06-17 14:04:46 +08:00
|
|
|
const BuyoutModel = artifacts.require("BuyoutModel");
|
2021-04-08 00:31:25 +08:00
|
|
|
const Fragment = artifacts.require("Fragment");
|
|
|
|
|
const DODONFTRegistry = artifacts.require("DODONFTRegistry");
|
|
|
|
|
const DODONFTProxy = artifacts.require("DODONFTProxy");
|
2021-04-09 14:58:30 +08:00
|
|
|
const DODONFTRouteHelper = artifacts.require("DODONFTRouteHelper");
|
2021-04-08 00:31:25 +08:00
|
|
|
|
|
|
|
|
const InitializableERC721 = artifacts.require("InitializableERC721");
|
|
|
|
|
const InitializableERC1155 = artifacts.require("InitializableERC1155");
|
|
|
|
|
const NFTTokenFactory = artifacts.require("NFTTokenFactory");
|
|
|
|
|
|
2021-05-27 20:07:47 +08:00
|
|
|
const DodoNftErc721 = artifacts.require("DODONFT");
|
|
|
|
|
const DodoNftErc1155 = artifacts.require("DODONFT1155");
|
|
|
|
|
|
2021-05-31 14:33:08 +08:00
|
|
|
const DODODropsV1 = artifacts.require("DODODropsV1");
|
2021-04-15 10:38:19 +08:00
|
|
|
const RandomGenerator = artifacts.require("RandomGenerator");
|
|
|
|
|
|
2021-04-08 00:31:25 +08:00
|
|
|
module.exports = async (deployer, network, accounts) => {
|
|
|
|
|
let CONFIG = GetConfig(network, accounts)
|
|
|
|
|
if (CONFIG == null) return;
|
|
|
|
|
//Need Deploy first
|
|
|
|
|
let WETHAddress = CONFIG.WETH;
|
|
|
|
|
let DVMTemplateAddress = CONFIG.DVM;
|
|
|
|
|
let CloneFactoryAddress = CONFIG.CloneFactory;
|
|
|
|
|
let DODOApproveProxyAddress = CONFIG.DODOApproveProxy;
|
|
|
|
|
|
2021-04-08 16:16:11 +08:00
|
|
|
if (DODOApproveProxyAddress == "" || CloneFactoryAddress == "") return;
|
2021-04-08 00:31:25 +08:00
|
|
|
|
2021-04-30 12:29:35 +08:00
|
|
|
let MtFeeRateModelAddress = CONFIG.FeeRateModel;
|
2021-04-08 00:31:25 +08:00
|
|
|
let FragmentAddress = CONFIG.Fragment;
|
2021-06-17 14:04:46 +08:00
|
|
|
let BuyoutModelAddress = CONFIG.BuyoutModel;
|
2021-04-08 00:31:25 +08:00
|
|
|
let NFTCollateralVaultAddress = CONFIG.NFTCollateralVault;
|
2021-04-09 14:58:30 +08:00
|
|
|
let DODONFTRouteHelperAddress = CONFIG.DODONFTRouteHelper;
|
2021-04-08 00:31:25 +08:00
|
|
|
|
|
|
|
|
let DODONFTRegistryAddress = CONFIG.DODONFTRegistry;
|
|
|
|
|
let DODONFTProxyAddress = CONFIG.DODONFTProxy;
|
|
|
|
|
|
|
|
|
|
let ERC721Address = CONFIG.InitializableERC721;
|
|
|
|
|
let ERC1155Address = CONFIG.InitializableERC1155;
|
|
|
|
|
let NFTTokenFactoryAddress = CONFIG.NFTTokenFactory;
|
|
|
|
|
|
2021-04-15 10:38:19 +08:00
|
|
|
let MysteryBoxV1Address = CONFIG.MysteryBoxV1;
|
|
|
|
|
let RandomGeneratorAddress = CONFIG.RandomGenerator;
|
|
|
|
|
let RandomPool = CONFIG.RandomPool;
|
|
|
|
|
|
2021-05-27 20:07:47 +08:00
|
|
|
let DodoNftErc721Address = CONFIG.DodoNftErc721;
|
|
|
|
|
let DodoNftErc1155Address = CONFIG.DodoNftErc1155;
|
|
|
|
|
|
2021-04-08 00:31:25 +08:00
|
|
|
let multiSigAddress = CONFIG.multiSigAddress;
|
|
|
|
|
let defaultMaintainer = CONFIG.defaultMaintainer;
|
|
|
|
|
|
2021-04-15 10:38:19 +08:00
|
|
|
if (deploySwitch.MYSTERYBOX_V1) {
|
|
|
|
|
logger.log("====================================================");
|
|
|
|
|
logger.log("network type: " + network);
|
|
|
|
|
logger.log("Deploy time: " + new Date().toLocaleString());
|
2021-06-03 14:17:34 +08:00
|
|
|
logger.log("Deploy type: FearNFT");
|
2021-04-15 10:38:19 +08:00
|
|
|
|
|
|
|
|
if (RandomGeneratorAddress == "") {
|
2021-04-15 13:40:48 +08:00
|
|
|
await deployer.deploy(RandomGenerator, RandomPool);
|
2021-04-15 10:38:19 +08:00
|
|
|
RandomGeneratorAddress = RandomGenerator.address;
|
|
|
|
|
logger.log("RandomGeneratorAddress: ", RandomGeneratorAddress);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (MysteryBoxV1Address == "") {
|
2021-05-24 20:32:05 +08:00
|
|
|
await deployer.deploy(DODODropsV1);
|
|
|
|
|
MysteryBoxV1Address = DODODropsV1.address;
|
2021-04-15 10:38:19 +08:00
|
|
|
logger.log("MysteryBoxV1Address: ", MysteryBoxV1Address);
|
2021-05-24 20:32:05 +08:00
|
|
|
const MysteryBoxV1Instance = await DODODropsV1.at(MysteryBoxV1Address);
|
2021-04-15 10:38:19 +08:00
|
|
|
var tx = await MysteryBoxV1Instance.init(
|
2021-06-22 11:24:41 +08:00
|
|
|
"DODOTest",
|
|
|
|
|
"DODOTest",
|
2021-04-15 10:38:19 +08:00
|
|
|
"",
|
|
|
|
|
multiSigAddress,
|
|
|
|
|
RandomGeneratorAddress
|
|
|
|
|
);
|
|
|
|
|
logger.log("Init MysteryBoxV1 Tx:", tx.tx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 20:07:47 +08:00
|
|
|
if (deploySwitch.COLLECTIONS) {
|
|
|
|
|
logger.log("====================================================");
|
|
|
|
|
logger.log("network type: " + network);
|
|
|
|
|
logger.log("Deploy time: " + new Date().toLocaleString());
|
|
|
|
|
logger.log("Deploy type: DODO Collections");
|
|
|
|
|
|
|
|
|
|
//ERC721
|
|
|
|
|
if (DodoNftErc721Address == "") {
|
|
|
|
|
await deployer.deploy(DodoNftErc721);
|
|
|
|
|
DodoNftErc721Address = DodoNftErc721.address;
|
|
|
|
|
logger.log("DodoNftErc721Address: ", DodoNftErc721Address);
|
|
|
|
|
const DodoNftErc721Instance = await DodoNftErc721.at(DodoNftErc721Address);
|
|
|
|
|
var tx = await DodoNftErc721Instance.init(
|
2021-08-30 19:26:06 +08:00
|
|
|
"0x16CC37d06FE5061CD0023fb8d142ABaAbB396A2b",
|
2021-05-27 20:07:47 +08:00
|
|
|
"DODONFT",
|
|
|
|
|
"DODONFT"
|
|
|
|
|
);
|
|
|
|
|
logger.log("Init DodoNftErc721 Tx:", tx.tx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ERC1155
|
|
|
|
|
if (DodoNftErc1155Address == "") {
|
|
|
|
|
await deployer.deploy(DodoNftErc1155);
|
|
|
|
|
DodoNftErc1155Address = DodoNftErc1155.address;
|
|
|
|
|
logger.log("DodoNftErc1155Address: ", DodoNftErc1155Address);
|
|
|
|
|
const DodoNftErc1155Instance = await DodoNftErc1155.at(DodoNftErc1155Address);
|
|
|
|
|
var tx = await DodoNftErc1155Instance.initOwner(multiSigAddress);
|
|
|
|
|
logger.log("Init DodoNftErc1155 Tx:", tx.tx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 00:31:25 +08:00
|
|
|
if (deploySwitch.DEPLOY_NFT) {
|
|
|
|
|
logger.log("====================================================");
|
|
|
|
|
logger.log("network type: " + network);
|
|
|
|
|
logger.log("Deploy time: " + new Date().toLocaleString());
|
|
|
|
|
logger.log("Deploy type: NFT");
|
|
|
|
|
logger.log("multiSigAddress: ", multiSigAddress)
|
|
|
|
|
|
|
|
|
|
//ERC721
|
|
|
|
|
if (ERC721Address == "") {
|
|
|
|
|
await deployer.deploy(InitializableERC721);
|
|
|
|
|
ERC721Address = InitializableERC721.address;
|
|
|
|
|
logger.log("ERC721Address: ", ERC721Address);
|
|
|
|
|
}
|
|
|
|
|
//ERC1155
|
|
|
|
|
if (ERC1155Address == "") {
|
|
|
|
|
await deployer.deploy(InitializableERC1155);
|
|
|
|
|
ERC1155Address = InitializableERC1155.address;
|
|
|
|
|
logger.log("ERC1155Address: ", ERC1155Address);
|
|
|
|
|
}
|
|
|
|
|
//NFTTokenFactory
|
|
|
|
|
if (NFTTokenFactoryAddress == "") {
|
|
|
|
|
await deployer.deploy(
|
|
|
|
|
NFTTokenFactory,
|
|
|
|
|
CloneFactoryAddress,
|
|
|
|
|
ERC721Address,
|
|
|
|
|
ERC1155Address
|
|
|
|
|
);
|
|
|
|
|
NFTTokenFactoryAddress = NFTTokenFactory.address;
|
|
|
|
|
logger.log("NFTTokenFactoryAddress: ", NFTTokenFactoryAddress);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//NFTRegister
|
|
|
|
|
if (DODONFTRegistryAddress == "") {
|
|
|
|
|
await deployer.deploy(DODONFTRegistry);
|
|
|
|
|
DODONFTRegistryAddress = DODONFTRegistry.address;
|
|
|
|
|
logger.log("DODONFTRegistryAddress: ", DODONFTRegistryAddress);
|
|
|
|
|
const DODONFTRegistrynstance = await DODONFTRegistry.at(DODONFTRegistryAddress);
|
|
|
|
|
var tx = await DODONFTRegistrynstance.initOwner(multiSigAddress);
|
|
|
|
|
logger.log("Init DODONFTRegistryAddress Tx:", tx.tx);
|
2021-04-09 14:58:30 +08:00
|
|
|
|
|
|
|
|
await deployer.deploy(
|
|
|
|
|
DODONFTRouteHelper,
|
|
|
|
|
DODONFTRegistryAddress
|
|
|
|
|
);
|
|
|
|
|
DODONFTRouteHelperAddress = DODONFTRouteHelper.address;
|
|
|
|
|
logger.log("DODONFTRouteHelperAddress: ", DODONFTRouteHelperAddress);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-17 14:04:46 +08:00
|
|
|
//BuyoutModel
|
|
|
|
|
if(BuyoutModelAddress == "") {
|
|
|
|
|
await deployer.deploy(BuyoutModel);
|
|
|
|
|
BuyoutModelAddress = BuyoutModel.address;
|
|
|
|
|
logger.log("BuyoutModelAddress: ", BuyoutModelAddress);
|
2021-07-13 15:49:53 +08:00
|
|
|
const BuyoutModelInstance = await BuyoutModel.at(BuyoutModelAddress);
|
|
|
|
|
var tx = await BuyoutModelInstance.initOwner(multiSigAddress);
|
|
|
|
|
logger.log("Init BuyoutModelAddress Tx:", tx.tx);
|
|
|
|
|
|
2021-06-17 14:04:46 +08:00
|
|
|
}
|
2021-04-09 14:58:30 +08:00
|
|
|
|
|
|
|
|
//DODONFTRouteHelper
|
|
|
|
|
if (DODONFTRouteHelperAddress == "") {
|
|
|
|
|
await deployer.deploy(
|
|
|
|
|
DODONFTRouteHelper,
|
|
|
|
|
DODONFTRegistryAddress
|
|
|
|
|
);
|
|
|
|
|
DODONFTRouteHelperAddress = DODONFTRouteHelper.address;
|
|
|
|
|
logger.log("DODONFTRouteHelperAddress: ", DODONFTRouteHelperAddress);
|
2021-04-08 00:31:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Vault
|
|
|
|
|
if (NFTCollateralVaultAddress == "") {
|
|
|
|
|
await deployer.deploy(NFTCollateralVault);
|
2021-04-09 14:58:30 +08:00
|
|
|
NFTCollateralVaultAddress = NFTCollateralVault.address;
|
|
|
|
|
logger.log("NFTCollateralVaultAddress: ", NFTCollateralVaultAddress);
|
2021-04-08 00:31:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Frag
|
|
|
|
|
if (FragmentAddress == "") {
|
|
|
|
|
await deployer.deploy(Fragment);
|
|
|
|
|
FragmentAddress = Fragment.address;
|
|
|
|
|
logger.log("FragmentAddress: ", FragmentAddress);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (DODONFTProxyAddress == "") {
|
|
|
|
|
await deployer.deploy(
|
|
|
|
|
DODONFTProxy,
|
|
|
|
|
CloneFactoryAddress,
|
|
|
|
|
WETHAddress,
|
|
|
|
|
DODOApproveProxyAddress,
|
|
|
|
|
defaultMaintainer,
|
2021-06-17 14:04:46 +08:00
|
|
|
BuyoutModelAddress,
|
2021-04-30 12:29:35 +08:00
|
|
|
MtFeeRateModelAddress,
|
2021-04-08 00:31:25 +08:00
|
|
|
NFTCollateralVaultAddress,
|
|
|
|
|
FragmentAddress,
|
|
|
|
|
DVMTemplateAddress,
|
|
|
|
|
DODONFTRegistryAddress
|
|
|
|
|
);
|
|
|
|
|
DODONFTProxyAddress = DODONFTProxy.address;
|
|
|
|
|
logger.log("DODONFTProxyAddress: ", DODONFTProxyAddress);
|
|
|
|
|
const DODONFTProxyInstance = await DODONFTProxy.at(DODONFTProxyAddress);
|
|
|
|
|
var tx = await DODONFTProxyInstance.initOwner(multiSigAddress);
|
|
|
|
|
logger.log("Init DODONFTProxyAddress Tx:", tx.tx);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-09 22:24:23 +08:00
|
|
|
if (network == 'kovan' || network == 'rinkeby') {
|
2021-04-08 00:31:25 +08:00
|
|
|
|
|
|
|
|
const DODOApproveProxyInstance = await DODOApproveProxy.at(DODOApproveProxyAddress);
|
|
|
|
|
var tx = await DODOApproveProxyInstance.unlockAddProxy(DODONFTProxyAddress);
|
|
|
|
|
logger.log("DODOApproveProxy unlockAddProxy tx: ", tx.tx);
|
|
|
|
|
|
|
|
|
|
tx = await DODOApproveProxyInstance.addDODOProxy();
|
|
|
|
|
logger.log("DODOApproveProxy addDODOProxy tx: ", tx.tx);
|
2021-04-09 20:07:39 +08:00
|
|
|
|
|
|
|
|
const DODONFTRegistrynstance = await DODONFTRegistry.at(DODONFTRegistryAddress);
|
2021-04-28 00:04:40 +08:00
|
|
|
var tx = await DODONFTRegistrynstance.addAdminList(DODONFTProxyAddress);
|
2021-05-27 20:07:47 +08:00
|
|
|
logger.log("Add AdminList on DODONFTRegistry Tx:", tx.tx);
|
2021-04-08 00:31:25 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|