1
1
import type { HardhatRuntimeEnvironment } from 'hardhat/types' ;
2
2
import type { DeploymentsExtension } from 'hardhat-deploy/types' ;
3
3
4
+ const VERIFICATION_BLOCK_CONFIRMATIONS = 5 ;
5
+
4
6
const deployTestProxy = async ( deployments : DeploymentsExtension , deployerAddress : string ) => {
5
7
const { address : inverseApi3ReaderProxyV1Address } = await deployments
6
8
. get ( 'InverseApi3ReaderProxyV1' )
@@ -14,7 +16,8 @@ const deployTestProxy = async (deployments: DeploymentsExtension, deployerAddres
14
16
return inverseApi3ReaderProxyV1Address ;
15
17
} ;
16
18
17
- module . exports = async ( { getUnnamedAccounts, deployments, network, ethers } : HardhatRuntimeEnvironment ) => {
19
+ module . exports = async ( hre : HardhatRuntimeEnvironment ) => {
20
+ const { getUnnamedAccounts, deployments, network, ethers, run } = hre ;
18
21
const { deploy, log } = deployments ;
19
22
20
23
const [ deployerAddress ] = await getUnnamedAccounts ( ) ;
@@ -39,12 +42,29 @@ module.exports = async ({ getUnnamedAccounts, deployments, network, ethers }: Ha
39
42
}
40
43
log ( `Proxy address: ${ proxyAddress } ` ) ;
41
44
42
- await deployments . get ( 'ScaledApi3FeedProxyV1' ) . catch ( async ( ) => {
43
- return deploy ( 'ScaledApi3FeedProxyV1' , {
44
- from : deployerAddress ,
45
- args : [ proxyAddress , decimals ] ,
46
- log : true ,
47
- } ) ;
45
+ const isLocalNetwork = network . name === 'hardhat' || network . name === 'localhost' ;
46
+
47
+ const confirmations = isLocalNetwork ? 1 : VERIFICATION_BLOCK_CONFIRMATIONS ;
48
+ log ( `Deployment confirmations: ${ confirmations } ` ) ;
49
+
50
+ const contractName = 'ScaledApi3FeedProxyV1' ;
51
+
52
+ const deployment = await deploy ( contractName , {
53
+ from : deployerAddress ,
54
+ args : [ proxyAddress , decimals ] ,
55
+ log : true ,
56
+ waitConfirmations : confirmations ,
57
+ } ) ;
58
+
59
+ if ( isLocalNetwork ) {
60
+ log ( 'Skipping verification on local network.' ) ;
61
+ return ;
62
+ }
63
+
64
+ log ( `Attempting verification of ${ contractName } (already waited for confirmations)...` ) ;
65
+ await run ( 'verify:verify' , {
66
+ address : deployment . address ,
67
+ constructorArguments : deployment . args ,
48
68
} ) ;
49
69
} ;
50
70
module . exports . tags = [ 'ScaledApi3FeedProxyV1' ] ;
0 commit comments