Skip to content

Commit

Permalink
Fix circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
HickupHH3 committed Jan 11, 2022
1 parent a22a8b5 commit 96fd51e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import '@nomiclabs/hardhat-waffle';
import 'hardhat-gas-reporter';
import 'solidity-coverage';
import './scripts/deploy';
import './scripts/deployTokenSale';
import './scripts/verify';
import './scripts/proposals';

Expand Down Expand Up @@ -43,6 +42,7 @@ const config: HardhatUserConfig = {
},
},
typechain: {
outDir: 'typechain',
target: 'ethers-v5',
},
gasReporter: {
Expand Down
2 changes: 1 addition & 1 deletion scripts/config.ts → scripts/deploy/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BigNumber as BN, constants} from 'ethers';
import {ONE_18, ONE_DAY, ONE_YEAR} from '../test/shared/Constants';
import {ONE_18, ONE_DAY, ONE_YEAR} from '../../test/shared/Constants';

type Config = {
FREE_SUPPLY: BN;
Expand Down
8 changes: 4 additions & 4 deletions scripts/deploy.ts → scripts/deploy/deployGov.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {task} from 'hardhat/config';
import {expect} from 'chai';
import fs from 'fs';

Expand All @@ -11,9 +10,10 @@ import {
TimelockController,
ArenaGovernor__factory,
ArenaGovernor,
} from '../typechain';
} from '../../typechain';

import {allConfigs} from './config';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

let deployerAddress: string;
let token: ArenaToken;
Expand All @@ -26,7 +26,7 @@ const ADMIN_ROLE = '0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6
const PROPOSER_ROLE = '0xb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1';
const EXECUTOR_ROLE = '0xd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e63';

task('deploy', 'deploy contracts').setAction(async (taskArgs, hre) => {
export async function deployGov(hre: HardhatRuntimeEnvironment) {
const networkId = hre.network.config.chainId as number;
const [deployer] = await hre.ethers.getSigners();
deployerAddress = await deployer.getAddress();
Expand Down Expand Up @@ -170,4 +170,4 @@ task('deploy', 'deploy contracts').setAction(async (taskArgs, hre) => {

console.log('verification complete!');
process.exit(0);
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {task} from 'hardhat/config';
import {BigNumber as BN, Signer} from 'ethers';
import {expect} from 'chai';
import fs from 'fs';
Expand All @@ -11,9 +10,10 @@ import {
TokenSale__factory,
TokenSale,
TokenLock__factory,
} from '../typechain';
} from '../../typechain';

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

let proposerAddress: string;
let tokenSale: TokenSale;
Expand Down Expand Up @@ -50,7 +50,7 @@ const getContracts = (signer: Signer, config: typeof allConfigs[0]) => {
};
};

task('deployTokenSale', 'deploy token sale and make proposal for relevant actions').setAction(async (taskArgs, hre) => {
export async function deployTokenSale(hre: HardhatRuntimeEnvironment) {
const networkId = hre.network.config.chainId as number;
const [proposer] = await hre.ethers.getSigners();
proposerAddress = await proposer.getAddress();
Expand Down Expand Up @@ -123,4 +123,4 @@ task('deployTokenSale', 'deploy token sale and make proposal for relevant action

console.log('verification complete!');
process.exit(0);
});
}
15 changes: 15 additions & 0 deletions scripts/deploy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {task} from 'hardhat/config';

task('deployGov', 'deploy governance and token contracts').setAction(async (taskArgs, hre) => {
// only load this file when task is run because it depends on typechain built artifacts
// which will create a circular dependency when required by hardhat.config.ts for first compilation
const {deployGov} = await import('./deployGov');
await deployGov(hre);
});

task('deployTokenSale', 'deploy token sale and make proposal for relevant actions').setAction(async (taskArgs, hre) => {
// only load this file when task is run because it depends on typechain built artifacts
// which will create a circular dependency when required by hardhat.config.ts for first compilation
const {deployTokenSale} = await import('./deployTokenSale');
await deployTokenSale(hre);
});
2 changes: 1 addition & 1 deletion scripts/proposals/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs';
import path from 'path';
import _ from 'lodash';
import {ArenaGovernor__factory, ArenaToken__factory} from '../../typechain';
import {allConfigs} from '../config';
import {allConfigs} from '../deploy/config';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

let transferInterface = new ethers.utils.Interface([`function transfer(address to, uint256 amount)`]);
Expand Down
2 changes: 1 addition & 1 deletion scripts/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs';

import {ArenaToken, RevokableTokenLock, TimelockController, ArenaGovernor, TokenSale} from '../typechain';

import {allConfigs} from './config';
import {allConfigs} from './deploy/config';

let token: ArenaToken;
let revokableTokenLock: RevokableTokenLock;
Expand Down

0 comments on commit 96fd51e

Please sign in to comment.