-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
98 lines (88 loc) · 2.71 KB
/
hardhat.config.js
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
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-etherscan");
require("hardhat-contract-sizer");
require("hardhat-abi-exporter");
let PuzzleCard;
try {
PuzzleCard = require("./public/PuzzleCard.js");
} catch (e) {
// The require path is different from the GitHub action.
PuzzleCard = require("../../../PuzzleCard.js");
}
const liveProxyAddress = PuzzleCard.PROXY_REGISTRY_ADDRESS;
const system = (command) => require("child_process").execSync(command).toString().trim();
let privateKey, apiKey;
if (process.env.USER === "tuzz") {
privateKey = system("gpg --decrypt ~/Dropbox/Secrets/metamask/private-key.gpg 2>/dev/null");
apiKey = system("gpg --decrypt ~/Dropbox/Secrets/polygonscan/api-key.gpg 2>/dev/null");
}
module.exports = {
solidity: {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 1000000,
},
},
},
paths: {
artifacts: "./.artifacts",
cache: "./.cache",
},
abiExporter: {
path: './.abi',
only: ["PuzzleCard"],
flat: true,
pretty: true,
},
networks: {
hardhat: {
name: "hardhat",
allowUnlimitedContractSize: true,
accounts: {
accountsBalance: "1000000000000000000000000", // 1 million ETH
},
},
test: {
name: "Polygon Test Network",
url: "https://matic-mumbai.chainstacklabs.com",
url2: "https://rpc-mumbai.maticvigil.com",
chainId: 80001,
symbol: "MATIC",
explorer: "https://mumbai.polygonscan.com",
openseaProxyAddress: "0xff7ca10af37178bdd056628ef42fd7f799fac77c",
accounts: privateKey ? [`0x${privateKey}`] : [],
},
live: {
name: "Polygon Mainnet",
url: "https://matic-mainnet.chainstacklabs.com",
url2: "https://rpc-mainnet.maticvigil.com",
chainId: 137,
symbol: "MATIC",
explorer: "https://polygonscan.com",
openseaProxyAddress: "0x58807bad0b376efc12f5ad86aac70e78ed67deae",
accounts: privateKey ? [`0x${privateKey}`] : [],
polygonscanApiKey: apiKey,
},
},
etherscan: {
apiKey,
},
mocha: {
timeout: 0,
color: true,
}
};
const config = require("hardhat/config")
const names = require("hardhat/builtin-tasks/task-names");
const fs = require('fs')
// After compile, copy the exported ABI into a constant in the PuzzleCard.js library.
config.task(names.TASK_COMPILE, async (_taskArguments, _hre, runSuper) => {
await runSuper();
let json;
try { json = fs.readFileSync(".abi/PuzzleCard.json", "utf8").trim(); } catch (e) { return; }
const js = fs.readFileSync("public/PuzzleCard.js", "utf8");
const replaced = js.replaceAll(/CONTRACT_ABI = \[[\s\S]*\]/g, `CONTRACT_ABI = ${json}`);
fs.writeFileSync("public/PuzzleCard.js", replaced);
});