-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
115 lines (103 loc) · 2.83 KB
/
Copy pathhardhat.config.ts
File metadata and controls
115 lines (103 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import '@oasisprotocol/sapphire-hardhat'
import '@nomicfoundation/hardhat-ethers'
import '@nomicfoundation/hardhat-verify'
import { promises as fs } from 'fs'
import path from 'path'
import canonicalize from 'canonicalize'
import { TASK_COMPILE } from 'hardhat/builtin-tasks/task-names'
import { HardhatUserConfig, task } from 'hardhat/config'
import '@typechain/hardhat'
import './tasks/deploy'
const TASK_EXPORT_ABIS = 'export-abis'
task(TASK_COMPILE, async (_args, hre, runSuper) => {
await runSuper()
await hre.run(TASK_EXPORT_ABIS)
})
task(TASK_EXPORT_ABIS, async (_args, hre) => {
const srcDir = path.basename(hre.config.paths.sources)
const outDir = path.join(hre.config.paths.root, 'abis')
const [artifactNames] = await Promise.all([
hre.artifacts.getAllFullyQualifiedNames(),
fs.mkdir(outDir, { recursive: true }),
])
await Promise.all(
artifactNames.map(async fqn => {
const { abi, bytecode, contractName, sourceName } = await hre.artifacts.readArtifact(fqn)
if (abi.length === 0 || !sourceName.startsWith(srcDir) || contractName.endsWith('Test')) {
return
}
await fs.writeFile(`${path.join(outDir, contractName)}.json`, `${canonicalize(abi)}\n`)
await fs.writeFile(`${path.join(outDir, contractName)}.bin`, bytecode)
})
)
}).setDescription('Saves ABI and bytecode to the "abis" directory')
const TEST_HDWALLET = {
mnemonic: 'test test test test test test test test test test test junk',
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 20,
passphrase: '',
}
const accounts = process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : TEST_HDWALLET
const config: HardhatUserConfig = {
networks: {
hardhat: {
chainId: 1337, // @see https://hardhat.org/metamask-issue.html
},
hardhat_local: {
url: 'http://127.0.0.1:8545/',
},
sapphire: {
url: 'https://sapphire.oasis.io',
chainId: 0x5afe,
accounts,
},
'sapphire-testnet': {
url: 'https://testnet.sapphire.oasis.dev',
chainId: 0x5aff,
accounts,
},
'sapphire-localnet': {
url: 'http://127.0.0.1:8545',
chainId: 0x5afd,
accounts,
},
},
solidity: {
version: '0.8.23',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
viaIR: true,
},
},
typechain: {
target: 'ethers-v6',
outDir: 'src/contracts',
},
mocha: {
require: ['ts-node/register/files'],
timeout: 50_000,
},
sourcify: {
enabled: true,
},
etherscan: {
apiKey: {
'Oasis Sapphire Testnet': 'abc',
},
customChains: [
{
network: 'Oasis Sapphire Testnet',
chainId: 23295,
urls: {
apiURL: 'https://testnet.sapphire.oasis.dev/',
browserURL: 'https://explorer.oasis.io/testnet/sapphire',
},
},
],
},
}
export default config