Skip to content

Commit

Permalink
Merge branch 'main' into network-config-proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
tilacog authored Oct 24, 2022
2 parents 64c99df + c7d670c commit dfa66ad
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/indexer-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@graphprotocol/common-ts": "1.8.6",
"@graphprotocol/contracts": "1.13.0",
"@graphprotocol/contracts": "1.16.0",
"@graphprotocol/indexer-common": "^0.20.4",
"@thi.ng/heaps": "^1.3.1",
"@uniswap/sdk": "3.0.3",
Expand Down
11 changes: 9 additions & 2 deletions packages/indexer-cli/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export async function fetchAction(
export async function fetchActions(
client: IndexerManagementClient,
actionFilter: ActionFilter,
first?: number,
orderBy?: ActionParams,
orderDirection?: OrderDirection,
): Promise<ActionResult[]> {
Expand All @@ -284,10 +285,16 @@ export async function fetchActions(
gql`
query actions(
$filter: ActionFilter!
$first: Int
$orderBy: ActionParams
$orderDirection: OrderDirection
) {
actions(filter: $filter, orderBy: $orderBy, orderDirection: $orderDirection) {
actions(
filter: $filter
orderBy: $orderBy
orderDirection: $orderDirection
first: $first
) {
id
type
allocationID
Expand All @@ -304,7 +311,7 @@ export async function fetchActions(
}
}
`,
{ filter: actionFilter, orderBy, orderDirection },
{ filter: actionFilter, orderBy, orderDirection, first },
)
.toPromise()

Expand Down
33 changes: 28 additions & 5 deletions packages/indexer-cli/src/commands/indexer/actions/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ ${chalk.dim('Options:')}
-h, --help Show usage information
--type allocate|unallocate|reallocate|collect Filter by type
--status queued|approved|pending|success|failed|canceled Filter by status
--status queued|approved|pending|success|failed|canceled Filter by status
--source <source> Fetch only actions queued by a specific source
--reason <reason> Fetch only actions queued for a specific reason
--orderBy id|deploymentID|amount|priority|...|updatedAt Order actions by a specific field (default: id)
--orderDirection asc|desc Order direction (default: desc)
--first [N] Fetch only the N first records (default: all records)
-o, --output table|json|yaml Choose the output format: table (default), JSON, or YAML
`

Expand All @@ -38,8 +39,19 @@ module.exports = {

const inputSpinner = toolbox.print.spin('Processing inputs')

const { type, status, source, reason, orderBy, orderDirection, h, help, o, output } =
parameters.options
const {
type,
status,
source,
reason,
orderBy,
orderDirection,
h,
help,
o,
output,
first,
} = parameters.options

const [action] = fixParameters(parameters, { h, help }) || []
let orderByParam = ActionParams.ID
Expand All @@ -50,7 +62,6 @@ module.exports = {
inputSpinner.stopAndPersist({ symbol: '💁', text: HELP })
return
}

try {
if (!['json', 'yaml', 'table'].includes(outputFormat)) {
throw Error(
Expand Down Expand Up @@ -91,6 +102,11 @@ module.exports = {
? OrderDirection[orderDirection.toUpperCase() as keyof typeof OrderDirection]
: OrderDirection.DESC
}

if (!['undefined', 'number'].includes(typeof first)) {
throw Error(`Invalid value for '--first' option, must have a numeric value.`)
}

inputSpinner.succeed('Processed input parameters')
} catch (error) {
inputSpinner.fail(error.toString())
Expand All @@ -110,7 +126,13 @@ module.exports = {
let actions: ActionResult[] = []
if (action) {
if (action === 'all') {
actions = await fetchActions(client, {}, orderByParam, orderDirectionValue)
actions = await fetchActions(
client,
{},
first,
orderByParam,
orderDirectionValue,
)
} else {
actions = [await fetchAction(client, +action)]
}
Expand All @@ -123,6 +145,7 @@ module.exports = {
source,
reason,
},
first,
orderByParam,
orderDirectionValue,
)
Expand Down
2 changes: 2 additions & 0 deletions packages/indexer-common/src/indexer-management/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class ActionManager {
filter: ActionFilter,
orderBy?: ActionParams,
orderDirection?: OrderDirection,
first?: number,
): Promise<Action[]> {
const filterObject = JSON.parse(JSON.stringify(filter))
const orderObject: Order = orderBy
Expand All @@ -165,6 +166,7 @@ export class ActionManager {
return await this.models.Action.findAll({
where: filterObject,
order: orderObject,
limit: first,
})
}
}
1 change: 1 addition & 0 deletions packages/indexer-common/src/indexer-management/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ const SCHEMA_SDL = gql`
filter: ActionFilter
orderBy: ActionParams
orderDirection: OrderDirection
first: Int
): [Action]!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,22 @@ export default {
filter,
orderBy,
orderDirection,
}: { filter: ActionFilter; orderBy: ActionParams; orderDirection: OrderDirection },
first,
}: {
filter: ActionFilter
orderBy: ActionParams
orderDirection: OrderDirection
first: number
},
{ actionManager, logger }: IndexerManagementResolverContext,
): Promise<object[]> => {
logger.debug(`Execute 'actions' query`, {
filter,
orderBy,
orderDirection,
first,
})
return await actionManager.fetchActions(filter, orderBy, orderDirection)
return await actionManager.fetchActions(filter, orderBy, orderDirection, first)
},

queueActions: async (
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,13 @@
dependencies:
ethers "^5.4.4"

"@graphprotocol/[email protected]":
version "1.16.0"
resolved "https://registry.yarnpkg.com/@graphprotocol/contracts/-/contracts-1.16.0.tgz#3ecc43277b4da8ccbd14fb6ea42c93c888e52d53"
integrity sha512-/UldTtx6/GbeNqWlMf2P3a4l6gQYEiNdG+FooUfDQYansnOmLCe+vmnRnh+w2cnf3L6KteX2Qxih4ajI7q1gcQ==
dependencies:
ethers "^5.4.4"

"@graphprotocol/[email protected]":
version "0.1.14"
resolved "https://registry.npmjs.org/@graphprotocol/cost-model/-/cost-model-0.1.14.tgz#0eeab1c3c63d94600c2cc67e46965e0ba65b2353"
Expand Down

0 comments on commit dfa66ad

Please sign in to comment.