1
- import { runOnEvms , ChainInfo , LoggerFn , getContractAddress , getDeploymentArgs , getVerifyCommand } from "../../../helpers" ;
1
+ import { runOnEvms , ChainInfo , LoggerFn , getContractAddress , getDeploymentArgs , getVerifyCommand , verificationApiKeys , flattenObject } from "../../../helpers" ;
2
2
import { ethers } from "ethers" ;
3
3
import { execSync } from "child_process" ;
4
4
import path from "path" ;
@@ -8,44 +8,55 @@ runOnEvms("bytecode-verification-token-router", async (chain: ChainInfo, signer:
8
8
// The root path of the foundry project
9
9
const rootPath = path . resolve ( '../evm/' ) ;
10
10
11
- if ( chain . externalId === undefined )
12
- throw new Error ( `Chain ${ chain . chainId } does not have an external ID` ) ;
13
11
14
- // Implementation data
15
- const implementationName = "TokenRouter" ;
16
- const implementationPath = 'src/TokenRouter/TokenRouter.sol' ;
17
- const implementationAddress = getContractAddress ( "TokenRouterImplementation" , chain . chainId ) ;
18
- const implementationDeploymentArgs = getDeploymentArgs ( "TokenRouterImplementation" , chain . chainId ) ;
19
- const implementationConstructorSignature = "constructor(address,address,address,uint16,bytes32,bytes32,uint32)" ;
20
- const verifyImplementationCommand = getVerifyCommand (
21
- implementationName ,
22
- implementationPath ,
23
- implementationAddress ,
24
- implementationConstructorSignature ,
25
- implementationDeploymentArgs ,
26
- parseInt ( chain . externalId )
27
- ) ;
28
-
29
- // Proxy data
30
- const proxyName = "ERC1967Proxy" ;
31
- const proxyPath = 'lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol' ;
32
- const proxyAddress = getContractAddress ( "TokenRouterProxy" , chain . chainId ) ;
33
- const proxyDeploymentArgs = getDeploymentArgs ( "TokenRouterProxy" , chain . chainId ) ;
34
- const proxyConstructorSignature = "constructor(address,bytes)" ;
35
- const verifyProxyCommand = getVerifyCommand (
36
- proxyName ,
37
- proxyPath ,
38
- proxyAddress ,
39
- proxyConstructorSignature ,
40
- proxyDeploymentArgs ,
41
- parseInt ( chain . externalId )
42
- ) ;
12
+ const verifiersData = verificationApiKeys . find ( ( x ) => x . chainId == chain . chainId ) ;
13
+ const verifiers = flattenObject ( verifiersData ! ) ;
14
+ delete verifiers . chainId ;
43
15
44
- log ( chalk . green ( "Verifying implementation bytecode..." ) ) ;
45
- execSync ( verifyImplementationCommand , { stdio : "inherit" , cwd : rootPath } ) ;
46
- console . log ( )
16
+ for ( let [ name , apiKey ] of Object . entries ( verifiers ) ) {
17
+ name = name . split ( "-" ) [ 0 ] ;
47
18
48
- log ( chalk . green ( "Verifying proxy bytecode..." ) ) ;
49
- execSync ( verifyProxyCommand , { stdio : "inherit" , cwd : rootPath } ) ;
50
- console . log ( )
19
+ // Implementation data
20
+ const implementationName = "MatchingEngine" ;
21
+ const implementationPath = 'src/MatchingEngine/MatchingEngine.sol' ;
22
+ const implementationAddress = getContractAddress ( "MatchingEngineImplementation" , chain . chainId ) ;
23
+ const implementationDeploymentArgs = getDeploymentArgs ( "MatchingEngineImplementation" , chain . chainId ) ;
24
+ const implementationConstructorSignature = "constructor(address,address,address,uint24,uint24,uint8,uint8,uint8)" ;
25
+ const verifyImplementationCommand = getVerifyCommand (
26
+ chain ,
27
+ implementationName ,
28
+ implementationPath ,
29
+ implementationAddress ,
30
+ implementationConstructorSignature ,
31
+ implementationDeploymentArgs ,
32
+ name ,
33
+ apiKey
34
+ ) ;
35
+
36
+ // Proxy data
37
+ const proxyName = "ERC1967Proxy" ;
38
+ const proxyPath = 'lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol' ;
39
+ const proxyAddress = getContractAddress ( "MatchingEngineProxy" , chain . chainId ) ;
40
+ const proxyDeploymentArgs = getDeploymentArgs ( "MatchingEngineProxy" , chain . chainId ) ;
41
+ const proxyConstructorSignature = "constructor(address,bytes)" ;
42
+ const verifyProxyCommand = getVerifyCommand (
43
+ chain ,
44
+ proxyName ,
45
+ proxyPath ,
46
+ proxyAddress ,
47
+ proxyConstructorSignature ,
48
+ proxyDeploymentArgs ,
49
+ name ,
50
+ apiKey
51
+ ) ;
52
+
53
+ log ( chalk . green ( `Verifying bytecode on ${ name } ...` ) ) ;
54
+ log ( chalk . green ( "Verifying implementation bytecode..." ) ) ;
55
+ execSync ( verifyImplementationCommand , { stdio : "inherit" , cwd : rootPath } ) ;
56
+ console . log ( )
57
+
58
+ log ( chalk . green ( "Verifying proxy bytecode..." ) ) ;
59
+ execSync ( verifyProxyCommand , { stdio : "inherit" , cwd : rootPath } ) ;
60
+ console . log ( )
61
+ }
51
62
} ) ;
0 commit comments