Skip to content

Commit

Permalink
add upload-instantiate subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
eguajardo committed Jan 9, 2025
1 parent 0552e38 commit 435be0d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
35 changes: 11 additions & 24 deletions cosmwasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,35 +112,22 @@ This folder contains deployment scripts for cosmwasm contracts needed for amplif

Deploy each contract. Chain name should match the key of an object in the `chains` section of the config. Chain name should be omitted for contracts that are not chain specific.

`node deploy-contract.js [subcommand] -m [mnemonic] -a [path to contract artifacts] -c [contract name] -e [environment] -n <chain name>`
`node deploy-contract.js [upload|instantiate|upload-instantiate] -m [mnemonic] -a [path to contract artifacts] -c [contract name] -e [environment] -n <chain name>`

Some of the contracts depend on each other and need to be deployed in a specific order. Note the connection router and axelarnet gateway each need to know the other's address, so you need to pass `--instantiate2`, and upload both contract before instatiating them.

Upload:

1. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "AxelarnetGateway" --instantiate2 -e devnet`
2. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "Router" --instantiate2 -e devnet`
3. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "ServiceRegistry" -e devnet`
4. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "Rewards" -e devnet`
5. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "Coordinator" -e devnet`
6. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "Multisig" -e devnet`
7. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "InterchainTokenService" -e devnet`
8. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "VotingVerifier" -e devnet -n "avalanche"`
9. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "Gateway" -e devnet -n "avalanche"`
10. `node deploy-contract.js upload -m [mnemonic] -a [path to artifacts] -c "MultisigProver" -e devnet -n "avalanche"`

Instantiate:

1. `node deploy-contract.js instantiate -m [mnemonic] -c "AxelarnetGateway" --instantiate2 -e devnet`
2. `node deploy-contract.js instantiate -m [mnemonic] -c "Router" --instantiate2 -e devnet`
3. `node deploy-contract.js instantiate -m [mnemonic] -c "ServiceRegistry" -e devnet`
4. `node deploy-contract.js instantiate -m [mnemonic] -c "Rewards" -e devnet`
5. `node deploy-contract.js instantiate -m [mnemonic] -c "Coordinator" -e devnet`
6. `node deploy-contract.js instantiate -m [mnemonic] -c "Multisig" -e devnet`
7. `node deploy-contract.js instantiate -m [mnemonic] -c "InterchainTokenService" -e devnet`
8. `node deploy-contract.js instantiate -m [mnemonic] -c "VotingVerifier" -e devnet -n "avalanche"`
9. `node deploy-contract.js instantiate -m [mnemonic] -c "Gateway" -e devnet -n "avalanche"`
10. `node deploy-contract.js instantiate -m [mnemonic] -c "MultisigProver" -e devnet -n "avalanche"`
3. `node deploy-contract.js instantiate -m [mnemonic] -c "AxelarnetGateway" --instantiate2 -e devnet`
4. `node deploy-contract.js instantiate -m [mnemonic] -c "Router" --instantiate2 -e devnet`
5. `node deploy-contract.js upload-instantiate -m [mnemonic] -a [path to artifacts] -c "ServiceRegistry" -e devnet`
6. `node deploy-contract.js upload-instantiate -m [mnemonic] -a [path to artifacts] -c "Rewards" -e devnet`
7. `node deploy-contract.js upload-instantiate -m [mnemonic] -a [path to artifacts] -c "Coordinator" -e devnet`
8. `node deploy-contract.js upload-instantiate -m [mnemonic] -a [path to artifacts] -c "Multisig" -e devnet`
9. `node deploy-contract.js upload-instantiate -m [mnemonic] -a [path to artifacts] -c "InterchainTokenService" -e devnet`
10. `node deploy-contract.js upload-instantiate -m [mnemonic] -a [path to artifacts] -c "VotingVerifier" -e devnet -n "avalanche"`
11. `node deploy-contract.js upload-instantiate -m [mnemonic] -a [path to artifacts] -c "Gateway" -e devnet -n "avalanche"`
12. `node deploy-contract.js upload-instantiate -m [mnemonic] -a [path to artifacts] -c "MultisigProver" -e devnet -n "avalanche"`

### Constant Address Deployment

Expand Down
18 changes: 18 additions & 0 deletions cosmwasm/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ const instantiate = async (client, wallet, config, options) => {
printInfo(`Instantiated ${chainName ? chainName.concat(' ') : ''}${contractName}. Address`, contractAddress);
};

const uploadInstantiate = async (client, wallet, config, options) => {
await upload(client, wallet, config, options);
await instantiate(client, wallet, config, options);
};

const mainProcessor = async (processor, options) => {
const { env } = options;
const config = loadConfig(env);
Expand Down Expand Up @@ -109,6 +114,19 @@ const programHandler = () => {
fetchCodeId: true,
});

const uploadInstantiateCmd = program
.command('upload-instantiate')
.description('Upload wasm binary and instantiate contract')
.action((options) => {
mainProcessor(uploadInstantiate, options);
});
addAmplifierOptions(uploadInstantiateCmd, {
contractOptions: true,
storeOptions: true,
instantiateOptions: true,
instantiate2Options: true,
});

program.parse();
};

Expand Down

0 comments on commit 435be0d

Please sign in to comment.