Closed foufrix closed 5 months ago
Post your HH config.
Thanks for the quick reply,
Here is the hardhat.config.ts
:
import * as dotenv from 'dotenv';
import { HardhatUserConfig, task } from 'hardhat/config';
import '@nomiclabs/hardhat-ethers';
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomiclabs/hardhat-etherscan';
import '@nomicfoundation/hardhat-foundry';
import '@typechain/hardhat';
import 'xdeployer';
import 'hardhat-gas-reporter';
import 'solidity-coverage';
import 'hardhat-contract-sizer';
import * as tdly from '@tenderly/hardhat-tenderly';
import 'hardhat-abi-exporter';
import '@nomicfoundation/hardhat-toolbox';
import '@openzeppelin/hardhat-upgrades';
import 'hardhat-dependency-compiler';
dotenv.config();
// Turning off the automatic Tenderly verification
tdly.setup({ automaticVerifications: false });
task('accounts', 'Prints the list of accounts', async (_, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
// eslint-disable-next-line no-console
console.log(account.address);
}
});
task(
'balances',
'Prints the list of accounts and their balances',
async (_, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
// eslint-disable-next-line no-console
console.log(
account.address +
' ' +
(await hre.ethers.provider.getBalance(account.address))
);
}
}
);
const config: HardhatUserConfig = {
solidity: {
version: '0.8.9',
settings: { optimizer: { enabled: true, runs: 1000000 } },
},
defaultNetwork: 'hardhat',
networks: {
localhost: {
url: `http://127.0.0.1:${process.env.RPC_PORT || '8545'}`,
},
hardhat: {
forking: process.env.FORKING_URL
? {
url: process.env.FORKING_URL,
}
: undefined,
chainId: 1338,
},
tenderly: {
url: `https://rpc.tenderly.co/fork/${process.env.TENDERLY_FORK_ID}`,
},
mainnet: {
chainId: 1,
url: process.env.ETH_MAINNET_TESTNET_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
timeout: 2000000,
},
goerli: {
chainId: 5,
url: process.env.ETH_GOERLI_TESTNET_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
timeout: 2000000,
},
polygon: {
chainId: 137,
url: process.env.ETH_POLYGON_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
timeout: 2000000,
},
polygonMumbai: {
chainId: 80001,
url: process.env.ETH_POLYGON_MUMBAI_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
timeout: 2000000,
},
bsc: {
chainId: 56,
url: process.env.ETH_BSC_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
timeout: 2000000,
},
bscTestnet: {
chainId: 97,
url: process.env.ETH_BSC_TESTNET_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
timeout: 2000000,
},
moonbeam: {
chainId: 1284,
timeout: 2000000,
url: process.env.ETH_MOONBEAM_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
moonbaseAlpha: {
chainId: 1287,
timeout: 2000000,
url: process.env.ETH_MOONBASE_ALPHA_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
avalancheTestnet: {
chainId: 43113,
timeout: 2000000,
url: 'https://api.avax-test.network/ext/C/rpc',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
avalanche: {
chainId: 43114,
timeout: 2000000,
url: 'https://api.avax.network/ext/bc/C/rpc',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
skale: {
chainId: 1273227453,
timeout: 2000000,
url: process.env.ETH_SKALE_URL || '',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
oktcTestnet: {
chainId: 65,
timeout: 2000000,
url: 'https://exchaintestrpc.okex.org',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
oktc: {
chainId: 66,
timeout: 2000000,
url: 'https://exchainrpc.okex.org/',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: 'USD',
},
contractSizer: {
alphaSort: true,
runOnCompile: true,
disambiguatePaths: false,
strict: true,
only: [],
except: [],
},
abiExporter: {
path: './abis',
runOnCompile: true,
clear: true,
flat: true,
only: [],
spacing: 2,
format: 'json',
},
etherscan: {
apiKey: {
// For Mainnet, Goerli
mainnet: process.env.ETHERSCAN_API_KEY || '',
goerli: process.env.ETHERSCAN_API_KEY || '',
polygon: process.env.POLYGONSCAN_API_KEY || '',
polygonMumbai: process.env.POLYGONSCAN_API_KEY || '',
bsc: process.env.BSC_API_KEY || '',
bscTestnet: process.env.BSC_API_KEY || '',
moonbeam: process.env.MOONSCAN_API_KEY || '',
moonbaseAlpha: process.env.MOONSCAN_API_KEY || '',
skale: process.env.SKALE_API_KEY || '',
oktcTestnet: 'OKLINK',
},
customChains: [
{
network: 'skale',
chainId: 1273227453,
urls: {
apiURL: process.env.SKALE_BROWSER_API_URL || '',
browserURL: process.env.SKALE_BROWSER_URL || '',
},
},
{
network: 'oktcTestnet',
chainId: 65,
urls: {
apiURL:
'https://www.oklink.com/api/explorer/v1/contract/verify/async/api/okctest',
browserURL: 'https://www.oklink.com/fr/oktc-test',
},
},
],
},
mocha: {
timeout: 200000,
},
dependencyCompiler: {
paths: ['@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol'],
},
};
export default config;
I can't reproduce. That error should only be thrown if a custom path
is set which references a parent directory. See here: https://github.com/ItsNickBarry/hardhat-dependency-compiler/blob/83328c5a17e6d211095bdfee45f085c2d671472d/tasks/compile.js#L22-L27
Am I using path.resolve
incorrectly? Could it be an OS/filesystem issue?
I'm using the MacOS and I got the same error
hre.config.paths.sources => src
directory => ../../../src/hardhat-dependency-compiler
How can I solve this? @ItsNickBarry
Got the same error , any update on this?
Not enough information to reproduce. This error should only be thrown in the event of improper use of the path
configuration option. If anyone has a minimal reproduction process which doesn't use path
incorrectly, I can look into it.
Hey there! I can confirm that the issue arises when using @nomicfoundation/hardhat-foundry
. Removing the import from hardhat.config.js
makes the issue go away. I haven't looked into it further yet.
Ok, so I looked into it further. The issue arises because hre.config.paths.sources
contains a relative path when hardhat-foundry
is imported, and an absolute path when it isn't. This change fixes the issue:
diff --git a/tasks/compile.js b/tasks/compile.js
index 6c73040..ee81289 100644
--- a/tasks/compile.js
+++ b/tasks/compile.js
@@ -19,14 +19,15 @@ const generate = function (dependency) {
task(TASK_COMPILE, async function (args, hre, runSuper) {
const config = hre.config.dependencyCompiler;
- const directory = path.resolve(hre.config.paths.sources, config.path);
+ const sources = path.resolve(hre.config.paths.sources);
+ const directory = path.resolve(sources, config.path);
const tracker = path.resolve(directory, `.${ name }`);
- if (!directory.startsWith(hre.config.paths.sources)) {
+ if (!directory.startsWith(sources)) {
throw new HardhatPluginError('resolved path must be inside of sources directory');
}
- if (directory === hre.config.paths.sources) {
+ if (directory === sources) {
throw new HardhatPluginError('resolved path must not be sources directory');
}
It's also more inline with hardhat's documentation that the path is relative:
sources: The directory where your contract are stored. This path is resolved from the project's root. Default value: './contracts'.
Here's a workaround, add in hardhat.config.js
:
const path = require("path");
extendConfig((config) => {
config.paths.sources = path.resolve(config.paths.sources);
});
@gnpar Thanks for the solution. I'd accept a PR if you want to become a contributor, or I'll add the change myself some time this coming week.
Fix published in v1.1.4
.
Trying to use verification on okc network, configured in
hardhat.config.ts
But got :
This is my folder architecture
And I'm launching the command from the core folder
Any idea what could cause this issue? I tried without the args not working either. I don't understand the error message as my file are there
Here is the import in HMToken in case it's useful: