Skip to content

Commit 497a52b

Browse files
m30mali-behjati
authored andcommitted
Make contract manager evm chains accept rpc urls
1 parent 9cec35b commit 497a52b

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

contract_manager/scripts/fetch_fees.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

contract_manager/src/chains.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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(/\$ENV_\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

contract_manager/store/chains/EvmChains.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,12 @@
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

0 commit comments

Comments
 (0)