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 EvmContract ||
|
||||||
contract instanceof CosmWasmContract
|
contract instanceof CosmWasmContract
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
console.log(`${contract.getId()} ${await contract.getTotalFee()}`);
|
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 {
|
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;
|
return this.rpcUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -319,12 +319,12 @@
|
||||||
- id: saigon
|
- id: saigon
|
||||||
wormholeChainName: ronin
|
wormholeChainName: ronin
|
||||||
mainnet: false
|
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
|
networkId: 2021
|
||||||
type: EvmChain
|
type: EvmChain
|
||||||
- id: ronin
|
- id: ronin
|
||||||
wormholeChainName: ronin
|
wormholeChainName: ronin
|
||||||
mainnet: true
|
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
|
networkId: 2020
|
||||||
type: EvmChain
|
type: EvmChain
|
||||||
|
|
Loading…
Reference in New Issue