-
Notifications
You must be signed in to change notification settings - Fork 1
/
tools.ts
38 lines (31 loc) · 1.54 KB
/
tools.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
import {HardhatRuntimeEnvironment} from "hardhat/types";
export function checkConfigExists(hre: HardhatRuntimeEnvironment) {
if (!hre.config.functionSelectors) {
throw new Error(`Missing \`functionSelectors\` configuration in Hardhat config.
An example configuration looks like this:
module.exports = {
functionSelectors: {
separateContractSelectors: true, // separate by contract
orderedByValue: true, // order function selectors by hex value, least to greatest
outputPath: ".", // directory where output file should be written
outputFilename: "selectors.json", // filename of generated output
pretty: true, // pretty print the output JSON(s)
runOnCompile: true, // run the selectors task on compile
includeParams: true, // include the parameters in the selector title (outputs only)
only: [], // Array of String matchers used to select included contracts, defaults to all contracts if length is 0
except: [], // Array of String matchers used to exclude contracts
skipSelectors: [], // Array of selectors to be excluded from generated output
},
// other configurations...
}
`)
}
}
export function sortDict<T>(dict: { [key: string]: T }): { [key: string]: T } {
return Object.keys(dict)
.sort()
.reduce((obj, key) => {
obj[key] = dict[key]
return obj
}, {} as { [key: string]: T })
}