From 80078475d5d09a2b730f8334120a524d069ec5b1 Mon Sep 17 00:00:00 2001 From: AlienTornadosaurusHex <> Date: Mon, 12 Jun 2023 19:39:42 +0000 Subject: [PATCH] add hardhat deploy logic Signed-off-by: AlienTornadosaurusHex <> --- .env.example | 7 ++++ .gitignore | 7 +++- config.js | 5 +++ hardhat.config.js | 76 +++++++++++++++++++++++++++++++++++++++ package.json | 15 +++++--- scripts/deployProposal.js | 28 +++++++++++++++ 6 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 .env.example create mode 100644 config.js create mode 100644 hardhat.config.js create mode 100644 scripts/deployProposal.js diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..6f55435 --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +MAINNET_RPC_URL= +ETHERSCAN_KEY= +PRIVATE_KEY= + +GOERLI_RPC_URL= +SEOPLIA_RPC_URL= +RINKEBY_RPC_URL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index db72ca3..2e37349 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,11 @@ package-lock.json # yarn yarn.lock +yarn-error.log # VScode files -.vscode \ No newline at end of file +.vscode + +# hh +artifacts +cache_hardhat \ No newline at end of file diff --git a/config.js b/config.js new file mode 100644 index 0000000..48c6e49 --- /dev/null +++ b/config.js @@ -0,0 +1,5 @@ +module.exports = { + torn: "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C", + governanceProxy: "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce", + registryProxy: "0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2" +} \ No newline at end of file diff --git a/hardhat.config.js b/hardhat.config.js new file mode 100644 index 0000000..d4873ec --- /dev/null +++ b/hardhat.config.js @@ -0,0 +1,76 @@ +require('dotenv').config() +require('@nomicfoundation/hardhat-foundry') +require('@nomicfoundation/hardhat-verify') +require('@nomiclabs/hardhat-ethers') + +/** + * @type import('hardhat/config').HardhatUserConfig + */ +module.exports = { + solidity: { + compilers: [ + { + version: '0.6.2', + settings: { + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, + { + version: '0.6.12', + settings: { + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, + ], + }, + networks: { + hardhat: { + forking: { + url: `${process.env.MAINNET_RPC_URL}`, + }, + chainId: 1, + loggingEnabled: false, + allowUnlimitedContractSize: false, + }, + rinkeby: { + url: `${process.env.RINKEBY_RPC_URL}`, + accounts: `${process.env.PRIVATE_KEY}` + ? [`${process.env.PRIVATE_KEY}`] + : { mnemonic: 'test test test test test junk' }, + }, + goerli: { + url: `${process.env.GOERLI_RPC_URL}`, + accounts: `${process.env.PRIVATE_KEY}` + ? [`${process.env.PRIVATE_KEY}`] + : { mnemonic: 'test test test test test junk' }, + }, + sepolia: { + url: `${process.env.SEPOLIA_RPC_URL}`, + accounts: `${process.env.PRIVATE_KEY}` + ? [`${process.env.PRIVATE_KEY}`] + : { mnemonic: 'test test test test test junk' }, + }, + mainnet: { + url: `${process.env.MAINNET_RPC_URL}`, + accounts: `${process.env.PRIVATE_KEY}` + ? [`${process.env.PRIVATE_KEY}`] + : { mnemonic: 'test test test test test junk' }, + }, + }, + mocha: { + timeout: 9999999999 /* The following simply does not work: ignore: ["factory.with.registry.test.js", "sidechain.instance.factory.test.js"] */, + }, + spdxLicenseIdentifier: { + overwrite: true, + runOnCompile: true, + }, + etherscan: { + apiKey: `${process.env.ETHERSCAN_KEY}`, + }, +} \ No newline at end of file diff --git a/package.json b/package.json index ba397c8..0883c78 100644 --- a/package.json +++ b/package.json @@ -14,15 +14,20 @@ "author": "Theo", "license": "MIT", "dependencies": { - "bignumber.js": "^9.1.1", - "dotenv": "^16.1.3", - "web3": "^1.10.0", - "web3-utils": "^1.10.0", "@openzeppelin/contracts": "^3.2.0-rc.0", "@openzeppelin/upgrades-core": "^1.0.1", - "torn-token": "^1.0.4" + "bignumber.js": "^9.1.1", + "dotenv": "^16.1.4", + "torn-token": "^1.0.4", + "web3": "^1.10.0", + "web3-utils": "^1.10.0" }, "devDependencies": { + "@nomicfoundation/hardhat-foundry": "^1.0.1", + "@nomicfoundation/hardhat-verify": "^1.0.1", + "@nomiclabs/hardhat-ethers": "^2.2.3", + "ethers": "^5", + "hardhat": "^2.15.0", "ts-node": "^10.9.1", "typescript": "^5.1.3" } diff --git a/scripts/deployProposal.js b/scripts/deployProposal.js new file mode 100644 index 0000000..883ec70 --- /dev/null +++ b/scripts/deployProposal.js @@ -0,0 +1,28 @@ +const hre = require('hardhat') +const config = require("../config") +const { ethers } = hre + +async function main() { + const factory_staking = await ethers.getContractFactory("TornadoStakingRewards") + const factory_proposal = await ethers.getContractFactory("Proposal") + + const staking = await factory_staking.deploy(config.governanceProxy, config.torn, config.registryProxy) + + console.log("\nStaking contract impl successfully deployed @ " + staking.address + '\n') + + await hre.run('verify:verify', { + address: staking.address, + constructorArguments: [config.governanceProxy, config.torn, config.registryProxy], + }) + + const proposal = await factory_proposal.deploy(staking.address) + + console.log("\nProposal 25 successfully deployed @ " + proposal.address + '\n') + + await hre.run('verify:verify', { + address: proposal.address, + constructorArguments: [staking.address], + }) +} + +main().then((res) => console.log(res ?? "\nScript finished.\n")) \ No newline at end of file