Skip to content

Commit 72f7bb6

Browse files
authored
Improve configuration and tasks (#469)
Reorganize some actions as Hardhat tasks. Cleanup and refactor CLI.
1 parent 79da240 commit 72f7bb6

35 files changed

+475
-352
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"rules": {
99
"prefer-const": "warn",
1010
"no-extra-semi": "off",
11-
"@typescript-eslint/no-extra-semi": "warn",
11+
"@typescript-eslint/no-extra-semi": "off",
1212
"@typescript-eslint/no-inferrable-types": "warn",
1313
"@typescript-eslint/no-empty-function": "warn",
1414
"no-only-tests/no-only-tests": "error"

cli/commands/airdrop.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import consola from 'consola'
21
import inquirer from 'inquirer'
32
import fs from 'fs'
43
import PQueue from 'p-queue'
@@ -111,7 +110,7 @@ const loadRecipients = (path: string): Array<AirdropRecipient> => {
111110
logger.fatal(`Error loading address "${address}" please review the input file`)
112111
process.exit(1)
113112
}
114-
results.push({ address, amount: weiAmount as any, txHash })
113+
results.push({ address, amount: weiAmount, txHash })
115114
}
116115
return results
117116
}

cli/commands/contracts/curation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const curationCommand = {
8080
},
8181
})
8282
},
83-
handler: (argv: CLIArgs): void => {
83+
handler: (): void => {
8484
yargs.showHelp()
8585
},
8686
}

cli/commands/contracts/disputeManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export const disputeManagerCommand = {
234234
},
235235
})
236236
},
237-
handler: (argv: CLIArgs): void => {
237+
handler: (): void => {
238238
yargs.showHelp()
239239
},
240240
}

cli/commands/contracts/ens.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { logger } from '../../logging'
77

88
export const registerTestName = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
99
const name = cliArgs.name
10-
const testRegistrar = cli.contracts.ITestRegistrar
10+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
11+
const testRegistrar = (cli.contracts as any).ITestRegistrar
1112
const normalizedName = name.toLowerCase()
1213
const labelNameFull = `${normalizedName}.${'eth'}`
1314
const labelHashFull = utils.namehash(labelNameFull)
@@ -67,7 +68,7 @@ export const ensCommand = {
6768
},
6869
})
6970
},
70-
handler: (argv: CLIArgs): void => {
71+
handler: (): void => {
7172
yargs.showHelp()
7273
},
7374
}

cli/commands/contracts/ethereumDIDRegistry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const handleAccountMetadata = async (ipfs: string, path: string): Promise<string
3333
return IPFS.ipfsHashToBytes32(metaHash)
3434
}
3535

36-
export const setAttribute = async (cli: CLIEnvironment, cliArgs: CLIArgs) => {
36+
export const setAttribute = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
3737
const metadataPath = cliArgs.metadataPath
3838
const ipfsEndpoint = cliArgs.ipfs
3939
const ethereumDIDRegistry = cli.contracts.IEthereumDIDRegistry
@@ -83,7 +83,7 @@ export const ethereumDIDRegistryCommand = {
8383
},
8484
})
8585
},
86-
handler: (argv: CLIArgs): void => {
86+
handler: (): void => {
8787
yargs.showHelp()
8888
},
8989
}

cli/commands/contracts/gns.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as fs from 'fs'
21
import yargs, { Argv } from 'yargs'
32
import { parseGRT } from '@graphprotocol/common-ts'
43

cli/commands/contracts/gsr-gdai.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import yargs, { Argv } from 'yargs'
23
import { parseGRT } from '@graphprotocol/common-ts'
34

@@ -7,23 +8,23 @@ import { loadEnv, CLIArgs, CLIEnvironment } from '../../env'
78

89
export const setGSR = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
910
const account = cliArgs.account
10-
const gdai = cli.contracts.GDAI
11+
const gdai = (cli.contracts as any).GDAI
1112

1213
logger.log(`Setting GSR to ${account}...`)
1314
await sendTransaction(cli.wallet, gdai, 'setGSR', [account])
1415
}
1516

1617
export const setRate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
1718
const amount = parseGRT(cliArgs.amount)
18-
const gsr = cli.contracts.GSRManager
19+
const gsr = (cli.contracts as any).GSRManager
1920

2021
logger.log(`Setting rate to ${amount}...`)
2122
await sendTransaction(cli.wallet, gsr, 'setRate', [amount])
2223
}
2324

2425
export const join = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
2526
const amount = parseGRT(cliArgs.amount)
26-
const gsr = cli.contracts.GSRManager
27+
const gsr = (cli.contracts as any).GSRManager
2728

2829
logger.log(`Reminder - you must call approve on the GSR before`)
2930
logger.log(`Joining GSR with ${cliArgs.amount} tokens...`)
@@ -33,15 +34,15 @@ export const join = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void>
3334
export const mint = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
3435
const amount = parseGRT(cliArgs.amount)
3536
const account = cliArgs.account
36-
const gdai = cli.contracts.GDAI
37+
const gdai = (cli.contracts as any).GDAI
3738

3839
logger.log(`Minting ${cliArgs.amount} GDAI for user ${account}...`)
3940
await sendTransaction(cli.wallet, gdai, 'mint', [account, amount])
4041
}
4142

4243
export const burn = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
4344
const amount = parseGRT(cliArgs.amount)
44-
const gdai = cli.contracts.GDAI
45+
const gdai = (cli.contracts as any).GDAI
4546

4647
logger.log(`Burning ${cliArgs.amount} GDAI...`)
4748
await sendTransaction(cli.wallet, gdai, 'burn', [amount])
@@ -50,7 +51,7 @@ export const burn = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void>
5051
export const transfer = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
5152
const amount = parseGRT(cliArgs.amount)
5253
const account = cliArgs.account
53-
const gdai = cli.contracts.GDAI
54+
const gdai = (cli.contracts as any).GDAI
5455

5556
logger.log(`Transferring ${cliArgs.amount} tokens to user ${account}...`)
5657
await sendTransaction(cli.wallet, gdai, 'transfer', [account, amount])
@@ -59,7 +60,7 @@ export const transfer = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<v
5960
export const approve = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
6061
const amount = parseGRT(cliArgs.amount)
6162
const account = cliArgs.account
62-
const gdai = cli.contracts.GDAI
63+
const gdai = (cli.contracts as any).GDAI
6364

6465
logger.log(`Approving ${cliArgs.amount} GDAI for user ${account} to spend...`)
6566
await sendTransaction(cli.wallet, gdai, 'approve', [account, amount])

cli/commands/contracts/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { stakingCommand } from './staking'
1111
import { anyCommand } from './any'
1212
import { governanceCommand } from './governance'
1313

14-
import { CLIArgs } from '../../env'
1514
import { disputeManagerCommand } from './disputeManager'
1615

1716
export const contractsCommand = {
@@ -31,7 +30,7 @@ export const contractsCommand = {
3130
.command(disputeManagerCommand)
3231
.command(governanceCommand)
3332
},
34-
handler: (argv: CLIArgs): void => {
33+
handler: (): void => {
3534
yargs.showHelp()
3635
},
3736
}

cli/commands/contracts/serviceRegistry.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const register = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<v
1212
logger.log(`Registering indexer ${cli.walletAddress} with url ${url} and geoHash ${geoHash}`)
1313
await sendTransaction(cli.wallet, serviceRegistry, 'register', [url, geoHash])
1414
}
15-
export const unregister = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
15+
export const unregister = async (cli: CLIEnvironment): Promise<void> => {
1616
const serviceRegistry = cli.contracts.ServiceRegistry
1717

1818
logger.log(`Unregistering indexer ${cli.walletAddress}`)
@@ -52,11 +52,11 @@ export const serviceRegistryCommand = {
5252
command: 'unregister',
5353
describe: 'Unregister an indexer in the service registry',
5454
handler: async (argv: CLIArgs): Promise<void> => {
55-
return unregister(await loadEnv(argv), argv)
55+
return unregister(await loadEnv(argv))
5656
},
5757
})
5858
},
59-
handler: (argv: CLIArgs): void => {
59+
handler: (): void => {
6060
yargs.showHelp()
6161
},
6262
}

0 commit comments

Comments
 (0)