Skip to content

Commit beed3a7

Browse files
committed
cli: remove protocolNetwork from allocations commands
1 parent 06a3798 commit beed3a7

File tree

6 files changed

+12
-117
lines changed

6 files changed

+12
-117
lines changed

packages/indexer-cli/src/allocations.ts

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
CloseAllocationResult,
1111
CreateAllocationResult,
1212
ReallocateAllocationResult,
13-
resolveChainAlias,
1413
} from '@graphprotocol/indexer-common'
1514

1615
export interface IndexerAllocation {
@@ -29,7 +28,6 @@ export interface IndexerAllocation {
2928
indexingRewards: BigNumber
3029
queryFeesCollected: BigNumber
3130
status: string
32-
protocolNetwork: string
3331
}
3432

3533
const ALLOCATION_CONVERTERS_FROM_GRAPHQL: Record<
@@ -53,7 +51,6 @@ const ALLOCATION_CONVERTERS_FROM_GRAPHQL: Record<
5351
indexingRewards: nullPassThrough((x: string) => BigNumber.from(x)),
5452
queryFeesCollected: nullPassThrough((x: string) => BigNumber.from(x)),
5553
status: x => x,
56-
protocolNetwork: x => x,
5754
}
5855

5956
const ALLOCATION_FORMATTERS: Record<
@@ -76,7 +73,6 @@ const ALLOCATION_FORMATTERS: Record<
7673
indexingRewards: x => utils.commify(formatGRT(x)),
7774
queryFeesCollected: x => utils.commify(formatGRT(x)),
7875
status: x => x,
79-
protocolNetwork: resolveChainAlias,
8076
}
8177

8278
/**
@@ -175,35 +171,30 @@ export const createAllocation = async (
175171
deployment: string,
176172
amount: BigNumber,
177173
indexNode: string | undefined,
178-
protocolNetwork: string,
179174
): Promise<CreateAllocationResult> => {
180175
const result = await client
181176
.mutation(
182177
gql`
183178
mutation createAllocation(
184179
$deployment: String!
185180
$amount: String!
186-
$protocolNetwork: String!
187181
$indexNode: String
188182
) {
189183
createAllocation(
190184
deployment: $deployment
191185
amount: $amount
192-
protocolNetwork: $protocolNetwork
193186
indexNode: $indexNode
194187
) {
195188
allocation
196189
deployment
197190
allocatedTokens
198-
protocolNetwork
199191
}
200192
}
201193
`,
202194
{
203195
deployment,
204196
amount: amount.toString(),
205197
indexNode,
206-
protocolNetwork,
207198
},
208199
)
209200
.toPromise()
@@ -220,36 +211,23 @@ export const closeAllocation = async (
220211
allocationID: string,
221212
poi: string | undefined,
222213
force: boolean,
223-
protocolNetwork: string,
224214
): Promise<CloseAllocationResult> => {
225215
const result = await client
226216
.mutation(
227217
gql`
228-
mutation closeAllocation(
229-
$allocation: String!
230-
$poi: String
231-
$force: Boolean
232-
$protocolNetwork: String!
233-
) {
234-
closeAllocation(
235-
allocation: $allocation
236-
poi: $poi
237-
force: $force
238-
protocolNetwork: $protocolNetwork
239-
) {
218+
mutation closeAllocation($allocation: String!, $poi: String, $force: Boolean) {
219+
closeAllocation(allocation: $allocation, poi: $poi, force: $force) {
240220
allocation
241221
allocatedTokens
242222
indexingRewards
243223
receiptsWorthCollecting
244-
protocolNetwork
245224
}
246225
}
247226
`,
248227
{
249228
allocation: allocationID,
250229
poi,
251230
force,
252-
protocolNetwork,
253231
},
254232
)
255233
.toPromise()
@@ -267,7 +245,6 @@ export const reallocateAllocation = async (
267245
poi: string | undefined,
268246
amount: BigNumber,
269247
force: boolean,
270-
protocolNetwork: string,
271248
): Promise<ReallocateAllocationResult> => {
272249
const result = await client
273250
.mutation(
@@ -277,21 +254,18 @@ export const reallocateAllocation = async (
277254
$poi: String
278255
$amount: String!
279256
$force: Boolean
280-
$protocolNetwork: String!
281257
) {
282258
reallocateAllocation(
283259
allocation: $allocation
284260
poi: $poi
285261
amount: $amount
286262
force: $force
287-
protocolNetwork: $protocolNetwork
288263
) {
289264
closedAllocation
290265
indexingRewardsCollected
291266
receiptsWorthCollecting
292267
createdAllocation
293268
createdAllocationStake
294-
protocolNetwork
295269
}
296270
}
297271
`,
@@ -300,7 +274,6 @@ export const reallocateAllocation = async (
300274
poi,
301275
amount: amount.toString(),
302276
force,
303-
protocolNetwork,
304277
},
305278
)
306279
.toPromise()
@@ -315,24 +288,16 @@ export const reallocateAllocation = async (
315288
export const submitCollectReceiptsJob = async (
316289
client: IndexerManagementClient,
317290
allocationID: string,
318-
protocolNetwork: string,
319291
): Promise<void> => {
320292
const result = await client
321293
.mutation(
322294
gql`
323-
mutation submitCollectReceiptsJob(
324-
$allocation: String!
325-
$protocolNetwork: String!
326-
) {
327-
submitCollectReceiptsJob(
328-
allocation: $allocation
329-
protocolNetwork: $protocolNetwork
330-
)
295+
mutation submitCollectReceiptsJob($allocation: String!) {
296+
submitCollectReceiptsJob(allocation: $allocation)
331297
}
332298
`,
333299
{
334300
allocation: allocationID,
335-
protocolNetwork,
336301
},
337302
)
338303
.toPromise()

packages/indexer-cli/src/commands/indexer/allocations/close.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { loadValidatedConfig } from '../../../config'
55
import { createIndexerManagementClient } from '../../../client'
66
import { closeAllocation } from '../../../allocations'
77
import { validatePOI, printObjectOrArray } from '../../../command-helpers'
8-
import { validateNetworkIdentifier } from '@graphprotocol/indexer-common'
98

109
const HELP = `
1110
${chalk.bold('graph indexer allocations close')} [options] <network> <id> <poi>
@@ -15,9 +14,6 @@ ${chalk.dim('Options:')}
1514
-h, --help Show usage information
1615
-f, --force Bypass POIaccuracy checks and submit transaction with provided data
1716
-o, --output table|json|yaml Choose the output format: table (default), JSON, or YAML
18-
19-
${chalk.dim('Networks:')}
20-
mainnet, arbitrum-one, sepolia or arbitrum sepolia
2117
`
2218

2319
module.exports = {
@@ -46,7 +42,7 @@ module.exports = {
4642
return
4743
}
4844

49-
const [network, id, unformattedPoi] = parameters.array || []
45+
const [id, unformattedPoi] = parameters.array || []
5046

5147
if (id === undefined) {
5248
spinner.fail(`Missing required argument: 'id'`)
@@ -55,22 +51,6 @@ module.exports = {
5551
return
5652
}
5753

58-
let protocolNetwork: string
59-
if (!network) {
60-
spinner.fail(`Missing required argument: 'network'`)
61-
print.info(HELP)
62-
process.exitCode = 1
63-
return
64-
} else {
65-
try {
66-
protocolNetwork = validateNetworkIdentifier(network)
67-
} catch (error) {
68-
spinner.fail(`Invalid value for argument 'network': '${network}' `)
69-
process.exitCode = 1
70-
return
71-
}
72-
}
73-
7454
let poi: string | undefined
7555
try {
7656
poi = validatePOI(unformattedPoi)
@@ -84,7 +64,7 @@ module.exports = {
8464
try {
8565
const config = loadValidatedConfig()
8666
const client = await createIndexerManagementClient({ url: config.api })
87-
const closeResult = await closeAllocation(client, id, poi, toForce, protocolNetwork)
67+
const closeResult = await closeAllocation(client, id, poi, toForce)
8868

8969
spinner.succeed('Allocation closed')
9070
printObjectOrArray(print, outputFormat, closeResult, [

packages/indexer-cli/src/commands/indexer/allocations/collect.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import chalk from 'chalk'
44
import { loadValidatedConfig } from '../../../config'
55
import { createIndexerManagementClient } from '../../../client'
66
import { submitCollectReceiptsJob } from '../../../allocations'
7-
import { validateNetworkIdentifier } from '@graphprotocol/indexer-common'
87

98
const HELP = `
109
${chalk.bold('graph indexer allocations collect')} [options] <network> <id>
@@ -13,9 +12,6 @@ ${chalk.dim('Options:')}
1312
1413
-h, --help Show usage information
1514
-o, --output table|json|yaml Choose the output format: table (default), JSON, or YAML
16-
17-
${chalk.dim('Networks:')}
18-
mainnet, arbitrum-one, sepolia or arbitrum sepolia
1915
`
2016

2117
module.exports = {
@@ -43,7 +39,7 @@ module.exports = {
4339
return
4440
}
4541

46-
const [network, id] = parameters.array || []
42+
const [id] = parameters.array || []
4743

4844
if (id === undefined) {
4945
spinner.fail(`Missing required argument: 'id'`)
@@ -52,27 +48,11 @@ module.exports = {
5248
return
5349
}
5450

55-
let protocolNetwork: string
56-
if (!network) {
57-
spinner.fail(`Missing required argument: 'network'`)
58-
print.info(HELP)
59-
process.exitCode = 1
60-
return
61-
} else {
62-
try {
63-
protocolNetwork = validateNetworkIdentifier(network)
64-
} catch (error) {
65-
spinner.fail(`Invalid value for argument 'network': '${network}' `)
66-
process.exitCode = 1
67-
return
68-
}
69-
}
70-
7151
spinner.text = `Collecting receipts for allocation '${id}`
7252
try {
7353
const config = loadValidatedConfig()
7454
const client = await createIndexerManagementClient({ url: config.api })
75-
await submitCollectReceiptsJob(client, id, protocolNetwork)
55+
await submitCollectReceiptsJob(client, id)
7656

7757
spinner.succeed('Submitted collect receipts job')
7858
} catch (error) {

packages/indexer-cli/src/commands/indexer/allocations/create.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,19 @@ import { loadValidatedConfig } from '../../../config'
55
import { createIndexerManagementClient } from '../../../client'
66
import { BigNumber } from 'ethers'
77
import { createAllocation } from '../../../allocations'
8-
import {
9-
processIdentifier,
10-
SubgraphIdentifierType,
11-
validateNetworkIdentifier,
12-
} from '@graphprotocol/indexer-common'
8+
import { processIdentifier, SubgraphIdentifierType } from '@graphprotocol/indexer-common'
139
import { printObjectOrArray } from '../../../command-helpers'
1410

1511
const HELP = `
1612
${chalk.bold(
1713
'graph indexer allocations create',
18-
)} [options] <deployment-id> <network> <amount> <index-node>
14+
)} [options] <deployment-id> <amount> <index-node>
1915
2016
${chalk.dim('Options:')}
2117
2218
-h, --help Show usage information
2319
-f, --force Bypass POI accuracy checks and submit transaction with provided data
2420
-o, --output table|json|yaml Choose the output format: table (default), JSON, or YAML
25-
26-
${chalk.dim('Networks:')}
27-
mainnet, arbitrum-one, sepolia or arbitrum sepolia
2821
`
2922

3023
module.exports = {
@@ -62,13 +55,6 @@ module.exports = {
6255
)
6356
}
6457

65-
// This nested try block is necessary to complement the parsing error with the 'network' field.
66-
try {
67-
validateNetworkIdentifier(protocolNetwork)
68-
} catch (parsingError) {
69-
throw new Error(`Invalid 'network' provided. ${parsingError}`)
70-
}
71-
7258
const [deploymentString, type] = await processIdentifier(deploymentID, {
7359
all: false,
7460
global: false,
@@ -89,7 +75,6 @@ module.exports = {
8975
deploymentString,
9076
allocationAmount,
9177
indexNode,
92-
protocolNetwork,
9378
)
9479

9580
spinner.succeed('Allocation created')

packages/indexer-cli/src/commands/indexer/allocations/get.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ module.exports = {
9696
query allocations($filter: AllocationFilter!) {
9797
allocations(filter: $filter) {
9898
id
99-
protocolNetwork
10099
indexer
101100
subgraphDeployment
102101
allocatedTokens
@@ -141,7 +140,6 @@ module.exports = {
141140

142141
let displayProperties: (keyof IndexerAllocation)[] = [
143142
'id',
144-
'protocolNetwork',
145143
'indexer',
146144
'subgraphDeployment',
147145
'allocatedTokens',

packages/indexer-cli/src/commands/indexer/allocations/reallocate.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@ import { reallocateAllocation } from '../../../allocations'
88
import { printObjectOrArray, validatePOI } from '../../../command-helpers'
99

1010
const HELP = `
11-
${chalk.bold(
12-
'graph indexer allocations reallocate',
13-
)} [options] <network> <id> <amount> <poi>
11+
${chalk.bold('graph indexer allocations reallocate')} [options] <id> <amount> <poi>
1412
1513
${chalk.dim('Options:')}
1614
1715
-h, --help Show usage information
1816
-f, --force Bypass POI accuracy checks and submit transaction with provided data
19-
20-
${chalk.dim('Networks:')}
21-
mainnet, arbitrum-one, sepolia or arbitrum sepolia
2217
`
2318

2419
module.exports = {
@@ -48,14 +43,7 @@ module.exports = {
4843
}
4944

5045
// eslint-disable-next-line prefer-const
51-
let [network, id, amount, poi] = parameters.array || []
52-
53-
if (network === undefined) {
54-
spinner.fail(`Missing required argument: 'network'`)
55-
print.info(HELP)
56-
process.exitCode = 1
57-
return
58-
}
46+
let [id, amount, poi] = parameters.array || []
5947

6048
if (id === undefined) {
6149
spinner.fail(`Missing required argument: 'id'`)
@@ -84,7 +72,6 @@ module.exports = {
8472
poi,
8573
allocationAmount,
8674
toForce,
87-
network,
8875
)
8976

9077
spinner.succeed('Reallocated')

0 commit comments

Comments
 (0)