Make contract manager evm chains accept rpc urls
This commit is contained in:
parent
9cec35b251
commit
497a52bb94
|
@ -26,7 +26,11 @@ async function main() {
|
|||
contract instanceof EvmContract ||
|
||||
contract instanceof CosmWasmContract
|
||||
) {
|
||||
try {
|
||||
console.log(`${contract.getId()} ${await contract.getTotalFee()}`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,7 +264,23 @@ export class EvmChain extends Chain {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the chain rpc url with any environment variables replaced or throws an error if any are missing
|
||||
*/
|
||||
getRpcUrl(): string {
|
||||
const envMatches = this.rpcUrl.match(/\$ENV_\w+/);
|
||||
if (envMatches) {
|
||||
for (const envMatch of envMatches) {
|
||||
const envName = envMatch.replace("$ENV_", "");
|
||||
const envValue = process.env[envName];
|
||||
if (!envValue) {
|
||||
throw new Error(
|
||||
`Missing env variable ${envName} required for chain ${this.id} rpc: ${this.rpcUrl}`
|
||||
);
|
||||
}
|
||||
this.rpcUrl = this.rpcUrl.replace(envMatch, envValue);
|
||||
}
|
||||
}
|
||||
return this.rpcUrl;
|
||||
}
|
||||
|
||||
|
|
|
@ -319,12 +319,12 @@
|
|||
- id: saigon
|
||||
wormholeChainName: ronin
|
||||
mainnet: false
|
||||
rpcUrl: https://api-gateway.skymavis.com/rpc/testnet?apikey=put-me-here-from-ronin-wallet
|
||||
rpcUrl: https://api-gateway.skymavis.com/rpc/testnet?apikey=$ENV_RONIN_API_KEY
|
||||
networkId: 2021
|
||||
type: EvmChain
|
||||
- id: ronin
|
||||
wormholeChainName: ronin
|
||||
mainnet: true
|
||||
rpcUrl: https://api-gateway.skymavis.com/rpc?apikey=put-me-here-from-ronin-wallet
|
||||
rpcUrl: https://api-gateway.skymavis.com/rpc?apikey=$ENV_RONIN_API_KEY
|
||||
networkId: 2020
|
||||
type: EvmChain
|
||||
|
|
Loading…
Reference in New Issue