diff --git a/.changeset/config.json b/.changeset/config.json index 3fdd82c95..26ce41eb1 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,11 +1,11 @@ { - "$schema": "https://unpkg.com/@changesets/config@2.1.0/schema.json", - "changelog": "@changesets/cli/changelog", - "commit": false, - "fixed": [], - "linked": [], - "access": "restricted", - "baseBranch": "origin/main", - "updateInternalDependencies": "patch", - "ignore": [] + "$schema": "https://unpkg.com/@changesets/config@2.1.0/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "origin/main", + "updateInternalDependencies": "patch", + "ignore": [] } diff --git a/.eslintrc.json b/.eslintrc.json index 257e960ef..6a1efda6e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,33 +1,37 @@ { - "root": true, - "env": { - "browser": true, - "commonjs": true, - "es6": true, - "mocha": true, - "node": true - }, - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "mocha", "prettier"], - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], - "parserOptions": { - "ecmaVersion": 8 - }, - "ignorePatterns": ["node_modules/", "dist/", ".turbo/"], - "rules": { - "mocha/no-skipped-tests": "error", - "mocha/no-exclusive-tests": "error", - "prettier/prettier": "error", + "root": true, + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "mocha": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint", "mocha", "prettier"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "prettier" + ], + "parserOptions": { + "ecmaVersion": 8 + }, + "ignorePatterns": ["node_modules/", "dist/", ".turbo/"], + "rules": { + "mocha/no-skipped-tests": "error", + "mocha/no-exclusive-tests": "error", + "prettier/prettier": "error", - // Intermediate deescalation to warnings - // - // FIXME Slowly remove these problems, then remove these overrides - "no-undef": "warn", - "no-constant-condition": "warn", + // Intermediate deescalation to warnings + // + // FIXME Slowly remove these problems, then remove these overrides + "no-undef": "warn", + "no-constant-condition": "warn", - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": "warn", - "@typescript-eslint/no-explicit-any": "warn", - "@typescript-eslint/no-var-requires": "warn" - } + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "warn", + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-var-requires": "warn" + } } diff --git a/.github/workflows/on-develop.yaml b/.github/workflows/on-develop.yaml index 8a1097b0d..6744ee50b 100644 --- a/.github/workflows/on-develop.yaml +++ b/.github/workflows/on-develop.yaml @@ -11,17 +11,17 @@ name: Check code submission on: - push: - # We have package publishing workflow running on main so this one is redundant - branches-ignore: - - "main" + push: + # We have package publishing workflow running on main so this one is redundant + branches-ignore: + - "main" # We want the workflow to stop and yield to a new run if new code is pushed concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - check: - uses: ./.github/workflows/reusable-test.yaml - secrets: inherit + check: + uses: ./.github/workflows/reusable-test.yaml + secrets: inherit diff --git a/.github/workflows/on-main.yaml b/.github/workflows/on-main.yaml index a6c9bf8ca..0fb662a9d 100644 --- a/.github/workflows/on-main.yaml +++ b/.github/workflows/on-main.yaml @@ -11,21 +11,21 @@ name: Check & publish on: - push: - branches: - - main + push: + branches: + - main # We only want one workflow to run at a time concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: false + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false jobs: - check: - uses: ./.github/workflows/reusable-test.yaml - secrets: inherit + check: + uses: ./.github/workflows/reusable-test.yaml + secrets: inherit - publish: - needs: check - uses: ./.github/workflows/reusable-publish.yaml - secrets: inherit + publish: + needs: check + uses: ./.github/workflows/reusable-publish.yaml + secrets: inherit diff --git a/.github/workflows/reusable-publish.yaml b/.github/workflows/reusable-publish.yaml index 038f1b1cf..8a84eda99 100644 --- a/.github/workflows/reusable-publish.yaml +++ b/.github/workflows/reusable-publish.yaml @@ -10,77 +10,77 @@ name: Publish packages on: - workflow_call: + workflow_call: # We'll default the NPM_TOKEN to an empty value since we use it # in .npmrc file and if undefined, the node setup would fail env: - NPM_TOKEN: "" + NPM_TOKEN: "" jobs: - publish: - name: Publish - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - cache: "yarn" + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + cache: "yarn" - # Install the dependencies without running the post-install scripts - - name: Install Dependencies - run: yarn install --frozen-lockfile --prefer-offline --ignore-scripts - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + # Install the dependencies without running the post-install scripts + - name: Install Dependencies + run: yarn install --frozen-lockfile --prefer-offline --ignore-scripts + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - # Run the post-install scripts - - name: Build Dependencies - run: yarn install --frozen-lockfile --offline + # Run the post-install scripts + - name: Build Dependencies + run: yarn install --frozen-lockfile --offline - # Cache build artifacts from turbo - # - # This step will speed up workflow runs that don't touch the whole codebase - # (or the ones that don't touch the codebase at all) - - name: Cache turbo build setup - uses: actions/cache@v3 - with: - path: node_modules/.cache/turbo - key: ${{ runner.os }}-turbo-${{ github.ref_name }} - restore-keys: | - ${{ runner.os }}-turbo- + # Cache build artifacts from turbo + # + # This step will speed up workflow runs that don't touch the whole codebase + # (or the ones that don't touch the codebase at all) + - name: Cache turbo build setup + uses: actions/cache@v3 + with: + path: node_modules/.cache/turbo + key: ${{ runner.os }}-turbo-${{ github.ref_name }} + restore-keys: | + ${{ runner.os }}-turbo- - - name: Build - run: yarn build - env: - NODE_ENV: production + - name: Build + run: yarn build + env: + NODE_ENV: production - # This step uses the changesets CLI to bump the package versions and/or publish the unpublished packages - # - # How this works is: - # - # - If there are any changesets (markdown files in the .changeset directory), - # changesets CLI will bump the package versions according to the bumps specified in the markdown files. - # - # - A PR is created containing these version bumps and with the changeset markdowns deleted - # - # - Once this PR is merged, this workflow kicks in again and this time checks - # whether there is anything that needs to be published - - name: Publish packages / create version bump PRs - uses: changesets/action@v1 - with: - version: yarn changeset version - publish: yarn changeset publish - title: "🚀 Version packages" + # This step uses the changesets CLI to bump the package versions and/or publish the unpublished packages + # + # How this works is: + # + # - If there are any changesets (markdown files in the .changeset directory), + # changesets CLI will bump the package versions according to the bumps specified in the markdown files. + # + # - A PR is created containing these version bumps and with the changeset markdowns deleted + # + # - Once this PR is merged, this workflow kicks in again and this time checks + # whether there is anything that needs to be published + - name: Publish packages / create version bump PRs + uses: changesets/action@v1 + with: + version: yarn changeset version + publish: yarn changeset publish + title: "🚀 Version packages" - env: - # This is here because changesets/action will look for the .npmrc - # in HOME folder and if it doesn't find one there it will create one - # - # Since we want to make sure it uses our .npmrc we'll just point it - # to our workspace root - HOME: ${{ github.workspace }} - GITHUB_TOKEN: ${{ secrets.LAYERZERO_BOT_GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISHER }} + env: + # This is here because changesets/action will look for the .npmrc + # in HOME folder and if it doesn't find one there it will create one + # + # Since we want to make sure it uses our .npmrc we'll just point it + # to our workspace root + HOME: ${{ github.workspace }} + GITHUB_TOKEN: ${{ secrets.LAYERZERO_BOT_GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISHER }} diff --git a/.github/workflows/reusable-test.yaml b/.github/workflows/reusable-test.yaml index 582ec4249..f88d8f030 100644 --- a/.github/workflows/reusable-test.yaml +++ b/.github/workflows/reusable-test.yaml @@ -10,57 +10,57 @@ name: Vape Tests on: - workflow_call: + workflow_call: # We'll default the NPM_TOKEN to an empty value since we use it # in .npmrc file and if undefined, the node setup would fail env: - NPM_TOKEN: "" + NPM_TOKEN: "" jobs: - build-and-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + build-and-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - cache: "yarn" + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + cache: "yarn" - # Install the dependencies without running the post-install scripts - - name: Install Dependencies - run: yarn install --frozen-lockfile --prefer-offline --ignore-scripts - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + # Install the dependencies without running the post-install scripts + - name: Install Dependencies + run: yarn install --frozen-lockfile --prefer-offline --ignore-scripts + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - # Run the post-install scripts - - name: Build Dependencies - run: yarn install --frozen-lockfile --offline + # Run the post-install scripts + - name: Build Dependencies + run: yarn install --frozen-lockfile --offline - # Cache build artifacts from turbo - # - # This step will speed up workflow runs that don't touch the whole codebase - # (or the ones that don't touch the codebase at all) - - name: Cache turbo build setup - uses: actions/cache@v3 - with: - path: node_modules/.cache/turbo - key: ${{ runner.os }}-turbo-${{ github.ref_name }} - restore-keys: | - ${{ runner.os }}-turbo- + # Cache build artifacts from turbo + # + # This step will speed up workflow runs that don't touch the whole codebase + # (or the ones that don't touch the codebase at all) + - name: Cache turbo build setup + uses: actions/cache@v3 + with: + path: node_modules/.cache/turbo + key: ${{ runner.os }}-turbo-${{ github.ref_name }} + restore-keys: | + ${{ runner.os }}-turbo- - - name: Lint - run: yarn lint + - name: Lint + run: yarn lint - - name: Build - run: yarn build + - name: Build + run: yarn build - - name: Test - run: yarn test - # Since we're running the E2E tests in docker, we'll need to reinstall - # the node modules. This is a temporary solution to bridge us between - # non-containerized and containerized development - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Test + run: yarn test + # Since we're running the E2E tests in docker, we'll need to reinstall + # the node modules. This is a temporary solution to bridge us between + # non-containerized and containerized development + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.prettierrc.js b/.prettierrc.js index 89f4730ea..6f55b4019 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,7 +1,3 @@ module.exports = { - printWidth: 145, - tabWidth: 4, - useTabs: false, - semi: false, - trailingComma: "es5", -} + ...require('@layerzerolabs/prettier-config-next'), +}; diff --git a/docker-compose.templates.yaml b/docker-compose.templates.yaml index 9c156e456..b662d5a91 100644 --- a/docker-compose.templates.yaml +++ b/docker-compose.templates.yaml @@ -10,13 +10,13 @@ version: "3.9" services: - # Service that contains the whole project - # - # It requires the PACKAGE argument that specifies - # the target package it should build (e.g. @layerzerolabs/utils-evm-hardhat) - project: - build: - context: . - args: - PACKAGE: - NPM_TOKEN: $NPM_TOKEN + # Service that contains the whole project + # + # It requires the PACKAGE argument that specifies + # the target package it should build (e.g. @layerzerolabs/utils-evm-hardhat) + project: + build: + context: . + args: + PACKAGE: + NPM_TOKEN: $NPM_TOKEN diff --git a/examples/oft/package.json b/examples/oft/package.json index 89f1ae6c4..c7ed91570 100644 --- a/examples/oft/package.json +++ b/examples/oft/package.json @@ -29,4 +29,4 @@ "ts-node": "^10.9.1", "typescript": "^5.3.2" } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 1b1f5756f..84f55ee10 100644 --- a/package.json +++ b/package.json @@ -1,40 +1,41 @@ { - "name": "@layerzerolabs/lz-utils", - "version": "0.0.1", - "private": true, - "workspaces": [ - "examples/*", - "packages/*" - ], - "scripts": { - "build": "npx turbo run build", - "clean": "npx turbo run clean", - "dev": "npx turbo run dev", - "lint": "npx turbo run lint", - "prepare": "husky install", - "test": "npx turbo run test" - }, - "lint-staged": { - "**/*": "npx prettier --write --ignore-unknown" - }, - "devDependencies": { - "@changesets/cli": "^2.26.2", - "@types/node": "~18.18.9", - "@typescript-eslint/eslint-plugin": "^6.12.0", - "@typescript-eslint/parser": "^6.12.0", - "eslint": "^8.54.0", - "eslint-config-prettier": "^9.0.0", - "eslint-config-standard": "^17.1.0", - "eslint-plugin-import": "^2.24.2", - "eslint-plugin-mocha": "10.2.0", - "eslint-plugin-n": "^16.3.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^5.0.1", - "eslint-plugin-promise": "^6.1.1", - "husky": "^8.0.3", - "lint-staged": "^15.1.0", - "prettier": "^3.1.0", - "prettier-plugin-solidity": "^1.0.0-beta.18", - "turbo": "1.5.6" - } -} + "name": "@layerzerolabs/lz-utils", + "version": "0.0.1", + "private": true, + "workspaces": [ + "examples/*", + "packages/*" + ], + "scripts": { + "build": "npx turbo run build", + "clean": "npx turbo run clean", + "dev": "npx turbo run dev", + "lint": "npx turbo run lint", + "prepare": "husky install", + "test": "npx turbo run test" + }, + "lint-staged": { + "**/*": "npx prettier --write --ignore-unknown" + }, + "devDependencies": { + "@changesets/cli": "^2.26.2", + "@layerzerolabs/prettier-config-next": "^1.5.60", + "@types/node": "~18.18.9", + "@typescript-eslint/eslint-plugin": "^6.12.0", + "@typescript-eslint/parser": "^6.12.0", + "eslint": "^8.54.0", + "eslint-config-prettier": "^9.0.0", + "eslint-config-standard": "^17.1.0", + "eslint-plugin-import": "^2.24.2", + "eslint-plugin-mocha": "10.2.0", + "eslint-plugin-n": "^16.3.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-promise": "^6.1.1", + "husky": "^8.0.3", + "lint-staged": "^15.1.0", + "prettier": "^3.1.0", + "prettier-plugin-solidity": "^1.0.0-beta.18", + "turbo": "1.5.6" + } +} \ No newline at end of file diff --git a/packages/create-lz-oapp/.mocharc.json b/packages/create-lz-oapp/.mocharc.json index d4ee538e6..4ddf3f6e5 100644 --- a/packages/create-lz-oapp/.mocharc.json +++ b/packages/create-lz-oapp/.mocharc.json @@ -1,5 +1,5 @@ { - "extensions": ["ts"], - "spec": ["**/*.test.*"], - "loader": "ts-node/esm" + "extensions": ["ts"], + "spec": ["**/*.test.*"], + "loader": "ts-node/esm" } diff --git a/packages/create-lz-oapp/CHANGELOG.md b/packages/create-lz-oapp/CHANGELOG.md index 9374e3c22..3f469452d 100644 --- a/packages/create-lz-oapp/CHANGELOG.md +++ b/packages/create-lz-oapp/CHANGELOG.md @@ -4,17 +4,17 @@ ### Patch Changes -- 7a0d823: Add the ability to override the default example repository using env variables +- 7a0d823: Add the ability to override the default example repository using env variables ## 0.1.1 ### Patch Changes -- 393bc3b: Only show available package managers when using create-lz-oapp -- 393bc3b: Add project directory validation +- 393bc3b: Only show available package managers when using create-lz-oapp +- 393bc3b: Add project directory validation ## 0.1.0 ### Minor Changes -- 65c2868: Add ability to download & install OApp & OFT examples +- 65c2868: Add ability to download & install OApp & OFT examples diff --git a/packages/create-lz-oapp/cli.cjs b/packages/create-lz-oapp/cli.cjs index 412593403..9d65330dd 100755 --- a/packages/create-lz-oapp/cli.cjs +++ b/packages/create-lz-oapp/cli.cjs @@ -1,3 +1,3 @@ #!/usr/bin/env node --max-old-space-size=4096 -import("./dist/index.js") +import("./dist/index.js"); diff --git a/packages/create-lz-oapp/package.json b/packages/create-lz-oapp/package.json index c7b1a7a93..97698e805 100644 --- a/packages/create-lz-oapp/package.json +++ b/packages/create-lz-oapp/package.json @@ -1,66 +1,66 @@ { - "name": "create-lz-oapp", - "version": "0.1.2", - "description": "Create LayerZero OApp with one command", - "keywords": [ - "LayerZero", - "OApp" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", - "directory": "packages/create-lz-oapp" - }, - "license": "MIT", - "type": "module", - "bin": { - "create-lz-oapp": "./cli.cjs" - }, - "files": [ - "./cli.cjs", - "./dist" - ], - "scripts": { - "prebuild": "tsc -noEmit", - "build": "npx tsup", - "clean": "rm -rf dist", - "dev": "npx tsup --watch", - "lint": "npx eslint '**/*.{js,ts,json}'", - "start": "./cli.cjs", - "test": "mocha --parallel" - }, - "dependencies": { - "yoga-wasm-web": "~0.3.3" - }, - "devDependencies": { - "@sindresorhus/tsconfig": "^5.0.0", - "@tanstack/react-query": "^5.8.4", - "@types/mocha": "^10.0.6", - "@types/prompts": "^2.4.9", - "@types/react": "^18.2.38", - "@types/which": "~3.0.3", - "chai": "^4.3.10", - "commander": "^11.1.0", - "eslint-plugin-react": "^7.32.2", - "eslint-plugin-react-hooks": "^4.6.0", - "ink": "^4.1.0", - "ink-gradient": "^3.0.0", - "ink-select-input": "^5.0.0", - "ink-spinner": "^5.0.0", - "ink-text-input": "^5.0.1", - "mocha": "^10.0.0", - "prompts": "^2.4.2", - "react": "^18.2.0", - "react-devtools-core": "^4.28.5", - "tiged": "^2.12.5", - "ts-node": "^10.9.1", - "typescript": "^5.3.2", - "which": "~4.0.0" - }, - "engines": { - "node": ">=18" - }, - "publishConfig": { - "access": "public" - } -} + "name": "create-lz-oapp", + "version": "0.1.2", + "description": "Create LayerZero OApp with one command", + "keywords": [ + "LayerZero", + "OApp" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", + "directory": "packages/create-lz-oapp" + }, + "license": "MIT", + "type": "module", + "bin": { + "create-lz-oapp": "./cli.cjs" + }, + "files": [ + "./cli.cjs", + "./dist" + ], + "scripts": { + "prebuild": "tsc -noEmit", + "build": "npx tsup", + "clean": "rm -rf dist", + "dev": "npx tsup --watch", + "lint": "npx eslint '**/*.{js,ts,json}'", + "start": "./cli.cjs", + "test": "mocha --parallel" + }, + "dependencies": { + "yoga-wasm-web": "~0.3.3" + }, + "devDependencies": { + "@sindresorhus/tsconfig": "^5.0.0", + "@tanstack/react-query": "^5.8.4", + "@types/mocha": "^10.0.6", + "@types/prompts": "^2.4.9", + "@types/react": "^18.2.38", + "@types/which": "~3.0.3", + "chai": "^4.3.10", + "commander": "^11.1.0", + "eslint-plugin-react": "^7.32.2", + "eslint-plugin-react-hooks": "^4.6.0", + "ink": "^4.1.0", + "ink-gradient": "^3.0.0", + "ink-select-input": "^5.0.0", + "ink-spinner": "^5.0.0", + "ink-text-input": "^5.0.1", + "mocha": "^10.0.0", + "prompts": "^2.4.2", + "react": "^18.2.0", + "react-devtools-core": "^4.28.5", + "tiged": "^2.12.5", + "ts-node": "^10.9.1", + "typescript": "^5.3.2", + "which": "~4.0.0" + }, + "engines": { + "node": ">=18" + }, + "publishConfig": { + "access": "public" + } +} \ No newline at end of file diff --git a/packages/create-lz-oapp/src/components/branding.tsx b/packages/create-lz-oapp/src/components/branding.tsx index 76d5d1b59..32fe02599 100644 --- a/packages/create-lz-oapp/src/components/branding.tsx +++ b/packages/create-lz-oapp/src/components/branding.tsx @@ -1,33 +1,33 @@ -import { Box, Text } from "ink" -import Gradient from "ink-gradient" -import { stdout } from "process" -import React, { useEffect, useState } from "react" +import { Box, Text } from "ink"; +import Gradient from "ink-gradient"; +import { stdout } from "process"; +import React, { useEffect, useState } from "react"; export const Header: React.FC = () => ( - - - -) + + + +); export const Logo: React.FC = () => { - const [columns, setColumns] = useState(stdout.columns ?? 80) - const logo = columns >= 130 ? LOGO_LARGE : LOGO_SMALL + const [columns, setColumns] = useState(stdout.columns ?? 80); + const logo = columns >= 130 ? LOGO_LARGE : LOGO_SMALL; - useEffect(() => { - const handleResize = () => setColumns(stdout.columns ?? 80) - stdout.on("resize", handleResize) + useEffect(() => { + const handleResize = () => setColumns(stdout.columns ?? 80); + stdout.on("resize", handleResize); - return () => { - stdout.off("resize", handleResize) - } - }, []) + return () => { + stdout.off("resize", handleResize); + }; + }, []); - return ( - - {logo} - - ) -} + return ( + + {logo} + + ); +}; // prettier-ignore const LOGO_LARGE = ` diff --git a/packages/create-lz-oapp/src/components/config.tsx b/packages/create-lz-oapp/src/components/config.tsx index 169279431..096890c05 100644 --- a/packages/create-lz-oapp/src/components/config.tsx +++ b/packages/create-lz-oapp/src/components/config.tsx @@ -1,25 +1,27 @@ -import React from "react" -import { Box, Text } from "ink" -import { Config } from "@/types.js" -import { resolve } from "path" +import React from "react"; +import { Box, Text } from "ink"; +import { Config } from "@/types.js"; +import { resolve } from "path"; interface Props { - value: Config + value: Config; } export const ConfigSummary: React.FC = ({ value }) => { - return ( - - - Will create a project in {value.destination || "current"} directory ( - {resolve(value.destination)}) - - - Will use the {value.example.label} example - - - Will use {value.packageManager.label} to install dependencies - - - ) -} + return ( + + + Will create a project in{" "} + {value.destination || "current"} directory ( + {resolve(value.destination)}) + + + Will use the {value.example.label} example + + + Will use {value.packageManager.label} to install + dependencies + + + ); +}; diff --git a/packages/create-lz-oapp/src/components/progress.tsx b/packages/create-lz-oapp/src/components/progress.tsx index 1cdf0a039..10debdddd 100644 --- a/packages/create-lz-oapp/src/components/progress.tsx +++ b/packages/create-lz-oapp/src/components/progress.tsx @@ -1,39 +1,43 @@ -import React from "react" -import { Box, Text } from "ink" -import Spinner from "ink-spinner" -import { UseMutationResult } from "@tanstack/react-query" +import React from "react"; +import { Box, Text } from "ink"; +import Spinner from "ink-spinner"; +import { UseMutationResult } from "@tanstack/react-query"; -type ErrorComponent = React.ComponentType<{ error: unknown }> +type ErrorComponent = React.ComponentType<{ error: unknown }>; interface Props { - error: ErrorComponent - message: string - mutation: Pick + error: ErrorComponent; + message: string; + mutation: Pick; } -export const Progress: React.FC = ({ mutation, message, error: Error }) => { - const { isPending, isSuccess, error } = mutation +export const Progress: React.FC = ({ + mutation, + message, + error: Error, +}) => { + const { isPending, isSuccess, error } = mutation; - return ( - - - {isPending ? ( - - ) : isSuccess ? ( - - ) : error ? ( - 𐄂 - ) : ( - - )} - {message} - + return ( + + + {isPending ? ( + + ) : isSuccess ? ( + + ) : error ? ( + 𐄂 + ) : ( + + )} + {message} + - {error == null ? null : ( - - - - )} + {error == null ? null : ( + + - ) -} + )} + + ); +}; diff --git a/packages/create-lz-oapp/src/components/providers.tsx b/packages/create-lz-oapp/src/components/providers.tsx index 91a7d34d3..c73489871 100644 --- a/packages/create-lz-oapp/src/components/providers.tsx +++ b/packages/create-lz-oapp/src/components/providers.tsx @@ -1,8 +1,10 @@ -import React, { useState } from "react" -import { QueryClient, QueryClientProvider } from "@tanstack/react-query" +import React, { useState } from "react"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; export const Providers: React.FC = ({ children }) => { - const [queryClient] = useState(() => new QueryClient()) + const [queryClient] = useState(() => new QueryClient()); - return {children} -} + return ( + {children} + ); +}; diff --git a/packages/create-lz-oapp/src/components/setup.tsx b/packages/create-lz-oapp/src/components/setup.tsx index 9e379bd54..53e2cc864 100644 --- a/packages/create-lz-oapp/src/components/setup.tsx +++ b/packages/create-lz-oapp/src/components/setup.tsx @@ -1,99 +1,110 @@ -import React, { useEffect } from "react" -import type { Config } from "@/types.js" -import { Box, Text } from "ink" -import { useMutation } from "@tanstack/react-query" -import { BadGitRefError, DestinationNotEmptyError, DownloadError, MissingGitRefError, cloneExample } from "@/utilities/cloning.js" -import { Progress } from "./progress.js" -import { installDependencies } from "@/utilities/installation.js" +import React, { useEffect } from "react"; +import type { Config } from "@/types.js"; +import { Box, Text } from "ink"; +import { useMutation } from "@tanstack/react-query"; +import { + BadGitRefError, + DestinationNotEmptyError, + DownloadError, + MissingGitRefError, + cloneExample, +} from "@/utilities/cloning.js"; +import { Progress } from "./progress.js"; +import { installDependencies } from "@/utilities/installation.js"; interface Props { - config: Config + config: Config; } export const Setup: React.FC = ({ config }) => { - const clone = useMutation({ - mutationKey: ["setup", "clone"], - mutationFn: () => cloneExample(config), - }) + const clone = useMutation({ + mutationKey: ["setup", "clone"], + mutationFn: () => cloneExample(config), + }); - const install = useMutation({ - mutationKey: ["setup", "install"], - mutationFn: () => installDependencies(config), - }) + const install = useMutation({ + mutationKey: ["setup", "install"], + mutationFn: () => installDependencies(config), + }); - const { mutate: setup } = useMutation({ - mutationKey: ["setup", "flow"], - mutationFn: async () => { - await clone.mutateAsync() - await install.mutateAsync() - }, - }) + const { mutate: setup } = useMutation({ + mutationKey: ["setup", "flow"], + mutationFn: async () => { + await clone.mutateAsync(); + await install.mutateAsync(); + }, + }); - useEffect(() => setup(), [setup]) + useEffect(() => setup(), [setup]); - return ( - - } - /> - } - /> - - ) -} + return ( + + } + /> + } + /> + + ); +}; interface ErrorMessageProps { - config: Config - error?: unknown + config: Config; + error?: unknown; } const ErrorMessage: React.FC = ({ config, error }) => { - if (error == null) return null + if (error == null) return null; - switch (true) { - case error instanceof DestinationNotEmptyError: - return ( - - Destination directory {config.destination} is not empty - - ) + switch (true) { + case error instanceof DestinationNotEmptyError: + return ( + + Destination directory {config.destination} is not + empty + + ); - case error instanceof BadGitRefError: - return ( - - The example {config.example.label} has its repository URL malformed: ' - {config.example.repository}' does not look like a valid repository - - ) + case error instanceof BadGitRefError: + return ( + + The example {config.example.label} has its + repository URL malformed: ' + {config.example.repository}' does not look like a + valid repository + + ); - case error instanceof MissingGitRefError: - return ( - - The example {config.example.label} does not seem to exist in the repository - - ) + case error instanceof MissingGitRefError: + return ( + + The example {config.example.label} does not seem to + exist in the repository + + ); - case error instanceof DownloadError: - return ( - - There was a problem downloading the example - ○ Please check your internet connection - - ○ Please check that the example exists ({config.example.repository}) - - - ) + case error instanceof DownloadError: + return ( + + There was a problem downloading the example + ○ Please check your internet connection + + ○ Please check that the example exists ( + {config.example.repository}) + + + ); - default: - return ( - - An unknown error happened: {String(error)} - - ) - } -} + default: + return ( + + An unknown error happened: {String(error)} + + ); + } +}; diff --git a/packages/create-lz-oapp/src/config.ts b/packages/create-lz-oapp/src/config.ts index 64dba60dc..215476e5f 100644 --- a/packages/create-lz-oapp/src/config.ts +++ b/packages/create-lz-oapp/src/config.ts @@ -1,10 +1,10 @@ -import type { Example, PackageManager } from "@/types.js" +import type { Example, PackageManager } from '@/types.js' /** * To enable example development in a custom repository * we open the repository URL field to be taken from the environment */ -const repository = process.env["LAYERZERO_EXAMPLES_REPOSITORY_URL"] || "git@github.com:LayerZero-Labs/lz-utils" +const repository = process.env['LAYERZERO_EXAMPLES_REPOSITORY_URL'] || 'git@github.com:LayerZero-Labs/lz-utils' /** * To enable example development in a custom branch, @@ -13,40 +13,40 @@ const repository = process.env["LAYERZERO_EXAMPLES_REPOSITORY_URL"] || "git@gith * `LAYERZERO_EXAMPLES_REPOSITORY_REF` can then be set to something like `#develop` or `#my-custom-branch` * to take the examples from a tag, a branch or a commit hash */ -const ref = process.env["LAYERZERO_EXAMPLES_REPOSITORY_REF"] || "" +const ref = process.env['LAYERZERO_EXAMPLES_REPOSITORY_REF'] || '' export const EXAMPLES: Example[] = [ { - id: "oft", - label: "OFT", + id: 'oft', + label: 'OFT', repository, - directory: "examples/oft", + directory: 'examples/oft', ref, }, { - id: "oapp", - label: "OApp", + id: 'oapp', + label: 'OApp', repository, - directory: "examples/oapp", + directory: 'examples/oapp', ref, }, ] export const PACKAGE_MANAGERS: PackageManager[] = [ { - command: "npm", - label: "npm", + command: 'npm', + label: 'npm', }, { - command: "yarn", - label: "yarn", + command: 'yarn', + label: 'yarn', }, { - command: "pnpm", - label: "pnpm", + command: 'pnpm', + label: 'pnpm', }, { - command: "bun", - label: "bun", + command: 'bun', + label: 'bun', }, ] diff --git a/packages/create-lz-oapp/src/index.tsx b/packages/create-lz-oapp/src/index.tsx index 5d97663c8..3dae794aa 100644 --- a/packages/create-lz-oapp/src/index.tsx +++ b/packages/create-lz-oapp/src/index.tsx @@ -1,41 +1,41 @@ -import React from "react" -import { render } from "ink" -import { Command } from "commander" -import { promptForConfig, promptForContinue } from "@/utilities/prompts.js" -import { Header } from "@/components/branding.js" -import { ConfigSummary } from "@/components/config.js" -import { Setup } from "@/components/setup.js" -import { Providers } from "@/components/providers.js" +import React from "react"; +import { render } from "ink"; +import { Command } from "commander"; +import { promptForConfig, promptForContinue } from "@/utilities/prompts.js"; +import { Header } from "@/components/branding.js"; +import { ConfigSummary } from "@/components/config.js"; +import { Setup } from "@/components/setup.js"; +import { Providers } from "@/components/providers.js"; new Command("create-lz-oapp") - .description("Create LayerZero OApp with one command") - .action(async () => { - // const exitAltScreen = await altScreen() + .description("Create LayerZero OApp with one command") + .action(async () => { + // const exitAltScreen = await altScreen() - try { - render(
).unmount() + try { + render(
).unmount(); - // First we get the config from the user - const config = await promptForConfig() - render().unmount() + // First we get the config from the user + const config = await promptForConfig(); + render().unmount(); - // Then we confirm we want to do this after showing the user what they have specified - const continuePlease = await promptForContinue() - if (!continuePlease) { - return - } + // Then we confirm we want to do this after showing the user what they have specified + const continuePlease = await promptForContinue(); + if (!continuePlease) { + return; + } - // Then the last step is to show the setup flow - const setup = render( - - - - ) + // Then the last step is to show the setup flow + const setup = render( + + + , + ); - // And wait for it to exit - await setup.waitUntilExit() - } finally { - // await exitAltScreen() - } - }) - .parseAsync() + // And wait for it to exit + await setup.waitUntilExit(); + } finally { + // await exitAltScreen() + } + }) + .parseAsync(); diff --git a/packages/create-lz-oapp/src/utilities/cloning.ts b/packages/create-lz-oapp/src/utilities/cloning.ts index c563b35ca..c55a03f3d 100644 --- a/packages/create-lz-oapp/src/utilities/cloning.ts +++ b/packages/create-lz-oapp/src/utilities/cloning.ts @@ -1,6 +1,6 @@ -import { Config, Example } from "@/types.js" -import { rm } from "fs/promises" -import tiged from "tiged" +import { Config, Example } from '@/types.js' +import { rm } from 'fs/promises' +import tiged from 'tiged' /** * Helper function to satisfy the `tiged` repository URL specification @@ -11,18 +11,18 @@ import tiged from "tiged" export const createExampleGitURL = (example: Example): string => { return [ example.repository, - example.directory ? "/" + example.directory.replace(/^\//, "") : undefined, - example.ref ? "#" + example.ref.replace(/^#/, "") : undefined, + example.directory ? '/' + example.directory.replace(/^\//, '') : undefined, + example.ref ? '#' + example.ref.replace(/^#/, '') : undefined, ] .filter(Boolean) - .join("") + .join('') } export const cloneExample = async ({ example, destination }: Config) => { const url = createExampleGitURL(example) const emitter = tiged(url, { disableCache: true, - mode: "git", + mode: 'git', verbose: true, }) @@ -36,25 +36,25 @@ export const cloneExample = async ({ example, destination }: Config) => { // If the cleanup fails let's just do nothing for now } - if (error instanceof Error && "code" in error) { + if (error instanceof Error && 'code' in error) { switch (error.code) { - case "BAD_SRC": + case 'BAD_SRC': throw new BadGitRefError() - case "DEST_NOT_EMPTY": + case 'DEST_NOT_EMPTY': throw new DestinationNotEmptyError() - case "ENOENT": - case "MISSING_REF": + case 'ENOENT': + case 'MISSING_REF': throw new MissingGitRefError() - case "COULD_NOT_DOWNLOAD": + case 'COULD_NOT_DOWNLOAD': throw new DownloadError() } } if (error instanceof Error) { - if (/fatal: couldn't find remote ref/.test(error.message ?? "")) { + if (/fatal: couldn't find remote ref/.test(error.message ?? '')) { throw new MissingGitRefError() } } @@ -64,31 +64,31 @@ export const cloneExample = async ({ example, destination }: Config) => { } export class CloningError extends Error { - constructor(message: string = "Unknown error during example cloning") { + constructor(message: string = 'Unknown error during example cloning') { super(message) } } export class DestinationNotEmptyError extends CloningError { - constructor(message: string = "Project destination directory is not empty") { + constructor(message: string = 'Project destination directory is not empty') { super(message) } } export class MissingGitRefError extends CloningError { - constructor(message: string = "Could not find the example repository or branch") { + constructor(message: string = 'Could not find the example repository or branch') { super(message) } } export class BadGitRefError extends CloningError { - constructor(message: string = "Malformed repository URL") { + constructor(message: string = 'Malformed repository URL') { super(message) } } export class DownloadError extends CloningError { - constructor(message: string = "Could not download the example from repository") { + constructor(message: string = 'Could not download the example from repository') { super(message) } } diff --git a/packages/create-lz-oapp/src/utilities/filesystem.ts b/packages/create-lz-oapp/src/utilities/filesystem.ts index bec86662a..f6ef1f54e 100644 --- a/packages/create-lz-oapp/src/utilities/filesystem.ts +++ b/packages/create-lz-oapp/src/utilities/filesystem.ts @@ -1,4 +1,4 @@ -import { lstatSync } from "fs" +import { lstatSync } from 'fs' export const isDirectory = (path: string) => { try { diff --git a/packages/create-lz-oapp/src/utilities/installation.ts b/packages/create-lz-oapp/src/utilities/installation.ts index 5b439dd74..4d53e776c 100644 --- a/packages/create-lz-oapp/src/utilities/installation.ts +++ b/packages/create-lz-oapp/src/utilities/installation.ts @@ -1,29 +1,34 @@ -import type { Config, PackageManager } from "@/types.js" -import { spawn } from "child_process" -import which from "which" +import type { Config, PackageManager } from '@/types.js' +import { spawn } from 'child_process' +import which from 'which' export const installDependencies = (config: Config) => new Promise((resolve, reject) => { /** * Spawn the installation process. */ - const child = spawn(config.packageManager.command, ["install"], { + const child = spawn(config.packageManager.command, ['install'], { cwd: config.destination, env: { ...process.env, - ADBLOCK: "1", + ADBLOCK: '1', // we set NODE_ENV to development as pnpm skips dev // dependencies when production - NODE_ENV: "development", - DISABLE_OPENCOLLECTIVE: "1", + NODE_ENV: 'development', + DISABLE_OPENCOLLECTIVE: '1', }, }) - child.on("close", (code) => { + child.on('close', (code) => { if (code !== 0) { - reject(new Error(`Failed to install dependencies: ${config.packageManager.label} install exited with code ${code}`)) + reject( + new Error( + `Failed to install dependencies: ${config.packageManager.label} install exited with code ${code}` + ) + ) } else resolve() }) }) -export const isPackageManagerAvailable = ({ command }: PackageManager): boolean => !!which.sync(command, { nothrow: true }) +export const isPackageManagerAvailable = ({ command }: PackageManager): boolean => + !!which.sync(command, { nothrow: true }) diff --git a/packages/create-lz-oapp/src/utilities/prompts.ts b/packages/create-lz-oapp/src/utilities/prompts.ts index 9301031c0..ac5fa79f3 100644 --- a/packages/create-lz-oapp/src/utilities/prompts.ts +++ b/packages/create-lz-oapp/src/utilities/prompts.ts @@ -1,24 +1,24 @@ -import { EXAMPLES, PACKAGE_MANAGERS } from "@/config.js" -import prompts from "prompts" -import { isPackageManagerAvailable } from "./installation.js" -import { isDirectory } from "./filesystem.js" -import { resolve } from "path" +import { EXAMPLES, PACKAGE_MANAGERS } from '@/config.js' +import prompts from 'prompts' +import { isPackageManagerAvailable } from './installation.js' +import { isDirectory } from './filesystem.js' +import { resolve } from 'path' const handlePromptState = (state: any) => { if (state.aborted) { // If we don't re-enable the terminal cursor before exiting // the program, the cursor will remain hidden - process.stdout.write("\x1B[?25h") - process.stdout.write("\n") + process.stdout.write('\x1B[?25h') + process.stdout.write('\n') process.exit(1) } } export const promptForContinue = async () => prompts({ - type: "confirm", - name: "pleasecontinue", - message: "Would you like to continue?", + type: 'confirm', + name: 'pleasecontinue', + message: 'Would you like to continue?', initial: true, }).then(({ pleasecontinue }): boolean => pleasecontinue) @@ -26,27 +26,27 @@ export const promptForConfig = () => prompts([ { onState: handlePromptState, - type: "text", - name: "destination", - message: "Where do you want to start your project?", - initial: "./my-lz-oapp", + type: 'text', + name: 'destination', + message: 'Where do you want to start your project?', + initial: './my-lz-oapp', validate: (path: string) => (isDirectory(path) ? `Directory '${resolve(path)}' already exists` : true), }, { onState: handlePromptState, - type: "select", - name: "example", - message: "Which example would you like to use as a starting point?", + type: 'select', + name: 'example', + message: 'Which example would you like to use as a starting point?', choices: EXAMPLES.map((example) => ({ title: example.label, value: example })), }, { onState: handlePromptState, - type: "select", - name: "packageManager", + type: 'select', + name: 'packageManager', choices: PACKAGE_MANAGERS.filter(isPackageManagerAvailable).map((packageManager) => ({ title: packageManager.label, value: packageManager, })), - message: "What package manager would you like to use in your project?", + message: 'What package manager would you like to use in your project?', }, ]) diff --git a/packages/create-lz-oapp/src/utilities/terminal.ts b/packages/create-lz-oapp/src/utilities/terminal.ts index c5c42c2df..6aa347d36 100644 --- a/packages/create-lz-oapp/src/utilities/terminal.ts +++ b/packages/create-lz-oapp/src/utilities/terminal.ts @@ -1,5 +1,5 @@ -const ENTER_ALT_SCREEN_ANSI = "\x1b[?1049h" -const EXIT_ALT_SCREEN_ANSI = "\x1b[?1049l" +const ENTER_ALT_SCREEN_ANSI = '\x1b[?1049h' +const EXIT_ALT_SCREEN_ANSI = '\x1b[?1049l' /** * Helper function that wraps socket writes with a promise diff --git a/packages/create-lz-oapp/test/utilities/cloning.test.ts b/packages/create-lz-oapp/test/utilities/cloning.test.ts index d5eca9485..428b99fcc 100644 --- a/packages/create-lz-oapp/test/utilities/cloning.test.ts +++ b/packages/create-lz-oapp/test/utilities/cloning.test.ts @@ -1,35 +1,49 @@ -import { expect } from "chai" -import { describe, it } from "mocha" -import { createExampleGitURL } from "../../src/utilities/cloning.js" +import { expect } from 'chai' +import { describe, it } from 'mocha' +import { createExampleGitURL } from '../../src/utilities/cloning.js' -describe("utilities/cloning", () => { - describe("createExampleGitURL", () => { - const REPO_URL = "git@github.com:LayerZero-Labs/lz-utils" +describe('utilities/cloning', () => { + describe('createExampleGitURL', () => { + const REPO_URL = 'git@github.com:LayerZero-Labs/lz-utils' - it("should return the repository field if directory and ref are not specified", () => { - expect(createExampleGitURL({ repository: REPO_URL, id: "dummy", label: "Dummy" })).to.eql(REPO_URL) + it('should return the repository field if directory and ref are not specified', () => { + expect(createExampleGitURL({ repository: REPO_URL, id: 'dummy', label: 'Dummy' })).to.eql(REPO_URL) }) - it("should return the repository field with directory if directory is specified", () => { - expect(createExampleGitURL({ repository: REPO_URL, directory: "dir", id: "dummy", label: "Dummy" })).to.eql(`${REPO_URL}/dir`) - expect(createExampleGitURL({ repository: REPO_URL, directory: "/dir", id: "dummy", label: "Dummy" })).to.eql(`${REPO_URL}/dir`) - expect(createExampleGitURL({ repository: REPO_URL, directory: "dir", ref: "", id: "dummy", label: "Dummy" })).to.eql( + it('should return the repository field with directory if directory is specified', () => { + expect(createExampleGitURL({ repository: REPO_URL, directory: 'dir', id: 'dummy', label: 'Dummy' })).to.eql( `${REPO_URL}/dir` ) + expect( + createExampleGitURL({ repository: REPO_URL, directory: '/dir', id: 'dummy', label: 'Dummy' }) + ).to.eql(`${REPO_URL}/dir`) + expect( + createExampleGitURL({ repository: REPO_URL, directory: 'dir', ref: '', id: 'dummy', label: 'Dummy' }) + ).to.eql(`${REPO_URL}/dir`) }) - it("should return the repository field with directory and ref if directory and ref are specified", () => { - expect(createExampleGitURL({ repository: REPO_URL, directory: "dir", ref: "ref", id: "dummy", label: "Dummy" })).to.eql( - `${REPO_URL}/dir#ref` - ) - expect(createExampleGitURL({ repository: REPO_URL, directory: "dir", ref: "#ref", id: "dummy", label: "Dummy" })).to.eql( - `${REPO_URL}/dir#ref` - ) + it('should return the repository field with directory and ref if directory and ref are specified', () => { + expect( + createExampleGitURL({ repository: REPO_URL, directory: 'dir', ref: 'ref', id: 'dummy', label: 'Dummy' }) + ).to.eql(`${REPO_URL}/dir#ref`) + expect( + createExampleGitURL({ + repository: REPO_URL, + directory: 'dir', + ref: '#ref', + id: 'dummy', + label: 'Dummy', + }) + ).to.eql(`${REPO_URL}/dir#ref`) }) - it("should return the repository field with ref if only ref specified", () => { - expect(createExampleGitURL({ repository: REPO_URL, ref: "ref", id: "dummy", label: "Dummy" })).to.eql(`${REPO_URL}#ref`) - expect(createExampleGitURL({ repository: REPO_URL, ref: "#ref", id: "dummy", label: "Dummy" })).to.eql(`${REPO_URL}#ref`) + it('should return the repository field with ref if only ref specified', () => { + expect(createExampleGitURL({ repository: REPO_URL, ref: 'ref', id: 'dummy', label: 'Dummy' })).to.eql( + `${REPO_URL}#ref` + ) + expect(createExampleGitURL({ repository: REPO_URL, ref: '#ref', id: 'dummy', label: 'Dummy' })).to.eql( + `${REPO_URL}#ref` + ) }) }) }) diff --git a/packages/create-lz-oapp/tsconfig.json b/packages/create-lz-oapp/tsconfig.json index 13b91d00f..0a46d685e 100644 --- a/packages/create-lz-oapp/tsconfig.json +++ b/packages/create-lz-oapp/tsconfig.json @@ -1,14 +1,14 @@ { - "extends": "@sindresorhus/tsconfig", - "compilerOptions": { - "outDir": "dist", - "declaration": false, - "target": "esnext", - "types": ["mocha", "node"], - "paths": { - "@/*": ["./src/*"] - } - }, - "files": ["./types/tiged.d.ts"], - "include": ["src", "test", "types"] + "extends": "@sindresorhus/tsconfig", + "compilerOptions": { + "outDir": "dist", + "declaration": false, + "target": "esnext", + "types": ["mocha", "node"], + "paths": { + "@/*": ["./src/*"] + } + }, + "files": ["./types/tiged.d.ts"], + "include": ["src", "test", "types"] } diff --git a/packages/create-lz-oapp/tsup.config.ts b/packages/create-lz-oapp/tsup.config.ts index 4464289f7..63be5472b 100644 --- a/packages/create-lz-oapp/tsup.config.ts +++ b/packages/create-lz-oapp/tsup.config.ts @@ -1,17 +1,17 @@ -import { defineConfig } from "tsup" +import { defineConfig } from 'tsup' export default defineConfig({ - entry: ["src/index.tsx"], - outDir: "./dist", + entry: ['src/index.tsx'], + outDir: './dist', clean: true, dts: false, minify: true, sourcemap: false, splitting: false, treeshake: true, - format: ["esm"], + format: ['esm'], env: { - NODE_ENV: "production", + NODE_ENV: 'production', }, // This needs to be included for the CommonJS interoperability to work // @@ -19,5 +19,5 @@ export default defineConfig({ banner: { js: `import { createRequire as _createRequire } from 'node:module'; const require = _createRequire(import.meta.url);`, }, - external: ["yoga-wasm-web"], + external: ['yoga-wasm-web'], }) diff --git a/packages/create-lz-oapp/types/tiged.d.ts b/packages/create-lz-oapp/types/tiged.d.ts index 76fa70ade..0ed85b562 100644 --- a/packages/create-lz-oapp/types/tiged.d.ts +++ b/packages/create-lz-oapp/types/tiged.d.ts @@ -1,7 +1,7 @@ -declare module "tiged" { - import EventEmitter from "events" +declare module 'tiged' { + import EventEmitter from 'events' - export type TigedMode = "git" | "tar" + export type TigedMode = 'git' | 'tar' export interface TigedOptions { disableCache?: boolean diff --git a/packages/ua-utils-evm-hardhat-test/deploy/001_bootstrap.ts b/packages/ua-utils-evm-hardhat-test/deploy/001_bootstrap.ts index 0a63c41b2..288deeeec 100644 --- a/packages/ua-utils-evm-hardhat-test/deploy/001_bootstrap.ts +++ b/packages/ua-utils-evm-hardhat-test/deploy/001_bootstrap.ts @@ -1,6 +1,6 @@ -import { type DeployFunction } from "hardhat-deploy/types" -import { AddressZero } from "@ethersproject/constants" -import assert from "assert" +import { type DeployFunction } from 'hardhat-deploy/types' +import { AddressZero } from '@ethersproject/constants' +import assert from 'assert' /** * This deploy function will deploy and configure LayerZero endpoint @@ -12,12 +12,12 @@ const deploy: DeployFunction = async ({ getUnnamedAccounts, deployments, network const [deployer] = await getUnnamedAccounts() - const endpointV2Deployment = await deployments.deploy("EndpointV2", { + const endpointV2Deployment = await deployments.deploy('EndpointV2', { from: deployer, args: [network.config.endpointId, AddressZero], }) - const uln302Deployment = await deployments.deploy("UltraLightNode302", { + const uln302Deployment = await deployments.deploy('UltraLightNode302', { from: deployer, args: [endpointV2Deployment.address, 0], }) @@ -28,6 +28,6 @@ const deploy: DeployFunction = async ({ getUnnamedAccounts, deployments, network }) } -deploy.tags = ["Bootstrap", "EndpointV2"] +deploy.tags = ['Bootstrap', 'EndpointV2'] export default deploy diff --git a/packages/ua-utils-evm-hardhat-test/docker-compose.templates.yaml b/packages/ua-utils-evm-hardhat-test/docker-compose.templates.yaml index f13507292..bd0db5985 100644 --- a/packages/ua-utils-evm-hardhat-test/docker-compose.templates.yaml +++ b/packages/ua-utils-evm-hardhat-test/docker-compose.templates.yaml @@ -10,24 +10,24 @@ version: "3.9" services: - # Service that can build this package - package: - build: - args: - PACKAGE: "@layerzerolabs/ua-utils-evm-hardhat-test" - extends: - file: ../../docker-compose.templates.yaml - service: project - working_dir: /app/packages/ua-utils-evm-hardhat-test - volumes: - - ./:/app/packages/ua-utils-evm-hardhat-test + # Service that can build this package + package: + build: + args: + PACKAGE: "@layerzerolabs/ua-utils-evm-hardhat-test" + extends: + file: ../../docker-compose.templates.yaml + service: project + working_dir: /app/packages/ua-utils-evm-hardhat-test + volumes: + - ./:/app/packages/ua-utils-evm-hardhat-test - # Hardhat node started on port 8545 - node: - extends: - service: package - expose: - - 8545 - command: ["npx", "hardhat", "node", "--hostname", "0.0.0.0", "--no-deploy"] - healthcheck: - test: ["CMD", "curl", "-f", "http://0.0.0.0:8545/"] + # Hardhat node started on port 8545 + node: + extends: + service: package + expose: + - 8545 + command: ["npx", "hardhat", "node", "--hostname", "0.0.0.0", "--no-deploy"] + healthcheck: + test: ["CMD", "curl", "-f", "http://0.0.0.0:8545/"] diff --git a/packages/ua-utils-evm-hardhat-test/docker-compose.yaml b/packages/ua-utils-evm-hardhat-test/docker-compose.yaml index 119ef83b8..4efe23e85 100644 --- a/packages/ua-utils-evm-hardhat-test/docker-compose.yaml +++ b/packages/ua-utils-evm-hardhat-test/docker-compose.yaml @@ -10,58 +10,58 @@ version: "3.9" services: - # ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ - # - # Network nodes, one for every hardhat network - # - # .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. - network-vengaboys: - extends: - file: docker-compose.templates.yaml - service: node + # ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ + # + # Network nodes, one for every hardhat network + # + # .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. + network-vengaboys: + extends: + file: docker-compose.templates.yaml + service: node - network-britney: - extends: - file: docker-compose.templates.yaml - service: node + network-britney: + extends: + file: docker-compose.templates.yaml + service: node - # ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ - # - # Bootstrap script that deploys all the networks + # ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ + # + # Bootstrap script that deploys all the networks + # + # .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. + bootstrap: + extends: + file: docker-compose.templates.yaml + service: package + depends_on: + network-vengaboys: + condition: service_healthy + network-britney: + condition: service_healthy + # Can't say I love the fact that the deploy scripts are inlined here + # but at least it's all in this file that bootstraps the whole environment # - # .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. - bootstrap: - extends: - file: docker-compose.templates.yaml - service: package - depends_on: - network-vengaboys: - condition: service_healthy - network-britney: - condition: service_healthy - # Can't say I love the fact that the deploy scripts are inlined here - # but at least it's all in this file that bootstraps the whole environment - # - # The "&" at the end of the lines and "wait" work together to execute the deployments - # in parallel and wait until they are all complete - command: - - /bin/bash - - -c - - | - npx hardhat --network vengaboys deploy --reset & - npx hardhat --network britney deploy --reset & - wait + # The "&" at the end of the lines and "wait" work together to execute the deployments + # in parallel and wait until they are all complete + command: + - /bin/bash + - -c + - | + npx hardhat --network vengaboys deploy --reset & + npx hardhat --network britney deploy --reset & + wait - # ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ - # - # The actual tests - # - # .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. - tests: - extends: - file: docker-compose.templates.yaml - service: package - depends_on: - bootstrap: - condition: service_completed_successfully - command: ["npx", "hardhat", "test"] + # ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ + # + # The actual tests + # + # .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. + tests: + extends: + file: docker-compose.templates.yaml + service: package + depends_on: + bootstrap: + condition: service_completed_successfully + command: ["npx", "hardhat", "test"] diff --git a/packages/ua-utils-evm-hardhat-test/hardhat.config.ts b/packages/ua-utils-evm-hardhat-test/hardhat.config.ts index 0f76d0a67..0c06d2bc6 100644 --- a/packages/ua-utils-evm-hardhat-test/hardhat.config.ts +++ b/packages/ua-utils-evm-hardhat-test/hardhat.config.ts @@ -1,10 +1,10 @@ -import "hardhat-deploy" -import "hardhat-deploy-ethers" -import { withLayerZeroArtifacts } from "../utils-evm-hardhat/dist" -import { EndpointId } from "@layerzerolabs/lz-definitions" -import { HardhatUserConfig } from "hardhat/types" +import 'hardhat-deploy' +import 'hardhat-deploy-ethers' +import { withLayerZeroArtifacts } from '../utils-evm-hardhat/dist' +import { EndpointId } from '@layerzerolabs/lz-definitions' +import { HardhatUserConfig } from 'hardhat/types' -const MNEMONIC = "test test test test test test test test test test test test" +const MNEMONIC = 'test test test test test test test test test test test test' /** * This is a dummy hardhat config that enables us to test @@ -19,14 +19,14 @@ const config: HardhatUserConfig = { }, vengaboys: { endpointId: EndpointId.ETHEREUM_MAINNET, - url: "http://network-vengaboys:8545", + url: 'http://network-vengaboys:8545', accounts: { mnemonic: MNEMONIC, }, }, britney: { endpointId: EndpointId.AVALANCHE_MAINNET, - url: "http://network-britney:8545", + url: 'http://network-britney:8545', accounts: { mnemonic: MNEMONIC, }, @@ -34,4 +34,4 @@ const config: HardhatUserConfig = { }, } -export default withLayerZeroArtifacts("@layerzerolabs/lz-evm-sdk-v2")(config) +export default withLayerZeroArtifacts('@layerzerolabs/lz-evm-sdk-v2')(config) diff --git a/packages/ua-utils-evm-hardhat-test/package.json b/packages/ua-utils-evm-hardhat-test/package.json index 42f7822f8..bbb7f3463 100644 --- a/packages/ua-utils-evm-hardhat-test/package.json +++ b/packages/ua-utils-evm-hardhat-test/package.json @@ -1,42 +1,42 @@ { - "name": "@layerzerolabs/ua-utils-evm-hardhat-test", - "version": "0.0.1", - "private": true, - "description": "Integration tests for ua-utils-evm-hardhat for V2", - "repository": { - "type": "git", - "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", - "directory": "packages/ua-utils-evm-hardhat-test" - }, - "license": "MIT", - "scripts": { - "lint": "npx eslint '**/*.{js,ts,json}'", - "test": "docker compose run --rm tests" - }, - "devDependencies": { - "@ethersproject/abstract-signer": "^5.7.0", - "@ethersproject/constants": "^5.7.0", - "@ethersproject/providers": "^5.7.0", - "@ethersproject/wallet": "^5.7.0", - "@gnosis.pm/safe-core-sdk": "^2.0.0", - "@gnosis.pm/safe-core-sdk-types": "^1.0.0", - "@gnosis.pm/safe-ethers-lib": "^1.0.0", - "@gnosis.pm/safe-service-client": "1.1.1", - "@layerzerolabs/lz-definitions": "~1.5.61", - "@layerzerolabs/lz-evm-sdk-v1": "~1.5.61", - "@layerzerolabs/lz-evm-sdk-v2": "~1.5.61", - "@layerzerolabs/utils-evm-hardhat": "~0.0.1", - "@nomiclabs/hardhat-ethers": "^2.2.3", - "@types/chai-as-promised": "^7.1.7", - "@types/mocha": "^10.0.6", - "chai": "^4.3.10", - "chai-as-promised": "^7.1.1", - "ethers": "^5.7.0", - "hardhat": "^2.9.9", - "hardhat-deploy": "^0.11.22", - "hardhat-deploy-ethers": "^0.3.0-beta.12", - "sinon": "^17.0.1", - "ts-node": "^10.9.1", - "typescript": "^5.3.2" - } -} + "name": "@layerzerolabs/ua-utils-evm-hardhat-test", + "version": "0.0.1", + "private": true, + "description": "Integration tests for ua-utils-evm-hardhat for V2", + "repository": { + "type": "git", + "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", + "directory": "packages/ua-utils-evm-hardhat-test" + }, + "license": "MIT", + "scripts": { + "lint": "npx eslint '**/*.{js,ts,json}'", + "test": "docker compose run --rm tests" + }, + "devDependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/providers": "^5.7.0", + "@ethersproject/wallet": "^5.7.0", + "@gnosis.pm/safe-core-sdk": "^2.0.0", + "@gnosis.pm/safe-core-sdk-types": "^1.0.0", + "@gnosis.pm/safe-ethers-lib": "^1.0.0", + "@gnosis.pm/safe-service-client": "1.1.1", + "@layerzerolabs/lz-definitions": "~1.5.61", + "@layerzerolabs/lz-evm-sdk-v1": "~1.5.61", + "@layerzerolabs/lz-evm-sdk-v2": "~1.5.61", + "@layerzerolabs/utils-evm-hardhat": "~0.0.1", + "@nomiclabs/hardhat-ethers": "^2.2.3", + "@types/chai-as-promised": "^7.1.7", + "@types/mocha": "^10.0.6", + "chai": "^4.3.10", + "chai-as-promised": "^7.1.1", + "ethers": "^5.7.0", + "hardhat": "^2.9.9", + "hardhat-deploy": "^0.11.22", + "hardhat-deploy-ethers": "^0.3.0-beta.12", + "sinon": "^17.0.1", + "ts-node": "^10.9.1", + "typescript": "^5.3.2" + } +} \ No newline at end of file diff --git a/packages/ua-utils-evm-hardhat-test/test/config.test.ts b/packages/ua-utils-evm-hardhat-test/test/config.test.ts index 04b522814..c4d412783 100644 --- a/packages/ua-utils-evm-hardhat-test/test/config.test.ts +++ b/packages/ua-utils-evm-hardhat-test/test/config.test.ts @@ -1,11 +1,11 @@ -import { expect } from "chai" -import { describe } from "mocha" -import { getNetworkRuntimeEnvironment } from "../../utils-evm-hardhat/dist" -import { HardhatRuntimeEnvironment } from "hardhat/types" +import { expect } from 'chai' +import { describe } from 'mocha' +import { getNetworkRuntimeEnvironment } from '../../utils-evm-hardhat/dist' +import { HardhatRuntimeEnvironment } from 'hardhat/types' -const NETWORK_NAMES = ["vengaboys", "britney"] +const NETWORK_NAMES = ['vengaboys', 'britney'] -describe("config", () => { +describe('config', () => { NETWORK_NAMES.forEach((networkName) => { describe(`Network '${networkName}`, () => { let environment: HardhatRuntimeEnvironment @@ -14,11 +14,11 @@ describe("config", () => { environment = await getNetworkRuntimeEnvironment(networkName) }) - it("should have an endpoint deployed", async () => { - const endpoint = await environment.ethers.getContract("EndpointV2") + it('should have an endpoint deployed', async () => { + const endpoint = await environment.ethers.getContract('EndpointV2') const endpointId = await endpoint.eid() - expect(environment.network.config.endpointId).to.be.a("number") + expect(environment.network.config.endpointId).to.be.a('number') expect(endpointId).to.eql(environment.network.config.endpointId) }) }) diff --git a/packages/ua-utils-evm-hardhat-test/tsconfig.json b/packages/ua-utils-evm-hardhat-test/tsconfig.json index 3df851287..b1fedd432 100644 --- a/packages/ua-utils-evm-hardhat-test/tsconfig.json +++ b/packages/ua-utils-evm-hardhat-test/tsconfig.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", - "exclude": ["dist", "node_modules"], - "include": ["src", "test", "deploy", "*.config.ts"], - "compilerOptions": { - "module": "commonjs", - "types": ["node", "mocha"] - } + "extends": "../../tsconfig.json", + "exclude": ["dist", "node_modules"], + "include": ["src", "test", "deploy", "*.config.ts"], + "compilerOptions": { + "module": "commonjs", + "types": ["node", "mocha"] + } } diff --git a/packages/ua-utils-evm-hardhat/.eslintrc.json b/packages/ua-utils-evm-hardhat/.eslintrc.json index 5aa34cd97..be97c53fb 100644 --- a/packages/ua-utils-evm-hardhat/.eslintrc.json +++ b/packages/ua-utils-evm-hardhat/.eslintrc.json @@ -1,3 +1,3 @@ { - "extends": "../../.eslintrc.json" + "extends": "../../.eslintrc.json" } diff --git a/packages/ua-utils-evm-hardhat/README.md b/packages/ua-utils-evm-hardhat/README.md index 1fe4f8ac2..d8aada75c 100644 --- a/packages/ua-utils-evm-hardhat/README.md +++ b/packages/ua-utils-evm-hardhat/README.md @@ -25,15 +25,15 @@ $ npm install @layerzerolabs/ua-utils-evm-hardhat The plugin depends on [`@nomiclabs/hardhat-ethers`](https://www.npmjs.com/package/@nomiclabs/hardhat-ethers), so you need to import both plugins in your `hardhat.config.js`: ```js -require("@nomiclabs/hardhat-ethers") -require("@layerzerolabs/ua-utils-evm-hardhat") +require("@nomiclabs/hardhat-ethers"); +require("@layerzerolabs/ua-utils-evm-hardhat"); ``` Or if you are using TypeScript, in your `hardhat.config.ts`: ```ts -import "@nomiclabs/hardhat-ethers" -import "@layerzerolabs/ua-utils-evm-hardhat" +import "@nomiclabs/hardhat-ethers"; +import "@layerzerolabs/ua-utils-evm-hardhat"; ``` Make sure that network names in your `hardhat.config.js` match the following [naming convention](https://github.com/LayerZero-Labs/sdk/blob/main/packages/lz-sdk/src/enums/ChainKey.ts). @@ -42,243 +42,243 @@ Make sure that network names in your `hardhat.config.js` match the following [na The package adds the following tasks: -- `getDefaultConfig` returns the default configuration for the specified chains. +- `getDefaultConfig` returns the default configuration for the specified chains. - Usage: + Usage: - ```sh - npx hardhat getDefaultConfig --networks ethereum,bsc,polygon,avalanche - ``` + ```sh + npx hardhat getDefaultConfig --networks ethereum,bsc,polygon,avalanche + ``` -- `getConfig` returns the configuration of the specified contract. +- `getConfig` returns the configuration of the specified contract. - Parameters: + Parameters: - - `address` - the contract address. An optional parameter. Either contract name or contract address must be specified. - - `name` - the contract name. An optional parameter. It must be specified only if the contract was deployed using [`hardhat-deploy`](https://www.npmjs.com/package/hardhat-deploy) and the deployments information is located in the deployments folder. - - `network` - the network the contract is deployed to. - - `remote-networks` - a comma separated list of remote networks the contract is configured with. + - `address` - the contract address. An optional parameter. Either contract name or contract address must be specified. + - `name` - the contract name. An optional parameter. It must be specified only if the contract was deployed using [`hardhat-deploy`](https://www.npmjs.com/package/hardhat-deploy) and the deployments information is located in the deployments folder. + - `network` - the network the contract is deployed to. + - `remote-networks` - a comma separated list of remote networks the contract is configured with. - Usage: + Usage: - ```sh - npx hardhat getConfig --network ethereum --remote-networks bsc,polygon,avalanche --name OFT - ``` + ```sh + npx hardhat getConfig --network ethereum --remote-networks bsc,polygon,avalanche --name OFT + ``` -- `setConfig` sets the configuration of the specified contract. +- `setConfig` sets the configuration of the specified contract. - Parameters: + Parameters: - - `config-path` - the relative path to a file containing the configuration. - - `address` - the address of the deployed contracts. An optional parameter. It should be provided if the contract address is the same on all chains. For contracts with different addresses, specify the address for each chain in the config. - - `name` - the name of the deployed contracts. An optional parameter. It should be provided only if the same contract deployed on all chains using [`hardhat-deploy`](https://www.npmjs.com/package/hardhat-deploy) and the deployment information is located in the deployments folder. For contracts with different names, specify the name for each chain in the config. - - `gnosis-config-path` - the relative path to a file containing the gnosis configuration. An optional parameter. If specified, the transactions will be sent to Gnosis. + - `config-path` - the relative path to a file containing the configuration. + - `address` - the address of the deployed contracts. An optional parameter. It should be provided if the contract address is the same on all chains. For contracts with different addresses, specify the address for each chain in the config. + - `name` - the name of the deployed contracts. An optional parameter. It should be provided only if the same contract deployed on all chains using [`hardhat-deploy`](https://www.npmjs.com/package/hardhat-deploy) and the deployment information is located in the deployments folder. For contracts with different names, specify the name for each chain in the config. + - `gnosis-config-path` - the relative path to a file containing the gnosis configuration. An optional parameter. If specified, the transactions will be sent to Gnosis. - Usage: + Usage: - ```sh - npx hardhat setConfig --networks ethereum,bsc,avalanche --name OFT --config-path "./appConfig.json" --gnosis-config-path "./gnosisConfig.json" - ``` + ```sh + npx hardhat setConfig --networks ethereum,bsc,avalanche --name OFT --config-path "./appConfig.json" --gnosis-config-path "./gnosisConfig.json" + ``` -
+
- Below is an example of the application configuration + Below is an example of the application configuration - ```json - { - "ethereum": { - "address": "", - "name": "ProxyOFT", - "sendVersion": 2, - "receiveVersion": 2, - "remoteConfigs": [ - { - "remoteChain": "bsc", - "inboundProofLibraryVersion": 1, - "inboundBlockConfirmations": 20, - "relayer": "0x902F09715B6303d4173037652FA7377e5b98089E", - "outboundProofType": 1, - "outboundBlockConfirmations": 15, - "oracle": "0x5a54fe5234E811466D5366846283323c954310B2" - }, - { - "remoteChain": "avalanche", - "inboundProofLibraryVersion": 1, - "inboundBlockConfirmations": 12, - "relayer": "0x902F09715B6303d4173037652FA7377e5b98089E", - "outboundProofType": 1, - "outboundBlockConfirmations": 15, - "oracle": "0x5a54fe5234E811466D5366846283323c954310B2" - } - ] + ```json + { + "ethereum": { + "address": "", + "name": "ProxyOFT", + "sendVersion": 2, + "receiveVersion": 2, + "remoteConfigs": [ + { + "remoteChain": "bsc", + "inboundProofLibraryVersion": 1, + "inboundBlockConfirmations": 20, + "relayer": "0x902F09715B6303d4173037652FA7377e5b98089E", + "outboundProofType": 1, + "outboundBlockConfirmations": 15, + "oracle": "0x5a54fe5234E811466D5366846283323c954310B2" }, - "bsc": { - "address": "0x0702c7B1b18E5EBf022e17182b52F0AC262A8062", - "name": "", - "sendVersion": 2, - "receiveVersion": 2, - "remoteConfigs": [ - { - "remoteChain": "ethereum", - "inboundProofLibraryVersion": 1, - "inboundBlockConfirmations": 15, - "relayer": "0xA27A2cA24DD28Ce14Fb5f5844b59851F03DCf182", - "outboundProofType": 1, - "outboundBlockConfirmations": 20, - "oracle": "0x5a54fe5234E811466D5366846283323c954310B2" - } - ] + { + "remoteChain": "avalanche", + "inboundProofLibraryVersion": 1, + "inboundBlockConfirmations": 12, + "relayer": "0x902F09715B6303d4173037652FA7377e5b98089E", + "outboundProofType": 1, + "outboundBlockConfirmations": 15, + "oracle": "0x5a54fe5234E811466D5366846283323c954310B2" + } + ] + }, + "bsc": { + "address": "0x0702c7B1b18E5EBf022e17182b52F0AC262A8062", + "name": "", + "sendVersion": 2, + "receiveVersion": 2, + "remoteConfigs": [ + { + "remoteChain": "ethereum", + "inboundProofLibraryVersion": 1, + "inboundBlockConfirmations": 15, + "relayer": "0xA27A2cA24DD28Ce14Fb5f5844b59851F03DCf182", + "outboundProofType": 1, + "outboundBlockConfirmations": 20, + "oracle": "0x5a54fe5234E811466D5366846283323c954310B2" } + ] } - ``` + } + ``` - The top level elements represent chains the contracts are deployed to. The configuration section for each chain has the following fields: + The top level elements represent chains the contracts are deployed to. The configuration section for each chain has the following fields: - - `address` - the contract address. An optional parameter. It should be provided if no address was specified in the task parameters. - - `name` - the contract name. An optional parameter. It should be provided only if the contract was deployed using [`hardhat-deploy`](https://www.npmjs.com/package/hardhat-deploy) and the deployment information is located in the deployments folder. - - `sendVersion` - the version of a messaging library contract used to send messages. If it isn't specified, the default version will be used. - - `receiveVersion` - the version of a messaging library contract used to receive messages. If it isn't specified, the default version will be used. - - `remoteConfigs` - an array of configuration settings for remote chains. + - `address` - the contract address. An optional parameter. It should be provided if no address was specified in the task parameters. + - `name` - the contract name. An optional parameter. It should be provided only if the contract was deployed using [`hardhat-deploy`](https://www.npmjs.com/package/hardhat-deploy) and the deployment information is located in the deployments folder. + - `sendVersion` - the version of a messaging library contract used to send messages. If it isn't specified, the default version will be used. + - `receiveVersion` - the version of a messaging library contract used to receive messages. If it isn't specified, the default version will be used. + - `remoteConfigs` - an array of configuration settings for remote chains. -
+
- The configuration section for each chain has the following fields: + The configuration section for each chain has the following fields: - - `remoteChain` - the remote chain name. - - `inboundProofLibraryVersion` - the version of proof library for inbound messages. - - `inboundBlockConfirmations` - the number of block confirmations for inbound messages. - - `relayer` - the address of Relayer contract. - - `outboundProofType` - proof type used for outbound messages. - - `outboundBlockConfirmations` - the number of block confirmations for outbound messages. - - `oracle` - the address of the Oracle contract. + - `remoteChain` - the remote chain name. + - `inboundProofLibraryVersion` - the version of proof library for inbound messages. + - `inboundBlockConfirmations` - the number of block confirmations for inbound messages. + - `relayer` - the address of Relayer contract. + - `outboundProofType` - proof type used for outbound messages. + - `outboundBlockConfirmations` - the number of block confirmations for outbound messages. + - `oracle` - the address of the Oracle contract. -
+
-- `checkWireAllConfig` returns the current wired up configurations of the specified contract. +- `checkWireAllConfig` returns the current wired up configurations of the specified contract. - Parameters: + Parameters: - - `e` - the environment ie: mainnet, testnet or sandbox. - - `u` - flag to show use custom adapter params. - - `t` - flag to show trusted remotes. - - `m` - flag to show min destination gas. - - `chains` - comma separated list of networks. - - `addresses` - comma separated list of contract addresses in same order as chains. An optional parameter, if no deployment folder is available and want to use contract addresses. - - `contract` - name of contract. An optional parameter. If all contract names are the same. - - `proxyContract` - name of proxy contract. An optional parameter. If one contract name is different. - - `proxyChain` - name of proxy chain. An optional parameter. If one chain has different contract name . + - `e` - the environment ie: mainnet, testnet or sandbox. + - `u` - flag to show use custom adapter params. + - `t` - flag to show trusted remotes. + - `m` - flag to show min destination gas. + - `chains` - comma separated list of networks. + - `addresses` - comma separated list of contract addresses in same order as chains. An optional parameter, if no deployment folder is available and want to use contract addresses. + - `contract` - name of contract. An optional parameter. If all contract names are the same. + - `proxyContract` - name of proxy contract. An optional parameter. If one contract name is different. + - `proxyChain` - name of proxy chain. An optional parameter. If one chain has different contract name . - Usage: + Usage: - ```sh - npx hardhat checkWireAllConfig --e testnet --u --t --m --chains ethereum-testnet,arbitrum-testnet --contract ExampleOFTV2 + ```sh + npx hardhat checkWireAllConfig --e testnet --u --t --m --chains ethereum-testnet,arbitrum-testnet --contract ExampleOFTV2 - npx hardhat checkWireAllConfig --e testnet --u --t --m --chains ethereum-testnet,arbitrum-testnet,optimism-testnet --contract OFTV2 --proxy-contract ProxyOFTV2 --proxy-chain optimism-testnet + npx hardhat checkWireAllConfig --e testnet --u --t --m --chains ethereum-testnet,arbitrum-testnet,optimism-testnet --contract OFTV2 --proxy-contract ProxyOFTV2 --proxy-chain optimism-testnet - npx hardhat checkWireAllConfig --e testnet --u --t --m --chains ethereum-testnet,arbitrum-testnet,optimism-testnet --addresses "0xD90E022dE858DfDFC3C0f66b0D9ACD12CA6eA3Ec,0x137d4e9C2431A3DCBa6e615E9438F2c558353a17,0x27631753FC88e7b45a46679B9Cd2e06378cB43dC" - ``` + npx hardhat checkWireAllConfig --e testnet --u --t --m --chains ethereum-testnet,arbitrum-testnet,optimism-testnet --addresses "0xD90E022dE858DfDFC3C0f66b0D9ACD12CA6eA3Ec,0x137d4e9C2431A3DCBa6e615E9438F2c558353a17,0x27631753FC88e7b45a46679B9Cd2e06378cB43dC" + ``` -
+
-- `wireAll` sets the wire all configuration of the specified contract. +- `wireAll` sets the wire all configuration of the specified contract. - Parameters: + Parameters: - - `e` - the environment ie: mainnet, testnet or sandbox. - - `noPrompt` - no prompt. An optional parameter defaults to false. - - `configPath` - config path. An optional parameter. Default: ./constants/wireUpConfig.json. - - `n` - send to gnosis. An optional parameter defaults to false. - - `gnosisConfigPath` - gnosis config path. An optional parameter. Default: ./constants/gnosisConfig.json. + - `e` - the environment ie: mainnet, testnet or sandbox. + - `noPrompt` - no prompt. An optional parameter defaults to false. + - `configPath` - config path. An optional parameter. Default: ./constants/wireUpConfig.json. + - `n` - send to gnosis. An optional parameter defaults to false. + - `gnosisConfigPath` - gnosis config path. An optional parameter. Default: ./constants/gnosisConfig.json. - Usage: + Usage: - ```sh - npx hardhat --network ethereum-testnet wireAll --e testnet - ``` + ```sh + npx hardhat --network ethereum-testnet wireAll --e testnet + ``` - Below is an example of the wire all configuration + Below is an example of the wire all configuration - ```json - { - "proxyContractConfig": { - "chain": "avalanche", - "name": "ProxyOFT" - }, - "contractConfig": { - "name": "OFT" - }, - "chainConfig": { - "avalanche": { - "defaultFeeBp": 2, - "useCustomAdapterParams": true, - "remoteNetworkConfig": { - "ethereum": { - "feeBpConfig": { - "feeBp": 5, - "enabled": true - }, - "minDstGasConfig": { - "packetType_0": 100000, - "packetType_1": 200000 - } - }, - "polygon": { - "minDstGasConfig": { - "packetType_0": 100000, - "packetType_1": 160000 - } - } - } + ```json + { + "proxyContractConfig": { + "chain": "avalanche", + "name": "ProxyOFT" + }, + "contractConfig": { + "name": "OFT" + }, + "chainConfig": { + "avalanche": { + "defaultFeeBp": 2, + "useCustomAdapterParams": true, + "remoteNetworkConfig": { + "ethereum": { + "feeBpConfig": { + "feeBp": 5, + "enabled": true + }, + "minDstGasConfig": { + "packetType_0": 100000, + "packetType_1": 200000 + } + }, + "polygon": { + "minDstGasConfig": { + "packetType_0": 100000, + "packetType_1": 160000 } + } } + } } - ``` + } + ``` - The `proxyContractConfig` is an optional setting, that defines the proxy chain and proxy contract name. + The `proxyContractConfig` is an optional setting, that defines the proxy chain and proxy contract name. - - `chain`: An optional string, defines the proxy chain. - - `name`: An optional string, defines the proxy contract name. - - `address`: A optional string, defines the contract address. Used when deployments folder are not available. Uses standard LzApp/Nonblocking/OFT/ONFT abi calls such as: + - `chain`: An optional string, defines the proxy chain. + - `name`: An optional string, defines the proxy contract name. + - `address`: A optional string, defines the contract address. Used when deployments folder are not available. Uses standard LzApp/Nonblocking/OFT/ONFT abi calls such as: - - `function setFeeBp(uint16, bool, uint16)` - - `function setDefaultFeeBp(uint16)` - - `function setMinDstGas(uint16, uint16, uint)` - - `function setUseCustomAdapterParams(bool)` - - `function setTrustedRemote(uint16, bytes)` + - `function setFeeBp(uint16, bool, uint16)` + - `function setDefaultFeeBp(uint16)` + - `function setMinDstGas(uint16, uint16, uint)` + - `function setUseCustomAdapterParams(bool)` + - `function setTrustedRemote(uint16, bytes)` - - The `contractConfig` is a conditionally required setting, that defines the contract name. - - `function setFeeBp(uint16, bool, uint16)` - - The `chainConfig`: is required and defines the chain settings (default fees, useCustomAdapterParams) and the remote chain configs (minDstGas config based of packetType, and custom feeBP per chain) + - The `contractConfig` is a conditionally required setting, that defines the contract name. + - `function setFeeBp(uint16, bool, uint16)` + - The `chainConfig`: is required and defines the chain settings (default fees, useCustomAdapterParams) and the remote chain configs (minDstGas config based of packetType, and custom feeBP per chain) - - `name`: A conditionally required string, defines the contract name. Used when contract names differ per chain. - - `address`: A conditionally required string, defines the contract address. Used when deployments folder are not available. Uses standard LzApp/Nonblocking/OFT/ONFT abi calls. - - `defaultFeeBp`: An optional number, defines the default fee bp for the chain. (Available in [OFTV2 w/ fee](https://github.com/LayerZero-Labs/solidity-examples/blob/ca7d4f1d482df5e17f8aaf1b34d0e4432020bc4e/contracts/token/oft/v2/fee/Fee.sol#L27).) - - `useCustomAdapterParams`: An optional bool that defaults to false. Uses default 200k destination gas on all cross chain messages. When false adapter parameters must be empty. When useCustomAdapterParams is true the minDstGasLookup must be set for each packet type and each chain. This requires whoever calls the send function to provide the adapter params with a destination gas >= amount set for that packet type and that destination chain. - - `remoteNetworkConfig` is a conditionally required setting, that defines the contract name. - `minDstGasConfig`: is an optional object that defines the minDstGas required based off packetType. So for example when the UA on Avalanche sends [packet type 0](https://github.com/LayerZero-Labs/solidity-examples/blob/9134640fe5b618a047f365555e760c8736ebc162/contracts/token/oft/v2/OFTCoreV2.sol#L17) to Ethereum the minDstGas will be 100000. When the UA on Avalanche sends [packet type 1](https://github.com/LayerZero-Labs/solidity-examples/blob/9134640fe5b618a047f365555e760c8736ebc162/contracts/token/oft/v2/OFTCoreV2.sol#L18) to Polygon the minDstGas will be 160000. - The `feeBpConfig` is an optional setting that defines custom feeBP per chain. (Note: setting custom fee per chain with enabled = TRUE, will triumph over defaultFeeBp.) - `feeBp`: is an optional number, defines custom feeBP per chain. - `enabled`: is an optional bool, defines if custom feeBP per chain is enabled + - `name`: A conditionally required string, defines the contract name. Used when contract names differ per chain. + - `address`: A conditionally required string, defines the contract address. Used when deployments folder are not available. Uses standard LzApp/Nonblocking/OFT/ONFT abi calls. + - `defaultFeeBp`: An optional number, defines the default fee bp for the chain. (Available in [OFTV2 w/ fee](https://github.com/LayerZero-Labs/solidity-examples/blob/ca7d4f1d482df5e17f8aaf1b34d0e4432020bc4e/contracts/token/oft/v2/fee/Fee.sol#L27).) + - `useCustomAdapterParams`: An optional bool that defaults to false. Uses default 200k destination gas on all cross chain messages. When false adapter parameters must be empty. When useCustomAdapterParams is true the minDstGasLookup must be set for each packet type and each chain. This requires whoever calls the send function to provide the adapter params with a destination gas >= amount set for that packet type and that destination chain. + - `remoteNetworkConfig` is a conditionally required setting, that defines the contract name. - `minDstGasConfig`: is an optional object that defines the minDstGas required based off packetType. So for example when the UA on Avalanche sends [packet type 0](https://github.com/LayerZero-Labs/solidity-examples/blob/9134640fe5b618a047f365555e760c8736ebc162/contracts/token/oft/v2/OFTCoreV2.sol#L17) to Ethereum the minDstGas will be 100000. When the UA on Avalanche sends [packet type 1](https://github.com/LayerZero-Labs/solidity-examples/blob/9134640fe5b618a047f365555e760c8736ebc162/contracts/token/oft/v2/OFTCoreV2.sol#L18) to Polygon the minDstGas will be 160000. - The `feeBpConfig` is an optional setting that defines custom feeBP per chain. (Note: setting custom fee per chain with enabled = TRUE, will triumph over defaultFeeBp.) - `feeBp`: is an optional number, defines custom feeBP per chain. - `enabled`: is an optional bool, defines if custom feeBP per chain is enabled -
+
- More info and examples can be found here in the [Wire Up Configuration](https://layerzero.gitbook.io/docs/evm-guides/layerzero-tooling/wire-up-configuration) documentation. + More info and examples can be found here in the [Wire Up Configuration](https://layerzero.gitbook.io/docs/evm-guides/layerzero-tooling/wire-up-configuration) documentation. -
+
- Below is an example of the Gnosis configuration + Below is an example of the Gnosis configuration - ```json - { - "ethereum": { - "safeAddress": "0xa36B7e7894aCfaa6c35A8A0EC630B71A6B8A6D22", - "url": "https://safe-transaction.mainnet.gnosis.io/" - }, - "bsc": { - "safeAddress": "0x4755D44c1C196dC524848200B0556A09084D1dFD", - "url": "https://safe-transaction.bsc.gnosis.io/" - }, - "avalanche": { - "safeAddress": "0x4FF2C33FD9042a76eaC920C037383E51659417Ee", - "url": "https://safe-transaction.avalanche.gnosis.io/" - } - } - ``` + ```json + { + "ethereum": { + "safeAddress": "0xa36B7e7894aCfaa6c35A8A0EC630B71A6B8A6D22", + "url": "https://safe-transaction.mainnet.gnosis.io/" + }, + "bsc": { + "safeAddress": "0x4755D44c1C196dC524848200B0556A09084D1dFD", + "url": "https://safe-transaction.bsc.gnosis.io/" + }, + "avalanche": { + "safeAddress": "0x4FF2C33FD9042a76eaC920C037383E51659417Ee", + "url": "https://safe-transaction.avalanche.gnosis.io/" + } + } + ``` - For each chain you need to specify your Gnosis safe address and Gnosis Safe API url. You can find the list of supported chains and API urls in [Gnosis Safe documentation](https://docs.safe.global/learn/safe-core/safe-core-api/available-services). + For each chain you need to specify your Gnosis safe address and Gnosis Safe API url. You can find the list of supported chains and API urls in [Gnosis Safe documentation](https://docs.safe.global/learn/safe-core/safe-core-api/available-services). diff --git a/packages/ua-utils-evm-hardhat/package.json b/packages/ua-utils-evm-hardhat/package.json index 2d6b01f8d..720b6c206 100644 --- a/packages/ua-utils-evm-hardhat/package.json +++ b/packages/ua-utils-evm-hardhat/package.json @@ -1,65 +1,65 @@ { - "name": "@layerzerolabs/ua-utils-evm-hardhat", - "version": "0.0.1", - "private": true, - "description": "Hardhat utilities for working with LayerZero EVM contracts", - "repository": { - "type": "git", - "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", - "directory": "packages/ua-utils-evm-hardhat" + "name": "@layerzerolabs/ua-utils-evm-hardhat", + "version": "0.0.1", + "private": true, + "description": "Hardhat utilities for working with LayerZero EVM contracts", + "repository": { + "type": "git", + "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", + "directory": "packages/ua-utils-evm-hardhat" + }, + "license": "MIT", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "require": "./dist/index.js", + "import": "./dist/index.mjs" }, - "license": "MIT", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "require": "./dist/index.js", - "import": "./dist/index.mjs" - }, - "./tasks": { - "types": "./dist/tasks/index.d.ts", - "require": "./dist/tasks/index.js", - "import": "./dist/tasks/index.mjs" - } - }, - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "files": [ - "dist/", - "LICENSE" - ], - "scripts": { - "prebuild": "tsc -noEmit", - "build": "npx tsup", - "clean": "rm -rf dist", - "lint": "npx eslint '**/*.{js,ts,json}'" - }, - "devDependencies": { - "@gnosis.pm/safe-core-sdk": "^2.0.0", - "@gnosis.pm/safe-core-sdk-types": "^1.0.0", - "@gnosis.pm/safe-ethers-lib": "^1.0.0", - "@gnosis.pm/safe-service-client": "1.1.1", - "@layerzerolabs/lz-definitions": "~1.5.61", - "@nomiclabs/hardhat-ethers": "^2.2.3", - "@types/mocha": "^10.0.6", - "cli-ux": "^6.0.9", - "dotenv": "^16.0.3", - "ethers": "^5.7.0", - "hardhat": "^2.9.9", - "hardhat-deploy": "^0.11.22", - "ts-node": "^10.9.1", - "tsup": "^8.0.1", - "typescript": "^5.3.2" - }, - "peerDependencies": { - "@gnosis.pm/safe-core-sdk": "^2.0.0", - "@gnosis.pm/safe-core-sdk-types": "^1.0.0", - "@gnosis.pm/safe-ethers-lib": "^1.0.0", - "@gnosis.pm/safe-service-client": "1.1.1", - "@layerzerolabs/lz-definitions": "~1.5.58", - "@nomiclabs/hardhat-ethers": "^2.2.3", - "ethers": "^5.5.2", - "hardhat": "^2.9.9", - "hardhat-deploy": "^0.11.22" + "./tasks": { + "types": "./dist/tasks/index.d.ts", + "require": "./dist/tasks/index.js", + "import": "./dist/tasks/index.mjs" } -} + }, + "main": "dist/index.js", + "module": "dist/index.mjs", + "types": "dist/index.d.ts", + "files": [ + "dist/", + "LICENSE" + ], + "scripts": { + "prebuild": "tsc -noEmit", + "build": "npx tsup", + "clean": "rm -rf dist", + "lint": "npx eslint '**/*.{js,ts,json}'" + }, + "devDependencies": { + "@gnosis.pm/safe-core-sdk": "^2.0.0", + "@gnosis.pm/safe-core-sdk-types": "^1.0.0", + "@gnosis.pm/safe-ethers-lib": "^1.0.0", + "@gnosis.pm/safe-service-client": "1.1.1", + "@layerzerolabs/lz-definitions": "~1.5.61", + "@nomiclabs/hardhat-ethers": "^2.2.3", + "@types/mocha": "^10.0.6", + "cli-ux": "^6.0.9", + "dotenv": "^16.0.3", + "ethers": "^5.7.0", + "hardhat": "^2.9.9", + "hardhat-deploy": "^0.11.22", + "ts-node": "^10.9.1", + "tsup": "^8.0.1", + "typescript": "^5.3.2" + }, + "peerDependencies": { + "@gnosis.pm/safe-core-sdk": "^2.0.0", + "@gnosis.pm/safe-core-sdk-types": "^1.0.0", + "@gnosis.pm/safe-ethers-lib": "^1.0.0", + "@gnosis.pm/safe-service-client": "1.1.1", + "@layerzerolabs/lz-definitions": "~1.5.58", + "@nomiclabs/hardhat-ethers": "^2.2.3", + "ethers": "^5.5.2", + "hardhat": "^2.9.9", + "hardhat-deploy": "^0.11.22" + } +} \ No newline at end of file diff --git a/packages/ua-utils-evm-hardhat/src/constants/abi.ts b/packages/ua-utils-evm-hardhat/src/constants/abi.ts index 038026fc2..082dcc198 100644 --- a/packages/ua-utils-evm-hardhat/src/constants/abi.ts +++ b/packages/ua-utils-evm-hardhat/src/constants/abi.ts @@ -1,31 +1,31 @@ export const ENDPOINT_ABI = [ - "function defaultSendVersion() view returns (uint16)", - "function defaultReceiveVersion() view returns (uint16)", - "function defaultSendLibrary() view returns (address)", - "function defaultReceiveLibraryAddress() view returns (address)", - "function uaConfigLookup(address) view returns (tuple(uint16 sendVersion, uint16 receiveVersion, address receiveLibraryAddress, address sendLibrary))", + 'function defaultSendVersion() view returns (uint16)', + 'function defaultReceiveVersion() view returns (uint16)', + 'function defaultSendLibrary() view returns (address)', + 'function defaultReceiveLibraryAddress() view returns (address)', + 'function uaConfigLookup(address) view returns (tuple(uint16 sendVersion, uint16 receiveVersion, address receiveLibraryAddress, address sendLibrary))', ] export const MESSAGING_LIBRARY_ABI = [ - "function appConfig(address, uint16) view returns (tuple(uint16 inboundProofLibraryVersion, uint64 inboundBlockConfirmations, address relayer, uint16 outboundProofType, uint64 outboundBlockConfirmations, address oracle))", - "function defaultAppConfig(uint16) view returns (tuple(uint16 inboundProofLibraryVersion, uint64 inboundBlockConfirmations, address relayer, uint16 outboundProofType, uint64 outboundBlockConfirmations, address oracle))", + 'function appConfig(address, uint16) view returns (tuple(uint16 inboundProofLibraryVersion, uint64 inboundBlockConfirmations, address relayer, uint16 outboundProofType, uint64 outboundBlockConfirmations, address oracle))', + 'function defaultAppConfig(uint16) view returns (tuple(uint16 inboundProofLibraryVersion, uint64 inboundBlockConfirmations, address relayer, uint16 outboundProofType, uint64 outboundBlockConfirmations, address oracle))', ] export const USER_APPLICATION_ABI = [ - "function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config)", - "function setSendVersion(uint16 _version)", - "function setReceiveVersion(uint16 _version)", + 'function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config)', + 'function setSendVersion(uint16 _version)', + 'function setReceiveVersion(uint16 _version)', ] export const LZ_APP_ABI = [ - "function setTrustedRemote(uint16 _srcChainId, bytes calldata _path)", - "function setUseCustomAdapterParams(bool _useCustomAdapterParams)", - "function setDefaultFeeBp(uint16 _feeBp)", - "function setFeeBp(uint16 _dstChainId, bool _enabled, uint16 _feeBp)", - "function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint _minGas)", - "function useCustomAdapterParams() public view returns (bool) ", - "function trustedRemoteLookup(uint16) public view returns (bytes)", - "function minDstGasLookup(uint16, uint16) public view returns (uint)", - "function defaultFeeBp() public view returns (uint16)", - "function chainIdToFeeBps(uint16) public view returns (uint16, bool)", + 'function setTrustedRemote(uint16 _srcChainId, bytes calldata _path)', + 'function setUseCustomAdapterParams(bool _useCustomAdapterParams)', + 'function setDefaultFeeBp(uint16 _feeBp)', + 'function setFeeBp(uint16 _dstChainId, bool _enabled, uint16 _feeBp)', + 'function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint _minGas)', + 'function useCustomAdapterParams() public view returns (bool) ', + 'function trustedRemoteLookup(uint16) public view returns (bytes)', + 'function minDstGasLookup(uint16, uint16) public view returns (uint)', + 'function defaultFeeBp() public view returns (uint16)', + 'function chainIdToFeeBps(uint16) public view returns (uint16, bool)', ] diff --git a/packages/ua-utils-evm-hardhat/src/constants/endpoints.ts b/packages/ua-utils-evm-hardhat/src/constants/endpoints.ts index 353204ee3..3e897842e 100644 --- a/packages/ua-utils-evm-hardhat/src/constants/endpoints.ts +++ b/packages/ua-utils-evm-hardhat/src/constants/endpoints.ts @@ -1,87 +1,87 @@ export const LZ_ENDPOINTS: { [key: string]: string } = { - "aavegotchi-testnet": "0xfeBE4c839EFA9f506C092a32fD0BB546B76A1d38", - "arbitrum-mainnet": "0x3c2269811836af69497E5F486A85D7316753cf62", - "arbitrum-testnet": "0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab", - "astar-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "aurora-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "aurora-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "avalanche-mainnet": "0x3c2269811836af69497E5F486A85D7316753cf62", - "avalanche-testnet": "0x93f54D755A063cE7bB9e6Ac47Eccc8e33411d706", - "base-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "base-testnet": "0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab", - "blockgen-testnet": "0x55370E0fBB5f5b8dAeD978BA1c075a499eB107B8", - "bsc-mainnet": "0x3c2269811836af69497E5F486A85D7316753cf62", - "bsc-testnet": "0x6Fcb97553D41516Cb228ac03FdC8B9a0a9df04A1", - "canto-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "canto-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "celo-mainnet": "0x3A73033C0b1407574C76BdBAc67f126f6b4a9AA9", - "celo-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "conflux-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "conflux-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "coredao-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "coredao-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "dexalot-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "dexalot-testnet": "0x6C7Ab2202C98C4227C5c46f1417D81144DA716Ff", - "dfk-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "dos-testnet": "0x45841dd1ca50265Da7614fC43A361e526c0e6160", - "eon-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "ethereum-mainnet": "0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675", - "ethereum-testnet": "0xbfD2135BFfbb0B5378b56643c2Df8a87552Bfa23", - "fantom-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "fantom-testnet": "0x7dcAD72640F835B0FA36EFD3D6d3ec902C7E5acf", - "fuse-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "gnosis-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "gnosis-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "harmony-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "harmony-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "hubble-testnet": "0x8b14D287B4150Ff22Ac73DF8BE720e933f659abc", - "kava-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "kava-testnet": "0x8b14D287B4150Ff22Ac73DF8BE720e933f659abc", - "klaytn-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "klaytn-testnet": "0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab", - "lif3-testnet": "0x55370E0fBB5f5b8dAeD978BA1c075a499eB107B8", - "loot-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "loot-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "mantle-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "mantle-testnet": "0x2cA20802fd1Fd9649bA8Aa7E50F0C82b479f35fe", - "meritcircle-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "meritcircle-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "meter-mainnet": "0xa3a8e19253Ab400acDac1cB0eA36B88664D8DedF", - "meter-testnet": "0x3De2f3D1Ac59F18159ebCB422322Cb209BA96aAD", - "metis-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "metis-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "moonbeam-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "moonbeam-testnet": "0xb23b28012ee92E8dE39DEb57Af31722223034747", - "moonriver-mainnet": "0x7004396C99D5690da76A7C59057C5f3A53e01704", - "nova-mainnet": "0x4EE2F9B7cf3A68966c370F3eb2C16613d3235245", - "okx-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "okx-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "opbnb-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "opbnb-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "optimism-mainnet": "0x3c2269811836af69497E5F486A85D7316753cf62", - "optimism-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "orderly-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "polygon-mainnet": "0x3c2269811836af69497E5F486A85D7316753cf62", - "polygon-testnet": "0xf69186dfBa60DdB133E91E9A4B5673624293d8F8", - "portal-testnet": "0xd682ECF100f6F4284138AA925348633B0611Ae21", - "scroll-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "scroll-testnet": "0x6098e96a28E02f27B1e6BD381f870F1C8Bd169d3", - "sepolia-mainnet": "0x7cacBe439EaD55fa1c22790330b12835c6884a91", - "sepolia-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "shimmer-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "telos-mainnet": "0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675", - "telos-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "tenet-mainnet": "0x2D61DCDD36F10b22176E0433B86F74567d529aAa", - "tenet-testnet": "0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab", - "tomo-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "tomo-testnet": "0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1", - "xpla-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", - "zkconsensys-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "zkconsensys-testnet": "0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab", - "zkpolygon-mainnet": "0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4", - "zkpolygon-testnet": "0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab", - "zksync-mainnet": "0x9b896c0e23220469C7AE69cb4BbAE391eAa4C8da", - "zksync-testnet": "0x093D2CF57f764f09C3c2Ac58a42A2601B8C79281", - "zora-mainnet": "0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7", - "zora-testnet": "0x83c73Da98cf733B03315aFa8758834b36a195b87", + 'aavegotchi-testnet': '0xfeBE4c839EFA9f506C092a32fD0BB546B76A1d38', + 'arbitrum-mainnet': '0x3c2269811836af69497E5F486A85D7316753cf62', + 'arbitrum-testnet': '0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab', + 'astar-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'aurora-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'aurora-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'avalanche-mainnet': '0x3c2269811836af69497E5F486A85D7316753cf62', + 'avalanche-testnet': '0x93f54D755A063cE7bB9e6Ac47Eccc8e33411d706', + 'base-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'base-testnet': '0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab', + 'blockgen-testnet': '0x55370E0fBB5f5b8dAeD978BA1c075a499eB107B8', + 'bsc-mainnet': '0x3c2269811836af69497E5F486A85D7316753cf62', + 'bsc-testnet': '0x6Fcb97553D41516Cb228ac03FdC8B9a0a9df04A1', + 'canto-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'canto-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'celo-mainnet': '0x3A73033C0b1407574C76BdBAc67f126f6b4a9AA9', + 'celo-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'conflux-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'conflux-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'coredao-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'coredao-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'dexalot-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'dexalot-testnet': '0x6C7Ab2202C98C4227C5c46f1417D81144DA716Ff', + 'dfk-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'dos-testnet': '0x45841dd1ca50265Da7614fC43A361e526c0e6160', + 'eon-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'ethereum-mainnet': '0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675', + 'ethereum-testnet': '0xbfD2135BFfbb0B5378b56643c2Df8a87552Bfa23', + 'fantom-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'fantom-testnet': '0x7dcAD72640F835B0FA36EFD3D6d3ec902C7E5acf', + 'fuse-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'gnosis-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'gnosis-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'harmony-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'harmony-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'hubble-testnet': '0x8b14D287B4150Ff22Ac73DF8BE720e933f659abc', + 'kava-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'kava-testnet': '0x8b14D287B4150Ff22Ac73DF8BE720e933f659abc', + 'klaytn-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'klaytn-testnet': '0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab', + 'lif3-testnet': '0x55370E0fBB5f5b8dAeD978BA1c075a499eB107B8', + 'loot-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'loot-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'mantle-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'mantle-testnet': '0x2cA20802fd1Fd9649bA8Aa7E50F0C82b479f35fe', + 'meritcircle-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'meritcircle-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'meter-mainnet': '0xa3a8e19253Ab400acDac1cB0eA36B88664D8DedF', + 'meter-testnet': '0x3De2f3D1Ac59F18159ebCB422322Cb209BA96aAD', + 'metis-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'metis-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'moonbeam-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'moonbeam-testnet': '0xb23b28012ee92E8dE39DEb57Af31722223034747', + 'moonriver-mainnet': '0x7004396C99D5690da76A7C59057C5f3A53e01704', + 'nova-mainnet': '0x4EE2F9B7cf3A68966c370F3eb2C16613d3235245', + 'okx-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'okx-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'opbnb-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'opbnb-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'optimism-mainnet': '0x3c2269811836af69497E5F486A85D7316753cf62', + 'optimism-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'orderly-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'polygon-mainnet': '0x3c2269811836af69497E5F486A85D7316753cf62', + 'polygon-testnet': '0xf69186dfBa60DdB133E91E9A4B5673624293d8F8', + 'portal-testnet': '0xd682ECF100f6F4284138AA925348633B0611Ae21', + 'scroll-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'scroll-testnet': '0x6098e96a28E02f27B1e6BD381f870F1C8Bd169d3', + 'sepolia-mainnet': '0x7cacBe439EaD55fa1c22790330b12835c6884a91', + 'sepolia-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'shimmer-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'telos-mainnet': '0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675', + 'telos-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'tenet-mainnet': '0x2D61DCDD36F10b22176E0433B86F74567d529aAa', + 'tenet-testnet': '0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab', + 'tomo-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'tomo-testnet': '0xae92d5aD7583AD66E49A0c67BAd18F6ba52dDDc1', + 'xpla-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', + 'zkconsensys-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'zkconsensys-testnet': '0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab', + 'zkpolygon-mainnet': '0x9740FF91F1985D8d2B71494aE1A2f723bb3Ed9E4', + 'zkpolygon-testnet': '0x6aB5Ae6822647046626e83ee6dB8187151E1d5ab', + 'zksync-mainnet': '0x9b896c0e23220469C7AE69cb4BbAE391eAa4C8da', + 'zksync-testnet': '0x093D2CF57f764f09C3c2Ac58a42A2601B8C79281', + 'zora-mainnet': '0xb6319cC6c8c27A8F5dAF0dD3DF91EA35C4720dd7', + 'zora-testnet': '0x83c73Da98cf733B03315aFa8758834b36a195b87', } diff --git a/packages/ua-utils-evm-hardhat/src/constants/node-url.json b/packages/ua-utils-evm-hardhat/src/constants/node-url.json index 2f73a4560..ee115a562 100644 --- a/packages/ua-utils-evm-hardhat/src/constants/node-url.json +++ b/packages/ua-utils-evm-hardhat/src/constants/node-url.json @@ -1,68 +1,68 @@ { - "mainnet": { - "arbitrum-mainnet": "https://endpoints.omniatech.io/v1/arbitrum/one/public", - "avalanche-mainnet": "https://avalanche-c-chain.publicnode.com", - "bsc-mainnet": "https://binance.llamarpc.com", - "celo-mainnet": "https://1rpc.io/celo", - "coredao-mainnet": "https://rpc.coredao.org", - "dexalot-mainnet": "https://subnets.avax.network/dexalot/mainnet/rpc", - "dfk-mainnet": "https://dfkchain.api.onfinality.io/public", - "dos-mainnet": "https://main.doschain.com", - "ethereum-mainnet": "https://eth.llamarpc.com", - "fantom-mainnet": "https://fantom.publicnode.com", - "fuse-mainnet": "https://rpc.fuse.io", - "gnosis-mainnet": "https://gnosis-mainnet.public.blastapi.io", - "goerli-mainnet": "https://ethereum-goerli.publicnode.com", - "harmony-mainnet": "https://1rpc.io/one", - "klaytn-mainnet": "https://1rpc.io/klay", - "meter-mainnet": "https://rpc.meter.io", - "metis-mainnet": "https://metis-mainnet.public.blastapi.io", - "moonbeam-mainnet": "https://1rpc.io/glmr", - "moonriver-mainnet": "https://rpc.api.moonriver.moonbeam.network", - "okx-mainnet": "https://oktc-mainnet.public.blastapi.io", - "optimism-mainnet": "https://1rpc.io/op", - "polygon-mainnet": "https://polygon.llamarpc.com", - "sepolia-mainnet": "https://rpc-sepolia.rockx.com", - "shrapnel-mainnet": "https://subnets.avax.network/shrapnel/mainnet/rpc", - "tenet-mainnet": "https://rpc.tenet.org", - "telos-mainnet": "https://rpc1.eu.telos.net/evm", - "zkpolygon-mainnet": "https://zkevm-rpc.com", - "zksync-mainnet": "https://zksync.drpc.org" - }, - "testnet": { - "aavegotchi": "", - "arbitrum-testnet": "https://arbitrum-goerli.publicnode.com", - "avalanche-testnet": "https://avalanche-fuji-c-chain.publicnode.com", - "base-testnet": "https://base-goerli.publicnode.com", - "bsc-testnet": "https://bsc-testnet.publicnode.com", - "canto": "https://testnet-archive.plexnode.wtf", - "cathay": "", - "celo-testnet": "https://alfajores-forno.celo-testnet.org", - "coredao-testnet": "https://rpc.test.btcs.network", - "dexalot-testnet": "https://subnets.avax.network/dexalot/testnet/rpc", - "dfk-testnet": "https://subnets.avax.network/defi-kingdoms/dfk-chain-testnet/rpc", - "dos-testnet": "https://test.doschain.com", - "ethereum-testnet": "https://ethereum-goerli.publicnode.com", - "fantom-testnet": "https://fantom-testnet.publicnode.com", - "fuse-testnet": "https://rpc.fusespark.io", - "gnosis-testnet": "https://rpc.chiadochain.net", - "harmony-testnet": "https://api.s0.ps.hmny.io", - "kava-testnet": "https://evm.testnet.kava.io", - "klaytn-testnet": "https://public-node-api.klaytnapi.com/v1/baobab", - "meter-testnet": "https://rpctest.meter.io", - "metis-testnet": "https://goerli.gateway.metisdevops.link", - "moonbeam-testnet": "https://rpc.api.moonbase.moonbeam.network", - "okx-testnet": "https://exchaintestrpc.okex.org", - "optimism-testnet": "https://optimism-goerli.publicnode.com", - "orderly-testnet": "", - "polygon-testnet": "https://polygon-mumbai-bor.publicnode.com", - "scroll-testnet": "https://scroll-testnet.blockpi.network/v1/rpc/public", - "sepolia-testnet": "https://api.zan.top/node/v1/eth/sepolia/public", - "shrapnel-testnet": "https://subnets.avax.network/shrapnel/testnet/rpc", - "tenet-testnet": "https://rpc.testnet.tenet.org", - "telos-testnet": "https://testnet.telos.net/evm", - "linea-testnet": "https://rpc.goerli.linea.build", - "zkpolygon": "https://rpc.public.zkevm-test.net", - "zksync-testnet": "https://testnet.era.zksync.dev" - } + "mainnet": { + "arbitrum-mainnet": "https://endpoints.omniatech.io/v1/arbitrum/one/public", + "avalanche-mainnet": "https://avalanche-c-chain.publicnode.com", + "bsc-mainnet": "https://binance.llamarpc.com", + "celo-mainnet": "https://1rpc.io/celo", + "coredao-mainnet": "https://rpc.coredao.org", + "dexalot-mainnet": "https://subnets.avax.network/dexalot/mainnet/rpc", + "dfk-mainnet": "https://dfkchain.api.onfinality.io/public", + "dos-mainnet": "https://main.doschain.com", + "ethereum-mainnet": "https://eth.llamarpc.com", + "fantom-mainnet": "https://fantom.publicnode.com", + "fuse-mainnet": "https://rpc.fuse.io", + "gnosis-mainnet": "https://gnosis-mainnet.public.blastapi.io", + "goerli-mainnet": "https://ethereum-goerli.publicnode.com", + "harmony-mainnet": "https://1rpc.io/one", + "klaytn-mainnet": "https://1rpc.io/klay", + "meter-mainnet": "https://rpc.meter.io", + "metis-mainnet": "https://metis-mainnet.public.blastapi.io", + "moonbeam-mainnet": "https://1rpc.io/glmr", + "moonriver-mainnet": "https://rpc.api.moonriver.moonbeam.network", + "okx-mainnet": "https://oktc-mainnet.public.blastapi.io", + "optimism-mainnet": "https://1rpc.io/op", + "polygon-mainnet": "https://polygon.llamarpc.com", + "sepolia-mainnet": "https://rpc-sepolia.rockx.com", + "shrapnel-mainnet": "https://subnets.avax.network/shrapnel/mainnet/rpc", + "tenet-mainnet": "https://rpc.tenet.org", + "telos-mainnet": "https://rpc1.eu.telos.net/evm", + "zkpolygon-mainnet": "https://zkevm-rpc.com", + "zksync-mainnet": "https://zksync.drpc.org" + }, + "testnet": { + "aavegotchi": "", + "arbitrum-testnet": "https://arbitrum-goerli.publicnode.com", + "avalanche-testnet": "https://avalanche-fuji-c-chain.publicnode.com", + "base-testnet": "https://base-goerli.publicnode.com", + "bsc-testnet": "https://bsc-testnet.publicnode.com", + "canto": "https://testnet-archive.plexnode.wtf", + "cathay": "", + "celo-testnet": "https://alfajores-forno.celo-testnet.org", + "coredao-testnet": "https://rpc.test.btcs.network", + "dexalot-testnet": "https://subnets.avax.network/dexalot/testnet/rpc", + "dfk-testnet": "https://subnets.avax.network/defi-kingdoms/dfk-chain-testnet/rpc", + "dos-testnet": "https://test.doschain.com", + "ethereum-testnet": "https://ethereum-goerli.publicnode.com", + "fantom-testnet": "https://fantom-testnet.publicnode.com", + "fuse-testnet": "https://rpc.fusespark.io", + "gnosis-testnet": "https://rpc.chiadochain.net", + "harmony-testnet": "https://api.s0.ps.hmny.io", + "kava-testnet": "https://evm.testnet.kava.io", + "klaytn-testnet": "https://public-node-api.klaytnapi.com/v1/baobab", + "meter-testnet": "https://rpctest.meter.io", + "metis-testnet": "https://goerli.gateway.metisdevops.link", + "moonbeam-testnet": "https://rpc.api.moonbase.moonbeam.network", + "okx-testnet": "https://exchaintestrpc.okex.org", + "optimism-testnet": "https://optimism-goerli.publicnode.com", + "orderly-testnet": "", + "polygon-testnet": "https://polygon-mumbai-bor.publicnode.com", + "scroll-testnet": "https://scroll-testnet.blockpi.network/v1/rpc/public", + "sepolia-testnet": "https://api.zan.top/node/v1/eth/sepolia/public", + "shrapnel-testnet": "https://subnets.avax.network/shrapnel/testnet/rpc", + "tenet-testnet": "https://rpc.testnet.tenet.org", + "telos-testnet": "https://testnet.telos.net/evm", + "linea-testnet": "https://rpc.goerli.linea.build", + "zkpolygon": "https://rpc.public.zkevm-test.net", + "zksync-testnet": "https://testnet.era.zksync.dev" + } } diff --git a/packages/ua-utils-evm-hardhat/src/tasks/checkWireAllConfig.ts b/packages/ua-utils-evm-hardhat/src/tasks/checkWireAllConfig.ts index fd9b22572..12976fc3a 100644 --- a/packages/ua-utils-evm-hardhat/src/tasks/checkWireAllConfig.ts +++ b/packages/ua-utils-evm-hardhat/src/tasks/checkWireAllConfig.ts @@ -1,11 +1,11 @@ -import { getContract, getContractAt, getLayerZeroChainId } from "@/utils/crossChainHelper" -import { logError } from "@/utils/helpers" -import { LZ_APP_ABI } from "@/constants/abi" +import { getContract, getContractAt, getLayerZeroChainId } from '@/utils/crossChainHelper' +import { logError } from '@/utils/helpers' +import { LZ_APP_ABI } from '@/constants/abi' export default async function (taskArgs: any, hre: any) { - const localNetworks = taskArgs.chains.split(",") + const localNetworks = taskArgs.chains.split(',') const remoteNetworks = localNetworks - const contractAddresses = taskArgs?.addresses?.split(",") + const contractAddresses = taskArgs?.addresses?.split(',') const checkWireAllConfigObj: { [key: string]: any } = {} await Promise.all( @@ -17,10 +17,10 @@ export default async function (taskArgs: any, hre: any) { trustedRemoteLookup: {}, } - checkWireAllConfigObj[localNetwork].useCustomAdapterParams["useCustomAdapterParams"] = "" - checkWireAllConfigObj[localNetwork].withdrawalFeeBps["withdrawalFeeBps"] = "" - checkWireAllConfigObj[localNetwork].minDstGasLookup[localNetwork] = "" - checkWireAllConfigObj[localNetwork].trustedRemoteLookup[localNetwork] = "" + checkWireAllConfigObj[localNetwork].useCustomAdapterParams['useCustomAdapterParams'] = '' + checkWireAllConfigObj[localNetwork].withdrawalFeeBps['withdrawalFeeBps'] = '' + checkWireAllConfigObj[localNetwork].minDstGasLookup[localNetwork] = '' + checkWireAllConfigObj[localNetwork].trustedRemoteLookup[localNetwork] = '' let localContractNameOrAddress: any if (taskArgs?.proxyChain && taskArgs?.proxyContract && localNetwork == taskArgs?.proxyChain) { @@ -37,13 +37,10 @@ export default async function (taskArgs: any, hre: any) { } if (taskArgs.u) - checkWireAllConfigObj[localNetwork].useCustomAdapterParams["useCustomAdapterParams"] = await getUseCustomAdapterParams( - hre, - localNetwork, - localContractNameOrAddress - ) + checkWireAllConfigObj[localNetwork].useCustomAdapterParams['useCustomAdapterParams'] = + await getUseCustomAdapterParams(hre, localNetwork, localContractNameOrAddress) if (taskArgs.wfb) - checkWireAllConfigObj[localNetwork].withdrawalFeeBps["withdrawalFeeBps"] = await getWithdrawalFeeBps( + checkWireAllConfigObj[localNetwork].withdrawalFeeBps['withdrawalFeeBps'] = await getWithdrawalFeeBps( hre, localNetwork, localContractNameOrAddress @@ -86,7 +83,7 @@ export default async function (taskArgs: any, hre: any) { ) if (taskArgs.u) { - console.log("Use Custom Adapter Params Table") + console.log('Use Custom Adapter Params Table') const useCustomAdapterParamsTable = Object.keys(checkWireAllConfigObj).map((network) => ({ [network]: checkWireAllConfigObj[network].useCustomAdapterParams, })) @@ -94,7 +91,7 @@ export default async function (taskArgs: any, hre: any) { } if (taskArgs.wfb) { - console.log("Withdrawal Fee Bps Lookup Table") + console.log('Withdrawal Fee Bps Lookup Table') const minDstGasLookupTable = Object.keys(checkWireAllConfigObj).map((network) => ({ [network]: checkWireAllConfigObj[network].withdrawalFeeBps, })) @@ -102,7 +99,7 @@ export default async function (taskArgs: any, hre: any) { } if (taskArgs.t) { - console.log("Trusted Remote Lookup Table") + console.log('Trusted Remote Lookup Table') const trustedRemoteLookupTable = Object.keys(checkWireAllConfigObj).map((network) => ({ [network]: checkWireAllConfigObj[network].trustedRemoteLookup, })) @@ -110,7 +107,7 @@ export default async function (taskArgs: any, hre: any) { } if (taskArgs.m) { - console.log("Min Dst Gas Lookup Table") + console.log('Min Dst Gas Lookup Table') const minDstGasLookupTable = Object.keys(checkWireAllConfigObj).map((network) => ({ [network]: checkWireAllConfigObj[network].minDstGasLookup, })) @@ -118,7 +115,11 @@ export default async function (taskArgs: any, hre: any) { } } -async function getUseCustomAdapterParams(hre: any, localNetwork: string, localContractNameOrAddress: string): Promise { +async function getUseCustomAdapterParams( + hre: any, + localNetwork: string, + localContractNameOrAddress: string +): Promise { let localContract if (hre.ethers.utils.isAddress(localContractNameOrAddress)) { localContract = await getContractAt(hre, localNetwork, LZ_APP_ABI, localContractNameOrAddress) @@ -139,7 +140,7 @@ async function getWithdrawalFeeBps(hre: any, localNetwork: string, localContract try { withdrawalFeeBps = await localContract.withdrawalFeeBps() } catch (e) { - withdrawalFeeBps = "N/A" + withdrawalFeeBps = 'N/A' } return withdrawalFeeBps } @@ -156,7 +157,7 @@ async function getMinDstGas( } else { localContract = await getContract(hre, localNetwork, localContractNameOrAddress) } - if (localNetwork === remoteNetwork) return "" + if (localNetwork === remoteNetwork) return '' const remoteChainId = getLayerZeroChainId(remoteNetwork) const minGasPk_0 = await localContract.minDstGasLookup(remoteChainId, 0) const minGasPk_1 = await localContract.minDstGasLookup(remoteChainId, 1) @@ -189,8 +190,11 @@ async function getTrustedRemote( } const remoteContractAddress = await remoteContract.address - const desiredTrustedRemote = hre.ethers.utils.solidityPack(["bytes"], [remoteContractAddress + localContract.address.substring(2)]) + const desiredTrustedRemote = hre.ethers.utils.solidityPack( + ['bytes'], + [remoteContractAddress + localContract.address.substring(2)] + ) const remoteChainId = getLayerZeroChainId(remoteNetwork) const currentTrustedRemote = await localContract.trustedRemoteLookup(remoteChainId) - return currentTrustedRemote != desiredTrustedRemote ? (localNetwork === remoteNetwork ? "" : "🟥") : "🟩" + return currentTrustedRemote != desiredTrustedRemote ? (localNetwork === remoteNetwork ? '' : '🟥') : '🟩' } diff --git a/packages/ua-utils-evm-hardhat/src/tasks/getConfig.ts b/packages/ua-utils-evm-hardhat/src/tasks/getConfig.ts index 830ebdd70..96f36e8b2 100644 --- a/packages/ua-utils-evm-hardhat/src/tasks/getConfig.ts +++ b/packages/ua-utils-evm-hardhat/src/tasks/getConfig.ts @@ -1,15 +1,15 @@ -import { getDeploymentAddresses, getApplicationConfig, getEndpointAddress } from "@/utils/crossChainHelper" -import { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI } from "@/constants/abi" -import { logError } from "@/utils/helpers" +import { getDeploymentAddresses, getApplicationConfig, getEndpointAddress } from '@/utils/crossChainHelper' +import { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI } from '@/constants/abi' +import { logError } from '@/utils/helpers' export default async (taskArgs: any, hre: any) => { const network = hre.network.name - const remoteNetworks = taskArgs.remoteNetworks.split(",") + const remoteNetworks = taskArgs.remoteNetworks.split(',') const contractName = taskArgs.name let contractAddress = taskArgs.address if (!contractName && !contractAddress) { - logError("Provide contract name or address") + logError('Provide contract name or address') return } @@ -30,7 +30,8 @@ export default async (taskArgs: any, hre: any) => { let receiveLibrary: any if (sendVersion !== receiveVersion) { - const receiveLibraryAddress = receiveVersion === 0 ? await endpoint.defaultReceiveLibraryAddress() : appConfig.receiveLibraryAddress + const receiveLibraryAddress = + receiveVersion === 0 ? await endpoint.defaultReceiveLibraryAddress() : appConfig.receiveLibraryAddress receiveLibrary = await hre.ethers.getContractAt(MESSAGING_LIBRARY_ABI, receiveLibraryAddress) } @@ -41,9 +42,9 @@ export default async (taskArgs: any, hre: any) => { }) ) - console.log("Network ", network) - console.log("Application address", contractAddress) - console.log("Send version ", sendVersion) - console.log("Receive version ", receiveVersion) + console.log('Network ', network) + console.log('Application address', contractAddress) + console.log('Send version ', sendVersion) + console.log('Receive version ', receiveVersion) console.table(remoteConfig) } diff --git a/packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts b/packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts index dd72fdb9b..55dfbb0f0 100644 --- a/packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts +++ b/packages/ua-utils-evm-hardhat/src/tasks/getDefaultConfig.ts @@ -1,9 +1,9 @@ -import { ethers } from "ethers" -import { getProvider, getLayerZeroChainId, getEndpointAddress } from "@/utils/crossChainHelper" -import { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI } from "@/constants/abi" +import { ethers } from 'ethers' +import { getProvider, getLayerZeroChainId, getEndpointAddress } from '@/utils/crossChainHelper' +import { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI } from '@/constants/abi' export default async (taskArgs: any, hre: any) => { - const networks = taskArgs.networks.split(",") + const networks = taskArgs.networks.split(',') const configByNetwork = await Promise.all( networks.map(async (network: string) => { diff --git a/packages/ua-utils-evm-hardhat/src/tasks/index.ts b/packages/ua-utils-evm-hardhat/src/tasks/index.ts index ce273379d..83bc4ce8f 100644 --- a/packages/ua-utils-evm-hardhat/src/tasks/index.ts +++ b/packages/ua-utils-evm-hardhat/src/tasks/index.ts @@ -1,63 +1,73 @@ -import { task, types } from "hardhat/config" -import wireAll from "./wireAll" -import setConfig from "./setConfig" -import getDefaultConfig from "./getDefaultConfig" -import getConfig from "./getConfig" -import checkWireAllConfig from "./checkWireAllConfig" +import { task, types } from 'hardhat/config' +import wireAll from './wireAll' +import setConfig from './setConfig' +import getDefaultConfig from './getDefaultConfig' +import getConfig from './getConfig' +import checkWireAllConfig from './checkWireAllConfig' task( - "setConfig", - "sets Send and Receive Messaging Library versions and a custom application config for contracts implementing ILayerZeroUserApplicationConfig interface", + 'setConfig', + 'sets Send and Receive Messaging Library versions and a custom application config for contracts implementing ILayerZeroUserApplicationConfig interface', setConfig ) - .addParam("configPath", "the application config file path") + .addParam('configPath', 'the application config file path') .addOptionalParam( - "name", - "name of the deployed contracts. Should be specified if the same contract deployed on different chains and the deployment information is located in the deployments folder" + 'name', + 'name of the deployed contracts. Should be specified if the same contract deployed on different chains and the deployment information is located in the deployments folder' ) - .addOptionalParam("address", "address of the deployed contracts. Should be specified if the contract address is the same on all chains") - .addOptionalParam("gnosisConfigPath", "the path to a file with Gnosis config. If specified, the transactions will be sent to Gnosis") - .addOptionalParam("gasLimit", "override execution gasLimit") + .addOptionalParam( + 'address', + 'address of the deployed contracts. Should be specified if the contract address is the same on all chains' + ) + .addOptionalParam( + 'gnosisConfigPath', + 'the path to a file with Gnosis config. If specified, the transactions will be sent to Gnosis' + ) + .addOptionalParam('gasLimit', 'override execution gasLimit') task( - "getDefaultConfig", - "outputs the default Send and Receive Messaging Library versions and the default application config", + 'getDefaultConfig', + 'outputs the default Send and Receive Messaging Library versions and the default application config', getDefaultConfig -).addParam("networks", "comma separated list of networks") +).addParam('networks', 'comma separated list of networks') -task("getConfig", "outputs the application's Send and Receive Messaging Library versions and the config for remote networks", getConfig) - .addParam("remoteNetworks", "comma separated list of remote networks") +task( + 'getConfig', + "outputs the application's Send and Receive Messaging Library versions and the config for remote networks", + getConfig +) + .addParam('remoteNetworks', 'comma separated list of remote networks') .addOptionalParam( - "name", - "name of the deployed contract. Should be specified only if the deployment information is located in the deployments folder" + 'name', + 'name of the deployed contract. Should be specified only if the deployment information is located in the deployments folder' ) - .addOptionalParam("address", "the contract address") + .addOptionalParam('address', 'the contract address') -task("checkWireAllConfig", "", checkWireAllConfig) - .addParam("e", "the environment ie: mainnet, testnet or sandbox") - .addFlag("u", "show use custom adapter params") - .addFlag("t", "show trusted remote lookup") - .addFlag("m", "show min destination gas lookup") - .addParam("chains", "comma separated list of networks") - .addOptionalParam("contract", "name of contract") - .addOptionalParam("addresses", "addresses of contracts in same order as chains") - .addOptionalParam("proxyContract", "name of proxy contract") - .addOptionalParam("proxyChain", "name of proxy chain") +task('checkWireAllConfig', '', checkWireAllConfig) + .addParam('e', 'the environment ie: mainnet, testnet or sandbox') + .addFlag('u', 'show use custom adapter params') + .addFlag('t', 'show trusted remote lookup') + .addFlag('m', 'show min destination gas lookup') + .addParam('chains', 'comma separated list of networks') + .addOptionalParam('contract', 'name of contract') + .addOptionalParam('addresses', 'addresses of contracts in same order as chains') + .addOptionalParam('proxyContract', 'name of proxy contract') + .addOptionalParam('proxyChain', 'name of proxy chain') -task("wireAll", "", wireAll) - .addParam("e", "the environment ie: mainnet, testnet or sandbox") - .addOptionalParam("noPrompt", "no prompt", false, types.boolean) +task('wireAll', '', wireAll) + .addParam('e', 'the environment ie: mainnet, testnet or sandbox') + .addOptionalParam('noPrompt', 'no prompt', false, types.boolean) .addOptionalParam( - "configPath", - "Optional config path. Default: ./constants/wireUpConfig.json", - "./constants/wireUpConfig.json", + 'configPath', + 'Optional config path. Default: ./constants/wireUpConfig.json', + './constants/wireUpConfig.json', types.string ) - .addOptionalParam("n", "send to gnosis", false, types.boolean) - .addOptionalParam("gasLimit", "override execution gasLimit") + .addOptionalParam('n', 'send to gnosis', false, types.boolean) + .addOptionalParam('gasLimit', 'override execution gasLimit') .addOptionalParam( - "gnosisConfigPath", - "Optional config path. Default: ./constants/gnosisConfig.json", - "./constants/gnosisConfig.json", + 'gnosisConfigPath', + 'Optional config path. Default: ./constants/gnosisConfig.json', + './constants/gnosisConfig.json', types.string ) diff --git a/packages/ua-utils-evm-hardhat/src/tasks/setConfig.ts b/packages/ua-utils-evm-hardhat/src/tasks/setConfig.ts index 4e64a16b7..066d48412 100644 --- a/packages/ua-utils-evm-hardhat/src/tasks/setConfig.ts +++ b/packages/ua-utils-evm-hardhat/src/tasks/setConfig.ts @@ -1,4 +1,13 @@ -import { promptToProceed, writeToCsv, logError, logWarning, printTransactions, logSuccess, configExist, getConfig } from "@/utils/helpers" +import { + promptToProceed, + writeToCsv, + logError, + logWarning, + printTransactions, + logSuccess, + configExist, + getConfig, +} from '@/utils/helpers' import { executeTransaction, executeGnosisTransactions, @@ -10,9 +19,9 @@ import { getApplicationConfig, getEndpointAddress, getLayerZeroChainId, -} from "@/utils/crossChainHelper" -import { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI, USER_APPLICATION_ABI } from "@/constants/abi" -import { utils } from "ethers" +} from '@/utils/crossChainHelper' +import { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI, USER_APPLICATION_ABI } from '@/constants/abi' +import { utils } from 'ethers' // Application config types from UltraLightNodeV2 contract const CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION = 1 @@ -58,22 +67,29 @@ export default async (taskArgs: any, hre: any) => { ? await getContract(hre, network, contractName) : await getContractAt(hre, network, USER_APPLICATION_ABI, contractAddress) const appConfig = await endpoint.uaConfigLookup(app.address) - const sendLibraryAddress = appConfig.sendVersion === 0 ? await endpoint.defaultSendLibrary() : appConfig.sendLibrary + const sendLibraryAddress = + appConfig.sendVersion === 0 ? await endpoint.defaultSendLibrary() : appConfig.sendLibrary const sendLibrary = await getContractAt(hre, network, MESSAGING_LIBRARY_ABI, sendLibraryAddress) let receiveLibrary: any if (appConfig.sendVersion !== appConfig.receiveVersion) { const receiveLibraryAddress = - appConfig.receiveVersion === 0 ? await endpoint.defaultReceiveLibraryAddress() : appConfig.receiveLibraryAddress + appConfig.receiveVersion === 0 + ? await endpoint.defaultReceiveLibraryAddress() + : appConfig.receiveLibraryAddress receiveLibrary = await getContractAt(hre, network, MESSAGING_LIBRARY_ABI, receiveLibraryAddress) } if (networkConfig.sendVersion) { - transactions.push(...(await setSendVersion(chainId, app, appConfig.sendVersion, networkConfig.sendVersion))) + transactions.push( + ...(await setSendVersion(chainId, app, appConfig.sendVersion, networkConfig.sendVersion)) + ) } if (networkConfig.receiveVersion) { - transactions.push(...(await setReceiveVersion(chainId, app, appConfig.receiveVersion, networkConfig.receiveVersion))) + transactions.push( + ...(await setReceiveVersion(chainId, app, appConfig.receiveVersion, networkConfig.receiveVersion)) + ) } const remoteConfigs = networkConfig.remoteConfigs @@ -85,7 +101,12 @@ export default async (taskArgs: any, hre: any) => { remoteConfigs.map(async (newConfig: any) => { if (newConfig.remoteChain === network) return - const oldConfig = await getApplicationConfig(newConfig.remoteChain, sendLibrary, receiveLibrary, app.address) + const oldConfig = await getApplicationConfig( + newConfig.remoteChain, + sendLibrary, + receiveLibrary, + app.address + ) const remoteChainId = getLayerZeroChainId(newConfig.remoteChain) if (newConfig.inboundProofLibraryVersion) { @@ -96,7 +117,7 @@ export default async (taskArgs: any, hre: any) => { remoteChainId, app, CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION, - "uint16", + 'uint16', oldConfig.inboundProofLibraryVersion, newConfig.inboundProofLibraryVersion )) @@ -111,7 +132,7 @@ export default async (taskArgs: any, hre: any) => { remoteChainId, app, CONFIG_TYPE_INBOUND_BLOCK_CONFIRMATIONS, - "uint64", + 'uint64', oldConfig.inboundBlockConfirmations, newConfig.inboundBlockConfirmations )) @@ -126,7 +147,7 @@ export default async (taskArgs: any, hre: any) => { remoteChainId, app, CONFIG_TYPE_RELAYER, - "address", + 'address', oldConfig.relayer, newConfig.relayer )) @@ -141,7 +162,7 @@ export default async (taskArgs: any, hre: any) => { remoteChainId, app, CONFIG_TYPE_OUTBOUND_PROOF_TYPE, - "uint16", + 'uint16', oldConfig.outboundProofType, newConfig.outboundProofType )) @@ -156,7 +177,7 @@ export default async (taskArgs: any, hre: any) => { remoteChainId, app, CONFIG_TYPE_OUTBOUND_BLOCK_CONFIRMATIONS, - "uint64", + 'uint64', oldConfig.outboundBlockConfirmations, newConfig.outboundBlockConfirmations )) @@ -171,7 +192,7 @@ export default async (taskArgs: any, hre: any) => { remoteChainId, app, CONFIG_TYPE_ORACLE, - "address", + 'address', oldConfig.oracle, newConfig.oracle )) @@ -193,14 +214,14 @@ export default async (taskArgs: any, hre: any) => { }, 0) if (totalTransactionsNeedingChange == 0) { - console.log("No changes needed") + console.log('No changes needed') return } - const columns = ["chainId", "remoteChainId", "contractAddress", "functionName", "args", "diff"] + const columns = ['chainId', 'remoteChainId', 'contractAddress', 'functionName', 'args', 'diff'] printTransactions(columns, transactionByNetwork) - writeToCsv("setConfigTransactions.csv", columns, transactionByNetwork) - await promptToProceed(`Would you like to proceed with the above instructions ${sendToGnosis ? "in Gnosis?" : "?"}`) + writeToCsv('setConfigTransactions.csv', columns, transactionByNetwork) + await promptToProceed(`Would you like to proceed with the above instructions ${sendToGnosis ? 'in Gnosis?' : '?'}`) const errors: any[] = [] const print: any = {} @@ -220,11 +241,11 @@ export default async (taskArgs: any, hre: any) => { await Promise.all( transactionByNetwork.map(async ({ network, transactions }) => { const transactionToCommit = transactions.filter((transaction: Transaction) => transaction.needChange) - print[network] = print[network] || { requests: "1/1" } + print[network] = print[network] || { requests: '1/1' } print[network].current = `executeGnosisTransactions: ${transactionToCommit}` try { await executeGnosisTransactions(hre, network, gnosisConfig, transactionToCommit) - print[network].requests = "1/1" + print[network].requests = '1/1' } catch (err: any) { errors.push({ network, err }) print[network].current = err.message @@ -234,7 +255,7 @@ export default async (taskArgs: any, hre: any) => { ) printResult() if (errors.length) { - logError(`\nFinished with ${errors.length === 1 ? "an error" : `${errors.length} errors`}`, false) + logError(`\nFinished with ${errors.length === 1 ? 'an error' : `${errors.length} errors`}`, false) errors.forEach((x) => { console.log(x.err) console.log() @@ -264,7 +285,9 @@ export default async (taskArgs: any, hre: any) => { print[network].requests = `${successTx}/${transactionToCommit.length}` printResult() } catch (err: any) { - logError(`Failing to call ${transaction.contractName}.${transaction.functionName} on ${network} with an error ${err}`) + logError( + `Failing to call ${transaction.contractName}.${transaction.functionName} on ${network} with an error ${err}` + ) errors.push({ network, err }) print[network].current = err print[network].err = true @@ -277,14 +300,19 @@ export default async (taskArgs: any, hre: any) => { } if (!errors.length) { - logSuccess("\nFinished successfully") + logSuccess('\nFinished successfully') } } -const setSendVersion = async (chainId: string, app: any, oldSendVersion: any, newSendVersion: any): Promise => { +const setSendVersion = async ( + chainId: string, + app: any, + oldSendVersion: any, + newSendVersion: any +): Promise => { const needChange = oldSendVersion !== newSendVersion const contractAddress = app.address - const functionName = "setSendVersion" + const functionName = 'setSendVersion' const args = [newSendVersion] const calldata = app.interface.encodeFunctionData(functionName, args) const diff = needChange ? { oldValue: oldSendVersion, newValue: newSendVersion } : undefined @@ -292,10 +320,15 @@ const setSendVersion = async (chainId: string, app: any, oldSendVersion: any, ne return [{ needChange, chainId, contractAddress, functionName, args, calldata, diff }] } -const setReceiveVersion = async (chainId: string, app: any, currentReceiveVersion: any, newReceiveVersion: any): Promise => { +const setReceiveVersion = async ( + chainId: string, + app: any, + currentReceiveVersion: any, + newReceiveVersion: any +): Promise => { const needChange = currentReceiveVersion !== newReceiveVersion const contractAddress = app.address - const functionName = "setReceiveVersion" + const functionName = 'setReceiveVersion' const args = [newReceiveVersion] const calldata = app.interface.encodeFunctionData(functionName, args) const diff = needChange ? { oldValue: currentReceiveVersion, newValue: newReceiveVersion } : undefined @@ -315,7 +348,7 @@ const setConfig = async ( ): Promise => { const newConfig = utils.defaultAbiCoder.encode([configValueType], [newValue]) const contractAddress = app.address - const functionName = "setConfig" + const functionName = 'setConfig' const args = [configVersion, remoteChainId, configType, newConfig] const needChange = oldValue !== newValue const calldata = app.interface.encodeFunctionData(functionName, args) diff --git a/packages/ua-utils-evm-hardhat/src/tasks/wireAll.ts b/packages/ua-utils-evm-hardhat/src/tasks/wireAll.ts index e438043ec..e8119fdfe 100644 --- a/packages/ua-utils-evm-hardhat/src/tasks/wireAll.ts +++ b/packages/ua-utils-evm-hardhat/src/tasks/wireAll.ts @@ -1,6 +1,17 @@ -import { Transaction, NetworkTransactions, getContractInstance, getLayerZeroChainId, executeTransactions } from "@/utils/crossChainHelper" -import { configExist, getConfig, logError, printTransactions } from "@/utils/helpers" -import { setUseCustomAdapterParams, setMinDstGas, setTrustedRemote, getContractNameOrAddress } from "@/utils/wireAllHelpers" +import { + Transaction, + NetworkTransactions, + getContractInstance, + getLayerZeroChainId, + executeTransactions, +} from '@/utils/crossChainHelper' +import { configExist, getConfig, logError, printTransactions } from '@/utils/helpers' +import { + setUseCustomAdapterParams, + setMinDstGas, + setTrustedRemote, + getContractNameOrAddress, +} from '@/utils/wireAllHelpers' export default async function (taskArgs: any, hre: any) { if (!configExist(taskArgs.configPath)) { @@ -38,13 +49,22 @@ export default async function (taskArgs: any, hre: any) { // check if useCustomAdapterParams needs to be set const useCustomAdapterParams = WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.useCustomAdapterParams if (useCustomAdapterParams !== undefined) { - transactions.push(...(await setUseCustomAdapterParams(hre, localNetwork, localContractNameOrAddress, useCustomAdapterParams))) + transactions.push( + ...(await setUseCustomAdapterParams( + hre, + localNetwork, + localContractNameOrAddress, + useCustomAdapterParams + )) + ) } // check if defaultFeeBp needs to be set const defaultFeeBp = WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.defaultFeeBp if (defaultFeeBp !== undefined) { - transactions.push(...(await setDefaultFeeBp(hre, localNetwork, localContractNameOrAddress, defaultFeeBp))) + transactions.push( + ...(await setDefaultFeeBp(hre, localNetwork, localContractNameOrAddress, defaultFeeBp)) + ) } await Promise.all( @@ -61,30 +81,44 @@ export default async function (taskArgs: any, hre: any) { // setTrustedRemote transactions.push( - ...(await setTrustedRemote(hre, localNetwork, localContractNameOrAddress, remoteNetwork, remoteContractNameOrAddress)) + ...(await setTrustedRemote( + hre, + localNetwork, + localContractNameOrAddress, + remoteNetwork, + remoteContractNameOrAddress + )) ) // setFeeBp - if (WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.remoteNetworkConfig?.[remoteNetwork]?.feeBpConfig !== undefined) { + if ( + WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.remoteNetworkConfig?.[remoteNetwork] + ?.feeBpConfig !== undefined + ) { transactions.push( ...(await setFeeBp( hre, localNetwork, localContractNameOrAddress, - WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.remoteNetworkConfig?.[remoteNetwork].feeBpConfig, + WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.remoteNetworkConfig?.[remoteNetwork] + .feeBpConfig, getLayerZeroChainId(remoteNetwork) )) ) } // setMinDstGas - if (WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.remoteNetworkConfig?.[remoteNetwork]?.minDstGasConfig !== undefined) { + if ( + WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.remoteNetworkConfig?.[remoteNetwork] + ?.minDstGasConfig !== undefined + ) { transactions.push( ...(await setMinDstGas( hre, localNetwork, localContractNameOrAddress, - WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.remoteNetworkConfig?.[remoteNetwork].minDstGasConfig, + WIRE_UP_CONFIG?.chainConfig?.[localNetwork]?.remoteNetworkConfig?.[remoteNetwork] + .minDstGasConfig, getLayerZeroChainId(remoteNetwork) )) ) @@ -104,10 +138,10 @@ export default async function (taskArgs: any, hre: any) { }, 0) if (noChanges == 0) { //early return - console.log("No changes needed") + console.log('No changes needed') return } - const columns = ["needChange", "chainId", "contractName", "functionName", "args", "diff"] + const columns = ['needChange', 'chainId', 'contractName', 'functionName', 'args', 'diff'] printTransactions(columns, transactionByNetwork) await executeTransactions(hre, taskArgs, transactionByNetwork) } @@ -123,8 +157,8 @@ async function setDefaultFeeBp( const needChange = cur !== defaultFeeBp // function setDefaultFeeBp(uint16 _feeBp) - const functionName = "setDefaultFeeBp" - const params = ["uint16"] + const functionName = 'setDefaultFeeBp' + const params = ['uint16'] const args = [defaultFeeBp] const tx: any = { @@ -155,8 +189,8 @@ async function setFeeBp( const needChange = curFeeBp !== feeBpConfig.feeBp || curEnabled !== feeBpConfig.enabled // function setFeeBp(uint16 _dstChainId, bool _enabled, uint16 _feeBp) - const functionName = "setFeeBp" - const params = ["uint16", "bool", "uint16"] + const functionName = 'setFeeBp' + const params = ['uint16', 'bool', 'uint16'] const args = [remoteChainId, feeBpConfig.enabled, feeBpConfig.feeBp] const calldata = localContract.interface.encodeFunctionData(functionName, args) @@ -170,7 +204,12 @@ async function setFeeBp( } if (tx.needChange) { tx.diff = JSON.stringify({ - feeBp: { oldFeeBpValue: curFeeBp, newFeeBpValue: feeBpConfig.feeBp, oldEnabledFee: curEnabled, newEnabledFee: feeBpConfig.enabled }, + feeBp: { + oldFeeBpValue: curFeeBp, + newFeeBpValue: feeBpConfig.feeBp, + oldEnabledFee: curEnabled, + newEnabledFee: feeBpConfig.enabled, + }, }) } return [tx] diff --git a/packages/ua-utils-evm-hardhat/src/utils/crossChainHelper.ts b/packages/ua-utils-evm-hardhat/src/utils/crossChainHelper.ts index 98f0da516..6ef474c4f 100644 --- a/packages/ua-utils-evm-hardhat/src/utils/crossChainHelper.ts +++ b/packages/ua-utils-evm-hardhat/src/utils/crossChainHelper.ts @@ -1,15 +1,15 @@ -import * as ethers from "ethers" -import { Contract, ContractReceipt } from "ethers" -import EthersAdapter from "@gnosis.pm/safe-ethers-lib" -import SafeServiceClient from "@gnosis.pm/safe-service-client" -import Safe from "@gnosis.pm/safe-core-sdk" -import { LZ_APP_ABI } from "@/constants/abi" -import { LZ_ENDPOINTS } from "@/constants/endpoints" -import { MainnetEndpointId, TestnetEndpointId, SandboxEndpointId } from "@layerzerolabs/lz-definitions" -import { promptToProceed, arrayToCsv, getConfig } from "./helpers" -import path from "path" -import fs from "fs" -import { writeFile } from "fs/promises" +import * as ethers from 'ethers' +import { Contract, ContractReceipt } from 'ethers' +import EthersAdapter from '@gnosis.pm/safe-ethers-lib' +import SafeServiceClient from '@gnosis.pm/safe-service-client' +import Safe from '@gnosis.pm/safe-core-sdk' +import { LZ_APP_ABI } from '@/constants/abi' +import { LZ_ENDPOINTS } from '@/constants/endpoints' +import { MainnetEndpointId, TestnetEndpointId, SandboxEndpointId } from '@layerzerolabs/lz-definitions' +import { promptToProceed, arrayToCsv, getConfig } from './helpers' +import path from 'path' +import fs from 'fs' +import { writeFile } from 'fs/promises' export interface ExecutableTransaction { contractName: string @@ -43,7 +43,8 @@ export const getProvider = (hre: any, network: string) => { return providerByNetwork[network] } -export const getWallet = (index: number) => ethers.Wallet.fromMnemonic(process.env.MNEMONIC || "", `m/44'/60'/0'/0/${index}`) +export const getWallet = (index: number) => + ethers.Wallet.fromMnemonic(process.env.MNEMONIC || '', `m/44'/60'/0'/0/${index}`) const connectedWallets: { [key: string]: any } = {} export const getConnectedWallet = (hre: any, network: string, walletIndex: number) => { @@ -70,7 +71,7 @@ export const getDeploymentAddress = (network: string, contractName: string) => { const contracts: { [key: string]: any } = {} export const getContract = async (hre: any, network: string, contractName: string) => { - if (network == "hardhat") { + if (network == 'hardhat') { return await hre.ethers.getContract(contractName) } @@ -101,7 +102,13 @@ export const getWalletContract = async (hre: any, network: string, contractName: return contract.connect(wallet) } -export const getWalletContractAt = async (hre: any, network: string, abi: any, contractAddress: string, walletIndex = 0) => { +export const getWalletContractAt = async ( + hre: any, + network: string, + abi: any, + contractAddress: string, + walletIndex = 0 +) => { const contract = await getContractAt(hre, network, abi, contractAddress) const wallet = getConnectedWallet(hre, network, walletIndex) return contract.connect(wallet) @@ -143,14 +150,23 @@ export const executeTransaction = async ( } export async function executeTransactions(hre: any, taskArgs: any, transactionBynetwork: any[]) { - const columns = ["needChange", "chainId", "remoteChainId", "contractName", "functionName", "args", "diff", "calldata"] + const columns = [ + 'needChange', + 'chainId', + 'remoteChainId', + 'contractName', + 'functionName', + 'args', + 'diff', + 'calldata', + ] const data = transactionBynetwork.reduce((acc, { network, transactions }) => { transactions.forEach((transaction: any) => { acc.push([ network, ...columns.map((key) => { - if (typeof transaction[key] === "object") { + if (typeof transaction[key] === 'object') { return JSON.stringify(transaction[key]) } else { return transaction[key] @@ -160,9 +176,9 @@ export async function executeTransactions(hre: any, taskArgs: any, transactionBy }) return acc }, [] as any) - await writeFile("./transactions.csv", arrayToCsv(["network"].concat(columns), data)) + await writeFile('./transactions.csv', arrayToCsv(['network'].concat(columns), data)) - console.log("Full configuration is written at:") + console.log('Full configuration is written at:') console.log(`file:/${process.cwd()}/transactions.csv`) const errs: any[] = [] @@ -179,7 +195,7 @@ export async function executeTransactions(hre: any, taskArgs: any, transactionBy } if (taskArgs.n) { - await promptToProceed("Would you like to Submit to gnosis?", taskArgs.noPrompt) + await promptToProceed('Would you like to Submit to gnosis?', taskArgs.noPrompt) const gnosisConfig = getConfig(taskArgs.gnosisConfigPath) await Promise.all( transactionBynetwork.map(async ({ network, transactions }) => { @@ -203,7 +219,7 @@ export async function executeTransactions(hre: any, taskArgs: any, transactionBy }) ) } else { - await promptToProceed("Would you like to run these transactions?", taskArgs.noPrompt) + await promptToProceed('Would you like to run these transactions?', taskArgs.noPrompt) await Promise.all( transactionBynetwork.map(async ({ network, transactions }) => { const transactionToCommit = transactions.filter((transaction: any) => transaction.needChange) @@ -216,7 +232,8 @@ export async function executeTransactions(hre: any, taskArgs: any, transactionBy try { const gasLimit = taskArgs.gasLimit const tx = await executeTransaction(hre, network, transaction, gasLimit) - print[network].past = `${transaction.contractName}.${transaction.functionName} (${tx.transactionHash})` + print[network].past = + `${transaction.contractName}.${transaction.functionName} (${tx.transactionHash})` successTx++ print[network].requests = `${successTx}/${transactionToCommit.length}` printResult() @@ -240,13 +257,18 @@ export async function executeTransactions(hre: any, taskArgs: any, transactionBy } if (!errs.length) { - console.log("Wired all networks successfully") + console.log('Wired all networks successfully') } else { console.log(errs) } } -export const executeGnosisTransactions = async (hre: any, network: string, gnosisConfig: any, transactions: Transaction[]) => { +export const executeGnosisTransactions = async ( + hre: any, + network: string, + gnosisConfig: any, + transactions: Transaction[] +) => { const signer = await getConnectedWallet(hre, network, 0) if (!gnosisConfig[network]) { throw Error(`Gnosis for ${network} not found or not supported`) @@ -262,7 +284,7 @@ export const executeGnosisTransactions = async (hre: any, network: string, gnosi }) const safeSdk: Safe = await Safe.create({ ethAdapter, safeAddress }) - const gnosisTransactions = transactions.map((tx) => ({ to: tx.contractAddress, data: tx.calldata!, value: "0" })) + const gnosisTransactions = transactions.map((tx) => ({ to: tx.contractAddress, data: tx.calldata!, value: '0' })) const nonce = await safeService.getNextNonce(safeAddress) const safeTransaction = await safeSdk.createTransaction(gnosisTransactions, { nonce }) @@ -278,37 +300,42 @@ export const executeGnosisTransactions = async (hre: any, network: string, gnosi export const getDeploymentAddresses = (network: string, throwIfMissing: boolean = true): any => { const deploymentAddresses: { [key: string]: any } = {} - const DEPLOYMENT_PATH = path.resolve("deployments") + const DEPLOYMENT_PATH = path.resolve('deployments') if (!fs.existsSync(DEPLOYMENT_PATH)) { return deploymentAddresses } let folderName = network - if (network === "hardhat") { - folderName = "localhost" + if (network === 'hardhat') { + folderName = 'localhost' } const networkFolderName = fs.readdirSync(DEPLOYMENT_PATH).filter((f: string) => f === folderName)[0] if (networkFolderName === undefined) { if (throwIfMissing) { - throw new Error("missing deployment files for endpoint " + folderName) + throw new Error('missing deployment files for endpoint ' + folderName) } return deploymentAddresses } const networkFolderPath = path.resolve(DEPLOYMENT_PATH, folderName) - const files = fs.readdirSync(networkFolderPath).filter((f: string) => f.includes(".json")) + const files = fs.readdirSync(networkFolderPath).filter((f: string) => f.includes('.json')) files.forEach((file: string) => { const filepath = path.resolve(networkFolderPath, file) - const data = JSON.parse(fs.readFileSync(filepath, "utf8")) - const contractName = file.split(".")[0] + const data = JSON.parse(fs.readFileSync(filepath, 'utf8')) + const contractName = file.split('.')[0] deploymentAddresses[contractName] = data.address }) return deploymentAddresses } -export const getApplicationConfig = async (remoteNetwork: string, sendLibrary: any, receiveLibrary: any, applicationAddress: string) => { +export const getApplicationConfig = async ( + remoteNetwork: string, + sendLibrary: any, + receiveLibrary: any, + applicationAddress: string +) => { const remoteChainId = getLayerZeroChainId(remoteNetwork) const sendConfig = await sendLibrary.appConfig(applicationAddress, remoteChainId) let inboundProofLibraryVersion = sendConfig.inboundProofLibraryVersion @@ -336,21 +363,21 @@ export const getEndpointAddress = (network: string): string => { // expecting "chain-environment" eg. "ethereum-mainnet", "ethereum-testnet", "ethereum-sandbox" export const getLayerZeroChainId = (network: string): string => { - const [chainName, environment] = network.split("-") + const [chainName, environment] = network.split('-') const chainIdEnum = getChainIdEnum(chainName, environment) - if (environment == "mainnet") { + if (environment == 'mainnet') { return MainnetEndpointId[chainIdEnum as any] - } else if (environment == "testnet") { + } else if (environment == 'testnet') { return TestnetEndpointId[chainIdEnum as any] - } else if (environment == "sandbox") { + } else if (environment == 'sandbox') { return SandboxEndpointId[chainIdEnum as any] } else { - throw new Error("cannot find chainId") + throw new Error('cannot find chainId') } } const getChainIdEnum = (chainName: string, environment: string): string => { - return `${chainName.split("-")[0].toUpperCase()}_${environment.toUpperCase()}` + return `${chainName.split('-')[0].toUpperCase()}_${environment.toUpperCase()}` } export const getContractInstance = async (hre: any, network: string, contractNameOrAddress: string) => { diff --git a/packages/ua-utils-evm-hardhat/src/utils/helpers.ts b/packages/ua-utils-evm-hardhat/src/utils/helpers.ts index 388b63a75..5994face7 100644 --- a/packages/ua-utils-evm-hardhat/src/utils/helpers.ts +++ b/packages/ua-utils-evm-hardhat/src/utils/helpers.ts @@ -1,12 +1,12 @@ -import { cli } from "cli-ux" -import fs from "fs" -import chalk from "chalk" -import { Transaction, NetworkTransactions } from "./crossChainHelper" +import { cli } from 'cli-ux' +import fs from 'fs' +import chalk from 'chalk' +import { Transaction, NetworkTransactions } from './crossChainHelper' export const promptToProceed = async (msg: string, noPrompt: boolean = false) => { if (!noPrompt) { const proceed = await cli.prompt(`${msg} Y/N`) - if (!["y", "yes"].includes(proceed.toLowerCase())) { + if (!['y', 'yes'].includes(proceed.toLowerCase())) { process.exit(0) } } @@ -14,20 +14,20 @@ export const promptToProceed = async (msg: string, noPrompt: boolean = false) => export const arrayToCsv = (columns: string[], data: any) => columns - .join(",") - .concat("\n") + .join(',') + .concat('\n') .concat( data .map( (row: any) => row .map(String) // convert every value to String - .map((v: any) => (v === "undefined" ? "" : v)) + .map((v: any) => (v === 'undefined' ? '' : v)) .map((v: any) => v.replace(/"/g, '""')) // escape double colons .map((v: any) => `"${v}"`) // quote it - .join(",") // comma-separated + .join(',') // comma-separated ) - .join("\r\n") // rows starting on new lines + .join('\r\n') // rows starting on new lines ) export const writeToCsv = async (fileName: string, columns: string[], transactionByNetwork: any[]) => { @@ -36,10 +36,10 @@ export const writeToCsv = async (fileName: string, columns: string[], transactio acc.push([ network, ...columns.map((key) => { - const keys = key.split("/") + const keys = key.split('/') for (const field in tx) { if (keys.includes(field)) { - if (typeof tx[field] === "object") { + if (typeof tx[field] === 'object') { return JSON.stringify(tx[field]) } else { return tx[field] @@ -51,7 +51,7 @@ export const writeToCsv = async (fileName: string, columns: string[], transactio }) return acc }, []) - fs.writeFileSync(fileName, arrayToCsv(["network"].concat(columns), data)) + fs.writeFileSync(fileName, arrayToCsv(['network'].concat(columns), data)) console.log(`Transactions are written to: ${chalk.green(fileName)}`) } @@ -66,7 +66,7 @@ export const printTransactions = (columns: string[], transactionByNetwork: Netwo totalTransactionsNeedingChange += transactionsNeedingChange.length if (!transactionsNeedingChange.length) { - console.log("No changes needed\n") + console.log('No changes needed\n') } else { console.table(transactionsNeedingChange, columns) } @@ -78,4 +78,4 @@ export const logError = (message: string, includeErrorText: boolean = true) => export const logWarning = (message: string) => console.log(chalk.yellow(`WARNING: ${message}`)) export const logSuccess = (message: string) => console.log(chalk.green(`${message}`)) export const configExist = (fileName: string) => fs.existsSync(fileName) -export const getConfig = (fileName: string) => JSON.parse(fs.readFileSync(fileName, "utf-8")) +export const getConfig = (fileName: string) => JSON.parse(fs.readFileSync(fileName, 'utf-8')) diff --git a/packages/ua-utils-evm-hardhat/src/utils/wireAllHelpers.ts b/packages/ua-utils-evm-hardhat/src/utils/wireAllHelpers.ts index 7d81ce005..13c873e36 100644 --- a/packages/ua-utils-evm-hardhat/src/utils/wireAllHelpers.ts +++ b/packages/ua-utils-evm-hardhat/src/utils/wireAllHelpers.ts @@ -1,4 +1,4 @@ -import { Transaction, getLayerZeroChainId, getContractInstance } from "./crossChainHelper" +import { Transaction, getLayerZeroChainId, getContractInstance } from './crossChainHelper' export async function setUseCustomAdapterParams( hre: any, @@ -11,8 +11,8 @@ export async function setUseCustomAdapterParams( const needChange = cur !== useCustom // function setUseCustomAdapterParams(bool _useCustomAdapterParams) - const functionName = "setUseCustomAdapterParams" - const params = ["bool"] + const functionName = 'setUseCustomAdapterParams' + const params = ['bool'] const args = [useCustom] const tx: any = { @@ -46,8 +46,8 @@ export async function setMinDstGas( const needChange = cur !== minGas // function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint _minGas) - const functionName = "setMinDstGas" - const params = ["uint16", "uint16", "uint256"] + const functionName = 'setMinDstGas' + const params = ['uint16', 'uint16', 'uint256'] const args = [remoteChainId, packetType, minGas] const tx: any = { @@ -77,15 +77,18 @@ export async function setTrustedRemote( const remoteContract = await getContractInstance(hre, remoteNetwork, remoteContractNameOrAddress) const remoteContractAddress = await remoteContract.address - const desiredTrustedRemote = hre.ethers.utils.solidityPack(["bytes"], [remoteContractAddress + localContract.address.substring(2)]) + const desiredTrustedRemote = hre.ethers.utils.solidityPack( + ['bytes'], + [remoteContractAddress + localContract.address.substring(2)] + ) const remoteChainId = getLayerZeroChainId(remoteNetwork) const cur = await localContract.trustedRemoteLookup(remoteChainId) const needChange = cur != desiredTrustedRemote // function setTrustedRemote(uint16 _srcChainId, bytes calldata _path) - const functionName = "setTrustedRemote" - const params = ["uint16", "bytes"] + const functionName = 'setTrustedRemote' + const params = ['uint16', 'bytes'] const args = [remoteChainId, desiredTrustedRemote] const tx: any = { diff --git a/packages/ua-utils-evm-hardhat/tsconfig.json b/packages/ua-utils-evm-hardhat/tsconfig.json index 8600addf7..62d56546d 100644 --- a/packages/ua-utils-evm-hardhat/tsconfig.json +++ b/packages/ua-utils-evm-hardhat/tsconfig.json @@ -1,10 +1,10 @@ { - "extends": "../../tsconfig.json", - "exclude": ["dist", "node_modules"], - "compilerOptions": { - "types": ["node", "mocha"], - "paths": { - "@/*": ["./src/*"] - } + "extends": "../../tsconfig.json", + "exclude": ["dist", "node_modules"], + "compilerOptions": { + "types": ["node", "mocha"], + "paths": { + "@/*": ["./src/*"] } + } } diff --git a/packages/ua-utils-evm-hardhat/tsup.config.ts b/packages/ua-utils-evm-hardhat/tsup.config.ts index 2178967ff..6af24d435 100644 --- a/packages/ua-utils-evm-hardhat/tsup.config.ts +++ b/packages/ua-utils-evm-hardhat/tsup.config.ts @@ -1,12 +1,12 @@ -import { defineConfig } from "tsup" +import { defineConfig } from 'tsup' export default defineConfig({ - entry: ["src/tasks/index.ts"], - outDir: "./dist/tasks", + entry: ['src/tasks/index.ts'], + outDir: './dist/tasks', clean: true, dts: true, sourcemap: true, splitting: false, treeshake: true, - format: ["esm", "cjs"], + format: ['esm', 'cjs'], }) diff --git a/packages/utils-evm-hardhat/CHANGELOG.md b/packages/utils-evm-hardhat/CHANGELOG.md index 28ad22bda..da2e7c7d4 100644 --- a/packages/utils-evm-hardhat/CHANGELOG.md +++ b/packages/utils-evm-hardhat/CHANGELOG.md @@ -4,4 +4,4 @@ ### Patch Changes -- 6964deb: Memoize create\* calls +- 6964deb: Memoize create\* calls diff --git a/packages/utils-evm-hardhat/hardhat.config.ts b/packages/utils-evm-hardhat/hardhat.config.ts index 62d525b25..04e532046 100644 --- a/packages/utils-evm-hardhat/hardhat.config.ts +++ b/packages/utils-evm-hardhat/hardhat.config.ts @@ -1,5 +1,5 @@ -import "hardhat-deploy" -import { HardhatUserConfig } from "hardhat/types" +import 'hardhat-deploy' +import { HardhatUserConfig } from 'hardhat/types' /** * This is a dummy hardhat config that enables us to test @@ -7,14 +7,14 @@ import { HardhatUserConfig } from "hardhat/types" */ const config: HardhatUserConfig = { networks: { - "ethereum-mainnet": { - url: "https://eth.llamarpc.com", + 'ethereum-mainnet': { + url: 'https://eth.llamarpc.com', saveDeployments: true, }, - "bsc-testnet": { - url: "https://bsc-testnet.publicnode.com", + 'bsc-testnet': { + url: 'https://bsc-testnet.publicnode.com', accounts: { - mnemonic: "test test test test test test test test test test test junk", + mnemonic: 'test test test test test test test test test test test junk', }, }, }, diff --git a/packages/utils-evm-hardhat/package.json b/packages/utils-evm-hardhat/package.json index 19b2869e9..0f6a163ca 100644 --- a/packages/utils-evm-hardhat/package.json +++ b/packages/utils-evm-hardhat/package.json @@ -1,61 +1,61 @@ { - "name": "@layerzerolabs/utils-evm-hardhat", - "version": "0.0.2", - "private": true, - "description": "Hardhat utilities for LayerZero EVM projects", - "repository": { - "type": "git", - "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", - "directory": "packages/utils-evm-hardhat" - }, - "license": "MIT", - "exports": { - "types": "./dist/index.d.ts", - "require": "./dist/index.js", - "import": "./dist/index.mjs" - }, - "main": "./dist/index.js", - "module": "./dist/index.mjs", + "name": "@layerzerolabs/utils-evm-hardhat", + "version": "0.0.2", + "private": true, + "description": "Hardhat utilities for LayerZero EVM projects", + "repository": { + "type": "git", + "url": "git+https://github.com/LayerZero-Labs/lz-utils.git", + "directory": "packages/utils-evm-hardhat" + }, + "license": "MIT", + "exports": { "types": "./dist/index.d.ts", - "files": [ - "./dist/index.*" - ], - "scripts": { - "prebuild": "npx tsc --noEmit -p tsconfig.build.json", - "build": "npx tsup", - "clean": "rm -rf dist", - "dev": "npx tsup --watch", - "lint": "npx eslint '**/*.{js,ts,json}'", - "test": "npx hardhat test" - }, - "dependencies": { - "micro-memoize": "~4.1.2", - "p-memoize": "~4.0.1", - "zod": "^3.22.4" - }, - "devDependencies": { - "@ethersproject/abstract-signer": "^5.7.0", - "@ethersproject/providers": "^5.7.0", - "@ethersproject/wallet": "^5.7.0", - "@layerzerolabs/lz-definitions": "~1.5.61", - "@layerzerolabs/lz-evm-sdk-v1": "~1.5.61", - "@types/chai-as-promised": "^7.1.7", - "@types/mocha": "^10.0.6", - "chai": "^4.3.10", - "chai-as-promised": "^7.1.1", - "hardhat": "^2.9.9", - "hardhat-deploy": "^0.11.22", - "sinon": "^17.0.1", - "ts-node": "^10.9.1", - "tsup": "~8.0.1", - "typescript": "^5.3.2", - "winston": "^3.11.0" - }, - "peerDependencies": { - "@ethersproject/abstract-signer": "^5.7.0", - "@ethersproject/providers": "^5.7.0", - "@layerzerolabs/lz-definitions": "~1.5.58", - "hardhat": "^2.9.9", - "hardhat-deploy": "^0.9.19" - } -} + "require": "./dist/index.js", + "import": "./dist/index.mjs" + }, + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "files": [ + "./dist/index.*" + ], + "scripts": { + "prebuild": "npx tsc --noEmit -p tsconfig.build.json", + "build": "npx tsup", + "clean": "rm -rf dist", + "dev": "npx tsup --watch", + "lint": "npx eslint '**/*.{js,ts,json}'", + "test": "npx hardhat test" + }, + "dependencies": { + "micro-memoize": "~4.1.2", + "p-memoize": "~4.0.1", + "zod": "^3.22.4" + }, + "devDependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/providers": "^5.7.0", + "@ethersproject/wallet": "^5.7.0", + "@layerzerolabs/lz-definitions": "~1.5.61", + "@layerzerolabs/lz-evm-sdk-v1": "~1.5.61", + "@types/chai-as-promised": "^7.1.7", + "@types/mocha": "^10.0.6", + "chai": "^4.3.10", + "chai-as-promised": "^7.1.1", + "hardhat": "^2.9.9", + "hardhat-deploy": "^0.11.22", + "sinon": "^17.0.1", + "ts-node": "^10.9.1", + "tsup": "~8.0.1", + "typescript": "^5.3.2", + "winston": "^3.11.0" + }, + "peerDependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/providers": "^5.7.0", + "@layerzerolabs/lz-definitions": "~1.5.58", + "hardhat": "^2.9.9", + "hardhat-deploy": "^0.9.19" + } +} \ No newline at end of file diff --git a/packages/utils-evm-hardhat/src/config.ts b/packages/utils-evm-hardhat/src/config.ts index c1c3ac468..75c3c5957 100644 --- a/packages/utils-evm-hardhat/src/config.ts +++ b/packages/utils-evm-hardhat/src/config.ts @@ -1,9 +1,9 @@ -import "hardhat-deploy/dist/src/type-extensions" +import 'hardhat-deploy/dist/src/type-extensions' -import { endpointIdToNetwork } from "@layerzerolabs/lz-definitions" -import { HardhatUserConfig } from "hardhat/types" -import { join, dirname } from "path" -import { createNetworkLogger } from "./logger" +import { endpointIdToNetwork } from '@layerzerolabs/lz-definitions' +import { HardhatUserConfig } from 'hardhat/types' +import { join, dirname } from 'path' +import { createNetworkLogger } from './logger' const resolvePackageDirectory = (packageName: string): string => { // The tricky bit here is the fact that if we resolve packages by their package name, @@ -11,7 +11,7 @@ const resolvePackageDirectory = (packageName: string): string => { // entry in package.json and point us there // // So in order to get a stable path we choose package.json, pretty solid choice - const packageJsonName = join(packageName, "package.json") + const packageJsonName = join(packageName, 'package.json') // We now resolve the path to package.json const packageJsonPath = require.resolve(packageJsonName) // And return its directory @@ -49,7 +49,7 @@ export const withLayerZeroDeployments = (...packageNames: string[]) => { // The first thing we do is we resolve the paths to LayerZero packages .map(resolvePackageDirectory) // Then navigate to the deployments folder - .map((resolvedPackagePath) => join(resolvedPackagePath, "deployments")) + .map((resolvedPackagePath) => join(resolvedPackagePath, 'deployments')) // We return a function that will enrich hardhat config with the external deployments configuration // @@ -66,7 +66,9 @@ export const withLayerZeroDeployments = (...packageNames: string[]) => { // Let's first check whether endpointId is defined on the network config if (endpointId == null) { - networkLogger.debug("Endpoint ID not specified in hardhat config, skipping external deployment configuration") + networkLogger.debug( + 'Endpoint ID not specified in hardhat config, skipping external deployment configuration' + ) return [] } @@ -74,8 +76,8 @@ export const withLayerZeroDeployments = (...packageNames: string[]) => { try { // This operation is unsafe and can throw - let's make sure we don't explode with some unreadable error const layerZeroNetworkName = endpointIdToNetwork(endpointId) - const layerZeroNetworkDeploymentsDirectories = resolvedDeploymentsDirectories.map((deploymentsDirectory) => - join(deploymentsDirectory, layerZeroNetworkName) + const layerZeroNetworkDeploymentsDirectories = resolvedDeploymentsDirectories.map( + (deploymentsDirectory) => join(deploymentsDirectory, layerZeroNetworkName) ) return [ @@ -139,7 +141,7 @@ export const withLayerZeroArtifacts = (...packageNames: string[]) => { // The first thing we do is we resolve the paths to LayerZero packages .map(resolvePackageDirectory) // Then navigate to the artifacts folder - .map((resolvedPackagePath) => join(resolvedPackagePath, "artifacts")) + .map((resolvedPackagePath) => join(resolvedPackagePath, 'artifacts')) // We return a function that will enrich hardhat config with the external artifacts configuration // @@ -149,7 +151,9 @@ export const withLayerZeroArtifacts = (...packageNames: string[]) => { const existingArtifacts = new Set(config.external?.contracts?.flatMap(({ artifacts }) => artifacts) ?? []) // And only append stuff if we have something new to say - const newArtifacts = new Set(resolvedArtifactsDirectories.filter((artifact) => !existingArtifacts.has(artifact))) + const newArtifacts = new Set( + resolvedArtifactsDirectories.filter((artifact) => !existingArtifacts.has(artifact)) + ) if (newArtifacts.size === 0) return config return { diff --git a/packages/utils-evm-hardhat/src/errors.ts b/packages/utils-evm-hardhat/src/errors.ts index 8118da574..9d61fd292 100644 --- a/packages/utils-evm-hardhat/src/errors.ts +++ b/packages/utils-evm-hardhat/src/errors.ts @@ -1,3 +1,3 @@ -"use strict" +'use strict' export class ConfigurationError extends Error {} diff --git a/packages/utils-evm-hardhat/src/index.ts b/packages/utils-evm-hardhat/src/index.ts index 1dea7cf15..eebc0b211 100644 --- a/packages/utils-evm-hardhat/src/index.ts +++ b/packages/utils-evm-hardhat/src/index.ts @@ -1,8 +1,8 @@ // Hardhat type augmentation -import "./type-extensions" +import './type-extensions' // Regular exports -export * from "./config" -export * from "./logger" -export * from "./runtime" -export * from "./types" +export * from './config' +export * from './logger' +export * from './runtime' +export * from './types' diff --git a/packages/utils-evm-hardhat/src/logger.ts b/packages/utils-evm-hardhat/src/logger.ts index 279bf03a4..dc584141e 100644 --- a/packages/utils-evm-hardhat/src/logger.ts +++ b/packages/utils-evm-hardhat/src/logger.ts @@ -1,16 +1,16 @@ -import { createLogger as createWinstonLogger, format, transports } from "winston" +import { createLogger as createWinstonLogger, format, transports } from 'winston' /** * Valid logging levels */ export enum LogLevel { - error = "error", - warn = "warn", - info = "info", - http = "http", - verbose = "verbose", - debug = "debug", - silly = "silly", + error = 'error', + warn = 'warn', + info = 'info', + http = 'http', + verbose = 'verbose', + debug = 'debug', + silly = 'silly', } /** @@ -19,7 +19,7 @@ export enum LogLevel { * @param value `unknown` * @returns `value is LogLevel` */ -const isLogLevel = (value: unknown): value is LogLevel => typeof value === "string" && value in LogLevel +const isLogLevel = (value: unknown): value is LogLevel => typeof value === 'string' && value in LogLevel let DEFAULT_LOG_LEVEL = LogLevel.info @@ -30,7 +30,9 @@ let DEFAULT_LOG_LEVEL = LogLevel.info */ export const setDefaultLogLevel = (level: string) => { if (!isLogLevel(level)) { - console.warn(`Invalid log level specified: ${level}. Ignoring and keeping the current value of ${DEFAULT_LOG_LEVEL}`) + console.warn( + `Invalid log level specified: ${level}. Ignoring and keeping the current value of ${DEFAULT_LOG_LEVEL}` + ) return } @@ -81,8 +83,15 @@ export const createNetworkLogger = (networkName: string, level: string = DEFAULT * * @returns `Logger` */ -export const createNetworkToNetworkLogger = (sourceNetworkName: string, destinationNetworkName: string, level: string = DEFAULT_LOG_LEVEL) => - createLogger(level, format.combine(prefix({ label: `${sourceNetworkName} ➝ ${destinationNetworkName}` }), format.cli())) +export const createNetworkToNetworkLogger = ( + sourceNetworkName: string, + destinationNetworkName: string, + level: string = DEFAULT_LOG_LEVEL +) => + createLogger( + level, + format.combine(prefix({ label: `${sourceNetworkName} ➝ ${destinationNetworkName}` }), format.cli()) + ) /** * Helper utility that prefixes logged messages @@ -94,5 +103,5 @@ export const createNetworkToNetworkLogger = (sourceNetworkName: string, destinat */ const prefix = format((info, { label }) => ({ ...info, - message: `${label ? `[${label}] ` : ""}${info.message}`, + message: `${label ? `[${label}] ` : ''}${info.message}`, })) diff --git a/packages/utils-evm-hardhat/src/runtime.ts b/packages/utils-evm-hardhat/src/runtime.ts index e6534048f..030638636 100644 --- a/packages/utils-evm-hardhat/src/runtime.ts +++ b/packages/utils-evm-hardhat/src/runtime.ts @@ -1,10 +1,10 @@ -import type { HardhatRuntimeEnvironment, EIP1193Provider } from "hardhat/types" +import type { HardhatRuntimeEnvironment, EIP1193Provider } from 'hardhat/types' -import pMemoize from "p-memoize" -import { Web3Provider } from "@ethersproject/providers" -import { ConfigurationError } from "./errors" -import { HardhatContext } from "hardhat/internal/context" -import { Environment as HardhatRuntimeEnvironmentImplementation } from "hardhat/internal/core/runtime-environment" +import pMemoize from 'p-memoize' +import { Web3Provider } from '@ethersproject/providers' +import { ConfigurationError } from './errors' +import { HardhatContext } from 'hardhat/internal/context' +import { Environment as HardhatRuntimeEnvironmentImplementation } from 'hardhat/internal/core/runtime-environment' /** * Helper type for when we need to grab something asynchronously by the network name diff --git a/packages/utils-evm-hardhat/src/type-extensions.ts b/packages/utils-evm-hardhat/src/type-extensions.ts index 125dbb9d8..d49514861 100644 --- a/packages/utils-evm-hardhat/src/type-extensions.ts +++ b/packages/utils-evm-hardhat/src/type-extensions.ts @@ -1,6 +1,6 @@ -import { EndpointId } from "@layerzerolabs/lz-definitions" +import { EndpointId } from '@layerzerolabs/lz-definitions' -declare module "hardhat/types/config" { +declare module 'hardhat/types/config' { interface HardhatNetworkUserConfig { endpointId?: never } diff --git a/packages/utils-evm-hardhat/src/types.ts b/packages/utils-evm-hardhat/src/types.ts index b198c0409..9d8cfa58f 100644 --- a/packages/utils-evm-hardhat/src/types.ts +++ b/packages/utils-evm-hardhat/src/types.ts @@ -1,8 +1,8 @@ -import { Chain, ChainType, Stage, getChainType } from "@layerzerolabs/lz-definitions" -import { HardhatError } from "hardhat/internal/core/errors" -import { ERRORS } from "hardhat/internal/core/errors-list" -import { CLIArgumentType } from "hardhat/types" -import { z } from "zod" +import { Chain, ChainType, Stage, getChainType } from '@layerzerolabs/lz-definitions' +import { HardhatError } from 'hardhat/internal/core/errors' +import { ERRORS } from 'hardhat/internal/core/errors-list' +import { CLIArgumentType } from 'hardhat/types' +import { z } from 'zod' const StageSchema = z.nativeEnum(Stage).default(Stage.TESTNET) @@ -32,14 +32,14 @@ const ChainListSchema = CommaSeparatedValuesSchema.pipe(z.array(ChainSchema)) * Hardhat CLI type for Chain (e.g. avalanche, bsc, base) */ const chains: CLIArgumentType = { - name: "chains", + name: 'chains', parse(name: string, value: string) { const result = ChainListSchema.safeParse(value) if (!result.success) { throw new HardhatError(ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE, { value, name: name, - type: "chains", + type: 'chains', }) } @@ -52,14 +52,14 @@ const chains: CLIArgumentType = { * Hardhat CLI type for Stage (mainnet/testnet/sandbox) */ const stage: CLIArgumentType = { - name: "stage", + name: 'stage', parse(name: string, value: string) { const result = StageSchema.safeParse(value) if (!result.success) { throw new HardhatError(ERRORS.ARGUMENTS.INVALID_VALUE_FOR_TYPE, { value, name: name, - type: "stage", + type: 'stage', }) } diff --git a/packages/utils-evm-hardhat/test/config.test.ts b/packages/utils-evm-hardhat/test/config.test.ts index 06a5f6239..de464a118 100644 --- a/packages/utils-evm-hardhat/test/config.test.ts +++ b/packages/utils-evm-hardhat/test/config.test.ts @@ -1,33 +1,35 @@ -import { EndpointId } from "@layerzerolabs/lz-definitions" -import { expect } from "chai" -import { describe } from "mocha" -import { withLayerZeroArtifacts, withLayerZeroDeployments } from "../src/config" -import { dirname, join } from "path" - -describe("config", () => { - describe("withLayerZeroDeployments()", () => { - const resolvedLzEvmSdkPackageJson = dirname(require.resolve(join("@layerzerolabs/lz-evm-sdk-v1", "package.json"))) - - it("should add no external deployments if no networks have been specified", () => { +import { EndpointId } from '@layerzerolabs/lz-definitions' +import { expect } from 'chai' +import { describe } from 'mocha' +import { withLayerZeroArtifacts, withLayerZeroDeployments } from '../src/config' +import { dirname, join } from 'path' + +describe('config', () => { + describe('withLayerZeroDeployments()', () => { + const resolvedLzEvmSdkPackageJson = dirname( + require.resolve(join('@layerzerolabs/lz-evm-sdk-v1', 'package.json')) + ) + + it('should add no external deployments if no networks have been specified', () => { const config = {} - expect(withLayerZeroDeployments("@layerzerolabs/lz-evm-sdk-v1")(config)).to.eql({ + expect(withLayerZeroDeployments('@layerzerolabs/lz-evm-sdk-v1')(config)).to.eql({ external: { deployments: {}, }, }) }) - it("should not add external deployments for networks without endpointId", () => { + it('should not add external deployments for networks without endpointId', () => { const config = { networks: { - "vengaboys-testnet": {}, + 'vengaboys-testnet': {}, }, } - expect(withLayerZeroDeployments("@layerzerolabs/lz-evm-sdk-v1")(config)).to.eql({ + expect(withLayerZeroDeployments('@layerzerolabs/lz-evm-sdk-v1')(config)).to.eql({ networks: { - "vengaboys-testnet": {}, + 'vengaboys-testnet': {}, }, external: { deployments: {}, @@ -35,18 +37,18 @@ describe("config", () => { }) }) - it("should not add external deployments for networks with invalid endpointId", () => { + it('should not add external deployments for networks with invalid endpointId', () => { const config = { networks: { - "vengaboys-testnet": { + 'vengaboys-testnet': { endpointId: 0, }, }, } - expect(withLayerZeroDeployments("@layerzerolabs/lz-evm-sdk-v1")(config)).to.eql({ + expect(withLayerZeroDeployments('@layerzerolabs/lz-evm-sdk-v1')(config)).to.eql({ networks: { - "vengaboys-testnet": { + 'vengaboys-testnet': { endpointId: 0, }, }, @@ -56,65 +58,70 @@ describe("config", () => { }) }) - it("should append external deployments for all networks", () => { + it('should append external deployments for all networks', () => { const config = { networks: { - "vengaboys-testnet": { + 'vengaboys-testnet': { endpointId: EndpointId.ARBITRUM_MAINNET, }, }, } - expect(withLayerZeroDeployments("@layerzerolabs/lz-evm-sdk-v1")(config)).to.eql({ + expect(withLayerZeroDeployments('@layerzerolabs/lz-evm-sdk-v1')(config)).to.eql({ networks: { - "vengaboys-testnet": { + 'vengaboys-testnet': { endpointId: EndpointId.ARBITRUM_MAINNET, }, }, external: { deployments: { - "vengaboys-testnet": [join(resolvedLzEvmSdkPackageJson, "deployments", "arbitrum-mainnet")], + 'vengaboys-testnet': [join(resolvedLzEvmSdkPackageJson, 'deployments', 'arbitrum-mainnet')], }, }, }) }) - it("should not append duplicate external deployments for all networks", () => { + it('should not append duplicate external deployments for all networks', () => { const config = { networks: { - "vengaboys-testnet": { + 'vengaboys-testnet': { endpointId: EndpointId.BSC_TESTNET, }, }, } - const configWithSomePath = withLayerZeroDeployments("@layerzerolabs/lz-evm-sdk-v1", "@layerzerolabs/lz-evm-sdk-v1")(config) - const configWithSomePathAgain = withLayerZeroDeployments("@layerzerolabs/lz-evm-sdk-v1")(configWithSomePath) + const configWithSomePath = withLayerZeroDeployments( + '@layerzerolabs/lz-evm-sdk-v1', + '@layerzerolabs/lz-evm-sdk-v1' + )(config) + const configWithSomePathAgain = withLayerZeroDeployments('@layerzerolabs/lz-evm-sdk-v1')(configWithSomePath) expect(configWithSomePathAgain).to.eql({ networks: { - "vengaboys-testnet": { + 'vengaboys-testnet': { endpointId: EndpointId.BSC_TESTNET, }, }, external: { deployments: { - "vengaboys-testnet": [join(resolvedLzEvmSdkPackageJson, "deployments", "bsc-testnet")], + 'vengaboys-testnet': [join(resolvedLzEvmSdkPackageJson, 'deployments', 'bsc-testnet')], }, }, }) }) }) - describe("withLayerZeroArtifacts()", () => { - const resolvedLzEvmSdkPackageJson = dirname(require.resolve(join("@layerzerolabs/lz-evm-sdk-v1", "package.json"))) + describe('withLayerZeroArtifacts()', () => { + const resolvedLzEvmSdkPackageJson = dirname( + require.resolve(join('@layerzerolabs/lz-evm-sdk-v1', 'package.json')) + ) - it("should append external artifacts", () => { + it('should append external artifacts', () => { const config = { networks: {}, } - expect(withLayerZeroArtifacts("@layerzerolabs/lz-evm-sdk-v1")(config)).to.eql({ + expect(withLayerZeroArtifacts('@layerzerolabs/lz-evm-sdk-v1')(config)).to.eql({ networks: {}, external: { contracts: [ @@ -126,33 +133,36 @@ describe("config", () => { }) }) - it("should not append duplicate external artifacts", () => { + it('should not append duplicate external artifacts', () => { const config = { external: { contracts: [ { - artifacts: "./my/external/artifact", + artifacts: './my/external/artifact', }, { - artifacts: ["./my/other/external/artifact"], + artifacts: ['./my/other/external/artifact'], }, ], }, networks: {}, } - const configWithSomePath = withLayerZeroArtifacts("@layerzerolabs/lz-evm-sdk-v1", "@layerzerolabs/lz-evm-sdk-v1")(config) - const configWithSomePathAgain = withLayerZeroArtifacts("@layerzerolabs/lz-evm-sdk-v1")(configWithSomePath) + const configWithSomePath = withLayerZeroArtifacts( + '@layerzerolabs/lz-evm-sdk-v1', + '@layerzerolabs/lz-evm-sdk-v1' + )(config) + const configWithSomePathAgain = withLayerZeroArtifacts('@layerzerolabs/lz-evm-sdk-v1')(configWithSomePath) expect(configWithSomePathAgain).to.eql({ networks: {}, external: { contracts: [ { - artifacts: "./my/external/artifact", + artifacts: './my/external/artifact', }, { - artifacts: ["./my/other/external/artifact"], + artifacts: ['./my/other/external/artifact'], }, { artifacts: [`${resolvedLzEvmSdkPackageJson}/artifacts`], diff --git a/packages/utils-evm-hardhat/test/runtime.test.ts b/packages/utils-evm-hardhat/test/runtime.test.ts index 262b5ef0a..6de8cb105 100644 --- a/packages/utils-evm-hardhat/test/runtime.test.ts +++ b/packages/utils-evm-hardhat/test/runtime.test.ts @@ -1,49 +1,49 @@ -import chai from "chai" -import chaiAsPromised from "chai-as-promised" -import { expect } from "chai" -import { getNetworkRuntimeEnvironment } from "../src/runtime" -import { DeploymentSubmission } from "hardhat-deploy/dist/types" +import chai from 'chai' +import chaiAsPromised from 'chai-as-promised' +import { expect } from 'chai' +import { getNetworkRuntimeEnvironment } from '../src/runtime' +import { DeploymentSubmission } from 'hardhat-deploy/dist/types' chai.use(chaiAsPromised) -describe("runtime", () => { - describe("getNetworkRuntimeEnvironment", () => { - it("should reject with an invalid network", async () => { - await expect(getNetworkRuntimeEnvironment("not-in-hardhat-config")).to.eventually.be.rejected +describe('runtime', () => { + describe('getNetworkRuntimeEnvironment', () => { + it('should reject with an invalid network', async () => { + await expect(getNetworkRuntimeEnvironment('not-in-hardhat-config')).to.eventually.be.rejected }) - it("should return a HardhatRuntimeEnvironment with correct network", async () => { - const runtime = await getNetworkRuntimeEnvironment("ethereum-mainnet") + it('should return a HardhatRuntimeEnvironment with correct network', async () => { + const runtime = await getNetworkRuntimeEnvironment('ethereum-mainnet') - expect(runtime.network.name).to.eql("ethereum-mainnet") - expect(runtime.deployments).to.be.an("object") + expect(runtime.network.name).to.eql('ethereum-mainnet') + expect(runtime.deployments).to.be.an('object') }) - it("should have the config setup correctly", async () => { - const ethRuntime = await getNetworkRuntimeEnvironment("ethereum-mainnet") - const bscRuntime = await getNetworkRuntimeEnvironment("bsc-testnet") + it('should have the config setup correctly', async () => { + const ethRuntime = await getNetworkRuntimeEnvironment('ethereum-mainnet') + const bscRuntime = await getNetworkRuntimeEnvironment('bsc-testnet') expect(ethRuntime.network.config.saveDeployments).to.be.true expect(bscRuntime.network.config.saveDeployments).to.be.undefined }) - it("should save the deployment to correct network", async () => { - const bscRuntime = await getNetworkRuntimeEnvironment("bsc-testnet") - const ethRuntime = await getNetworkRuntimeEnvironment("ethereum-mainnet") + it('should save the deployment to correct network', async () => { + const bscRuntime = await getNetworkRuntimeEnvironment('bsc-testnet') + const ethRuntime = await getNetworkRuntimeEnvironment('ethereum-mainnet') const now = Date.now() const deploymentSubmission = { - args: ["bsc-testnet", now], + args: ['bsc-testnet', now], } as DeploymentSubmission // First we want to save the deployment for bsc-testnet - await bscRuntime.deployments.save("Mock", deploymentSubmission) + await bscRuntime.deployments.save('Mock', deploymentSubmission) // Then we check whether it has been saved - const deployment = await bscRuntime.deployments.get("Mock") + const deployment = await bscRuntime.deployments.get('Mock') expect(deployment.args).to.eql(deploymentSubmission.args) // And finally we check whether it was not by accident saved for ethereum-mainnet - const nonExistentDeployment = await ethRuntime.deployments.getOrNull("Mock") + const nonExistentDeployment = await ethRuntime.deployments.getOrNull('Mock') expect(nonExistentDeployment?.args).not.to.eql(deploymentSubmission.args) }) }) diff --git a/packages/utils-evm-hardhat/tsconfig.build.json b/packages/utils-evm-hardhat/tsconfig.build.json index 1e8f7493d..0507620e8 100644 --- a/packages/utils-evm-hardhat/tsconfig.build.json +++ b/packages/utils-evm-hardhat/tsconfig.build.json @@ -1,4 +1,4 @@ { - "extends": "./tsconfig.json", - "exclude": ["node_modules", "dist", "test"] + "extends": "./tsconfig.json", + "exclude": ["node_modules", "dist", "test"] } diff --git a/packages/utils-evm-hardhat/tsconfig.json b/packages/utils-evm-hardhat/tsconfig.json index 084db5958..1e471dfdd 100644 --- a/packages/utils-evm-hardhat/tsconfig.json +++ b/packages/utils-evm-hardhat/tsconfig.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", - "exclude": ["dist", "node_modules"], - "include": ["src", "test", "*.config.ts"], - "compilerOptions": { - "module": "commonjs", - "types": ["node", "mocha"] - } + "extends": "../../tsconfig.json", + "exclude": ["dist", "node_modules"], + "include": ["src", "test", "*.config.ts"], + "compilerOptions": { + "module": "commonjs", + "types": ["node", "mocha"] + } } diff --git a/packages/utils-evm-hardhat/tsup.config.ts b/packages/utils-evm-hardhat/tsup.config.ts index 16d909226..b0e373950 100644 --- a/packages/utils-evm-hardhat/tsup.config.ts +++ b/packages/utils-evm-hardhat/tsup.config.ts @@ -1,12 +1,12 @@ -import { defineConfig } from "tsup" +import { defineConfig } from 'tsup' export default defineConfig({ - entry: ["src/index.ts"], - outDir: "./dist", + entry: ['src/index.ts'], + outDir: './dist', clean: true, dts: true, sourcemap: true, splitting: false, treeshake: true, - format: ["esm", "cjs"], + format: ['esm', 'cjs'], }) diff --git a/tsconfig.json b/tsconfig.json index 30aae84ab..c5144f6db 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,29 +1,29 @@ { - "compilerOptions": { - "target": "es2018", - "module": "esnext", - "lib": ["es2021", "dom"], - "importHelpers": true, - "noEmit": true, - "declaration": true, - "sourceMap": true, - "strict": true, - "noImplicitAny": false, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictPropertyInitialization": true, - "noImplicitThis": true, - "alwaysStrict": true, - "noUnusedLocals": false, - "noUnusedParameters": false, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "moduleResolution": "node", - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "allowJs": true, - "resolveJsonModule": true, - "types": ["node"], - "skipLibCheck": true - } + "compilerOptions": { + "target": "es2018", + "module": "esnext", + "lib": ["es2021", "dom"], + "importHelpers": true, + "noEmit": true, + "declaration": true, + "sourceMap": true, + "strict": true, + "noImplicitAny": false, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strictPropertyInitialization": true, + "noImplicitThis": true, + "alwaysStrict": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "moduleResolution": "node", + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "allowJs": true, + "resolveJsonModule": true, + "types": ["node"], + "skipLibCheck": true + } } diff --git a/turbo.json b/turbo.json index 1e93ae11c..69101a56b 100644 --- a/turbo.json +++ b/turbo.json @@ -1,30 +1,30 @@ { - "$schema": "https://turbo.build/schema.json", - "pipeline": { - "compile": { - "outputs": ["artifacts/**", "cache/**"], - "dependsOn": ["^build"] - }, - "build": { - "outputs": ["dist/**"], - "dependsOn": ["compile", "^build"] - }, - "clean": { - "outputs": [], - "cache": false - }, - "dev": { - "cache": false, - "outputs": [], - "persistent": true - }, - "lint": { - "cache": false - }, - "test": { - "outputs": [], - "dependsOn": ["^build"] - } + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "compile": { + "outputs": ["artifacts/**", "cache/**"], + "dependsOn": ["^build"] }, - "globalDependencies": ["tsconfig.json"] + "build": { + "outputs": ["dist/**"], + "dependsOn": ["compile", "^build"] + }, + "clean": { + "outputs": [], + "cache": false + }, + "dev": { + "cache": false, + "outputs": [], + "persistent": true + }, + "lint": { + "cache": false + }, + "test": { + "outputs": [], + "dependsOn": ["^build"] + } + }, + "globalDependencies": ["tsconfig.json"] }