Skip to content
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

cli: add a --network option for the actions approve command #783

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/indexer-cli/src/commands/indexer/actions/approve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import {
fixParameters,
printObjectOrArray,
parseOutputFormat,
extractProtocolNetworkOption,
} from '../../../command-helpers'
import { approveActions, fetchActions } from '../../../actions'
import { ActionStatus, resolveChainAlias } from '@graphprotocol/indexer-common'

const HELP = `
${chalk.bold('graph indexer actions approve')} [options] [<actionID1> ...]
${chalk.bold('graph indexer actions approve')} [options] queued
${chalk.bold('graph indexer actions approve')} [options] queued --network <networkName>

${chalk.dim('Options:')}

-h, --help Show usage information
-n, --network <STRING> Filter action selection by their protocol network (mainnet, arbitrum-one, goerli, arbitrum-goerli)
-o, --output table|json|yaml Choose the output format: table (default), JSON, or YAML
`

Expand Down Expand Up @@ -45,6 +47,7 @@ module.exports = {
return
}

const protocolNetwork = extractProtocolNetworkOption(parameters.options)
let numericActionIDs: number[]

const config = loadValidatedConfig()
Expand All @@ -56,12 +59,19 @@ module.exports = {

// If actionIDs is 'queued', then populate actionIDs with actions that are queued
if (actionIDs.join() == 'queued') {
if (!protocolNetwork) {
throw new Error(
`Missing required option for approving queued actions: --network`,
)
}
const queuedActions = await fetchActions(client, {
status: ActionStatus.QUEUED,
protocolNetwork,
})

numericActionIDs = queuedActions.map(action => action.id)
if (numericActionIDs.length === 0) {
throw Error(`No 'queued' actions found`)
throw Error(`No 'queued' actions found for network '${protocolNetwork}'`)
}
} else {
numericActionIDs = actionIDs.map(action => +action)
Expand Down