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() {
2626 contract instanceof EvmContract ||
2727 contract instanceof CosmWasmContract
2828 ) {
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+ }
3034 }
3135 }
3236}
Original file line number Diff line number Diff line change @@ -264,7 +264,23 @@ export class EvmChain extends Chain {
264264 ) ;
265265 }
266266
267+ /**
268+ * Returns the chain rpc url with any environment variables replaced or throws an error if any are missing
269+ */
267270 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+ }
268284 return this . rpcUrl ;
269285 }
270286
Original file line number Diff line number Diff line change 319319- id : saigon
320320 wormholeChainName : ronin
321321 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
323323 networkId : 2021
324324 type : EvmChain
325325- id : ronin
326326 wormholeChainName : ronin
327327 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
329329 networkId : 2020
330330 type : EvmChain
You can’t perform that action at this time.
0 commit comments