-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ján Jakub Naništa <[email protected]>
- Loading branch information
1 parent
a97bb50
commit b206cda
Showing
14 changed files
with
372 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
--- | ||
|
||
Adding checkWire task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const TASK_LZ_WIRE_OAPP = 'lz:oapp:wire' | ||
export const TASK_LZ_GET_DEFAULT_CONFIG = 'lz:oapp:getDefaultConfig' | ||
export const TASK_LZ_GET_OAPP_CONFIG = 'lz:oapp:getOAppConfig' | ||
export const TASK_LZ_CHECK_WIRE_OAPP = 'lz:oapp:checkWire' |
57 changes: 57 additions & 0 deletions
57
packages/ua-devtools-evm-hardhat/src/tasks/oapp/checkWire.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { ActionType } from 'hardhat/types' | ||
import { task, types } from 'hardhat/config' | ||
import { createLogger, setDefaultLogLevel } from '@layerzerolabs/io-devtools' | ||
import { printRecords } from '@layerzerolabs/io-devtools/swag' | ||
import { TASK_LZ_CHECK_WIRE_OAPP } from '@/constants/tasks' | ||
import { printLogo } from '@layerzerolabs/io-devtools/swag' | ||
import { OAppOmniGraph } from '@layerzerolabs/ua-devtools' | ||
import { createConnectedContractFactory } from '@layerzerolabs/devtools-evm-hardhat' | ||
import { createOAppFactory } from '@layerzerolabs/ua-devtools-evm' | ||
import { checkOAppPeers } from '@layerzerolabs/ua-devtools' | ||
import { validateAndTransformOappConfig } from '@/utils/taskHelpers' | ||
import { getNetworkNameForEid } from '@layerzerolabs/devtools-evm-hardhat' | ||
import { printBoolean } from '@layerzerolabs/io-devtools' | ||
|
||
interface TaskArgs { | ||
oappConfig: string | ||
logLevel?: string | ||
} | ||
|
||
export const checkWire: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLevel = 'info' }) => { | ||
printLogo() | ||
|
||
// We'll set the global logging level to get as much info as needed | ||
setDefaultLogLevel(logLevel) | ||
|
||
// And we'll create a logger for ourselves | ||
const logger = createLogger() | ||
const graph: OAppOmniGraph = await validateAndTransformOappConfig(oappConfigPath, logger) | ||
|
||
// At this point we are ready read data from the OApp | ||
logger.verbose(`Reading peers from OApps`) | ||
const contractFactory = createConnectedContractFactory() | ||
const oAppFactory = createOAppFactory(contractFactory) | ||
|
||
try { | ||
const peers = await checkOAppPeers(graph, oAppFactory) | ||
|
||
const formattedPeers = peers.map((peer) => ({ | ||
'From network': getNetworkNameForEid(peer.vector.from.eid), | ||
'To network': getNetworkNameForEid(peer.vector.to.eid), | ||
Connected: printBoolean(peer.hasPeer), | ||
})) | ||
|
||
printRecords(formattedPeers) | ||
|
||
return peers | ||
} catch (error) { | ||
throw new Error(`An error occurred while getting the OApp configuration: ${error}`) | ||
} | ||
} | ||
|
||
task( | ||
TASK_LZ_CHECK_WIRE_OAPP, | ||
'outputs visual console table to show current state of oapp connections via configuration' | ||
) | ||
.addParam('oappConfig', 'Path to your LayerZero OApp config', './layerzero.config.js', types.string) | ||
.setAction(checkWire) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import './wire' | ||
import './checkWire' | ||
import './getDefaultConfig' | ||
import './getOAppConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { OAppFactory, OAppOmniGraph, OAppPeers } from '@/oapp/types' | ||
|
||
export type OAppRead = (graph: OAppOmniGraph, createSdk: OAppFactory) => Promise<OAppPeers[]> | ||
|
||
export const checkOAppPeers: OAppRead = async (graph, createSdk): Promise<OAppPeers[]> => { | ||
return await Promise.all( | ||
graph.connections.map(async ({ vector }): Promise<OAppPeers> => { | ||
const sdk = await createSdk(vector.from) | ||
const hasPeer = await sdk.hasPeer(vector.to.eid, vector.to.address) | ||
return { vector: vector, hasPeer } | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './check' | ||
export * from './config' | ||
export * from './schema' | ||
export * from './types' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.