diff --git a/.env.example b/.env.example index e3761cc..5eba1ba 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,3 @@ -etherscan_api_key= -mainnet_rpc_key= +ETHERSCAN_KEY= +ALCHEMY_KEY_MAINNET= use_latest_block=false \ No newline at end of file diff --git a/contracts/v1/Configuration.sol b/contracts/v1/Configuration.sol index 1a26e92..6f3ffef 100644 --- a/contracts/v1/Configuration.sol +++ b/contracts/v1/Configuration.sol @@ -31,7 +31,7 @@ contract Configuration { EXECUTION_DELAY = 2 days; EXECUTION_EXPIRATION = 3 days; QUORUM_VOTES = 25000e18; // 0.25% of TORN - PROPOSAL_THRESHOLD = 10000e18; // 0.1% of TORN + PROPOSAL_THRESHOLD = 1000e18; // 0.1% of TORN VOTING_DELAY = 75 seconds; VOTING_PERIOD = 3 days; CLOSING_PERIOD = 1 hours; diff --git a/contracts/v1/Governance.sol b/contracts/v1/Governance.sol index 149c3fd..51adca9 100644 --- a/contracts/v1/Governance.sol +++ b/contracts/v1/Governance.sol @@ -89,8 +89,8 @@ contract Governance is Initializable, Configuration, Delegation, EnsResolve { _initializeConfiguration(); } - function initialize(address _torn) public initializer { - torn = TORN(_torn); + function initialize(bytes32 _torn) public initializer { + torn = TORN(resolve(_torn)); // Create a dummy proposal so that indexes start from 1 proposals.push( Proposal({ diff --git a/hardhat.config.js b/hardhat.config.js index 3ce8f68..61f4627 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -46,7 +46,7 @@ module.exports = { networks: { hardhat: { forking: { - url: `https://mainnet.infura.io/v3/${process.env.mainnet_rpc_key}`, + url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY_MAINNET}`, blockNumber: 13042331, }, initialBaseFeePerGas: 5, @@ -56,7 +56,7 @@ module.exports = { timeout: 120000, }, mainnet: { - url: `https://mainnet.infura.io/v3/${process.env.mainnet_rpc_key}`, + url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY_MAINNET}`, accounts: ['900e9f0e8ce24c022026649c48a059fb6ffa0a2523811d797b47d789bf106def'], // random pk off keys.lol timeout: 2147483647, }, @@ -67,6 +67,6 @@ module.exports = { runOnCompile: true, }, etherscan: { - apiKey: `${process.env.etherscan_api_key}`, + apiKey: `${process.env.ETHERSCAN_KEY}`, }, } diff --git a/test/v1/governance.v1.test.js b/test/v1/governance.v1.test.js index 5626f43..c2d250b 100644 --- a/test/v1/governance.v1.test.js +++ b/test/v1/governance.v1.test.js @@ -85,10 +85,7 @@ describe('Governance tests', () => { proxy = await ethers.getContractFactory('MockProxy') - proxy = await proxy.deploy( - governance.address, - '0xc4d66de8000000000000000000000000c351628eb244ec633d5f21fbd6621e1a683b1181', - ) + proxy = await proxy.deploy(governance.address, []) governance = await ethers.getContractAt('MockGovernance', proxy.address) @@ -96,7 +93,7 @@ describe('Governance tests', () => { { to: miningPublicKey, amount: cap.toString() }, ]) - await governance.setTorn(torn.address) + await governance.initialize(torn.address + '000000000000000000000000') expect(await governance.torn()).to.equal(torn.address) @@ -223,21 +220,21 @@ describe('Governance tests', () => { }) it('fails if proposer does not have voting power', async function () { const voterBob = signerArray[5] - const tenThousandTorn = ethers.utils.parseEther('10000') + const oneThousandTorn = ethers.utils.parseEther('1000') torn = await torn.connect(miningPublicKey) - await torn.transfer(voterBob.address, tenThousandTorn) + await torn.transfer(voterBob.address, oneThousandTorn) torn = await torn.connect(voterBob) - await torn.approve(governance.address, tenThousandTorn) + await torn.approve(governance.address, oneThousandTorn) expect(await governance.torn()).to.equal(torn.address) governance = await governance.connect(voterBob) - await governance.lockWithApproval(tenThousandTorn.sub(1)) + await governance.lockWithApproval(oneThousandTorn.sub(1)) await expect(governance.propose(dummy.address, 'dummy')).to.be.revertedWith( 'Governance::propose: proposer votes below proposal threshold', @@ -921,7 +918,7 @@ describe('Governance tests', () => { }) it('cannot initialize implementation contract', async () => { const impl = await (await ethers.getContractFactory('NewImplementation')).deploy() - await expect(impl.initialize(signerArray[0].address)).to.be.revertedWith( + await expect(impl.initialize(signerArray[0].address + '000000000000000000000000')).to.be.revertedWith( 'Contract instance has already been initialized', ) }) @@ -936,7 +933,7 @@ describe('Governance tests', () => { await ethers.provider.send('hardhat_reset', [ { forking: { - jsonRpcUrl: `https://mainnet.infura.io/v3/${process.env.mainnet_rpc_key}`, + jsonRpcUrl: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY_MAINNET}`, blockNumber: process.env.use_latest_block == 'true' ? undefined : 13042331, }, }, diff --git a/test/v2/all.governance.v2.test.js b/test/v2/all.governance.v2.test.js index 4769ca8..282a409 100644 --- a/test/v2/all.governance.v2.test.js +++ b/test/v2/all.governance.v2.test.js @@ -788,7 +788,7 @@ describe('Start of tests', () => { await ethers.provider.send('hardhat_reset', [ { forking: { - jsonRpcUrl: `https://mainnet.infura.io/v3/${process.env.mainnet_rpc_key}`, + jsonRpcUrl: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY_MAINNET}`, blockNumber: process.env.use_latest_block == 'true' ? undefined : 13211966, }, },