@@ -4,6 +4,8 @@ import { EvmChain } from "../src/chains";
4
4
import { DefaultStore } from "../src/store" ;
5
5
import {
6
6
DeploymentType ,
7
+ ENTROPY_DEFAULT_KEEPER ,
8
+ ENTROPY_DEFAULT_PROVIDER ,
7
9
EvmEntropyContract ,
8
10
getDefaultDeploymentConfig ,
9
11
toDeploymentType ,
@@ -24,10 +26,6 @@ interface DeploymentConfig extends BaseDeployConfig {
24
26
}
25
27
26
28
const CACHE_FILE = ".cache-deploy-evm-entropy-contracts" ;
27
- const ENTROPY_DEFAULT_PROVIDER = {
28
- mainnet : "0x52DeaA1c84233F7bb8C8A45baeDE41091c616506" ,
29
- testnet : "0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344" ,
30
- } ;
31
29
32
30
const parser = yargs ( hideBin ( process . argv ) )
33
31
. scriptName ( "deploy_evm_entropy_contracts.ts" )
@@ -125,34 +123,42 @@ async function deployEntropyContracts(
125
123
) ;
126
124
}
127
125
128
- async function topupProviderIfNecessary (
126
+ async function topupAccountsIfNecessary (
129
127
chain : EvmChain ,
130
128
deploymentConfig : DeploymentConfig
131
129
) {
132
- const provider = chain . isMainnet ( )
133
- ? ENTROPY_DEFAULT_PROVIDER . mainnet
134
- : ENTROPY_DEFAULT_PROVIDER . testnet ;
135
- const web3 = new Web3 ( chain . getRpcUrl ( ) ) ;
136
- const balance = Number (
137
- web3 . utils . fromWei ( await web3 . eth . getBalance ( provider ) , "ether" )
138
- ) ;
139
- const MIN_BALANCE = 0.01 ;
140
- console . log ( `Provider balance: ${ balance } ETH` ) ;
141
- if ( balance < MIN_BALANCE ) {
142
- console . log (
143
- `Balance is less than ${ MIN_BALANCE } . Topping up the provider address...`
144
- ) ;
145
- const signer = web3 . eth . accounts . privateKeyToAccount (
146
- deploymentConfig . privateKey
130
+ for ( const [ accountName , defaultAddresses ] of [
131
+ [ "keeper" , ENTROPY_DEFAULT_KEEPER ] ,
132
+ [ "provider" , ENTROPY_DEFAULT_PROVIDER ] ,
133
+ ] as const ) {
134
+ const accountAddress = chain . isMainnet ( )
135
+ ? defaultAddresses . mainnet
136
+ : defaultAddresses . testnet ;
137
+ const web3 = new Web3 ( chain . getRpcUrl ( ) ) ;
138
+ const balance = Number (
139
+ web3 . utils . fromWei ( await web3 . eth . getBalance ( accountAddress ) , "ether" )
147
140
) ;
148
- web3 . eth . accounts . wallet . add ( signer ) ;
149
- const tx = await web3 . eth . sendTransaction ( {
150
- from : signer . address ,
151
- to : provider ,
152
- gas : 30000 ,
153
- value : web3 . utils . toWei ( `${ MIN_BALANCE } ` , "ether" ) ,
154
- } ) ;
155
- console . log ( "Topped up the provider address. Tx: " , tx . transactionHash ) ;
141
+ const MIN_BALANCE = 0.01 ;
142
+ console . log ( `${ accountName } balance: ${ balance } ETH` ) ;
143
+ if ( balance < MIN_BALANCE ) {
144
+ console . log (
145
+ `Balance is less than ${ MIN_BALANCE } . Topping up the ${ accountName } address...`
146
+ ) ;
147
+ const signer = web3 . eth . accounts . privateKeyToAccount (
148
+ deploymentConfig . privateKey
149
+ ) ;
150
+ web3 . eth . accounts . wallet . add ( signer ) ;
151
+ const tx = await web3 . eth . sendTransaction ( {
152
+ from : signer . address ,
153
+ to : accountAddress ,
154
+ gas : 30000 ,
155
+ value : web3 . utils . toWei ( `${ MIN_BALANCE } ` , "ether" ) ,
156
+ } ) ;
157
+ console . log (
158
+ `Topped up the ${ accountName } address. Tx: ` ,
159
+ tx . transactionHash
160
+ ) ;
161
+ }
156
162
}
157
163
}
158
164
@@ -182,7 +188,7 @@ async function main() {
182
188
CACHE_FILE
183
189
) ;
184
190
185
- await topupProviderIfNecessary ( chain , deploymentConfig ) ;
191
+ await topupAccountsIfNecessary ( chain , deploymentConfig ) ;
186
192
187
193
console . log (
188
194
`Deployment config: ${ JSON . stringify ( deploymentConfig , null , 2 ) } \n`
0 commit comments