forked from synapsecns/sanguine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgeVerifyContract.js
executable file
·44 lines (40 loc) · 1.46 KB
/
forgeVerifyContract.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
#!/usr/bin/env node
const { getChainId, readChainVerificationOptions } = require('./utils/chain.js')
const {
getSavedDeployment,
getContractName,
} = require('./utils/deployments.js')
const { loadEnv } = require('./utils/env.js')
const { forgeVerify } = require('./utils/forge.js')
const { logError } = require('./utils/logger.js')
const { addOptions, parseCommandLineArgs } = require('./utils/options.js')
loadEnv()
const { positionalArgs, options } = parseCommandLineArgs({
requiredArgsCount: 2,
usage: 'Usage: "yarn fvc <chain-name> <contract-alias> [<options>]"',
})
const [chainName, contractAlias] = positionalArgs
const contractName = getContractName(contractAlias)
const chainId = getChainId(chainName)
const deployment = getSavedDeployment(chainName, contractAlias)
if (!deployment) {
process.exit(1)
}
const chainVerificationOptions = readChainVerificationOptions(chainName)
if (!chainVerificationOptions) {
process.exit(1)
}
const { address, constructorArgs } = deployment
if (!address) {
logError(`Missing address in deployment file for ${contractAlias}`)
process.exit(1)
}
if (!constructorArgs) {
constructorArgs = '0x'
}
let forgeOptions = `${address} ${contractName}`
forgeOptions = addOptions(forgeOptions, `--chain ${chainId} --watch`)
forgeOptions = addOptions(forgeOptions, chainVerificationOptions)
forgeOptions = addOptions(forgeOptions, options)
forgeOptions = addOptions(forgeOptions, `--constructor-args ${constructorArgs}`)
forgeVerify(forgeOptions)