Skip to content

Commit 39b161c

Browse files
committed
refactor(issuance): clean up Hardhat configuration with proper inheritance
- Convert from CommonJS to TypeScript for consistency - Create issuance-specific base config that inherits from toolshed - Remove unnecessary configuration duplication: - Remove unused hardhat-abi-exporter, hardhat-gas-reporter, solidity-coverage - Remove unnecessary mocha config (tests run in separate package) - Remove redundant etherscan customChains (arbitrumSepolia is built-in) - Remove manual etherscan API key config (inherited from toolshed) - Set evmVersion to 'cancun' for issuance contracts - Eliminate ~95% duplication across 3 config files - Follow established inheritance pattern like horizon/subgraph-service Before: 289 lines across 3 files with massive duplication After: ~90 lines with proper inheritance and minimal duplication
1 parent 61e32c9 commit 39b161c

File tree

7 files changed

+57
-240
lines changed

7 files changed

+57
-240
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { hardhatBaseConfig } from '@graphprotocol/toolshed/hardhat'
2+
import type { HardhatUserConfig } from 'hardhat/config'
3+
4+
// Issuance-specific Solidity configuration with Cancun EVM version
5+
// Based on toolshed solidityUserConfig but with Cancun EVM target
6+
export const issuanceSolidityConfig = {
7+
version: '0.8.27',
8+
settings: {
9+
optimizer: {
10+
enabled: true,
11+
runs: 100,
12+
},
13+
evmVersion: 'cancun' as const,
14+
},
15+
}
16+
17+
// Base configuration for issuance package - inherits from toolshed and overrides Solidity config
18+
export const issuanceBaseConfig = (() => {
19+
const baseConfig = hardhatBaseConfig(require)
20+
return {
21+
...baseConfig,
22+
solidity: issuanceSolidityConfig,
23+
} as HardhatUserConfig
24+
})()

packages/issuance/hardhat.config.cjs

Lines changed: 0 additions & 113 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import '@nomicfoundation/hardhat-ethers'
2+
import '@typechain/hardhat'
3+
import 'hardhat-contract-sizer'
4+
import '@openzeppelin/hardhat-upgrades'
5+
import '@nomicfoundation/hardhat-verify'
6+
7+
import type { HardhatUserConfig } from 'hardhat/config'
8+
9+
import { issuanceBaseConfig } from './hardhat.base.config'
10+
11+
const config: HardhatUserConfig = {
12+
...issuanceBaseConfig,
13+
// Main config specific settings
14+
typechain: {
15+
outDir: 'types',
16+
target: 'ethers-v6',
17+
},
18+
}
19+
20+
export default config

packages/issuance/hardhat.coverage.config.ts

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,20 @@ import '@nomicfoundation/hardhat-network-helpers'
44
import '@openzeppelin/hardhat-upgrades'
55
import 'hardhat-gas-reporter'
66
import 'solidity-coverage'
7-
import 'dotenv/config'
87

98
import { HardhatUserConfig } from 'hardhat/config'
109

10+
import { issuanceBaseConfig } from './hardhat.base.config'
11+
1112
const config: HardhatUserConfig = {
13+
...issuanceBaseConfig,
14+
// Coverage-specific paths
1215
paths: {
1316
sources: './contracts',
1417
tests: './test/tests',
1518
artifacts: './artifacts',
1619
cache: './cache',
1720
},
18-
solidity: {
19-
compilers: [
20-
{
21-
version: '0.8.27',
22-
},
23-
],
24-
},
25-
defaultNetwork: 'hardhat',
26-
networks: {
27-
hardhat: {
28-
chainId: 1337,
29-
loggingEnabled: false,
30-
gas: 12000000,
31-
gasPrice: 'auto',
32-
initialBaseFeePerGas: 0,
33-
blockGasLimit: 12000000,
34-
forking:
35-
process.env.FORK === 'true'
36-
? {
37-
url:
38-
process.env.FORK_NETWORK === 'arbitrumSepolia'
39-
? process.env.ARBITRUM_SEPOLIA_RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc'
40-
: process.env.ARBITRUM_ONE_RPC_URL || 'https://arb1.arbitrum.io/rpc',
41-
blockNumber: process.env.FORK_BLOCK_NUMBER ? parseInt(process.env.FORK_BLOCK_NUMBER) : undefined,
42-
}
43-
: undefined,
44-
},
45-
localhost: {
46-
chainId: 1337,
47-
url: 'http://127.0.0.1:8545',
48-
accounts: {
49-
mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect',
50-
},
51-
},
52-
anvilFork: {
53-
chainId: 31337,
54-
url: process.env.ANVIL_FORK_URL || 'http://127.0.0.1:8545',
55-
accounts: process.env.PRIVATE_KEY
56-
? [process.env.PRIVATE_KEY]
57-
: {
58-
mnemonic: 'test test test test test test test test test test test junk',
59-
},
60-
},
61-
arbitrumSepolia: {
62-
chainId: 421614,
63-
url: process.env.ARBITRUM_SEPOLIA_RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc',
64-
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
65-
gasPrice: 'auto',
66-
},
67-
arbitrumOne: {
68-
chainId: 42161,
69-
url: process.env.ARBITRUM_ONE_RPC_URL || 'https://arb1.arbitrum.io/rpc',
70-
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
71-
gasPrice: 'auto',
72-
},
73-
},
74-
gasReporter: {
75-
enabled: process.env.REPORT_GAS ? true : false,
76-
showTimeSpent: true,
77-
currency: 'USD',
78-
outputFile: 'reports/gas-report.log',
79-
},
80-
}
21+
} as HardhatUserConfig
8122

8223
export default config

packages/issuance/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"license": "GPL-2.0-or-later",
3939
"devDependencies": {
4040
"@graphprotocol/interfaces": "workspace:^",
41+
"@graphprotocol/toolshed": "workspace:^",
4142
"@nomicfoundation/hardhat-ethers": "catalog:",
4243
"@nomicfoundation/hardhat-verify": "catalog:",
4344
"@openzeppelin/contracts": "^5.3.0",

packages/issuance/test/hardhat.config.ts

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,20 @@ import '@nomicfoundation/hardhat-network-helpers'
44
import '@openzeppelin/hardhat-upgrades'
55
import 'hardhat-gas-reporter'
66
import 'solidity-coverage'
7-
import 'dotenv/config'
87

98
import { artifactsDir, cacheDir } from '@graphprotocol/issuance'
109
import { HardhatUserConfig } from 'hardhat/config'
1110

11+
import { issuanceBaseConfig } from '../hardhat.base.config'
12+
1213
const config: HardhatUserConfig = {
14+
...issuanceBaseConfig,
15+
// Test-specific paths using issuance package exports
1316
paths: {
1417
tests: './tests',
1518
artifacts: artifactsDir,
1619
cache: cacheDir,
1720
},
18-
solidity: {
19-
compilers: [
20-
{
21-
version: '0.8.27',
22-
},
23-
],
24-
},
25-
defaultNetwork: 'hardhat',
26-
networks: {
27-
hardhat: {
28-
chainId: 1337,
29-
loggingEnabled: false,
30-
gas: 12000000,
31-
gasPrice: 'auto',
32-
initialBaseFeePerGas: 0,
33-
blockGasLimit: 12000000,
34-
forking:
35-
process.env.FORK === 'true'
36-
? {
37-
url:
38-
process.env.FORK_NETWORK === 'arbitrumSepolia'
39-
? process.env.ARBITRUM_SEPOLIA_RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc'
40-
: process.env.ARBITRUM_ONE_RPC_URL || 'https://arb1.arbitrum.io/rpc',
41-
blockNumber: process.env.FORK_BLOCK_NUMBER ? parseInt(process.env.FORK_BLOCK_NUMBER) : undefined,
42-
}
43-
: undefined,
44-
},
45-
localhost: {
46-
chainId: 1337,
47-
url: 'http://127.0.0.1:8545',
48-
accounts: {
49-
mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect',
50-
},
51-
},
52-
anvilFork: {
53-
chainId: 31337,
54-
url: process.env.ANVIL_FORK_URL || 'http://127.0.0.1:8545',
55-
accounts: process.env.PRIVATE_KEY
56-
? [process.env.PRIVATE_KEY]
57-
: {
58-
mnemonic: 'test test test test test test test test test test test junk',
59-
},
60-
},
61-
arbitrumSepolia: {
62-
chainId: 421614,
63-
url: process.env.ARBITRUM_SEPOLIA_RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc',
64-
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
65-
gasPrice: 'auto',
66-
},
67-
arbitrumOne: {
68-
chainId: 42161,
69-
url: process.env.ARBITRUM_ONE_RPC_URL || 'https://arb1.arbitrum.io/rpc',
70-
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
71-
gasPrice: 'auto',
72-
},
73-
},
74-
gasReporter: {
75-
enabled: process.env.REPORT_GAS ? true : false,
76-
showTimeSpent: true,
77-
currency: 'USD',
78-
outputFile: 'reports/gas-report.log',
79-
},
8021
}
8122

8223
export default config

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)