This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuidler.config.ts
86 lines (75 loc) · 2.3 KB
/
buidler.config.ts
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
require("dotenv").config();
import { BuidlerConfig, usePlugin, internalTask } from "@nomiclabs/buidler/config";
import { TASK_COMPILE_RUN_COMPILER } from "@nomiclabs/buidler/builtin-tasks/task-names";
import { execSync } from "child_process";
import { privateKeys } from "./utils/wallets";
usePlugin("@nomiclabs/buidler-waffle");
usePlugin("buidler-typechain");
usePlugin("solidity-coverage");
usePlugin("buidler-deploy");
internalTask(TASK_COMPILE_RUN_COMPILER).setAction(setupNativeSolc);
const config: BuidlerConfig = {
solc: {
version: "0.6.10",
optimizer: { enabled: true, runs: 200 },
},
namedAccounts: {
deployer: 0,
},
networks: {
buidlerevm: {
hardfork: "istanbul",
accounts: getBuidlerPrivateKeys(),
},
localhost: {
url: "http://127.0.0.1:8545",
},
kovan: {
url: "https://kovan.infura.io/v3/" + process.env.INFURA_TOKEN,
// @ts-ignore
accounts: [`0x${process.env.KOVAN_DEPLOY_PRIVATE_KEY}`],
},
production: {
url: "https://mainnet.infura.io/v3/" + process.env.INFURA_TOKEN,
// @ts-ignore
accounts: [`0x${process.env.PRODUCTION_MAINNET_DEPLOY_PRIVATE_KEY}`],
},
// To update coverage network configuration got o .solcover.js and update param in providerOptions field
coverage: {
url: "http://127.0.0.1:8555", // Coverage launches its own ganache-cli client
},
},
typechain: {
outDir: "typechain",
target: "ethers-v4",
},
};
function getBuidlerPrivateKeys() {
return privateKeys.map(key => {
const HUNDRED_THOUSAND_ETH = "100000000000000000000000";
return {
privateKey: key,
balance: HUNDRED_THOUSAND_ETH,
};
});
}
// @ts-ignore
async function setupNativeSolc({ input }, { config }, runSuper) {
let solcVersionOutput = "";
try {
solcVersionOutput = execSync(`solc --version`).toString();
} catch (error) {
// Probably failed because solc wasn"t installed. We do nothing here.
}
console.log("Output", solcVersionOutput);
if (!solcVersionOutput.includes(config.solc.version)) {
console.log(`Using solcjs`);
return runSuper();
}
console.log(`Using native solc`);
const output = execSync(`solc --standard-json`, {
input: JSON.stringify(input, undefined, 2),
});
return JSON.parse(output.toString(`utf8`));
}
export default config;