File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,11 @@ async function main() {
26
26
contract instanceof EvmContract ||
27
27
contract instanceof CosmWasmContract
28
28
) {
29
- console . log ( `${ contract . getId ( ) } ${ await contract . getTotalFee ( ) } ` ) ;
29
+ try {
30
+ console . log ( `${ contract . getId ( ) } ${ await contract . getTotalFee ( ) } ` ) ;
31
+ } catch ( e ) {
32
+ console . error ( e ) ;
33
+ }
30
34
}
31
35
}
32
36
}
Original file line number Diff line number Diff line change @@ -264,7 +264,23 @@ export class EvmChain extends Chain {
264
264
) ;
265
265
}
266
266
267
+ /**
268
+ * Returns the chain rpc url with any environment variables replaced or throws an error if any are missing
269
+ */
267
270
getRpcUrl ( ) : string {
271
+ const envMatches = this . rpcUrl . match ( / \$ E N V _ \w + / ) ;
272
+ if ( envMatches ) {
273
+ for ( const envMatch of envMatches ) {
274
+ const envName = envMatch . replace ( "$ENV_" , "" ) ;
275
+ const envValue = process . env [ envName ] ;
276
+ if ( ! envValue ) {
277
+ throw new Error (
278
+ `Missing env variable ${ envName } required for chain ${ this . id } rpc: ${ this . rpcUrl } `
279
+ ) ;
280
+ }
281
+ this . rpcUrl = this . rpcUrl . replace ( envMatch , envValue ) ;
282
+ }
283
+ }
268
284
return this . rpcUrl ;
269
285
}
270
286
Original file line number Diff line number Diff line change 319
319
- id : saigon
320
320
wormholeChainName : ronin
321
321
mainnet : false
322
- rpcUrl : https://api-gateway.skymavis.com/rpc/testnet?apikey=put-me-here-from-ronin-wallet
322
+ rpcUrl : https://api-gateway.skymavis.com/rpc/testnet?apikey=$ENV_RONIN_API_KEY
323
323
networkId : 2021
324
324
type : EvmChain
325
325
- id : ronin
326
326
wormholeChainName : ronin
327
327
mainnet : true
328
- rpcUrl : https://api-gateway.skymavis.com/rpc?apikey=put-me-here-from-ronin-wallet
328
+ rpcUrl : https://api-gateway.skymavis.com/rpc?apikey=$ENV_RONIN_API_KEY
329
329
networkId : 2020
330
330
type : EvmChain
You can’t perform that action at this time.
0 commit comments