Skip to content

Commit

Permalink
Bump dependencies to programmtically verify contract + misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HickupHH3 committed Mar 4, 2022
1 parent 4365483 commit da10250
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 81 deletions.
3 changes: 2 additions & 1 deletion deployments/polygonAddresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"token": "0x6847D3A4c80a82e1fb26f1fC6F09F3Ad5BEB5222",
"tokenLock": "0xB17828789280C77C17B02fc8E6F20Ddc5721f2C2",
"timelock": "0xdFB26381aFBc37f0Fae4A77D385b91B90347aA12",
"governor": "0xc6eaDcC36aFcf1C430962506ad79145aD5140E58"
"governor": "0xc6eaDcC36aFcf1C430962506ad79145aD5140E58",
"tokenSale": "0xD0e7d5a2220e32914540D97A6D0548658050180b"
}
8 changes: 5 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ const config: HardhatUserConfig = {
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
},
etherscan: {
apiKey: {
polygon: process.env.POLYGONSCAN_API_KEY == undefined ? '' : process.env.POLYGONSCAN_API_KEY,
}
},
typechain: {
outDir: 'typechain',
target: 'ethers-v5',
Expand All @@ -54,9 +59,6 @@ const config: HardhatUserConfig = {
enabled: process.env.REPORT_GAS !== undefined,
currency: 'USD',
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
mocha: {
// 1 hour, essentially disabled auto timeout
timeout: 60 * 60 * 1000,
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
},
"homepage": "https://github.com/code-423n4/genesis#readme",
"dependencies": {
"hardhat": "2.7.0",
"hardhat": "2.8.3",
"lodash": "^4.17.21"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.3",
"@nomiclabs/hardhat-etherscan": "2.1.7",
"@nomiclabs/hardhat-ethers": "^2.0.4",
"@nomiclabs/hardhat-etherscan": "3.0.0",
"@nomiclabs/hardhat-waffle": "^2.0.0",
"@openzeppelin/contracts": "^4.4.0",
"@typechain/ethers-v5": "^7.0.1",
"@typechain/hardhat": "^2.3.0",
"@typechain/ethers-v5": "^9.0.0",
"@typechain/hardhat": "^4.0.0",
"@types/chai": "^4.2.21",
"@types/lodash": "^4.14.178",
"@types/mocha": "^9.0.0",
Expand All @@ -60,7 +60,7 @@
"solidity-coverage": "^0.7.16",
"ts-generator": "^0.1.1",
"ts-node": "^10.4.0",
"typechain": "^5.1.2",
"typescript": "^4.3.5"
"typechain": "^7.0.0",
"typescript": "^4.5.5"
}
}
2 changes: 1 addition & 1 deletion scripts/deploy/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const tokenSaleConfigs: {[key: number]: TokenSaleConfig} = {
TOKEN_SALE_DURATION: 10 * ONE_DAY,
TOKEN_SALE_USDC: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
TOKEN_SALE_ARENA_PRICE: BN.from(30_000).mul(ONE_18).div(ONE_18), // 0.03 USDC * 1e18 / 1.0 ARENA
TOKEN_SALE_RECIPIENT: '0x7f0049597056E37B4B1f887196E44CAc050D4863 ', // C4 Polygon multisig
TOKEN_SALE_RECIPIENT: '0x7f0049597056E37B4B1f887196E44CAc050D4863', // C4 Polygon multisig
TOKEN_SALE_WHITELIST,
RECIPIENT_AMOUNT: BN.from(1_750_000).mul(BN.from(10).pow(6)), // 1.75M USDC, rest to treasury
TOKEN_SALE_SUPPLY: BN.from(100_000_000).mul(ONE_18), // 100M ARENA tokens
Expand Down
18 changes: 16 additions & 2 deletions scripts/deploy/deployTokenSale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {

import {allConfigs, tokenSaleConfigs} from './config';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {verifyContract} from './verify';

let proposerAddress: string;
let tokenSale: TokenSale;
Expand Down Expand Up @@ -104,12 +105,12 @@ export async function deployTokenSale(hre: HardhatRuntimeEnvironment) {
targets,
values,
calldatas,
`"# C4IP-6: Transfer ARENA for token sale\nThis proposal takes action on the token sale approved by [C4IP-1\\]
`# C4IP-6: Transfer ARENA for token sale\nThis proposal takes action on the token sale approved by [C4IP-1\\]
\\(https://www.withtally.com/governance/eip155:137:0xc6eaDcC36aFcf1C430962506ad79145aD5140E58/proposal/61969381053746686972699442694032986733206504062025717191093241526145462208038)
and the hiring of Code4 Corporation approved by [C4IP-3\\]\\(https://www.withtally.com/governance/eip155:137:0xc6eaDcC36aFcf1C430962506ad79145aD5140E58/proposal/46190911081008287731655546929165163023822387405966829437304548060152876868278)
both of which are discussed in detail in [this forum post\\]\\(https://forum.code4rena.com/t/c4ip-1-constitution-dao-bootstrapping-reimbursements-token-sale/93)\n\n\n\n- 100,000,000 $ARENA tokens transferred to the [token sale contract\\]
\\(${tokenSale.address})\n\n- Tokens are sold at price of 1 ARENA = .03 USDC\n\n- Token sale details to be administered by Code4 Corporation\n\n- $1.75M of the initial sale will immediately be used to fund Code4 Corporation operations\n\n
- Remaining $1.25M proceeds will be transferred to the Code4rena treasury<br>\n\n\n<!-- -->\n\n"`
- Remaining $1.25M proceeds will be transferred to the Code4rena treasury<br>\n\n\n<!-- -->\n\n`
);
console.log(`proposal submitted: ${tx.hash}`);
console.log(`waiting for block inclusion ...`);
Expand All @@ -121,6 +122,19 @@ export async function deployTokenSale(hre: HardhatRuntimeEnvironment) {
let exportJson = JSON.stringify(addressesToExport, null, 2);
fs.writeFileSync(deploymentFilePath, exportJson);

console.log(`Verifying tokenSale contract...`);
await verifyContract(hre, tokenSale.address, [
config.TOKEN_SALE_USDC,
arenaToken.address,
config.TOKEN_SALE_START,
config.TOKEN_SALE_DURATION,
config.TOKEN_SALE_ARENA_PRICE,
config.TOKEN_SALE_RECIPIENT,
tokenLock.address,
allConfigs[networkId].VEST_DURATION,
config.RECIPIENT_AMOUNT,
]);

/////////////////////////////////
// ACCESS CONTROL VERIFICATION //
/////////////////////////////////
Expand Down
8 changes: 8 additions & 0 deletions scripts/deploy/verify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';

export async function verifyContract(hre: HardhatRuntimeEnvironment, contractAddress: string, ctorArgs: any[]) {
await hre.run('verify:verify', {
address: contractAddress,
constructorArguments: ctorArgs,
});
}
5 changes: 2 additions & 3 deletions test/RevokableTokenLock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ import {setNextBlockTimeStamp, mineBlockAt} from '../shared/TimeManipulation';

const {loadFixture} = waffle;

let token: IERC20;
let token: TestERC20;
let revokableTokenLock: RevokableTokenLock;

describe('RevokableTokenLock', async () => {
const [owner, revoker, recipient, other] = waffle.provider.getWallets();
const amount = ethers.utils.parseEther('20');

// TODO: maybe create shared fixtures that can be imported by the test files
async function fixture() {
const TokenFactory = await ethers.getContractFactory('TestERC20');
const token = (await TokenFactory.deploy('TEST', 'TEST')) as IERC20;
const token = await TokenFactory.deploy('TEST', 'TEST');
const RevokableTokenLockFactory = await ethers.getContractFactory('RevokableTokenLock');
const revokableTokenLock = (await RevokableTokenLockFactory.deploy(
token.address,
Expand Down
4 changes: 2 additions & 2 deletions test/TokenLock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {mineBlockAt, resetNetwork, setNextBlockTimeStamp} from '../shared/TimeMa
const {solidity, loadFixture} = waffle;
chai.use(solidity);

let token: IERC20;
let token: TestERC20;
let tokenLock: TokenLock;
let unlockBegin: number;
let unlockCliff: number;
Expand All @@ -20,7 +20,7 @@ describe('TokenLock', async () => {
// TODO: maybe create shared fixtures that can be imported by the test files
async function fixture() {
const TokenFactory = await ethers.getContractFactory('TestERC20');
const token = (await TokenFactory.connect(admin).deploy('TEST', 'TEST')) as IERC20;
const token = (await TokenFactory.connect(admin).deploy('TEST', 'TEST')) as TestERC20;
const TokenLockFactory = await ethers.getContractFactory('TokenLock');
const tokenLock = (await TokenLockFactory.connect(admin).deploy(token.address)) as TokenLock;
return {token, tokenLock};
Expand Down
Loading

0 comments on commit da10250

Please sign in to comment.