generated from projectsophon/zk-game-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
209 lines (200 loc) · 5.86 KB
/
hardhat.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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Hardhat plugins
// Note: Order probably matters!
import "@nomicfoundation/hardhat-chai-matchers";
import "@nomicfoundation/hardhat-network-helpers";
import "@nomiclabs/hardhat-ethers";
import "hardhat-abi-exporter";
import "hardhat-diamond-abi";
// Must be registered after hardhat-diamond-abi
import "@typechain/hardhat";
import "hardhat-circom";
import "hardhat-contract-sizer";
import "hardhat-settings";
import "@solidstate/hardhat-4byte-uploader";
// Our Hardhat tasks
import "hardhat-tasks/deploy";
import "hardhat-tasks/node";
import "hardhat-tasks/circom";
// Other
import type {
HardhatRuntimeEnvironment,
HardhatUserConfig,
} from "hardhat/types";
import { extendEnvironment } from "hardhat/config";
import * as diamondUtils from "hardhat-tasks/utils/diamond";
//@ts-ignore because they don't provide types
import * as mapWorkspaces from "@npmcli/map-workspaces";
declare module "hardhat/types/runtime" {
interface HardhatRuntimeEnvironment {
packages: Map<string, string>;
}
}
declare module "hardhat/types" {
interface HardhatSettings {
deployments: {
[key: string]: {
diamond: string;
initializer: string;
facets: { name: string; selectors: string | string[] }[];
};
};
}
}
const packages = mapWorkspaces.virtual({
cwd: __dirname,
pkg: require("./package.json"),
lockfile: require("./package-lock.json"),
});
extendEnvironment((env: HardhatRuntimeEnvironment) => {
env.packages = packages;
});
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
/**
* This configures which networks hardhat will communicate with
*/
networks: {
localhost: {
url: "http://localhost:8545/",
accounts: {
mnemonic:
"change typical hire slam amateur loan grid fix drama electric seed label",
},
chainId: 31337,
},
// Used when you don't specify a network on command line, like in tests
hardhat: {
accounts: [
{
privateKey:
"0x044C7963E9A89D4F8B64AB23E02E97B2E00DD57FCB60F316AC69B77135003AEF",
balance: "100000000000000000000",
},
{
privateKey:
"0x523170AAE57904F24FFE1F61B7E4FF9E9A0CE7557987C2FC034EACB1C267B4AE",
balance: "100000000000000000000",
},
{
privateKey:
"0x67195c963ff445314e667112ab22f4a7404bad7f9746564eb409b9bb8c6aed32",
balance: "100000000000000000000",
},
],
blockGasLimit: 16777215,
mining: {
auto: false,
interval: 1000,
},
},
},
/**
* This configures the solidity compiler used to build our Smart Contracts.
*/
solidity: {
version: "0.8.10",
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
/**
* This plugins compiles circom circuits and outputs the necessary files to
* the `@zkgame/snarks` package.
*/
circom: {
inputBasePath: "./circuits/",
outputBasePath: packages.get("@zkgame/snarks"),
// The ptau15 will be automatically fetched from the hermez dropbox
ptau: "https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_15.ptau",
circuits: [
{
name: "whitelist",
circuit: "whitelist.circom",
input: "whitelist-input.json",
beacon:
"0000000005060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
},
],
},
/**
* This plugin will provide size information about all our contracts
* via the `hardhat size-contracts` command.
*/
contractSizer: {
alphaSort: true,
runOnCompile: false,
disambiguatePaths: false,
},
/**
* This plugin generates TypeScript definitions for interacting with our
* Smart Contracts—primarily the ZKGame Contract, which is the Diamond.
*/
typechain: {
outDir: packages.get("@zkgame/typechain"),
target: "ethers-v5",
},
/**
* This plugin will combine all ABIs from any Smart Contract with `Facet`
* in the name or path and output it as `ZKGame.json`.
*/
diamondAbi: {
name: "ZKGame",
include: ["Facet$", ":Diamond$"],
// We explicitly set `strict` to `true` because we want to validate
// our facets don't accidentally provide overlapping functions
strict: true,
// We use our diamond utils to filter some functions we ignore from the combined ABI
filter(
abiElement: unknown,
index: number,
abi: unknown[],
fullyQualifiedName: string
) {
// Events can be defined in internal libraries or multiple facets and look like duplicates
if (diamondUtils.isOverlappingEvent(abiElement)) {
return false;
}
// Errors can be defined in internal libraries or multiple facets and look like duplicates
if (diamondUtils.isOverlappingError(abiElement)) {
return false;
}
const signature = diamondUtils.toSignature(abiElement);
return diamondUtils.isIncluded(fullyQualifiedName, signature);
},
},
/**
* This plugin will copy the ABI from the ZKGame artifact into our
* `@zkgame/contracts` package as `ZKGame.json`.
*/
abiExporter: {
path: packages.get("@zkgame/contracts"),
runOnCompile: true,
// We don't want additional directories created, so we explicitly
// set the `flat` option to `true`
flat: true,
// We want to copy the ZKGame ABI (which is the Diamond ABI we generate) and the
// initializer ABI to this folder, so we limit the matched files with the `only` option
only: [
":ZKGame$",
":Initializer$",
// We also want the Diamond so our Hardhat diamond utilities can filter its interface
":Diamond$",
],
},
/**
* This plugin will load and parse the `zkgame.toml` file and provide the
* values to tasks on the HardhatRuntimeEnvironment.
*/
settings: {
deployments: {
lazy: false,
},
zkgame: {
lazy: false,
},
},
};
export default config;