1- import { DeployFunction , DeploymentsExtension } from 'hardhat-deploy /types' ;
2- import { HardhatRuntimeEnvironment } from 'hardhat/types' ;
1+ import type { HardhatRuntimeEnvironment } from 'hardhat/types' ;
2+ import type { DeploymentsExtension } from 'hardhat-deploy /types' ;
33
44const deployTestProxy = async ( deployments : DeploymentsExtension , deployerAddress : string ) => {
5- const { address : inverseApi3ReaderProxyV1Address } = await deployments
6- . get ( " InverseApi3ReaderProxyV1" )
7- . catch ( async ( ) => {
8- return deployments . deploy ( " InverseApi3ReaderProxyV1" , {
9- from : deployerAddress ,
10- args : [ " 0x5b0cf2b36a65a6BB085D501B971e4c102B9Cd473" ] ,
11- log : true ,
12- } ) ;
13- } ) ;
14- return inverseApi3ReaderProxyV1Address ;
15- }
5+ const { address : inverseApi3ReaderProxyV1Address } = await deployments
6+ . get ( ' InverseApi3ReaderProxyV1' )
7+ . catch ( async ( ) => {
8+ return deployments . deploy ( ' InverseApi3ReaderProxyV1' , {
9+ from : deployerAddress ,
10+ args : [ ' 0x5b0cf2b36a65a6BB085D501B971e4c102B9Cd473' ] ,
11+ log : true ,
12+ } ) ;
13+ } ) ;
14+ return inverseApi3ReaderProxyV1Address ;
15+ } ;
1616
17- const func : DeployFunction = async function ( hre : HardhatRuntimeEnvironment ) {
18- const { deployments, getUnnamedAccounts, network } = hre ;
19- const { deploy, log } = deployments ;
17+ module . exports = async ( { getUnnamedAccounts, deployments, network, ethers } : HardhatRuntimeEnvironment ) => {
18+ const { deploy, log } = deployments ;
2019
21- const [ deployerAddress ] = await getUnnamedAccounts ( ) ;
22- if ( ! deployerAddress ) {
23- throw new Error ( " No deployer address found." ) ;
24- }
25- log ( `Deployer address: ${ deployerAddress } ` ) ;
20+ const [ deployerAddress ] = await getUnnamedAccounts ( ) ;
21+ if ( ! deployerAddress ) {
22+ throw new Error ( ' No deployer address found.' ) ;
23+ }
24+ log ( `Deployer address: ${ deployerAddress } ` ) ;
2625
27- const proxyAddress = network . name !== "hardhat" ? process . env . PROXY : await deployTestProxy ( deployments , deployerAddress ) ;
28- if ( ! proxyAddress ) {
29- throw new Error ( "PROXY environment variable not set. Please provide the address of the Api3ReaderProxy contract." ) ;
30- }
31- if ( ! hre . ethers . isAddress ( proxyAddress ) ) {
32- throw new Error ( `Invalid address provided for PROXY: ${ proxyAddress } ` ) ;
33- }
34- log ( `Proxy address: ${ proxyAddress } ` ) ;
26+ if ( ! process . env . DECIMALS ) {
27+ throw new Error ( 'DECIMALS environment variable not set. Please provide the number of decimals to use.' ) ;
28+ }
29+ const decimals = Number . parseInt ( process . env . DECIMALS , 10 ) ;
30+ log ( `Decimals: ${ decimals } ` ) ;
3531
36- const decimals = process . env . DECIMALS ? parseInt ( process . env . DECIMALS ) : 18 ;
37- log ( `Decimals: ${ decimals } ` ) ;
32+ const proxyAddress =
33+ network . name === 'hardhat' ? await deployTestProxy ( deployments , deployerAddress ) : process . env . PROXY ;
34+ if ( ! proxyAddress ) {
35+ throw new Error ( 'PROXY environment variable not set. Please provide the address of the Api3ReaderProxy contract.' ) ;
36+ }
37+ if ( ! ethers . isAddress ( proxyAddress ) ) {
38+ throw new Error ( `Invalid address provided for PROXY: ${ proxyAddress } ` ) ;
39+ }
40+ log ( `Proxy address: ${ proxyAddress } ` ) ;
3841
39- await deployments
40- . get ( "ScaledApi3FeedProxyV1" )
41- . catch ( async ( ) => {
42- return deploy ( "ScaledApi3FeedProxyV1" , {
43- from : deployerAddress ,
44- args : [ proxyAddress , decimals ] ,
45- log : true ,
46- } ) ;
47- } ) ;
42+ await deployments . get ( 'ScaledApi3FeedProxyV1' ) . catch ( async ( ) => {
43+ return deploy ( 'ScaledApi3FeedProxyV1' , {
44+ from : deployerAddress ,
45+ args : [ proxyAddress , decimals ] ,
46+ log : true ,
47+ } ) ;
48+ } ) ;
4849} ;
49-
50- export default func ;
51- func . tags = [ 'ScaledApi3FeedProxyV1' ] ;
50+ module . exports . tags = [ 'ScaledApi3FeedProxyV1' ] ;
0 commit comments