Skip to content

Commit

Permalink
🪲 Rename EVM Hardhat Tasks (LayerZero-Labs#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirarthurmoney authored Feb 8, 2024
1 parent b2670f8 commit cc62747
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 35 deletions.
7 changes: 7 additions & 0 deletions .changeset/metal-tables-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@layerzerolabs/ua-devtools-evm-hardhat-test": patch
"@layerzerolabs/ua-devtools-evm-hardhat": patch
"@layerzerolabs/ua-devtools": patch
---

Rename EVM Hardhat Tasks
4 changes: 2 additions & 2 deletions packages/ua-devtools-evm-hardhat/src/constants/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const TASK_LZ_OAPP_WIRE = 'lz:oapp:wire'
export const TASK_LZ_OAPP_CONFIG_GET_DEFAULT = 'lz:oapp:config:get:default'
export const TASK_LZ_OAPP_CONFIG_GET_EXECUTOR = 'lz:oapp:config:get:executor'
export const TASK_LZ_OAPP_CONFIG_GET = 'lz:oapp:config:get'
export const TASK_LZ_OAPP_CONFIG_CHECK = 'lz:oapp:config:check'
export const TASK_LZ_OAPP_ENFORCED_OPTIONS_GET = 'lz:oapp:enforced:options:get'
export const TASK_LZ_OAPP_PEERS_GET = 'lz:oapp:peers:get'
export const TASK_LZ_OAPP_ENFORCED_OPTS_GET = 'lz:oapp:enforced-opts:get'
export const TASK_LZ_OAPP_CONFIG_INIT = 'lz:oapp:config:init'

export const SUBTASK_LZ_OAPP_WIRE_CONFIGURE = '::lz:oapp:wire:configure'
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const action: ActionType<TaskArgs> = async ({ logLevel = 'info', networks: netwo

task(
TASK_LZ_OAPP_CONFIG_GET_DEFAULT,
'Outputs the default Send and Receive Messaging Library versions and the default application config',
'Outputs the Default OApp Config. Each config contains Send & Receive Libraries, Send Uln & Executor Configs, and Receive Executor Configs',
action
)
.addParam('networks', 'Comma-separated list of networks', undefined, types.csv, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const action: ActionType<TaskArgs> = async ({ logLevel = 'info', oappConfig }) =

task(
TASK_LZ_OAPP_CONFIG_GET,
'Outputs the default Send and Receive Messaging Library versions and the default application config',
'Outputs Custom OApp Config, Default OApp Config, and Active OApp Config. Each config contains Send & Receive Librarys, Send Uln & Executor Configs, and Recieve Executor Configs',
action
)
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.logLevel)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActionType } from 'hardhat/types'
import { task } from 'hardhat/config'
import { createLogger, printCrossTable, printRecord, setDefaultLogLevel } from '@layerzerolabs/io-devtools'
import { TASK_LZ_OAPP_ENFORCED_OPTIONS_GET } from '@/constants/tasks'
import { TASK_LZ_OAPP_ENFORCED_OPTS_GET } from '@/constants/tasks'
import { printLogo } from '@layerzerolabs/io-devtools/swag'
import { EncodedOption, OAppOmniGraph } from '@layerzerolabs/ua-devtools'
import { createConnectedContractFactory, types } from '@layerzerolabs/devtools-evm-hardhat'
Expand All @@ -17,7 +17,7 @@ interface TaskArgs {
logLevel?: string
}

export const enforcedOptionsGet: 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 @@ -87,10 +87,9 @@ export const enforcedOptionsGet: ActionType<TaskArgs> = async ({ oappConfig: oap
}
}

task(TASK_LZ_OAPP_ENFORCED_OPTIONS_GET, 'Outputs table of OApp enforced options using layerzero.config')
task(TASK_LZ_OAPP_ENFORCED_OPTS_GET, 'Outputs OApp enforced options', 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(enforcedOptionsGet)

/**
* Decodes enforced options from the provided encoded enforced options.
Expand Down
4 changes: 2 additions & 2 deletions packages/ua-devtools-evm-hardhat/src/tasks/oapp/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './wire'
import './config.check'
import './peers.get'
import './config.get.default'
import './config.get.executor'
import './config.get'
import './enforced.options.get'
import './enforced.opts.get'
import './config.init'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActionType } from 'hardhat/types'
import { task } from 'hardhat/config'
import { createLogger, printBoolean, printCrossTable, setDefaultLogLevel } from '@layerzerolabs/io-devtools'
import { TASK_LZ_OAPP_CONFIG_CHECK } from '@/constants/tasks'
import { TASK_LZ_OAPP_PEERS_GET } from '@/constants/tasks'
import { printLogo } from '@layerzerolabs/io-devtools/swag'
import { OAppOmniGraph } from '@layerzerolabs/ua-devtools'
import { createConnectedContractFactory, types } from '@layerzerolabs/devtools-evm-hardhat'
Expand Down Expand Up @@ -79,10 +79,6 @@ const action: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLev
}
}

task(
TASK_LZ_OAPP_CONFIG_CHECK,
'outputs visual console table to show current state of oapp connections via configuration',
action
)
task(TASK_LZ_OAPP_PEERS_GET, 'Outputs OApp peer connections', 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)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`task lz:oapp:config:check should show a standard lzReceive setting for all pathways 1`] = `
exports[`task lz:oapp:peers:get should show a standard lzReceive setting for all pathways 1`] = `
[
"┌───────────┬───────────────────────────────────────────────────────────┬───────────────────────────────────────────────────────────┐
│ from → to │ britney │ vengaboys │
Expand Down Expand Up @@ -28,7 +28,7 @@ exports[`task lz:oapp:config:check should show a standard lzReceive setting for
]
`;

exports[`task lz:oapp:config:check should show all chains are connected after running wire with three networks 1`] = `
exports[`task lz:oapp:peers:get should show all chains are connected after running wire with three networks 1`] = `
[
"┌───────────┬─────────┬───────────┬───────┐
│ from → to │ britney │ vengaboys │ tango │
Expand All @@ -48,7 +48,7 @@ exports[`task lz:oapp:config:check should show all chains are connected after ru
]
`;

exports[`task lz:oapp:config:check should show all chains are connected after running wire with two networks 1`] = `
exports[`task lz:oapp:peers:get should show all chains are connected after running wire with two networks 1`] = `
[
"┌───────────┬─────────┬───────────┐
│ from → to │ britney │ vengaboys │
Expand All @@ -66,7 +66,7 @@ exports[`task lz:oapp:config:check should show all chains are connected after ru
]
`;

exports[`task lz:oapp:config:check should show all chains are connected expect one after running wire with three networks 1`] = `
exports[`task lz:oapp:peers:get should show all chains are connected expect one after running wire with three networks 1`] = `
[
"┌───────────┬─────────┬───────────┬───────┐
│ from → to │ britney │ vengaboys │ tango │
Expand All @@ -86,7 +86,7 @@ exports[`task lz:oapp:config:check should show all chains are connected expect o
]
`;

exports[`task lz:oapp:config:check should show all chains are not connected expect one after running wire with three networks 1`] = `
exports[`task lz:oapp:peers:get should show all chains are not connected expect one after running wire with three networks 1`] = `
[
"┌───────────┬─────────┬───────────┬───────┐
│ from → to │ britney │ vengaboys │ tango │
Expand All @@ -106,7 +106,7 @@ exports[`task lz:oapp:config:check should show all chains are not connected expe
]
`;

exports[`task lz:oapp:config:check should show different combined enforced options for all pathways 1`] = `
exports[`task lz:oapp:peers:get should show different combined enforced options for all pathways 1`] = `
[
"┌───────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ from → to │ britney │ vengaboys │ tango │
Expand Down Expand Up @@ -220,7 +220,7 @@ exports[`task lz:oapp:config:check should show different combined enforced optio
]
`;

exports[`task lz:oapp:config:check should show enforced options for one pathway 1`] = `
exports[`task lz:oapp:peers:get should show enforced options for one pathway 1`] = `
[
"┌───────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬───────────┬───────┐
│ from → to │ britney │ vengaboys │ tango │
Expand Down Expand Up @@ -250,7 +250,7 @@ exports[`task lz:oapp:config:check should show enforced options for one pathway
]
`;

exports[`task lz:oapp:config:check should show no chains are connected with two networks 1`] = `
exports[`task lz:oapp:peers:get should show no chains are connected with two networks 1`] = `
[
"┌───────────┬─────────┬───────────┐
│ from → to │ britney │ vengaboys │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { resolve } from 'path'
import { isFile } from '@layerzerolabs/io-devtools'
import { deployOApp } from '../../__utils__/oapp'
import {
TASK_LZ_OAPP_CONFIG_CHECK,
TASK_LZ_OAPP_ENFORCED_OPTIONS_GET,
TASK_LZ_OAPP_PEERS_GET,
TASK_LZ_OAPP_ENFORCED_OPTS_GET,
TASK_LZ_OAPP_WIRE,
} from '@layerzerolabs/ua-devtools-evm-hardhat'
import { deployEndpoint, setupDefaultEndpoint } from '../../__utils__/endpoint'

describe(`task ${TASK_LZ_OAPP_CONFIG_CHECK}`, () => {
describe(`task ${TASK_LZ_OAPP_PEERS_GET}`, () => {
const CONFIGS_BASE_DIR = resolve(__dirname, '__data__', 'configs')
const configPathFixture = (fileName: string): string => {
const path = resolve(CONFIGS_BASE_DIR, fileName)
Expand All @@ -29,63 +29,63 @@ describe(`task ${TASK_LZ_OAPP_CONFIG_CHECK}`, () => {
it('should show no chains are connected with two networks', async () => {
const consoleSpy = jest.spyOn(console, 'log')
const oappConfig = configPathFixture('valid.config.connected.js')
await hre.run(TASK_LZ_OAPP_CONFIG_CHECK, { oappConfig })
await hre.run(TASK_LZ_OAPP_PEERS_GET, { oappConfig })
expect(consoleSpy.mock.lastCall).toMatchSnapshot()
})

it('should show all chains are connected after running wire with two networks', async () => {
const consoleSpy = jest.spyOn(console, 'log')
const oappConfig = configPathFixture('valid.config.connected.js')
await hre.run(TASK_LZ_OAPP_WIRE, { oappConfig, ci: true })
await hre.run(TASK_LZ_OAPP_CONFIG_CHECK, { oappConfig })
await hre.run(TASK_LZ_OAPP_PEERS_GET, { oappConfig })
expect(consoleSpy.mock.lastCall).toMatchSnapshot()
})

it('should show all chains are connected after running wire with three networks', async () => {
const consoleSpy = jest.spyOn(console, 'log')
const oappConfig = configPathFixture('valid.multi.network.config.connected.js')
await hre.run(TASK_LZ_OAPP_WIRE, { oappConfig, ci: true })
await hre.run(TASK_LZ_OAPP_CONFIG_CHECK, { oappConfig })
await hre.run(TASK_LZ_OAPP_PEERS_GET, { oappConfig })
expect(consoleSpy.mock.lastCall).toMatchSnapshot()
})

it('should show all chains are connected expect one after running wire with three networks', async () => {
const consoleSpy = jest.spyOn(console, 'log')
const oappConfig = configPathFixture('valid.multi.network.config.missing.connection.js')
await hre.run(TASK_LZ_OAPP_WIRE, { oappConfig, ci: true })
await hre.run(TASK_LZ_OAPP_CONFIG_CHECK, { oappConfig })
await hre.run(TASK_LZ_OAPP_PEERS_GET, { oappConfig })
expect(consoleSpy.mock.lastCall).toMatchSnapshot()
})

it('should show all chains are not connected expect one after running wire with three networks', async () => {
const consoleSpy = jest.spyOn(console, 'log')
const oappConfig = configPathFixture('valid.multi.network.config.one.connection.js')
await hre.run(TASK_LZ_OAPP_WIRE, { oappConfig, ci: true })
await hre.run(TASK_LZ_OAPP_CONFIG_CHECK, { oappConfig })
await hre.run(TASK_LZ_OAPP_PEERS_GET, { oappConfig })
expect(consoleSpy.mock.lastCall).toMatchSnapshot()
})

it('should show enforced options for one pathway', async () => {
const consoleSpy = jest.spyOn(console, 'log')
const oappConfig = configPathFixture('valid.multi.network.one.pathway.enforced.options.js')
await hre.run(TASK_LZ_OAPP_WIRE, { oappConfig, ci: true })
await hre.run(TASK_LZ_OAPP_ENFORCED_OPTIONS_GET, { oappConfig })
await hre.run(TASK_LZ_OAPP_ENFORCED_OPTS_GET, { oappConfig })
expect(consoleSpy.mock.lastCall).toMatchSnapshot()
})

it('should show a standard lzReceive setting for all pathways', async () => {
const consoleSpy = jest.spyOn(console, 'log')
const oappConfig = configPathFixture('valid.multi.network.lzreceive.enforced.options.js')
await hre.run(TASK_LZ_OAPP_WIRE, { oappConfig, ci: true })
await hre.run(TASK_LZ_OAPP_ENFORCED_OPTIONS_GET, { oappConfig })
await hre.run(TASK_LZ_OAPP_ENFORCED_OPTS_GET, { oappConfig })
expect(consoleSpy.mock.lastCall).toMatchSnapshot()
})

it('should show different combined enforced options for all pathways', async () => {
const consoleSpy = jest.spyOn(console, 'log')
const oappConfig = configPathFixture('valid.multi.network.enforced.options.js')
await hre.run(TASK_LZ_OAPP_WIRE, { oappConfig, ci: true })
await hre.run(TASK_LZ_OAPP_ENFORCED_OPTIONS_GET, { oappConfig })
await hre.run(TASK_LZ_OAPP_ENFORCED_OPTS_GET, { oappConfig })
expect(consoleSpy.mock.lastCall).toMatchSnapshot()
})
})

0 comments on commit cc62747

Please sign in to comment.