Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 0 additions & 124 deletions hardhat.config.js

This file was deleted.

94 changes: 94 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { defineConfig } from 'hardhat/config';

// Plugins
import hardhatEthers from '@nomicfoundation/hardhat-ethers';
import hardhatEthersChaiMatchers from '@nomicfoundation/hardhat-ethers-chai-matchers';
import hardhatIgnoreWarnings from 'hardhat-ignore-warnings';
import hardhatMocha from '@nomicfoundation/hardhat-mocha';
import hardhatNetworkHelpers from '@nomicfoundation/hardhat-network-helpers';
import hardhatPredeploy from 'hardhat-predeploy';
import hardhatExposed from './hardhat/hardhat-exposed/plugin.js';
import hardhatOzContractsHelpers from './hardhat/hardhat-oz-contracts-helpers/plugin.js';
import './hardhat/async-test-sanity.js';

// Parameters
import yargs from 'yargs/yargs';
const argv = await yargs()
.env('')
.options({
compiler: { type: 'string', default: '0.8.31' },
src: { type: 'string', default: 'contracts' },
runs: { type: 'number', default: 200 },
ir: { type: 'boolean', default: false },
evm: { type: 'string', default: 'osaka' },
})
.parse();

// Configuration
export default defineConfig({
plugins: [
// Imported plugins
hardhatEthers,
hardhatEthersChaiMatchers,
hardhatIgnoreWarnings,
hardhatMocha,
hardhatNetworkHelpers,
hardhatPredeploy,
// Local plugins
hardhatExposed,
hardhatOzContractsHelpers,
],
paths: {
sources: argv.src,
},
solidity: {
version: argv.compiler,
settings: {
optimizer: {
enabled: true,
runs: argv.runs,
},
evmVersion: argv.evm,
viaIR: argv.ir,
outputSelection: { '*': { '*': ['storageLayout'] } },
},
},
networks: {
default: {
type: 'edr-simulated',
hardfork: argv.evm,
// Exposed contracts often exceed the maximum contract size. For normal contract,
// we rely on the `code-size` compiler warning, that will cause a compilation error.
allowUnlimitedContractSize: true,
},
},
test: {
solidity: {
fuzz: {
// runs: 5000,
// maxTestRejects: 150000,
},
fsPermissions: {
readDirectory: ['node_modules/hardhat-predeploy/bin'],
},
},
},
warnings: {
'npm/**/*': 'off',
'test/**/*': 'off',
'contracts-exposed/**/*': {
'code-size': 'off',
'initcode-size': 'off',
},
'*': {
'transient-storage': 'off',
default: 'error',
},
},
exposed: {
imports: true,
initializers: true,
include: ['contracts/**/*.sol'],
exclude: ['contracts/vendor/**/*', '**/*WithInit.sol'],
},
});
29 changes: 0 additions & 29 deletions hardhat/env-artifacts.js

This file was deleted.

26 changes: 26 additions & 0 deletions hardhat/hardhat-exposed/core/format-lines.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export type Lines = string | typeof whitespace | Lines[];

const whitespace = Symbol('whitespace');

export function formatLines(...lines: Lines[]): string {
return [...indentEach(0, lines)].join('\n') + '\n';
}

function* indentEach(indent: number, lines: Lines[]): Generator<string | typeof whitespace> {
for (const line of lines) {
if (line === whitespace) {
yield '';
} else if (Array.isArray(line)) {
yield* indentEach(indent + 1, line);
} else {
yield ' '.repeat(indent) + line;
}
}
}

export function spaceBetween(...lines: Lines[][]): Lines[] {
return lines
.filter(l => l.length > 0)
.flatMap<Lines>(l => [whitespace, ...l])
.slice(1);
}
Loading
Loading