Skip to content

Commit

Permalink
chore: Switch setAction for passing an argument in hardhat tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Feb 7, 2024
1 parent 156d092 commit e15e149
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 28 deletions.
3 changes: 1 addition & 2 deletions packages/devtools-evm-hardhat/src/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const action: ActionType<TaskArgs> = async (
return results
}

task(TASK_LZ_DEPLOY, 'Deploy LayerZero contracts')
task(TASK_LZ_DEPLOY, 'Deploy LayerZero contracts', action)
.addParam(
'networks',
'List of comma-separated networks. If not provided, all networks will be deployed',
Expand All @@ -259,4 +259,3 @@ task(TASK_LZ_DEPLOY, 'Deploy LayerZero contracts')
false,
types.boolean
)
.setAction(action)
3 changes: 1 addition & 2 deletions packages/ua-devtools-evm-hardhat/src/tasks/errors/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const action: ActionType<TaskArgs> = async ({ hash, logLevel = 'info' },
return error
}

task(TASK_LZ_ERRORS_DECODE, 'Decodes custom error data based')
task(TASK_LZ_ERRORS_DECODE, 'Decodes custom error data based', action)
.addPositionalParam('hash', 'Encoded contract error hash (including the 0x prefix)', undefined, types.string, false)
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.logLevel)
.setAction(action)
3 changes: 1 addition & 2 deletions packages/ua-devtools-evm-hardhat/src/tasks/errors/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ export const action: ActionType<TaskArgs> = async (
printVerticalTable(rows)
}

task(TASK_LZ_ERRORS_LIST, 'List all custom errors from your project')
task(TASK_LZ_ERRORS_LIST, 'List all custom errors from your project', action)
.addParam('containing', 'Only show custom errors containing a string', '', types.string)
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.logLevel)
.addFlag('showSourcePath', 'Show contract source path')
.setAction(action)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface TaskArgs {
logLevel?: string
}

export const checkWire: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLevel = 'info' }) => {
const action: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLevel = 'info' }) => {
printLogo()

// We'll set the global logging level to get as much info as needed
Expand Down Expand Up @@ -81,8 +81,8 @@ export const checkWire: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPa

task(
TASK_LZ_OAPP_CONFIG_CHECK,
'outputs visual console table to show current state of oapp connections via configuration'
'outputs visual console table to show current state of oapp connections via configuration',
action
)
.addParam('oappConfig', 'Path to your LayerZero OApp config', undefined, types.string)
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.logLevel)
.setAction(checkWire)
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ interface TaskArgs {
json?: boolean
}

export const getDefaultConfig: ActionType<TaskArgs> = async (
{ logLevel = 'info', networks: networksArgument, json },
hre
) => {
const action: ActionType<TaskArgs> = async ({ logLevel = 'info', networks: networksArgument, json }, hre) => {
// We'll set the global logging level to get as much info as needed
setDefaultLogLevel(logLevel)
const logger = createLogger()
Expand Down Expand Up @@ -121,7 +118,8 @@ export const getDefaultConfig: ActionType<TaskArgs> = async (

task(
TASK_LZ_OAPP_CONFIG_GET_DEFAULT,
'Outputs the default Send and Receive Messaging Library versions and the default application config'
'Outputs the default Send and Receive Messaging Library versions and the default application config',
action
)
.addParam('networks', 'Comma-separated list of networks', undefined, types.csv, true)
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.logLevel)
Expand All @@ -132,4 +130,3 @@ task(
types.boolean,
true
)
.setAction(getDefaultConfig)
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ interface TaskArgs {
networks?: string[]
}

export const getExecutorConfig: ActionType<TaskArgs> = async (
{ logLevel = 'info', networks: networksArgument },
hre
) => {
const action: ActionType<TaskArgs> = async ({ logLevel = 'info', networks: networksArgument }, hre) => {
// We'll set the global logging level to get as much info as needed
setDefaultLogLevel(logLevel)

Expand Down Expand Up @@ -47,8 +44,8 @@ export const getExecutorConfig: ActionType<TaskArgs> = async (

task(
TASK_LZ_OAPP_CONFIG_GET_EXECUTOR,
'Outputs the Executors destination configurations including the native max cap amount '
'Outputs the Executors destination configurations including the native max cap amount',
action
)
.addParam('networks', 'Comma-separated list of networks', undefined, types.csv, true)
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.logLevel)
.setAction(getExecutorConfig)
6 changes: 3 additions & 3 deletions packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface TaskArgs {
oappConfig: string
}

export const getOAppConfig: ActionType<TaskArgs> = async ({ logLevel = 'info', oappConfig }) => {
const action: ActionType<TaskArgs> = async ({ logLevel = 'info', oappConfig }) => {
// We'll set the global logging level to get as much info as needed
setDefaultLogLevel(logLevel)

Expand Down Expand Up @@ -110,8 +110,8 @@ export const getOAppConfig: ActionType<TaskArgs> = async ({ logLevel = 'info', o

task(
TASK_LZ_OAPP_CONFIG_GET,
'Outputs the default Send and Receive Messaging Library versions and the default application config'
'Outputs the default Send and Receive Messaging Library versions and the default application config',
action
)
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.logLevel)
.addParam('oappConfig', 'Path to your LayerZero OApp config', undefined, types.string)
.setAction(getOAppConfig)
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const action: ActionType<TaskArgs> = async ({ logLevel = 'info' }, hre): Promise
}

if (process.env.LZ_ENABLE_EXPERIMENTAL_TASK_LZ_OAPP_CONFIG_INIT) {
task(TASK_LZ_OAPP_CONFIG_INIT, 'Initialize an OApp configuration file')
task(TASK_LZ_OAPP_CONFIG_INIT, 'Initialize an OApp configuration file', action)
.addParam('oappConfig', 'Path to the new LayerZero OApp config', undefined, types.string)
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.logLevel)
.addParam(
Expand All @@ -100,5 +100,4 @@ if (process.env.LZ_ENABLE_EXPERIMENTAL_TASK_LZ_OAPP_CONFIG_INIT) {
false,
types.boolean
)
.setAction(action)
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ const action: ActionType<TaskArgs> = async ({
}
}

subtask(SUBTASK_LZ_OAPP_WIRE_CONFIGURE, 'Create a list of OmniTransactions that configure your OApp')
subtask(SUBTASK_LZ_OAPP_WIRE_CONFIGURE, 'Create a list of OmniTransactions that configure your OApp', action)
.addParam('graph', 'Configuration of you OApp of type OAppOmniGraph', undefined, types.any)
.addParam('configurator', 'Configuration function of type OAppConfigurator', undefined, types.any, true)
.addParam('oappFactory', 'SDK factory for OApp SDK of type OAppFactory', undefined, types.any, true)
.setAction(action)

0 comments on commit e15e149

Please sign in to comment.