Skip to content

Commit 510409a

Browse files
authored
chore: use gre task for hardhat tasks (#915)
* chore: use graphTask for hardhat tasks Signed-off-by: Tomás Migone <[email protected]> * chore: rename graphTask to greTask Signed-off-by: Tomás Migone <[email protected]> * test: fix e2e task parsing values Signed-off-by: Tomás Migone <[email protected]>
1 parent ee324fa commit 510409a

File tree

18 files changed

+154
-301
lines changed

18 files changed

+154
-301
lines changed

packages/contracts/tasks/bridge/deposits.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
import { task } from 'hardhat/config'
1+
import { greTask } from '@graphprotocol/sdk/gre'
22
import { ethers } from 'ethers'
33
import { Table } from 'console-table-printer'
44
import { L1ToL2MessageStatus } from '@arbitrum/sdk'
5-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
65
import { getL1ToL2MessageStatus } from '@graphprotocol/sdk'
7-
export const TASK_BRIDGE_DEPOSITS = 'bridge:deposits'
86

9-
task(TASK_BRIDGE_DEPOSITS, 'List deposits initiated on L1GraphTokenGateway')
10-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
11-
.addOptionalParam(
12-
'arbitrumAddressBook',
13-
GRE_TASK_PARAMS.arbitrumAddressBook.description,
14-
GRE_TASK_PARAMS.arbitrumAddressBook.default,
15-
)
16-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
17-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
7+
greTask('bridge:deposits', 'List deposits initiated on L1GraphTokenGateway')
188
.addOptionalParam('startBlock', 'Start block for the search')
199
.addOptionalParam('endBlock', 'End block for the search')
2010
.setAction(async (taskArgs, hre) => {

packages/contracts/tasks/bridge/to-l2.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
import { task } from 'hardhat/config'
21
import { BigNumber } from 'ethers'
3-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
2+
import { greTask } from '@graphprotocol/sdk/gre'
43
import { sendToL2 } from '@graphprotocol/sdk'
54
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
65

7-
export const TASK_BRIDGE_TO_L2 = 'bridge:send-to-l2'
8-
9-
task(TASK_BRIDGE_TO_L2, 'Bridge GRT tokens from L1 to L2')
6+
greTask('bridge:send-to-l2', 'Bridge GRT tokens from L1 to L2')
107
.addParam('amount', 'Amount of tokens to bridge')
118
.addOptionalParam('sender', 'Address of the sender. L1 deployer if empty.')
129
.addOptionalParam('recipient', 'Receiving address in L2. Same to L1 address if empty.')
13-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
14-
.addOptionalParam(
15-
'arbitrumAddressBook',
16-
GRE_TASK_PARAMS.arbitrumAddressBook.description,
17-
GRE_TASK_PARAMS.arbitrumAddressBook.default,
18-
)
19-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
20-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
2110
.addOptionalParam(
2211
'deploymentFile',
2312
'Nitro testnode deployment file. Must specify if using nitro test nodes.',

packages/contracts/tasks/bridge/withdrawals.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1-
import { task } from 'hardhat/config'
21
import { ethers } from 'ethers'
32
import { Table } from 'console-table-printer'
43
import { L2ToL1MessageStatus } from '@arbitrum/sdk'
5-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
4+
import { greTask } from '@graphprotocol/sdk/gre'
65
import { getL2ToL1MessageStatus } from '@graphprotocol/sdk'
76

8-
export const TASK_BRIDGE_WITHDRAWALS = 'bridge:withdrawals'
9-
10-
task(TASK_BRIDGE_WITHDRAWALS, 'List withdrawals initiated on L2GraphTokenGateway')
11-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
12-
.addOptionalParam(
13-
'arbitrumAddressBook',
14-
GRE_TASK_PARAMS.arbitrumAddressBook.description,
15-
GRE_TASK_PARAMS.arbitrumAddressBook.default,
16-
)
17-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
18-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
7+
greTask('bridge:withdrawals', 'List withdrawals initiated on L2GraphTokenGateway')
198
.addOptionalParam('startBlock', 'Start block for the search')
209
.addOptionalParam('endBlock', 'End block for the search')
2110
.setAction(async (taskArgs, hre) => {

packages/contracts/tasks/contract/deploy.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
1-
import { task } from 'hardhat/config'
2-
31
import { DeployType, GraphNetworkAddressBook, confirm, deploy } from '@graphprotocol/sdk'
4-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
2+
import { greTask } from '@graphprotocol/sdk/gre'
53

6-
task('contract:deploy', 'Deploy a contract')
4+
greTask('contract:deploy', 'Deploy a contract')
75
.addPositionalParam('contract', 'Name of the contract to deploy')
86
.addPositionalParam(
97
'init',
108
'Initialization arguments for the contract constructor. Provide arguments as comma-separated values',
119
)
12-
.addParam(
13-
'addressBook',
14-
GRE_TASK_PARAMS.addressBook.description,
15-
GRE_TASK_PARAMS.addressBook.default,
16-
)
17-
.addParam(
18-
'graphConfig',
19-
GRE_TASK_PARAMS.graphConfig.description,
20-
GRE_TASK_PARAMS.graphConfig.default,
21-
)
2210
.addParam('deployType', 'Choose deploy, deploy-save, deploy-with-proxy, deploy-with-proxy-save')
23-
.addFlag('disableSecureAccounts', 'Disable secure accounts on GRE')
24-
.addFlag('skipConfirmation', GRE_TASK_PARAMS.skipConfirmation.description)
11+
.addFlag('skipConfirmation', 'Skip confirmation prompt on write actions')
2512
.addFlag('buildAcceptTx', '...')
2613
.setAction(async (taskArgs, hre) => {
2714
const graph = hre.graph(taskArgs)

packages/contracts/tasks/contract/upgrade.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
import { task } from 'hardhat/config'
2-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
1+
import { greTask } from '@graphprotocol/sdk/gre'
32
import { DeployType, GraphNetworkAddressBook, deploy } from '@graphprotocol/sdk'
43

5-
task('contract:upgrade', 'Upgrades a contract')
4+
greTask('contract:upgrade', 'Upgrades a contract')
65
.addParam('contract', 'Name of the contract to upgrade')
7-
.addFlag('disableSecureAccounts', 'Disable secure accounts on GRE')
8-
.addOptionalParam(
9-
'graphConfig',
10-
GRE_TASK_PARAMS.graphConfig.description,
11-
GRE_TASK_PARAMS.graphConfig.default,
12-
)
13-
.addOptionalParam(
14-
'addressBook',
15-
GRE_TASK_PARAMS.addressBook.description,
16-
GRE_TASK_PARAMS.addressBook.default,
17-
)
186
.addOptionalVariadicPositionalParam(
197
'init',
208
'Initialization arguments for the contract constructor',

packages/contracts/tasks/deployment/config.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { task } from 'hardhat/config'
2-
31
import {
42
GraphNetworkConfigContractList,
53
GraphNetworkConfigGeneralParams,
@@ -8,16 +6,11 @@ import {
86
writeConfig,
97
confirm,
108
} from '@graphprotocol/sdk'
11-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
9+
import { greTask } from '@graphprotocol/sdk/gre'
1210

13-
task('update-config', 'Update graph config parameters with onchain data')
14-
.addParam(
15-
'graphConfig',
16-
GRE_TASK_PARAMS.graphConfig.description,
17-
GRE_TASK_PARAMS.graphConfig.default,
18-
)
11+
greTask('update-config', 'Update graph config parameters with onchain data')
1912
.addFlag('dryRun', "Only print the changes, don't write them to the config file")
20-
.addFlag('skipConfirmation', GRE_TASK_PARAMS.skipConfirmation.description)
13+
.addFlag('skipConfirmation', 'Skip confirmation prompt on write actions.')
2114
.setAction(async (taskArgs, hre) => {
2215
const networkName = hre.network.name
2316
const configFile = taskArgs.graphConfig

packages/contracts/tasks/e2e/e2e.ts

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { task } from 'hardhat/config'
21
import { HardhatRuntimeEnvironment, TaskArguments } from 'hardhat/types'
32
import { TASK_TEST } from 'hardhat/builtin-tasks/task-names'
43
import glob from 'glob'
54
import fs from 'fs'
65
import { runScriptWithHardhat } from 'hardhat/internal/util/scripts-runner'
76
import { isGraphL1ChainId } from '@graphprotocol/sdk'
8-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
7+
import { greTask } from '@graphprotocol/sdk/gre'
98

109
const CONFIG_TESTS = 'test/e2e/deployment/config/**/*.test.ts'
1110
const INIT_TESTS = 'test/e2e/deployment/init/**/*.test.ts'
@@ -34,11 +33,7 @@ const setGraphConfig = async (args: TaskArguments, hre: HardhatRuntimeEnvironmen
3433
}
3534
}
3635

37-
task('e2e', 'Run all e2e tests')
38-
.addOptionalParam('graphConfig', GRE_TASK_PARAMS.graphConfig.description)
39-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
40-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
41-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
36+
greTask('e2e', 'Run all e2e tests')
4237
.addFlag('skipBridge', 'Skip bridge tests')
4338
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
4439
let testFiles = [
@@ -59,12 +54,8 @@ task('e2e', 'Run all e2e tests')
5954
})
6055
})
6156

62-
task('e2e:config', 'Run deployment configuration e2e tests')
63-
.addOptionalParam('graphConfig', GRE_TASK_PARAMS.graphConfig.description)
64-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
65-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
66-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
67-
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
57+
greTask('e2e:config', 'Run deployment configuration e2e tests').setAction(
58+
async (args, hre: HardhatRuntimeEnvironment) => {
6859
const files = new glob.GlobSync(CONFIG_TESTS).found
6960

7061
// Disable secure accounts, we don't need them for this task
@@ -74,14 +65,11 @@ task('e2e:config', 'Run deployment configuration e2e tests')
7465
await hre.run(TASK_TEST, {
7566
testFiles: files,
7667
})
77-
})
68+
},
69+
)
7870

79-
task('e2e:init', 'Run deployment initialization e2e tests')
80-
.addOptionalParam('graphConfig', GRE_TASK_PARAMS.graphConfig.description)
81-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
82-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
83-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
84-
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
71+
greTask('e2e:init', 'Run deployment initialization e2e tests').setAction(
72+
async (args, hre: HardhatRuntimeEnvironment) => {
8573
const files = new glob.GlobSync(INIT_TESTS).found
8674

8775
// Disable secure accounts, we don't need them for this task
@@ -91,15 +79,11 @@ task('e2e:init', 'Run deployment initialization e2e tests')
9179
await hre.run(TASK_TEST, {
9280
testFiles: files,
9381
})
94-
})
82+
},
83+
)
9584

96-
task('e2e:scenario', 'Run scenario scripts and e2e tests')
85+
greTask('e2e:scenario', 'Run scenario scripts and e2e tests')
9786
.addPositionalParam('scenario', 'Name of the scenario to run')
98-
.addFlag('disableSecureAccounts', 'Disable secure accounts on GRE')
99-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
100-
.addOptionalParam('graphConfig', GRE_TASK_PARAMS.graphConfig.description)
101-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
102-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
10387
.addFlag('skipScript', "Don't run scenario script")
10488
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
10589
setGraphConfig(args, hre)
@@ -134,15 +118,9 @@ task('e2e:scenario', 'Run scenario scripts and e2e tests')
134118
}
135119
})
136120

137-
task('e2e:upgrade', 'Run upgrade tests')
121+
greTask('e2e:upgrade', 'Run upgrade tests')
138122
.addPositionalParam('upgrade', 'Name of the upgrade to run')
139-
.addFlag('disableSecureAccounts', 'Disable secure accounts on GRE')
140-
.addFlag('fork', 'Enable fork behavior on GRE')
141123
.addFlag('post', 'Wether to run pre/post upgrade scripts')
142-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
143-
.addOptionalParam('graphConfig', GRE_TASK_PARAMS.graphConfig.description)
144-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
145-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
146124
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
147125
setGraphConfig(args, hre)
148126
await runUpgrade(args, hre, args.post ? 'post' : 'pre')

packages/contracts/tasks/migrate/bridge.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
import { task } from 'hardhat/config'
2-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
1+
import { greTask } from '@graphprotocol/sdk/gre'
32
import { configureL1Bridge, configureL2Bridge, setPausedBridge } from '@graphprotocol/sdk'
43

5-
task('migrate:bridge', 'Configure and unpause bridge')
6-
.addOptionalParam('addressBook', GRE_TASK_PARAMS.addressBook.description)
4+
greTask('migrate:bridge', 'Configure and unpause bridge')
75
.addOptionalParam(
86
'arbitrumAddressBook',
9-
GRE_TASK_PARAMS.arbitrumAddressBook.description,
10-
GRE_TASK_PARAMS.arbitrumAddressBook.default,
7+
'The path to the address book file for Arbitrum deployments',
8+
'./arbitrum-addresses.json',
119
)
12-
.addOptionalParam('graphConfig', GRE_TASK_PARAMS.graphConfig.description)
13-
.addOptionalParam('l1GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
14-
.addOptionalParam('l2GraphConfig', GRE_TASK_PARAMS.graphConfig.description)
15-
.addFlag('disableSecureAccounts', 'Disable secure accounts on GRE')
1610
.setAction(async (taskArgs, hre) => {
1711
const graph = hre.graph(taskArgs)
1812
const { governor: l1Governor } = await graph.l1.getNamedAccounts()

packages/contracts/tasks/migrate/nitro.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { subtask, task } from 'hardhat/config'
22
import fs from 'fs'
33
import { execSync } from 'child_process'
4-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
4+
import { greTask } from '@graphprotocol/sdk/gre'
55
import { helpers } from '@graphprotocol/sdk'
66

7-
task('migrate:nitro:fund-accounts', 'Funds protocol accounts on Arbitrum Nitro testnodes')
8-
.addFlag('disableSecureAccounts', 'Disable secure accounts on GRE')
9-
.addOptionalParam('graphConfig', GRE_TASK_PARAMS.graphConfig.description)
10-
.setAction(async (taskArgs, hre) => {
11-
const graph = hre.graph(taskArgs)
12-
await helpers.fundLocalAccounts(
13-
[await graph.getDeployer(), ...(await graph.getAllAccounts())],
14-
graph.provider,
15-
)
16-
})
7+
greTask(
8+
'migrate:nitro:fund-accounts',
9+
'Funds protocol accounts on Arbitrum Nitro testnodes',
10+
).setAction(async (taskArgs, hre) => {
11+
const graph = hre.graph(taskArgs)
12+
await helpers.fundLocalAccounts(
13+
[await graph.getDeployer(), ...(await graph.getAllAccounts())],
14+
graph.provider,
15+
)
16+
})
1717

1818
// Arbitrum SDK does not support Nitro testnodes out of the box
1919
// This adds the testnodes to the SDK configuration

packages/contracts/tasks/migrate/protocol.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
1-
import { task } from 'hardhat/config'
2-
31
import {
42
GraphChainId,
53
GraphNetworkGovernedContractNameList,
64
acceptOwnership,
75
deployGraphNetwork,
86
setPausedProtocol,
97
} from '@graphprotocol/sdk'
10-
import { GRE_TASK_PARAMS } from '@graphprotocol/sdk/gre'
8+
import { greTask } from '@graphprotocol/sdk/gre'
119
import { ContractTransaction } from 'ethers'
1210

13-
task('migrate', 'Deploy protocol contracts')
14-
.addParam(
15-
'addressBook',
16-
GRE_TASK_PARAMS.addressBook.description,
17-
GRE_TASK_PARAMS.addressBook.default,
18-
)
19-
.addParam(
20-
'graphConfig',
21-
GRE_TASK_PARAMS.graphConfig.description,
22-
GRE_TASK_PARAMS.graphConfig.default,
23-
)
24-
.addFlag('disableSecureAccounts', 'Disable secure accounts on GRE')
25-
.addFlag('skipConfirmation', GRE_TASK_PARAMS.skipConfirmation.description)
11+
greTask('migrate', 'Deploy protocol contracts')
12+
.addFlag('skipConfirmation', 'Skip confirmation prompt on write actions')
2613
.addFlag('skipPostDeploy', 'Skip accepting ownership and unpausing protocol after deploying')
27-
.addFlag('force', GRE_TASK_PARAMS.force.description)
14+
.addFlag('force', 'Deploy contract even if its already deployed')
2815
.addFlag('buildAcceptTx', '...')
2916
.setAction(async (taskArgs, hre) => {
3017
const graph = hre.graph(taskArgs)

0 commit comments

Comments
 (0)