deploy dropsV2 on kovan

This commit is contained in:
owen05
2021-05-27 14:49:51 +08:00
parent 36885daf49
commit eba59077c7
7 changed files with 211 additions and 9 deletions

View File

@@ -75,13 +75,17 @@ module.exports = {
DODONFTRegistry: "",
DODONFTProxy: "",
//================= MysteryBox =================
//================= DropsV1 =================
// MysteryBoxV1: "0xc25286ef3BaE3f6Fe2d6d0A6e2acAd0301AF97b8", //波老师
MysteryBoxV1: "0xDf7E00Cd0bb91D1502a1A14575E58b5d8f20C8D4", //KAVA
RandomGenerator: "0x7C062B9C584fA6eC2504270790D38240A2c5fE72",
RandomPool: [
"0x82aff931d74f0645ce80e8f419b94c8f93952686",
"0x327134de48fcdd75320f4c32498d1980470249ae"
]
],
//================= DropsV2 ==================
DropsFeeModel: "",
DropsProxy: ""
}
}

View File

@@ -73,7 +73,7 @@ module.exports = {
DODONFTRegistry: "0x579eBcC668b5517F733587091C35D495FE8d6b68",
DODONFTProxy: "0xe121c6C90735e2Ca12e21708F2F379A55Ce61426",
//================= MysteryBox =================
//================= DropsV1 =================
// MysteryBoxV1: "0x47d2b27525b93A9c9E03001E1D19310A08748D55",//波老师
MysteryBoxV1: "0xd56Fd300aE2e4C46cd34460776007dCE1C4F2043",
RandomGenerator: "0x53F54E4760FA5f839e5624782D032495613DF218",
@@ -81,6 +81,10 @@ module.exports = {
"0xa2e0ef85618732d80e5ef362773da1c92e8b1c57",
"0xaCfc959e0E85726d09A36E6DFdD56FB2e5dB8F77",
"0x7A733869CB210393f3c02B740c58498EB1f8815C"
]
],
//================= DropsV2 ==================
DropsFeeModel: "0xDBe1C360050638C9d0f28f23B51b198C8B70D9eA",
DropsProxy: "0xa3a23cee044F995a97D86defeABf769bAd57c7c8"
}
}

View File

@@ -31,7 +31,7 @@ contract DropsFeeModel is InitializableOwnable {
mapping(address => DropBoxInfo) dropBoxes;
function addMysteryBoxInfo(address dropBox, uint256 globalFee, address feeAddr, address priceAddr) external onlyOwner {
function addDropBoxInfo(address dropBox, uint256 globalFee, address feeAddr, address priceAddr) external onlyOwner {
DropBoxInfo memory dropBoxInfo = DropBoxInfo({
isSet: true,
globalFee: globalFee,

14
deploy-drops.txt Normal file
View File

@@ -0,0 +1,14 @@
====================================================
network type: kovan
Deploy time: 2021/5/27 下午2:08:33
Deploy type: Drops_V2
DropsFeeModelAddress: 0xDBe1C360050638C9d0f28f23B51b198C8B70D9eA
Init DropsFeeModel Tx: 0xd53bf7c0258fb92f11c0cfd46d016627e1c42daf1d8ba39ecc09d2992370e965
DropsERC721Address: 0xaF5801b7814926DD1D6a69C1D3a3429784131E2A
Init DropsERC721 Tx: 0x9d1711c4bb1bc158482e362c07744b7abdf142d1f03abcca2b4b6b4e88cf4586
DropsProxyAddress: 0xa3a23cee044F995a97D86defeABf769bAd57c7c8
BaseDropsAddress: 0xbe7a24D7E4af1C509D97d6972898389821143844
Init BaseDrops Tx: 0x53876ec779656923d19304c951f9eee3de7c12b22d7bc0e33e185a0f30788a30
DODOApproveProxy unlockAddProxy tx: 0x4bdefa4cdd3ea157228532b881816343bc08e6b4997085ba12340311f1756802
DODOApproveProxy addDODOProxy tx: 0xfded36432e52dd6b631e0f9ed375a38b9d921ac7a8a848b54082c95c34e63bca
AddMinter DropsERC721 Tx: 0x3b1272e13bd90268b25d03732f1719b7fcc5e4f4ba74981ca32f3062c24fc36e

View File

@@ -0,0 +1,162 @@
const fs = require("fs");
const { deploySwitch } = require('../truffle-config.js')
const file = fs.createWriteStream("../deploy-drops.txt", { 'flags': 'a' });
let logger = new console.Console(file, file);
const { GetConfig } = require("../configAdapter.js")
const DODOApproveProxy = artifacts.require("DODOApproveProxy");
const DropsFeeModel = artifacts.require("DropsFeeModel");
const DropsERC721 = artifacts.require("DropsERC721");
const DropsERC1155 = artifacts.require("DropsERC1155");
const DODODropsProxy = artifacts.require("DODODropsProxy")
const BaseDrops = artifacts.require("BaseDrops");
const RandomGenerator = artifacts.require("RandomGenerator");
module.exports = async (deployer, network, accounts) => {
let CONFIG = GetConfig(network, accounts)
if (CONFIG == null) return;
//Need Deploy first
let WETHAddress = CONFIG.WETH;
let DODOApproveProxyAddress = CONFIG.DODOApproveProxy;
if (DODOApproveProxyAddress == "" || WETHAddress == "") return;
let DropsFeeModelAddress = CONFIG.DropsFeeModel;
let DropsProxyAddress = CONFIG.DropsProxy;
let RandomGeneratorAddress = CONFIG.RandomGenerator;
let RandomPool = CONFIG.RandomPool;
let multiSigAddress = CONFIG.multiSigAddress;
let defaultMaintainer = CONFIG.defaultMaintainer;
//配置信息
var isProb = false;
var isReveal = true;
var curTime = Math.floor(new Date().getTime() / 1000)
var baseUri = ""
var name = "DROPS"
var symbol = "DROPS"
var buyToken = "0x854b0f89BAa9101e49Bfb357A38071C9db5d0DFa" //Kovan DODO
var sellTimeIntervals = [curTime + 60 * 10, curTime + 60 * 60, curTime + 60 * 120]
var sellPrices = ["1000000000000000000", "2000000000000000000", "0"]
var sellAmount = [30, 30, 0]
var redeemTime = curTime + 60 * 10
var probIntervals = [4, 10, 50, 100, 105]
var tokenIdMaps = [
[0],
[1, 38],
[3, 4, 5],
[6, 7],
[19, 30, 35, 40]
]
var tokenIdList = [1, 2, 3, 4, 5, 6, 7, 8]
if (deploySwitch.Drops_V2) {
logger.log("====================================================");
logger.log("network type: " + network);
logger.log("Deploy time: " + new Date().toLocaleString());
logger.log("Deploy type: Drops_V2");
if (DropsFeeModelAddress == "") {
await deployer.deploy(DropsFeeModel);
DropsFeeModelAddress = DropsFeeModel.address;
logger.log("DropsFeeModelAddress: ", DropsFeeModelAddress);
const DropsFeeModelInstance = await DropsFeeModel.at(DropsFeeModelAddress);
var tx = await DropsFeeModelInstance.initOwner(multiSigAddress);
logger.log("Init DropsFeeModel Tx:", tx.tx);
}
if (!isReveal) {
if (RandomGeneratorAddress == "") {
await deployer.deploy(RandomGenerator, RandomPool);
RandomGeneratorAddress = RandomGenerator.address;
logger.log("RandomGeneratorAddress: ", RandomGeneratorAddress);
}
} else {
RandomGeneratorAddress = "0x0000000000000000000000000000000000000000"
}
var nftContractAddress = "";
if (isProb) {
await deployer.deploy(DropsERC1155);
DropsERC1155Address = DropsERC1155.address;
logger.log("DropsERC1155Address: ", DropsERC1155Address);
const DropsERC1155Instance = await DropsERC1155.at(DropsERC1155Address);
var tx = await DropsERC1155Instance.init(multiSigAddress, baseUri);
logger.log("Init DropsERC1155 Tx:", tx.tx);
nftContractAddress = DropsERC1155Address;
} else {
await deployer.deploy(DropsERC721);
DropsERC721Address = DropsERC721.address;
logger.log("DropsERC721Address: ", DropsERC721Address);
const DropsERC721Instance = await DropsERC721.at(DropsERC721Address);
var tx = await DropsERC721Instance.init(multiSigAddress, name, symbol, baseUri);
logger.log("Init DropsERC721 Tx:", tx.tx);
nftContractAddress = DropsERC721Address;
}
if (DropsProxyAddress == "") {
await deployer.deploy(
DODODropsProxy,
DODOApproveProxyAddress
);
DropsProxyAddress = DODODropsProxy.address;
logger.log("DropsProxyAddress: ", DropsProxyAddress);
}
await deployer.deploy(BaseDrops);
BaseDropsAddress = BaseDrops.address;
logger.log("BaseDropsAddress: ", BaseDropsAddress);
//drops init
var addrList = [
multiSigAddress,
buyToken,
DropsFeeModelAddress,
defaultMaintainer,
RandomGeneratorAddress,
nftContractAddress
]
const BaseDropsInstance = await BaseDrops.at(BaseDropsAddress);
var tx = await BaseDropsInstance.init(
addrList,
sellTimeIntervals,
sellPrices,
sellAmount,
redeemTime,
isReveal,
isProb
);
logger.log("Init BaseDrops Tx:", tx.tx);
if (network == 'kovan') {
const DODOApproveProxyInstance = await DODOApproveProxy.at(DODOApproveProxyAddress);
var tx = await DODOApproveProxyInstance.unlockAddProxy(DropsProxyAddress);
logger.log("DODOApproveProxy unlockAddProxy tx: ", tx.tx);
tx = await DODOApproveProxyInstance.addDODOProxy();
logger.log("DODOApproveProxy addDODOProxy tx: ", tx.tx);
if (isProb) {
const DropsERC1155Instance = await DropsERC1155.at(DropsERC1155Address);
var tx = await DropsERC1155Instance.addMintAccount(DropsProxyAddress);
logger.log("AddMinter DropsERC1155 Tx:", tx.tx);
await BaseDropsInstance.setProbInfo(probIntervals, tokenIdMaps);
} else {
const DropsERC721Instance = await DropsERC721.at(DropsERC721Address);
var tx = await DropsERC721Instance.addMintAccount(DropsProxyAddress);
logger.log("AddMinter DropsERC721 Tx:", tx.tx);
await BaseDropsInstance.setFixedAmountInfo(tokenIdList);
}
}
}
};

View File

@@ -4,7 +4,7 @@
SPDX-License-Identifier: Apache-2.0
*/
import { decimalStr } from '../utils/Converter';
import { decimalStr, fromWei} from '../utils/Converter';
import { logGas } from '../utils/Log';
import { assert } from 'chai';
import { Contract } from 'web3-eth-contract';
@@ -257,10 +257,27 @@ describe("DODODropsV2", () => {
assert(tokenId, '10')
})
//TODO:
it("withdraw", async () => {
await init(ctx, ctxDVM, true, true);
await setProbMap(ctx);
await ctx.EVM.increaseTime(10);
await logGas(await ctx.DropsProxy.methods.buyTickets(ctx.DropsV2.options.address, 2), ctx.sendParam(user1), "buyTickets-user1");
await logGas(await ctx.DropsProxy.methods.buyTickets(ctx.DropsV2.options.address, 3), ctx.sendParam(user2), "buyTickets-user2");
var b_drops_balance = await ctx.DODO.methods.balanceOf(ctx.DropsV2.options.address).call()
var b_owner = await ctx.DODO.methods.balanceOf(ctx.Deployer).call();
await ctx.DropsV2.methods.withdraw().send(ctx.sendParam(ctx.Deployer));
var a_drops_balance = await ctx.DODO.methods.balanceOf(ctx.DropsV2.options.address).call()
var a_owner = await ctx.DODO.methods.balanceOf(ctx.Deployer).call();
console.log("b_drops_balance:", fromWei(b_drops_balance, 'ether'))
console.log("a_drops_balance:", fromWei(a_drops_balance, 'ether'))
console.log("b_owner:", fromWei(b_owner, 'ether'))
console.log("a_owner:", fromWei(a_owner, 'ether'))
assert(a_owner, decimalStr("0.00005"))
})
});
});

View File

@@ -61,7 +61,8 @@ module.exports = {
CpProxy: false,
ERC20V2Factory: false,
DEPLOY_NFT: false,
MYSTERYBOX_V1: false
MYSTERYBOX_V1: false,
Drops_V2: true
},
networks: {