diff --git a/hardhat.config.js b/hardhat.config.js index 8beee4d..8c3b7ae 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -1,7 +1,7 @@ -//require('dotenv').config(); +require('dotenv').config(); require('@nomiclabs/hardhat-waffle'); require('@nomiclabs/hardhat-truffle5'); -require("@nomiclabs/hardhat-etherscan"); +require('@nomiclabs/hardhat-etherscan'); require('@nomiclabs/hardhat-ethers'); require('hardhat-gas-reporter'); require('solidity-coverage'); @@ -9,9 +9,9 @@ require('@nomiclabs/hardhat-solhint'); require('hardhat-contract-sizer'); require('@openzeppelin/hardhat-upgrades'); require('@openzeppelin/test-helpers'); -require("@nomiclabs/hardhat-web3"); +require('@nomiclabs/hardhat-web3'); -//const PRIVATE_KEY = process.env.PRIVATE_KEY; +const PRIVATE_KEY = process.env.PRIVATE_KEY; module.exports = { solidity: { @@ -32,16 +32,16 @@ module.exports = { mainnet: { url: `https://rpcapi.fantom.network`, chainId: 250, - //accounts: [`0x${PRIVATE_KEY}`] + accounts: [`0x${PRIVATE_KEY}`] }, testnet: { url: `https://rpc.testnet.fantom.network`, chainId: 4002, - //accounts: [`0x${PRIVATE_KEY}`] + accounts: [`0x${PRIVATE_KEY}`] }, ropsten: { url: `https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161`, - chainId: 3, + chainId: 3 //accounts: [`0x${PRIVATE_KEY}`] }, coverage: { diff --git a/scripts/scripts2/deploy_all.js b/scripts/scripts2/deploy_all.js index 86c9eac..cf6b5db 100644 --- a/scripts/scripts2/deploy_all.js +++ b/scripts/scripts2/deploy_all.js @@ -2,271 +2,302 @@ // run: npx hardhat node on a terminal // then run: npx hardhat run --network localhost scripts/12_deploy_all.js async function main(network) { + console.log('network: ', network.name); - console.log('network: ', network.name); - - const [deployer] = await ethers.getSigners(); - const deployerAddress = await deployer.getAddress(); - console.log(`Deployer's address: `, deployerAddress); - - const { TREASURY_ADDRESS, PLATFORM_FEE, WRAPPED_FTM_MAINNET, WRAPPED_FTM_TESTNET } = require('../constantss'); - - //////////// - const Artion = await ethers.getContractFactory('Artion'); - const artion = await Artion.deploy(TREASURY_ADDRESS, '2000000000000000000'); - - await artion.deployed(); - console.log('FantomArtion deployed at', artion.address); - /////////// - - ////////// - const ProxyAdmin = await ethers.getContractFactory('ProxyAdmin'); - const proxyAdmin = await ProxyAdmin.deploy(); - await proxyAdmin.deployed(); - - const PROXY_ADDRESS = proxyAdmin.address; - - console.log('ProxyAdmin deployed to:', proxyAdmin.address); - - const AdminUpgradeabilityProxyFactory = await ethers.getContractFactory('AdminUpgradeabilityProxy'); - ////////// - - ///////// - const Marketplace = await ethers.getContractFactory('FantomMarketplace'); - const marketplaceImpl = await Marketplace.deploy(); - await marketplaceImpl.deployed(); - - console.log('FantomMarketplace deployed to:', marketplaceImpl.address); - - const marketplaceProxy = await AdminUpgradeabilityProxyFactory.deploy( - marketplaceImpl.address, - PROXY_ADDRESS, - [] - ); - await marketplaceProxy.deployed(); - console.log('Marketplace Proxy deployed at ', marketplaceProxy.address); - const MARKETPLACE_PROXY_ADDRESS = marketplaceProxy.address; - const marketplace = await ethers.getContractAt('FantomMarketplace', marketplaceProxy.address); - - await marketplace.initialize(TREASURY_ADDRESS, PLATFORM_FEE); - console.log('Marketplace Proxy initialized'); - - ///////// - - ///////// - const BundleMarketplace = await ethers.getContractFactory( - 'FantomBundleMarketplace' - ); - const bundleMarketplaceImpl = await BundleMarketplace.deploy(); - await bundleMarketplaceImpl.deployed(); - console.log('FantomBundleMarketplace deployed to:', bundleMarketplaceImpl.address); - - const bundleMarketplaceProxy = await AdminUpgradeabilityProxyFactory.deploy( - bundleMarketplaceImpl.address, - PROXY_ADDRESS, - [] - ); - await bundleMarketplaceProxy.deployed(); - console.log('Bundle Marketplace Proxy deployed at ', bundleMarketplaceProxy.address); - const BUNDLE_MARKETPLACE_PROXY_ADDRESS = bundleMarketplaceProxy.address; - const bundleMarketplace = await ethers.getContractAt('FantomBundleMarketplace', bundleMarketplaceProxy.address); - - await bundleMarketplace.initialize(TREASURY_ADDRESS, PLATFORM_FEE); - console.log('Bundle Marketplace Proxy initialized'); - - //////// - - //////// - const Auction = await ethers.getContractFactory('FantomAuction'); - const auctionImpl = await Auction.deploy(); - await auctionImpl.deployed(); - console.log('FantomAuction deployed to:', auctionImpl.address); - - const auctionProxy = await AdminUpgradeabilityProxyFactory.deploy( - auctionImpl.address, - PROXY_ADDRESS, - [] - ); - - await auctionProxy.deployed(); - console.log('Auction Proxy deployed at ', auctionProxy.address); - const AUCTION_PROXY_ADDRESS = auctionProxy.address; - const auction = await ethers.getContractAt('FantomAuction', auctionProxy.address); - - await auction.initialize(TREASURY_ADDRESS); - console.log('Auction Proxy initialized'); - - //////// - - //////// - const Factory = await ethers.getContractFactory('FantomNFTFactory'); - const factory = await Factory.deploy( - AUCTION_PROXY_ADDRESS, - MARKETPLACE_PROXY_ADDRESS, - BUNDLE_MARKETPLACE_PROXY_ADDRESS, - '10000000000000000000', - TREASURY_ADDRESS, - '50000000000000000000' - ); - await factory.deployed(); - console.log('FantomNFTFactory deployed to:', factory.address); - - const PrivateFactory = await ethers.getContractFactory( - 'FantomNFTFactoryPrivate' - ); - const privateFactory = await PrivateFactory.deploy( - AUCTION_PROXY_ADDRESS, - MARKETPLACE_PROXY_ADDRESS, - BUNDLE_MARKETPLACE_PROXY_ADDRESS, - '10000000000000000000', - TREASURY_ADDRESS, - '50000000000000000000' - ); - await privateFactory.deployed(); - console.log('FantomNFTFactoryPrivate deployed to:', privateFactory.address); - //////// - - //////// - const NFTTradable = await ethers.getContractFactory('FantomNFTTradable'); - const nft = await NFTTradable.deploy( - 'Artion', - 'ART', - AUCTION_PROXY_ADDRESS, - MARKETPLACE_PROXY_ADDRESS, - BUNDLE_MARKETPLACE_PROXY_ADDRESS, - '10000000000000000000', - TREASURY_ADDRESS - ); - await nft.deployed(); - console.log('FantomNFTTradable deployed to:', nft.address); - - const NFTTradablePrivate = await ethers.getContractFactory( - 'FantomNFTTradablePrivate' - ); - const nftPrivate = await NFTTradablePrivate.deploy( - 'IArtion', - 'IART', - AUCTION_PROXY_ADDRESS, - MARKETPLACE_PROXY_ADDRESS, - BUNDLE_MARKETPLACE_PROXY_ADDRESS, - '10000000000000000000', - TREASURY_ADDRESS - ); - await nftPrivate.deployed(); - console.log('FantomNFTTradablePrivate deployed to:', nftPrivate.address); - //////// - - //////// - const TokenRegistry = await ethers.getContractFactory('FantomTokenRegistry'); - const tokenRegistry = await TokenRegistry.deploy(); - - await tokenRegistry.deployed(); - - console.log('FantomTokenRegistry deployed to', tokenRegistry.address); - //////// - - //////// - const AddressRegistry = await ethers.getContractFactory('FantomAddressRegistry'); - const addressRegistry = await AddressRegistry.deploy(); - - await addressRegistry.deployed(); - - console.log('FantomAddressRegistry deployed to', addressRegistry.address); - const FANTOM_ADDRESS_REGISTRY = addressRegistry.address; - //////// - - //////// - const PriceFeed = await ethers.getContractFactory('FantomPriceFeed'); - const WRAPPED_FTM = network.name === 'mainnet' ? WRAPPED_FTM_MAINNET : WRAPPED_FTM_TESTNET; - const priceFeed = await PriceFeed.deploy( - FANTOM_ADDRESS_REGISTRY, - WRAPPED_FTM - ); - - await priceFeed.deployed(); - - console.log('FantomPriceFeed deployed to', priceFeed.address); - //////// - - //////// - const ArtTradable = await ethers.getContractFactory('FantomArtTradable'); - const artTradable = await ArtTradable.deploy( - 'FantomArt', - 'FART', - '20000000000000000000', - TREASURY_ADDRESS, - MARKETPLACE_PROXY_ADDRESS, - BUNDLE_MARKETPLACE_PROXY_ADDRESS - ); - await artTradable.deployed(); - console.log('FantomArtTradable deployed to:', artTradable.address); - - const ArtTradablePrivate = await ethers.getContractFactory( - 'FantomArtTradablePrivate' - ); - const artTradablePrivate = await ArtTradablePrivate.deploy( - 'FantomArt', - 'FART', - '20000000000000000000', - TREASURY_ADDRESS, - MARKETPLACE_PROXY_ADDRESS, - BUNDLE_MARKETPLACE_PROXY_ADDRESS - ); - await artTradablePrivate.deployed(); - console.log('FantomArtTradablePrivate deployed to:', artTradablePrivate.address); - //////// - - //////// - const ArtFactory = await ethers.getContractFactory('FantomArtFactory'); - const artFactory = await ArtFactory.deploy( - MARKETPLACE_PROXY_ADDRESS, - BUNDLE_MARKETPLACE_PROXY_ADDRESS, - '20000000000000000000', - TREASURY_ADDRESS, - '10000000000000000000' - ); - await artFactory.deployed(); - console.log('FantomArtFactory deployed to:', artFactory.address); - - const ArtFactoryPrivate = await ethers.getContractFactory( - 'FantomArtFactoryPrivate' - ); - const artFactoryPrivate = await ArtFactoryPrivate.deploy( - MARKETPLACE_PROXY_ADDRESS, - BUNDLE_MARKETPLACE_PROXY_ADDRESS, - '20000000000000000000', - TREASURY_ADDRESS, - '10000000000000000000' - ); - await artFactoryPrivate.deployed(); - console.log('FantomArtFactoryPrivate deployed to:', artFactoryPrivate.address); - //////// - - await marketplace.updateAddressRegistry(FANTOM_ADDRESS_REGISTRY); - await bundleMarketplace.updateAddressRegistry(FANTOM_ADDRESS_REGISTRY); - - await auction.updateAddressRegistry(FANTOM_ADDRESS_REGISTRY); - - await addressRegistry.updateArtion(artion.address); - await addressRegistry.updateAuction(auction.address); - await addressRegistry.updateMarketplace(marketplace.address); - await addressRegistry.updateBundleMarketplace(bundleMarketplace.address); - await addressRegistry.updateNFTFactory(factory.address); - await addressRegistry.updateTokenRegistry(tokenRegistry.address); - await addressRegistry.updatePriceFeed(priceFeed.address); - await addressRegistry.updateArtFactory(artFactory.address); - - await tokenRegistry.add(WRAPPED_FTM); - - } - - // We recommend this pattern to be able to use async/await everywhere - // and properly handle errors. - main(network) - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); - + const [deployer] = await ethers.getSigners(); + const deployerAddress = await deployer.getAddress(); + console.log(`Deployer's address: `, deployerAddress); + const { + TREASURY_ADDRESS, + PLATFORM_FEE, + WRAPPED_FTM_MAINNET, + WRAPPED_FTM_TESTNET + } = require('../constants'); + + //////////// + const Artion = await ethers.getContractFactory('Artion'); + const artion = await Artion.deploy(TREASURY_ADDRESS, '2000000000000000000'); + + await artion.deployed(); + console.log('FantomArtion deployed at', artion.address); + /////////// + + ////////// + const ProxyAdmin = await ethers.getContractFactory('ProxyAdmin'); + const proxyAdmin = await ProxyAdmin.deploy(); + await proxyAdmin.deployed(); + + const PROXY_ADDRESS = proxyAdmin.address; + + console.log('ProxyAdmin deployed to:', proxyAdmin.address); + + const AdminUpgradeabilityProxyFactory = await ethers.getContractFactory( + 'AdminUpgradeabilityProxy' + ); + ////////// + + ///////// + const Marketplace = await ethers.getContractFactory('FantomMarketplace'); + const marketplaceImpl = await Marketplace.deploy(); + await marketplaceImpl.deployed(); + + console.log('FantomMarketplace deployed to:', marketplaceImpl.address); + + const marketplaceProxy = await AdminUpgradeabilityProxyFactory.deploy( + marketplaceImpl.address, + PROXY_ADDRESS, + [] + ); + await marketplaceProxy.deployed(); + console.log('Marketplace Proxy deployed at ', marketplaceProxy.address); + const MARKETPLACE_PROXY_ADDRESS = marketplaceProxy.address; + const marketplace = await ethers.getContractAt( + 'FantomMarketplace', + marketplaceProxy.address + ); + + await marketplace.initialize(TREASURY_ADDRESS, PLATFORM_FEE); + // console.log('Marketplace Proxy initialized'); + + ///////// + + ///////// + const BundleMarketplace = await ethers.getContractFactory( + 'FantomBundleMarketplace' + ); + const bundleMarketplaceImpl = await BundleMarketplace.deploy(); + await bundleMarketplaceImpl.deployed(); + console.log( + 'FantomBundleMarketplace deployed to:', + bundleMarketplaceImpl.address + ); + + const bundleMarketplaceProxy = await AdminUpgradeabilityProxyFactory.deploy( + bundleMarketplaceImpl.address, + PROXY_ADDRESS, + [] + ); + await bundleMarketplaceProxy.deployed(); + console.log( + 'Bundle Marketplace Proxy deployed at ', + bundleMarketplaceProxy.address + ); + const BUNDLE_MARKETPLACE_PROXY_ADDRESS = bundleMarketplaceProxy.address; + const bundleMarketplace = await ethers.getContractAt( + 'FantomBundleMarketplace', + bundleMarketplaceProxy.address + ); + + await bundleMarketplace.initialize(TREASURY_ADDRESS, PLATFORM_FEE); + // console.log('Bundle Marketplace Proxy initialized'); + + //////// + + //////// + const Auction = await ethers.getContractFactory('FantomAuction'); + const auctionImpl = await Auction.deploy(); + await auctionImpl.deployed(); + console.log('FantomAuction deployed to:', auctionImpl.address); + + const auctionProxy = await AdminUpgradeabilityProxyFactory.deploy( + auctionImpl.address, + PROXY_ADDRESS, + [] + ); + + await auctionProxy.deployed(); + console.log('Auction Proxy deployed at ', auctionProxy.address); + const AUCTION_PROXY_ADDRESS = auctionProxy.address; + const auction = await ethers.getContractAt( + 'FantomAuction', + auctionProxy.address + ); + + await auction.initialize(TREASURY_ADDRESS); + // console.log('Auction Proxy initialized'); + + //////// + + //////// + const Factory = await ethers.getContractFactory('FantomNFTFactory'); + const factory = await Factory.deploy( + AUCTION_PROXY_ADDRESS, + MARKETPLACE_PROXY_ADDRESS, + BUNDLE_MARKETPLACE_PROXY_ADDRESS, + '10000000000000000000', + TREASURY_ADDRESS, + '50000000000000000000' + ); + await factory.deployed(); + console.log('FantomNFTFactory deployed to:', factory.address); + + const PrivateFactory = await ethers.getContractFactory( + 'FantomNFTFactoryPrivate' + ); + const privateFactory = await PrivateFactory.deploy( + AUCTION_PROXY_ADDRESS, + MARKETPLACE_PROXY_ADDRESS, + BUNDLE_MARKETPLACE_PROXY_ADDRESS, + '10000000000000000000', + TREASURY_ADDRESS, + '50000000000000000000' + ); + await privateFactory.deployed(); + console.log('FantomNFTFactoryPrivate deployed to:', privateFactory.address); + //////// + + //////// + const NFTTradable = await ethers.getContractFactory('FantomNFTTradable'); + const nft = await NFTTradable.deploy( + 'Artion', + 'ART', + AUCTION_PROXY_ADDRESS, + MARKETPLACE_PROXY_ADDRESS, + BUNDLE_MARKETPLACE_PROXY_ADDRESS, + '10000000000000000000', + TREASURY_ADDRESS + ); + await nft.deployed(); + console.log('FantomNFTTradable deployed to:', nft.address); + + const NFTTradablePrivate = await ethers.getContractFactory( + 'FantomNFTTradablePrivate' + ); + const nftPrivate = await NFTTradablePrivate.deploy( + 'IArtion', + 'IART', + AUCTION_PROXY_ADDRESS, + MARKETPLACE_PROXY_ADDRESS, + BUNDLE_MARKETPLACE_PROXY_ADDRESS, + '10000000000000000000', + TREASURY_ADDRESS + ); + await nftPrivate.deployed(); + console.log('FantomNFTTradablePrivate deployed to:', nftPrivate.address); + //////// + + //////// + const TokenRegistry = await ethers.getContractFactory('FantomTokenRegistry'); + const tokenRegistry = await TokenRegistry.deploy(); + + await tokenRegistry.deployed(); + + console.log('FantomTokenRegistry deployed to', tokenRegistry.address); + //////// + + //////// + const AddressRegistry = await ethers.getContractFactory( + 'FantomAddressRegistry' + ); + const addressRegistry = await AddressRegistry.deploy(); + + await addressRegistry.deployed(); + + console.log('FantomAddressRegistry deployed to', addressRegistry.address); + const FANTOM_ADDRESS_REGISTRY = addressRegistry.address; + //////// + + //////// + const PriceFeed = await ethers.getContractFactory('FantomPriceFeed'); + const WRAPPED_FTM = + network.name === 'mainnet' ? WRAPPED_FTM_MAINNET : WRAPPED_FTM_TESTNET; + const priceFeed = await PriceFeed.deploy( + FANTOM_ADDRESS_REGISTRY, + WRAPPED_FTM + ); + + await priceFeed.deployed(); + console.log('FantomPriceFeed deployed to', priceFeed.address); + //////// + + //////// + const ArtTradable = await ethers.getContractFactory('FantomArtTradable'); + const artTradable = await ArtTradable.deploy( + 'FantomArt', + 'FART', + '20000000000000000000', + TREASURY_ADDRESS, + MARKETPLACE_PROXY_ADDRESS, + BUNDLE_MARKETPLACE_PROXY_ADDRESS + ); + await artTradable.deployed(); + console.log('FantomArtTradable deployed to:', artTradable.address); + + const ArtTradablePrivate = await ethers.getContractFactory( + 'FantomArtTradablePrivate' + ); + const artTradablePrivate = await ArtTradablePrivate.deploy( + 'FantomArt', + 'FART', + '20000000000000000000', + TREASURY_ADDRESS, + MARKETPLACE_PROXY_ADDRESS, + BUNDLE_MARKETPLACE_PROXY_ADDRESS + ); + await artTradablePrivate.deployed(); + console.log( + 'FantomArtTradablePrivate deployed to:', + artTradablePrivate.address + ); + //////// + + //////// + const ArtFactory = await ethers.getContractFactory('FantomArtFactory'); + const artFactory = await ArtFactory.deploy( + MARKETPLACE_PROXY_ADDRESS, + BUNDLE_MARKETPLACE_PROXY_ADDRESS, + '20000000000000000000', + TREASURY_ADDRESS, + '10000000000000000000' + ); + await artFactory.deployed(); + console.log('FantomArtFactory deployed to:', artFactory.address); + + const ArtFactoryPrivate = await ethers.getContractFactory( + 'FantomArtFactoryPrivate' + ); + const artFactoryPrivate = await ArtFactoryPrivate.deploy( + MARKETPLACE_PROXY_ADDRESS, + BUNDLE_MARKETPLACE_PROXY_ADDRESS, + '20000000000000000000', + TREASURY_ADDRESS, + '10000000000000000000' + ); + await artFactoryPrivate.deployed(); + console.log( + 'FantomArtFactoryPrivate deployed to:', + artFactoryPrivate.address + ); + //////// + + await marketplace.updateAddressRegistry(FANTOM_ADDRESS_REGISTRY); + await bundleMarketplace.updateAddressRegistry(FANTOM_ADDRESS_REGISTRY); + await auction.updateAddressRegistry(FANTOM_ADDRESS_REGISTRY); + + await addressRegistry.updateArtion(artion.address); + + await addressRegistry.updateAuction(auction.address); + await addressRegistry.updateMarketplace(marketplace.address); + await addressRegistry.updateBundleMarketplace(bundleMarketplace.address); + + await addressRegistry.updateNFTFactory(factory.address); + await addressRegistry.updateNFTFactoryPrivate(privateFactory.address); + + await addressRegistry.updateTokenRegistry(tokenRegistry.address); + await addressRegistry.updatePriceFeed(priceFeed.address); + + await addressRegistry.updateArtFactory(artFactory.address); + await addressRegistry.updateArtFactoryPrivate(artFactoryPrivate.address); + + await tokenRegistry.add(WRAPPED_FTM); +} + +// We recommend this pattern to be able to use async/await everywhere +// and properly handle errors. +main(network) + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + });