-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/cosmwasm-migrate
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
|
||
require('dotenv').config(); | ||
|
||
const { printInfo, loadConfig, saveConfig } = require('../common'); | ||
const { prepareWallet, prepareClient, initContractConfig, getAmplifierContractConfig, fetchCodeIdFromContract } = require('./utils'); | ||
|
||
const { Command } = require('commander'); | ||
const { addAmplifierOptions } = require('./cli-utils'); | ||
|
||
const processCommand = async (options) => { | ||
const { env } = options; | ||
const config = loadConfig(env); | ||
|
||
initContractConfig(config, options); | ||
|
||
const wallet = await prepareWallet(options); | ||
const client = await prepareClient(config, wallet); | ||
|
||
const { contractConfig } = getAmplifierContractConfig(config, options); | ||
|
||
printInfo('Old code id', contractConfig.codeId); | ||
|
||
contractConfig.codeId = await fetchCodeIdFromContract(client, contractConfig); | ||
|
||
printInfo('New code id', contractConfig.codeId); | ||
|
||
saveConfig(config, env); | ||
}; | ||
|
||
const programHandler = () => { | ||
const program = new Command(); | ||
|
||
program.name('update-code-id').description('Update configured code id of contract with the one currently being used on-chain'); | ||
|
||
addAmplifierOptions(program, { | ||
contractOptions: true, | ||
}); | ||
|
||
program.action((options) => { | ||
processCommand(options); | ||
}); | ||
|
||
program.parse(); | ||
}; | ||
|
||
if (require.main === module) { | ||
programHandler(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters