diff --git a/config.json b/config.json deleted file mode 100644 index f534804..0000000 --- a/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "novaProxy": "0xD692Fd2D0b2Fbd2e52CFa5B5b9424bC981C30696", - "newNovaImpl": "TODO", - "ethAmbBridge": "0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e", - "gasLimit": 200000 -} diff --git a/contracts/helpers/TestExecutor.sol b/contracts/helpers/TestExecutor.sol new file mode 100644 index 0000000..6a79227 --- /dev/null +++ b/contracts/helpers/TestExecutor.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.6.12; + +import "@openzeppelin/contracts/utils/Address.sol"; + +contract TestExecutor { + event ProposalExecuted(address indexed target); + + function execute(address target) public payable virtual { + require(Address.isContract(target), "Governance::execute: not a contract"); + (bool success, bytes memory data) = target.delegatecall(abi.encodeWithSignature("executeProposal()")); + if (!success) { + if (data.length > 0) { + revert(string(data)); + } else { + revert("Proposal execution failed"); + } + } + + emit ProposalExecuted(target); + } +} diff --git a/hardhat.config.js b/hardhat.config.js index 9e28bd7..828eff4 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -66,5 +66,11 @@ module.exports = { : { mnemonic: 'test test test test test junk' }, timeout: 2147483647, }, + bsc: { + url: process.env.ETH_RPC || 'https://bsc-dataseed.binance.org/', + accounts: process.env.PRIVATE_KEY + ? [process.env.PRIVATE_KEY] + : { mnemonic: 'test test test test test junk' }, + }, }, } diff --git a/scripts/deploy.js b/scripts/deploy.js index 30980e5..dd2b31e 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -1,7 +1,18 @@ const { ethers } = require('hardhat') -const config = require('../config') async function main() { + const gasLimit = 200000 + + // BSC TEST VALUES + const novaProxy = '0xC953965A9287d298bbECF13fd59aA3F4cE69d322' // test one + const newNovaImpl = '0x75Df5AF045d91108662D8080fD1FEFAd6aA0bb59' // random contract + const ethAmbBridge = '0x05185872898b6f94AA600177EF41B9334B1FA48B' // on bsc + + // MAINNET VALUES + // const novaProxy = "0xD692Fd2D0b2Fbd2e52CFa5B5b9424bC981C30696" + // const newNovaImpl = "TODO" + // const ethAmbBridge = "0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e" + const [deployer] = await ethers.getSigners() console.log('Deploying contracts with the account:', deployer.address) @@ -9,12 +20,7 @@ async function main() { console.log('Account balance:', (await deployer.getBalance()).toString()) const Proposal = await ethers.getContractFactory('NovaUpgradeProposal') - const proposal = await Proposal.deploy( - config.novaProxy, - config.newNovaImpl, - config.ethAmbBridge, - config.gasLimit, - ) + const proposal = await Proposal.deploy(novaProxy, newNovaImpl, ethAmbBridge, gasLimit) console.log('Proposal address:', proposal.address) } diff --git a/scripts/deployExecutor.js b/scripts/deployExecutor.js new file mode 100644 index 0000000..3d9312b --- /dev/null +++ b/scripts/deployExecutor.js @@ -0,0 +1,22 @@ +const { ethers } = require('hardhat') + +async function main() { + const [deployer] = await ethers.getSigners() + + console.log('Deploying contracts with the account:', deployer.address) + + console.log('Account balance:', (await deployer.getBalance()).toString()) + + const Executor = await ethers.getContractFactory('TestExecutor') + const executor = await Executor.deploy() + await executor.deployed() + + console.log('Executor address:', executor.address) +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + }) diff --git a/scripts/testUpgrade.js b/scripts/testUpgrade.js new file mode 100644 index 0000000..f151ef1 --- /dev/null +++ b/scripts/testUpgrade.js @@ -0,0 +1,22 @@ +const { ethers } = require('hardhat') + +async function main() { + const [sender] = await ethers.getSigners() + + console.log('Calling contracts with the account:', sender.address) + console.log('Account balance:', (await sender.getBalance()).toString()) + + const executor = await ethers.getContractAt('TestExecutor', '0xC953965A9287d298bbECF13fd59aA3F4cE69d322') + console.log('Executor address:', executor.address) + + const tx = await executor.connect(sender).execute('0x189A86fB2c334095efd04B1F00d0ee27A54c74f5') + let receipt = await tx.wait() + console.log('Upgrade receipt:', receipt) +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error) + process.exit(1) + })