-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(mainnet): support running examples on mainnet #189
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,12 +38,12 @@ function getEVMChains(env, chains = []) { | |
return fs.readJsonSync(configPath.localEvmChains).filter((chain) => selectedChains.includes(chain.name)); | ||
} | ||
|
||
const testnet = getTestnetChains(selectedChains); | ||
const configs = env === 'mainnet' ? getMainnetChains(selectedChains) : getTestnetChains(selectedChains); | ||
|
||
return testnet.map((chain) => ({ | ||
...chain, | ||
gateway: chain.contracts.AxelarGateway.address, | ||
gasService: chain.contracts.AxelarGasService.address, | ||
return configs.map((config) => ({ | ||
...config, | ||
gateway: config.contracts.AxelarGateway.address, | ||
gasService: config.contracts.AxelarGasService.address, | ||
})); | ||
} | ||
|
||
|
@@ -57,7 +57,7 @@ function getTestnetChains(chains = []) { | |
let testnet = []; | ||
if (fs.existsSync(_path)) { | ||
testnet = fs | ||
.readJsonSync(path.join(__dirname, '../../chain-config/testnet-evm.json')) | ||
.readJsonSync(_path) | ||
.filter((chain) => chains.includes(chain.name)); | ||
} | ||
|
||
|
@@ -79,6 +79,33 @@ function getTestnetChains(chains = []) { | |
})); | ||
} | ||
|
||
/** | ||
* Get chains config for testnet. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. testnet -> mainnet |
||
* @param {*} chains - The list of chains to get the chain objects for. If this is empty, the default chains will be used. | ||
* @returns {Chain[]} - The chain objects. | ||
*/ | ||
function getMainnetChains(chains = []) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code duplication. reuse the same function, just make the path derivation dependent on env |
||
const _path = path.join(__dirname, '../../chain-config/mainnet-evm.json'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where does this file come from? why don't we just import the info files the axelar-chain-configs package published in deployments repo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It creates its own local config file and writes info for contracts deployed by examples. |
||
let mainnet = []; | ||
if (fs.existsSync(_path)) { | ||
mainnet = fs | ||
.readJsonSync(_path) | ||
.filter((chain) => chains.includes(chain.name)); | ||
} | ||
|
||
if (mainnet.length < chains.length) { | ||
const { mainnetInfo } = require('@axelar-network/axelar-local-dev'); | ||
mainnet = []; | ||
for (const chain of chains) { | ||
mainnet.push(mainnetInfo[chain.toLowerCase()]); | ||
} | ||
} | ||
|
||
// temporary fix for gas service contract address | ||
|
||
return mainnet; | ||
} | ||
|
||
/** | ||
* Get the balances of an address on a list of chains. | ||
* @param {*} chains - The list of chains to get the balances from. | ||
|
@@ -187,7 +214,7 @@ function checkWallet() { | |
* @param {*} env - The environment to check. Available options are 'local' and 'testnet'. | ||
*/ | ||
function checkEnv(env) { | ||
if (env == null || (env !== 'testnet' && env !== 'local')) { | ||
if (env == null || (env !== 'mainnet' && env !== 'testnet' && env !== 'local')) { | ||
throw new Error('Need to specify testnet or local as an argument to this script.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update error msg with mainnet as an option. |
||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this temporary fix needed anymore? we expose the gas service address in the config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a fix just a refactoring the same path was already defined as a variable
path