ing
This commit is contained in:
@@ -40,7 +40,6 @@ contract DODONFTProxy is ReentrancyGuard, InitializableOwnable {
|
|||||||
address public immutable _WETH_;
|
address public immutable _WETH_;
|
||||||
address public immutable _DODO_APPROVE_PROXY_;
|
address public immutable _DODO_APPROVE_PROXY_;
|
||||||
address public immutable _CLONE_FACTORY_;
|
address public immutable _CLONE_FACTORY_;
|
||||||
address public immutable _DVM_FACTORY_;
|
|
||||||
address public immutable _NFT_REGISTY_;
|
address public immutable _NFT_REGISTY_;
|
||||||
address public immutable _DEFAULT_MAINTAINER_;
|
address public immutable _DEFAULT_MAINTAINER_;
|
||||||
|
|
||||||
@@ -70,7 +69,6 @@ contract DODONFTProxy is ReentrancyGuard, InitializableOwnable {
|
|||||||
address cloneFactory,
|
address cloneFactory,
|
||||||
address payable weth,
|
address payable weth,
|
||||||
address dodoApproveProxy,
|
address dodoApproveProxy,
|
||||||
address dvmFactory,
|
|
||||||
address defaultMaintainer,
|
address defaultMaintainer,
|
||||||
address vaultTemplate,
|
address vaultTemplate,
|
||||||
address fragTemplate,
|
address fragTemplate,
|
||||||
@@ -82,7 +80,6 @@ contract DODONFTProxy is ReentrancyGuard, InitializableOwnable {
|
|||||||
_CLONE_FACTORY_ = cloneFactory;
|
_CLONE_FACTORY_ = cloneFactory;
|
||||||
_WETH_ = weth;
|
_WETH_ = weth;
|
||||||
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
|
_DODO_APPROVE_PROXY_ = dodoApproveProxy;
|
||||||
_DVM_FACTORY_ = dvmFactory;
|
|
||||||
_DEFAULT_MAINTAINER_ = defaultMaintainer;
|
_DEFAULT_MAINTAINER_ = defaultMaintainer;
|
||||||
_VAULT_TEMPLATE_ = vaultTemplate;
|
_VAULT_TEMPLATE_ = vaultTemplate;
|
||||||
_FRAG_TEMPLATE_ = fragTemplate;
|
_FRAG_TEMPLATE_ = fragTemplate;
|
||||||
|
|||||||
@@ -23,10 +23,9 @@ module.exports = async (deployer, network, accounts) => {
|
|||||||
let WETHAddress = CONFIG.WETH;
|
let WETHAddress = CONFIG.WETH;
|
||||||
let DVMTemplateAddress = CONFIG.DVM;
|
let DVMTemplateAddress = CONFIG.DVM;
|
||||||
let CloneFactoryAddress = CONFIG.CloneFactory;
|
let CloneFactoryAddress = CONFIG.CloneFactory;
|
||||||
let DvmFactoryAddress = CONFIG.DVMFactory;
|
|
||||||
let DODOApproveProxyAddress = CONFIG.DODOApproveProxy;
|
let DODOApproveProxyAddress = CONFIG.DODOApproveProxy;
|
||||||
|
|
||||||
if (DvmFactoryAddress == "" || DODOApproveProxyAddress == "" || CloneFactoryAddress == "") return;
|
if (DODOApproveProxyAddress == "" || CloneFactoryAddress == "") return;
|
||||||
|
|
||||||
let ConstFeeRateModelAddress = CONFIG.ConstFeeRateModel;
|
let ConstFeeRateModelAddress = CONFIG.ConstFeeRateModel;
|
||||||
let FeeDistributorAddress = CONFIG.FeeDistributor;
|
let FeeDistributorAddress = CONFIG.FeeDistributor;
|
||||||
@@ -119,7 +118,6 @@ module.exports = async (deployer, network, accounts) => {
|
|||||||
CloneFactoryAddress,
|
CloneFactoryAddress,
|
||||||
WETHAddress,
|
WETHAddress,
|
||||||
DODOApproveProxyAddress,
|
DODOApproveProxyAddress,
|
||||||
DvmFactoryAddress,
|
|
||||||
defaultMaintainer,
|
defaultMaintainer,
|
||||||
NFTCollateralVaultAddress,
|
NFTCollateralVaultAddress,
|
||||||
FragmentAddress,
|
FragmentAddress,
|
||||||
|
|||||||
0
test/DODONFT/collateralVault.test.ts
Normal file
0
test/DODONFT/collateralVault.test.ts
Normal file
0
test/DODONFT/feeDistributer.test.ts
Normal file
0
test/DODONFT/feeDistributer.test.ts
Normal file
0
test/DODONFT/fragment.test.ts
Normal file
0
test/DODONFT/fragment.test.ts
Normal file
69
test/DODONFT/nftProxy.test.ts
Normal file
69
test/DODONFT/nftProxy.test.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2020 DODO ZOO.
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
*/
|
||||||
|
import { decimalStr, mweiStr } from '../utils/Converter';
|
||||||
|
import { logGas } from '../utils/Log';
|
||||||
|
import { NFTContext, getDODONftContext } from '../utils/NFTContext';
|
||||||
|
import { assert } from 'chai';
|
||||||
|
import * as contracts from '../utils/Contracts';
|
||||||
|
import { Contract } from 'web3-eth-contract';
|
||||||
|
|
||||||
|
let author: string;
|
||||||
|
let user1: string;
|
||||||
|
let user2: string;
|
||||||
|
|
||||||
|
async function init(ctx: NFTContext): Promise<void> {
|
||||||
|
author = ctx.SpareAccounts[1];
|
||||||
|
user1 = ctx.SpareAccounts[2];
|
||||||
|
user2 = ctx.SpareAccounts[3];
|
||||||
|
|
||||||
|
await ctx.mintTestToken(user1, ctx.USDT, mweiStr("10000"));
|
||||||
|
await ctx.mintTestToken(user2, ctx.USDT, mweiStr("10000"));
|
||||||
|
|
||||||
|
await ctx.approveProxy(user1);
|
||||||
|
await ctx.approveProxy(user2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
describe("DODONFTProxy", () => {
|
||||||
|
let snapshotId: string;
|
||||||
|
let ctx: NFTContext;
|
||||||
|
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
let ETH = await contracts.newContract(
|
||||||
|
contracts.WETH_CONTRACT_NAME
|
||||||
|
);
|
||||||
|
ctx = await getDODONftContext(ETH.options.address);
|
||||||
|
await init(ctx);
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
snapshotId = await ctx.EVM.snapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await ctx.EVM.reset(snapshotId);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("DODONFTProxy", () => {
|
||||||
|
it("createNFTVault", async () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("buyout", async () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("AddLiquidity", async () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("AddLiquidity", async () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
0
test/DODONFT/nftTokenFactory.test.ts
Normal file
0
test/DODONFT/nftTokenFactory.test.ts
Normal file
@@ -32,7 +32,6 @@ export const DVM_VAULT_NAME = "DVMVault"
|
|||||||
export const DVM_NAME = "DVM"
|
export const DVM_NAME = "DVM"
|
||||||
export const DVM_FACTORY_NAME = "DVMFactory"
|
export const DVM_FACTORY_NAME = "DVMFactory"
|
||||||
export const DVM_PROXY_NAME = "DVMProxy"
|
export const DVM_PROXY_NAME = "DVMProxy"
|
||||||
export const CONST_FEE_RATE_MODEL_NAME = "ConstFeeRateModel"
|
|
||||||
export const PERMISSION_MANAGER_NAME = "PermissionManager"
|
export const PERMISSION_MANAGER_NAME = "PermissionManager"
|
||||||
export const EXTERNAL_VALUE_NAME = "ExternalValue"
|
export const EXTERNAL_VALUE_NAME = "ExternalValue"
|
||||||
export const FEE_RATE_MODEL_NAME = "FeeRateModel"
|
export const FEE_RATE_MODEL_NAME = "FeeRateModel"
|
||||||
@@ -55,6 +54,16 @@ export const DODO_PROXY_NAME = "DODOV2Proxy02"
|
|||||||
export const ERC20_MINE = "ERC20Mine"
|
export const ERC20_MINE = "ERC20Mine"
|
||||||
export const VDODO_MINE = "vDODOMine"
|
export const VDODO_MINE = "vDODOMine"
|
||||||
|
|
||||||
|
export const NFT_VAULT = "NFTCollateralVault"
|
||||||
|
export const NFT_FEE = "FeeDistributor"
|
||||||
|
export const NFT_FRAG = "Fragment"
|
||||||
|
export const ERC721 = "InitializableERC721"
|
||||||
|
export const ERC1155 = "InitializableERC1155"
|
||||||
|
export const CONST_FEE_RATE_MODEL_NAME = "ConstFeeRateModel"
|
||||||
|
export const NFT_TOKEN_FACTORY = "NFTTokenFactory"
|
||||||
|
export const NFT_REGISTER = "DODONFTRegistry"
|
||||||
|
export const NFT_PROXY = "DODONFTProxy"
|
||||||
|
|
||||||
interface ContractJson {
|
interface ContractJson {
|
||||||
abi: any;
|
abi: any;
|
||||||
networks: { [network: number]: any };
|
networks: { [network: number]: any };
|
||||||
|
|||||||
153
test/utils/NFTContext.ts
Normal file
153
test/utils/NFTContext.ts
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2020 DODO ZOO.
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
import BigNumber from 'bignumber.js';
|
||||||
|
import Web3 from 'web3';
|
||||||
|
import { Contract } from 'web3-eth-contract';
|
||||||
|
|
||||||
|
import * as contracts from './Contracts';
|
||||||
|
import { decimalStr, mweiStr, MAX_UINT256 } from './Converter';
|
||||||
|
import { EVM, getDefaultWeb3 } from './EVM';
|
||||||
|
import * as log from './Log';
|
||||||
|
|
||||||
|
BigNumber.config({
|
||||||
|
EXPONENTIAL_AT: 1000,
|
||||||
|
DECIMAL_PLACES: 80,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export class NFTContext {
|
||||||
|
EVM: EVM;
|
||||||
|
Web3: Web3;
|
||||||
|
NFTTokenFacotry: Contract;
|
||||||
|
|
||||||
|
NFTRegister: Contract;
|
||||||
|
CollatteralVault: Contract;
|
||||||
|
Fragment: Contract;
|
||||||
|
NFTFee: Contract;
|
||||||
|
|
||||||
|
NFTProxy: Contract;
|
||||||
|
DODOApprove: Contract;
|
||||||
|
DODOApproveProxy: Contract;
|
||||||
|
|
||||||
|
//token
|
||||||
|
USDT: Contract;
|
||||||
|
WETH: Contract;
|
||||||
|
|
||||||
|
Deployer: string;
|
||||||
|
Maintainer: string;
|
||||||
|
SpareAccounts: string[];
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
async init(weth: string) {
|
||||||
|
this.EVM = new EVM();
|
||||||
|
this.Web3 = getDefaultWeb3();
|
||||||
|
const allAccounts = await this.Web3.eth.getAccounts();
|
||||||
|
this.Deployer = allAccounts[0];
|
||||||
|
this.Maintainer = allAccounts[1];
|
||||||
|
this.SpareAccounts = allAccounts.slice(2, 10);
|
||||||
|
|
||||||
|
this.WETH = contracts.getContractWithAddress(contracts.WETH_CONTRACT_NAME, weth);
|
||||||
|
|
||||||
|
this.USDT = await contracts.newContract(
|
||||||
|
contracts.MINTABLE_ERC20_CONTRACT_NAME,
|
||||||
|
["USDT Token", "USDT", 6]
|
||||||
|
);
|
||||||
|
|
||||||
|
var cloneFactory = await contracts.newContract(
|
||||||
|
contracts.CLONE_FACTORY_CONTRACT_NAME
|
||||||
|
);
|
||||||
|
var dvmTemplate = await contracts.newContract(contracts.DVM_NAME)
|
||||||
|
var constFeeTemplate = await contracts.newContract(contracts.CONST_FEE_RATE_MODEL_NAME)
|
||||||
|
|
||||||
|
var ERC721Template = await contracts.newContract(contracts.ERC721)
|
||||||
|
var ERC1155Template = await contracts.newContract(contracts.ERC1155)
|
||||||
|
|
||||||
|
|
||||||
|
this.NFTTokenFacotry = await contracts.newContract(contracts.NFT_TOKEN_FACTORY,
|
||||||
|
[
|
||||||
|
cloneFactory.options.address,
|
||||||
|
ERC721Template.options.address,
|
||||||
|
ERC1155Template.options.address
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
this.DODOApprove = await contracts.newContract(
|
||||||
|
contracts.SMART_APPROVE
|
||||||
|
);
|
||||||
|
|
||||||
|
this.DODOApproveProxy = await contracts.newContract(
|
||||||
|
contracts.SMART_APPROVE_PROXY,
|
||||||
|
[this.DODOApprove.options.address]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
this.NFTRegister = await contracts.newContract(contracts.NFT_REGISTER)
|
||||||
|
await this.NFTRegister.methods.initOwner(this.Deployer).send(this.sendParam(this.Deployer));
|
||||||
|
|
||||||
|
|
||||||
|
this.CollatteralVault = await contracts.newContract(
|
||||||
|
contracts.NFT_VAULT
|
||||||
|
);
|
||||||
|
|
||||||
|
this.Fragment = await contracts.newContract(contracts.NFT_FRAG)
|
||||||
|
|
||||||
|
this.NFTFee = await contracts.newContract(contracts.NFT_FEE)
|
||||||
|
|
||||||
|
this.NFTProxy = await contracts.newContract(contracts.NFT_PROXY,
|
||||||
|
[
|
||||||
|
cloneFactory.options.address,
|
||||||
|
this.WETH.options.address,
|
||||||
|
this.DODOApproveProxy.options.address,
|
||||||
|
this.Deployer,
|
||||||
|
this.CollatteralVault.options.address,
|
||||||
|
this.Fragment.options.address,
|
||||||
|
this.NFTFee.options.address,
|
||||||
|
dvmTemplate.options.address,
|
||||||
|
constFeeTemplate.options.address,
|
||||||
|
this.NFTRegister.options.address
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
await this.NFTProxy.methods.initOwner(this.Deployer).send(this.sendParam(this.Deployer));
|
||||||
|
|
||||||
|
|
||||||
|
await this.DODOApprove.methods.init(this.Deployer, this.DODOApproveProxy.options.address).send(this.sendParam(this.Deployer));
|
||||||
|
await this.DODOApproveProxy.methods.init(this.Deployer, [this.NFTProxy.options.address]).send(this.sendParam(this.Deployer));
|
||||||
|
|
||||||
|
console.log(log.blueText("[Init DODONFT context]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
sendParam(sender, value = "0") {
|
||||||
|
return {
|
||||||
|
from: sender,
|
||||||
|
gas: process.env["COVERAGE"] ? 10000000000 : 7000000,
|
||||||
|
gasPrice: mweiStr("1000"),
|
||||||
|
value: decimalStr(value),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async mintTestToken(to: string, token: Contract, amount: string) {
|
||||||
|
await token.methods.mint(to, amount).send(this.sendParam(this.Deployer));
|
||||||
|
}
|
||||||
|
|
||||||
|
async approveProxy(account: string) {
|
||||||
|
await this.USDT.methods
|
||||||
|
.approve(this.DODOApprove.options.address, MAX_UINT256)
|
||||||
|
.send(this.sendParam(account));
|
||||||
|
await this.WETH.methods
|
||||||
|
.approve(this.DODOApprove.options.address, MAX_UINT256)
|
||||||
|
.send(this.sendParam(account));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getDODONftContext(weth: string): Promise<NFTContext> {
|
||||||
|
var context = new NFTContext();
|
||||||
|
await context.init(weth);
|
||||||
|
return context;
|
||||||
|
}
|
||||||
@@ -162,7 +162,7 @@ export class ProxyContext {
|
|||||||
[this.WETH.options.address]
|
[this.WETH.options.address]
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log(log.blueText("[Init DVM context]"));
|
console.log(log.blueText("[Init ProxyV2 context]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sendParam(sender, value = "0") {
|
sendParam(sender, value = "0") {
|
||||||
|
|||||||
Reference in New Issue
Block a user