From d14b237a345d6889e3739ca8703d030f2cc02bb1 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Mon, 25 Sep 2023 07:35:33 -0700 Subject: [PATCH] feat!: generalize ec cmd to gov any committee --- packages/agoric-cli/src/bin-agops.js | 4 +-- .../agoric-cli/src/commands/{ec.js => gov.js} | 29 ++++++++++++------- .../test/agops-governance-smoketest.sh | 10 +++---- 3 files changed, 25 insertions(+), 18 deletions(-) rename packages/agoric-cli/src/commands/{ec.js => gov.js} (91%) diff --git a/packages/agoric-cli/src/bin-agops.js b/packages/agoric-cli/src/bin-agops.js index daeaf9c0e6f2..1f8933530554 100755 --- a/packages/agoric-cli/src/bin-agops.js +++ b/packages/agoric-cli/src/bin-agops.js @@ -18,7 +18,7 @@ import process from 'process'; import anylogger from 'anylogger'; import { Command, CommanderError, createCommand } from 'commander'; import { makeOracleCommand } from './commands/oracle.js'; -import { makeEconomicCommiteeCommand } from './commands/ec.js'; +import { makeGovCommand } from './commands/gov.js'; import { makePsmCommand } from './commands/psm.js'; import { makeReserveCommand } from './commands/reserve.js'; import { makeVaultsCommand } from './commands/vaults.js'; @@ -34,7 +34,7 @@ const program = new Command(); program.name(progname).version('unversioned'); program.addCommand(makeOracleCommand(logger)); -program.addCommand(makeEconomicCommiteeCommand(logger)); +program.addCommand(makeGovCommand(logger)); program.addCommand(makePerfCommand(logger)); program.addCommand(makePsmCommand(logger)); program.addCommand(makeVaultsCommand(logger)); diff --git a/packages/agoric-cli/src/commands/ec.js b/packages/agoric-cli/src/commands/gov.js similarity index 91% rename from packages/agoric-cli/src/commands/ec.js rename to packages/agoric-cli/src/commands/gov.js index 0282ae39ccd4..09074c1fbfe6 100644 --- a/packages/agoric-cli/src/commands/ec.js +++ b/packages/agoric-cli/src/commands/gov.js @@ -26,7 +26,7 @@ import { * delay?: (ms: number) => Promise, * }} [io] */ -export const makeEconomicCommiteeCommand = (_logger, io = {}) => { +export const makeGovCommand = (_logger, io = {}) => { const { // Allow caller to provide access explicitly, but // default to conventional ambient IO facilities. @@ -127,7 +127,8 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => { }; ec.command('committee') - .description('accept invitation to join the economic committee') + .description('accept invitation to join a committee') + .requiredOption('--name string', 'Committee instance name') .option('--voter ', 'Voter number', Number, 0) .option( '--offerId ', @@ -141,14 +142,16 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => { normalizeAddress, ) .action(async function (opts) { + const { instanceName } = opts.name; + /** @type {Parameters[0]['toOffer']} */ const toOffer = (agoricNames, current) => { - const instance = agoricNames.instance.economicCommittee; - assert(instance, `missing economicCommittee`); + const instance = agoricNames.instance[instanceName]; + assert(instance, `missing ${instanceName}`); if (current) { const found = findContinuingIds(current, agoricNames); - abortIfSeen('economicCommittee', found); + abortIfSeen(instanceName, found); } return { @@ -164,13 +167,14 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => { await processOffer({ toOffer, - instanceName: 'economicCommittee', + instanceName, ...opts, }); }); ec.command('charter') .description('accept the charter invitation') + .requiredOption('--name string', 'Charter instance name') .option('--offerId ', 'Offer id', String, `ecCharter-${Date.now()}`) .option( '--send-from ', @@ -178,14 +182,16 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => { normalizeAddress, ) .action(async function (opts) { + const { instanceName } = opts.name; + /** @type {Parameters[0]['toOffer']} */ const toOffer = (agoricNames, current) => { - const instance = agoricNames.instance.econCommitteeCharter; - assert(instance, `missing econCommitteeCharter`); + const instance = agoricNames.instance[instanceName]; + assert(instance, `missing ${instanceName}`); if (current) { const found = findContinuingIds(current, agoricNames); - abortIfSeen('econCommitteeCharter', found); + abortIfSeen(instanceName, found); } return { @@ -201,7 +207,7 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => { await processOffer({ toOffer, - instanceName: 'econCommitteeCharter', + instanceName, ...opts, }); }); @@ -249,6 +255,7 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => { ec.command('vote') .description('vote on a question (hard-coded for now))') + .requiredOption('--committeeName', 'Committee instance name', String) .option('--offerId ', 'Offer id', String, `ecVote-${Date.now()}`) .requiredOption( '--forPosition ', @@ -280,7 +287,7 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => { const toOffer = (agoricNames, current) => { const cont = current ? findContinuingIds(current, agoricNames) : []; const votingRight = cont.find( - it => it.instance === agoricNames.instance.economicCommittee, + it => it.instance === agoricNames.instance[opts.committeeName], ); if (!votingRight) { console.debug('continuing ids', cont, 'for', current); diff --git a/packages/agoric-cli/test/agops-governance-smoketest.sh b/packages/agoric-cli/test/agops-governance-smoketest.sh index b0eb943fd80c..54e64eb814dd 100644 --- a/packages/agoric-cli/test/agops-governance-smoketest.sh +++ b/packages/agoric-cli/test/agops-governance-smoketest.sh @@ -20,10 +20,10 @@ set -x # NB: fee percentages must be at least the governed param values # Accept invitation to economic committee -bin/agops ec committee --send-from gov1 +bin/agops gov committee --name economicCommittee --send-from gov1 # Accept invitation to be a charter member -bin/agops ec charter --send-from gov1 +bin/agops gov charter --name economicCommitteeCharter --send-from gov1 ### Now we have the continuing invitationMakers saved in the wallet @@ -34,7 +34,7 @@ agoric wallet print --file "$PROPOSAL_OFFER" agoric wallet send --offer "$PROPOSAL_OFFER" --from gov1 --keyring-backend="test" # vote on the question that was made -bin/agops ec vote --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID" +bin/agops gov vote --committeeName economicCommittee --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID" ## wait for the election to be resolved (1m in commands/psm.js) # FIXME this one failing with: Error: cannot grab 10002ibc/toyellie coins: 0ibc/toyellie is smaller than 10002ibc/toyellie: insufficient funds @@ -64,7 +64,7 @@ agoric wallet send --offer "$PROPOSAL_OFFER" --from gov1 --keyring-backend="test # agoric -B $networkConfig follow published.committees.Economic_Committee.latestQuestion # vote on the question that was made -bin/agops ec vote --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID" +bin/agops gov vote --committeeName economicCommittee --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID" ## wait for the election to be resolved (1m default in commands/psm.js) # to see the new MintLimit @@ -77,4 +77,4 @@ agoric wallet print --file "$PROPOSAL_OFFER" agoric wallet send --offer "$PROPOSAL_OFFER" --from gov1 --keyring-backend="test" # Vote for the API call -bin/agops ec vote --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID" +bin/agops gov vote --committeeName economicCommittee --forPosition 0 --send-from gov1 --keyring-backend="test" "$COMMITTEE_OFFER_ID"