-
Notifications
You must be signed in to change notification settings - Fork 266
DEVREL-1186 devtools QoL batch 1 #1906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nazreen
wants to merge
10
commits into
main
Choose a base branch
from
devtools-qol
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3bb4d5a
include audit links
nazreen ae49390
try removing
nazreen 7263ee4
lint fix
nazreen 48f134e
lint
nazreen 8b44af3
fix 1155
nazreen 954f1d5
changeset
nazreen 9b9c9a8
update message
nazreen e7b05af
fix
nazreen ab680e5
message
nazreen 607c6e1
when none deployed
nazreen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,9 @@ | ||
| --- | ||
| "@layerzerolabs/ua-devtools-evm-hardhat": patch | ||
| "@layerzerolabs/lzapp-migration-example": patch | ||
| "@layerzerolabs/oapp-solana-example": patch | ||
| "@layerzerolabs/oft-solana-example": patch | ||
| "@layerzerolabs/devtools": patch | ||
| --- | ||
|
|
||
| fix misleading message after running init-config |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,5 +1,5 @@ | ||
| import { task } from 'hardhat/config' | ||
| import type { ActionType } from 'hardhat/types' | ||
| import type { ActionType, HardhatRuntimeEnvironment } from 'hardhat/types' | ||
| import { TASK_COMPILE } from 'hardhat/builtin-tasks/task-names' | ||
| import { TASK_LZ_DEPLOY } from '@/constants/tasks' | ||
| import { | ||
|
|
@@ -17,11 +17,57 @@ import { formatEid } from '@layerzerolabs/devtools' | |
| import { getEidsByNetworkName, getHreByNetworkName } from '@/runtime' | ||
| import { types } from '@/cli' | ||
| import { promptForText } from '@layerzerolabs/io-devtools' | ||
| import { Deployment } from 'hardhat-deploy/dist/types' | ||
| import { Deployment, DeployFunction } from 'hardhat-deploy/dist/types' | ||
| import { assertDefinedNetworks, assertHardhatDeploy } from '@/internal/assertions' | ||
| import { splitCommaSeparated } from '@layerzerolabs/devtools' | ||
| import { isDeepEqual } from '@layerzerolabs/devtools' | ||
| import { Stage, endpointIdToStage } from '@layerzerolabs/lz-definitions' | ||
| import { readdirSync, statSync } from 'fs' | ||
| import { join, extname } from 'path' | ||
|
|
||
| /** | ||
| * Get all available tags from deploy scripts in the given deploy paths. | ||
| * Uses require() with ts-node/esm loader to handle TypeScript files. | ||
| */ | ||
| const getAvailableTagsFromDeployScripts = async (hre: HardhatRuntimeEnvironment): Promise<Set<string>> => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is is declared async but contains only synchronous code, so it could also directly return |
||
| const tags = new Set<string>() | ||
| const deployPaths = hre.config.paths.deploy | ||
|
|
||
| for (const deployPath of deployPaths) { | ||
| try { | ||
| const files = readdirSync(deployPath) | ||
| for (const file of files) { | ||
| const filePath = join(deployPath, file) | ||
| // Skip directories and non-script files | ||
| if (statSync(filePath).isDirectory()) { | ||
| continue | ||
| } | ||
| const ext = extname(file) | ||
| if (!['.js', '.ts'].includes(ext)) { | ||
| continue | ||
| } | ||
|
|
||
| try { | ||
| // Use require which works with ts-node/register in hardhat context | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const deployScript = require(filePath) | ||
| const deployFunc: DeployFunction = deployScript.default ?? deployScript | ||
| if (deployFunc?.tags) { | ||
| for (const tag of deployFunc.tags) { | ||
| tags.add(tag) | ||
| } | ||
| } | ||
| } catch { | ||
| // Skip files that can't be imported | ||
| } | ||
| } | ||
| } catch { | ||
| // Skip paths that don't exist | ||
| } | ||
| } | ||
|
|
||
| return tags | ||
| } | ||
|
|
||
| interface TaskArgs { | ||
| networks?: string[] | ||
|
|
@@ -166,6 +212,16 @@ const action: ActionType<TaskArgs> = async ( | |
| logger.warn(`Will use all deployment scripts`) | ||
| } else { | ||
| logger.info(`Will use deploy scripts tagged with ${selectedTags.join(', ')}`) | ||
|
|
||
| // Check if selected tags match any available deploy script tags | ||
| const availableTags = await getAvailableTagsFromDeployScripts(hre) | ||
| const unmatchedTags = selectedTags.filter((tag) => !availableTags.has(tag)) | ||
|
|
||
| if (unmatchedTags.length > 0) { | ||
| logger.warn( | ||
| `The following tags do not match any deploy scripts: ${unmatchedTags.join(', ')}. Available tags: ${[...availableTags].join(', ') || 'none'}` | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| // Now we confirm with the user that they want to continue | ||
|
|
@@ -261,8 +317,23 @@ const action: ActionType<TaskArgs> = async ( | |
| error == null ? [] : [{ networkName, error }] | ||
| ) | ||
|
|
||
| // If nothing went wrong we just exit | ||
| // We check whether any contracts were actually deployed | ||
| const totalContractsDeployed = Object.values(results).reduce( | ||
| (sum, { contracts }) => sum + Object.keys(contracts ?? {}).length, | ||
| 0 | ||
| ) | ||
|
|
||
| // If nothing went wrong we check if any contracts were deployed | ||
| if (errors.length === 0) { | ||
| if (totalContractsDeployed === 0) { | ||
| return ( | ||
| logger.warn( | ||
| `${printBoolean(false)} No contracts were deployed. This could mean the deploy script tags don't match any scripts, or all contracts were already deployed.` | ||
| ), | ||
| results | ||
| ) | ||
| } | ||
|
|
||
| return logger.info(`${printBoolean(true)} Your contracts are now deployed`), results | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.