1+ import '@nomicfoundation/hardhat-toolbox' ;
12import 'dotenv/config' ;
23import * as fs from 'fs' ;
3- // hardhat-deploy temporarily disabled - not compatible with Hardhat 3 yet
4- // import 'hardhat-deploy';
4+ import 'hardhat-abi-exporter' ;
5+ import 'hardhat-dependency-compiler' ;
6+ import 'hardhat-deploy' ;
57import { HardhatUserConfig , task } from 'hardhat/config' ;
6- import * as path from 'path' ;
7- // solidity-docgen temporarily disabled - not compatible with Hardhat 3 yet
8- // import 'solidity-docgen';
8+ import {
9+ HARDHAT_NETWORK_MNEMONIC ,
10+ defaultHardhatNetworkParams ,
11+ defaultLocalhostNetworkParams ,
12+ } from 'hardhat/internal/core/config/default-config' ;
13+ import 'solidity-docgen' ;
914import { cleanupDeployments , copyDeployments } from './scripts/tools/copy-deployments' ;
1015import chainConfig from './utils/config' ;
11- // Hardhat 3: internal imports may have changed, using defaults directly
12- const HARDHAT_NETWORK_MNEMONIC = 'test test test test test test test test test test test junk' ;
13- const defaultHardhatNetworkParams = { } ;
14- const defaultLocalhostNetworkParams = { } ;
1516
1617const isNativeChainType = chainConfig . isNativeChain ( ) ;
1718const isLocalFork = chainConfig . isLocalFork ( ) ;
@@ -73,12 +74,6 @@ const v8Settings = {
7374} ;
7475
7576const config : HardhatUserConfig = {
76- paths : {
77- sources : './contracts' ,
78- tests : './test' ,
79- cache : './cache' ,
80- artifacts : './artifacts' ,
81- } ,
8277 solidity : {
8378 compilers : [
8479 { version : '0.8.21' , settings : v8Settings } , // PoCo Boost
@@ -102,7 +97,6 @@ const config: HardhatUserConfig = {
10297 } ,
10398 networks : {
10499 hardhat : {
105- type : 'edr-simulated' , // Hardhat 3: required network type
106100 accounts : {
107101 mnemonic : process . env . MNEMONIC || HARDHAT_NETWORK_MNEMONIC ,
108102 } ,
@@ -135,7 +129,6 @@ const config: HardhatUserConfig = {
135129 } ) ,
136130 } ,
137131 'external-hardhat' : {
138- type : 'edr-simulated' , // Hardhat 3: required network type
139132 ...defaultHardhatNetworkParams ,
140133 ...defaultLocalhostNetworkParams ,
141134 accounts : {
@@ -156,7 +149,6 @@ const config: HardhatUserConfig = {
156149 } ) ,
157150 } ,
158151 'dev-native' : {
159- type : 'http' , // Hardhat 3: required network type
160152 chainId : 65535 ,
161153 url : process . env . DEV_NODE || 'http://localhost:8545' ,
162154 accounts : {
@@ -165,7 +157,6 @@ const config: HardhatUserConfig = {
165157 gasPrice : bellecourBaseConfig . gasPrice , // Get closer to Bellecour network
166158 } ,
167159 'dev-token' : {
168- type : 'http' , // Hardhat 3: required network type
169160 chainId : 65535 ,
170161 url : process . env . DEV_NODE || 'http://localhost:8545' ,
171162 accounts : {
@@ -177,7 +168,6 @@ const config: HardhatUserConfig = {
177168 gasPrice : 8_000_000_000 , // 8 Gwei
178169 } ,
179170 arbitrum : {
180- type : 'http' , // Hardhat 3: required network type
181171 url :
182172 process . env . ARBITRUM_RPC_URL || // Used in local development
183173 process . env . RPC_URL || // Defined in Github Actions environments
@@ -186,7 +176,6 @@ const config: HardhatUserConfig = {
186176 ...arbitrumBaseConfig ,
187177 } ,
188178 arbitrumSepolia : {
189- type : 'http' , // Hardhat 3: required network type
190179 url :
191180 process . env . ARBITRUM_SEPOLIA_RPC_URL || // Used in local development
192181 process . env . RPC_URL || // Defined in Github Actions environments
@@ -195,7 +184,6 @@ const config: HardhatUserConfig = {
195184 ...arbitrumSepoliaBaseConfig ,
196185 } ,
197186 bellecour : {
198- type : 'http' , // Hardhat 3: required network type
199187 chainId : 134 ,
200188 url : 'https://bellecour.iex.ec' ,
201189 accounts : _getPrivateKeys ( ) ,
@@ -228,25 +216,23 @@ const config: HardhatUserConfig = {
228216 typechain : {
229217 outDir : 'typechain' ,
230218 } ,
231- // dependencyCompiler temporarily disabled - not compatible with Hardhat 3 yet
232- // TODO: Re-enable when hardhat-dependency-compiler supports Hardhat 3
233- // dependencyCompiler: {
234- // paths: [
235- // 'rlc-faucet-contract/contracts/RLC.sol',
236- // // ERC-2535 Diamond
237- // '@mudgen/diamond-1/contracts/facets/DiamondCutFacet.sol',
238- // '@mudgen/diamond-1/contracts/facets/DiamondLoupeFacet.sol',
239- // '@mudgen/diamond-1/contracts/facets/OwnershipFacet.sol',
240- // '@mudgen/diamond-1/contracts/libraries/LibDiamond.sol',
241- // '@mudgen/diamond-1/contracts/upgradeInitializers/DiamondInit.sol',
242- // // Used as mock or fake in UTs
243- // '@openzeppelin/contracts/interfaces/IERC1271.sol',
244- // // Used in deployment
245- // '@amxx/factory/contracts/v6/GenericFactory.sol',
246- // 'createx/src/ICreateX.sol',
247- // ],
248- // keep: true, // Slither requires compiled dependencies
249- // },
219+ dependencyCompiler : {
220+ paths : [
221+ 'rlc-faucet-contract/contracts/RLC.sol' ,
222+ // ERC-2535 Diamond
223+ '@mudgen/diamond-1/contracts/facets/DiamondCutFacet.sol' ,
224+ '@mudgen/diamond-1/contracts/facets/DiamondLoupeFacet.sol' ,
225+ '@mudgen/diamond-1/contracts/facets/OwnershipFacet.sol' ,
226+ '@mudgen/diamond-1/contracts/libraries/LibDiamond.sol' ,
227+ '@mudgen/diamond-1/contracts/upgradeInitializers/DiamondInit.sol' ,
228+ // Used as mock or fake in UTs
229+ '@openzeppelin/contracts/interfaces/IERC1271.sol' ,
230+ // Used in deployment
231+ '@amxx/factory/contracts/v6/GenericFactory.sol' ,
232+ 'createx/src/ICreateX.sol' ,
233+ ] ,
234+ keep : true , // Slither requires compiled dependencies
235+ } ,
250236 docgen : {
251237 outputDir : 'docs/solidity' ,
252238 templates : 'docs/solidity/templates' ,
@@ -265,6 +251,32 @@ const config: HardhatUserConfig = {
265251 ] ,
266252 } ,
267253 mocha : { timeout : 300000 } ,
254+ abiExporter : [
255+ // ABIs of PoCo contracts for integration with other tools.
256+ {
257+ path : './abis/contracts' ,
258+ format : 'json' ,
259+ runOnCompile : true ,
260+ clear : true ,
261+ only : [ '^contracts/' ] ,
262+ except : [
263+ // !!! Update package.json#files if this is modified.
264+ // TODO reorganize utility contracts.
265+ '^contracts/tools/testing/' ,
266+ '^contracts/tools/diagrams/' ,
267+ '^contracts/tools/TimelockController' ,
268+ ] ,
269+ rename : ( sourceName , contractName ) =>
270+ `${ sourceName . replace ( 'contracts/' , '' ) . replace ( '.sol' , '' ) } ` ,
271+ } ,
272+ // ABIs of all contracts in a human readable format for easier upgrade debugging.
273+ {
274+ path : './abis/human-readable-abis' ,
275+ format : 'minimal' ,
276+ runOnCompile : true ,
277+ clear : true ,
278+ } ,
279+ ] ,
268280} ;
269281
270282/**
@@ -287,6 +299,10 @@ task('docgen').setAction(async (taskArgs, hre, runSuper) => {
287299 } ) ;
288300} ) ;
289301
302+ /**
303+ * Override `test` task to copy deployments of Arbitrum Sepolia if running tests on
304+ * a forked Arbitrum Sepolia network and clean them up afterwards.
305+ */
290306task ( 'test' ) . setAction ( async ( taskArgs : any , hre , runSuper ) => {
291307 let deploymentsCopied = false ;
292308 let networkName = '' ;
@@ -303,37 +319,6 @@ task('test').setAction(async (taskArgs: any, hre, runSuper) => {
303319 }
304320} ) ;
305321
306- // Automatically update ABIs after compiling contracts.
307- task ( 'compile' ) . setAction ( async ( taskArgs : any , hre , runSuper ) => {
308- await runSuper ( taskArgs ) ;
309- await hre . run ( 'abis' ) ;
310- } ) ;
311-
312- task ( 'abis' , 'Generate contract ABIs' ) . setAction ( async ( taskArgs , hre ) => {
313- const abisDir = './abis' ;
314- // Remove old ABIs folder if it exists.
315- if ( fs . existsSync ( abisDir ) ) {
316- fs . rmSync ( abisDir , { recursive : true , force : true } ) ;
317- }
318- fs . mkdirSync ( abisDir ) ;
319- const contracts = ( await hre . artifacts . getAllFullyQualifiedNames ( ) )
320- // Keep only "contracts/" folder
321- . filter ( ( name ) => name . startsWith ( 'contracts/' ) )
322- // Remove non relevant contracts
323- // !!! Update package.json#files if this is updated.
324- . filter ( ( name ) => ! name . startsWith ( 'contracts/tools/testing' ) )
325- . filter ( ( name ) => ! name . startsWith ( 'contracts/tools/diagrams' ) )
326- . filter ( ( name ) => ! name . startsWith ( 'contracts/tools/TimelockController' ) ) ;
327- for ( const contractFile of contracts ) {
328- const artifact = await hre . artifacts . readArtifact ( contractFile ) ;
329- const abiFileDir = `${ abisDir } /${ path . dirname ( contractFile ) } ` ;
330- const abiFile = `${ abiFileDir } /${ artifact . contractName } .json` ;
331- fs . mkdirSync ( abiFileDir , { recursive : true } ) ;
332- fs . writeFileSync ( abiFile , JSON . stringify ( artifact . abi , null , 2 ) ) ;
333- }
334- console . log ( `Saved ${ contracts . length } ABI files to ${ abisDir } folder` ) ;
335- } ) ;
336-
337322function _getPrivateKeys ( ) {
338323 const ZERO_PRIVATE_KEY = '0x0000000000000000000000000000000000000000000000000000000000000000' ;
339324 const deployerKey = process . env . DEPLOYER_PRIVATE_KEY || ZERO_PRIVATE_KEY ;
0 commit comments