Skip to content

Commit

Permalink
chore: Move tasks under tasks directory; Update exports; Fix last ins…
Browse files Browse the repository at this point in the history
…tances of require
  • Loading branch information
janjakubnanista authored and TRileySchwarz committed Nov 15, 2023
1 parent 5e4055a commit d5d84dc
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
12 changes: 12 additions & 0 deletions packages/ua-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.mjs",
"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"
}
},
"scripts": {
"build": "npx tsup",
"clean": "rm -rf dist",
Expand Down
6 changes: 3 additions & 3 deletions packages/ua-utils/src/tasks/checkWireAllConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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(",")
Expand Down
6 changes: 3 additions & 3 deletions packages/ua-utils/src/tasks/getConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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
Expand Down
4 changes: 2 additions & 2 deletions packages/ua-utils/src/tasks/getDefaultConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ethers } from "ethers"
import { getProvider, getLayerZeroChainId, getEndpointAddress } from "../utils/crossChainHelper"
const { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI } = require("./constants/abi")
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(",")
Expand Down
6 changes: 3 additions & 3 deletions packages/ua-utils/src/tasks/setConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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,
Expand All @@ -10,8 +10,8 @@ import {
getApplicationConfig,
getEndpointAddress,
getLayerZeroChainId,
} from "../utils/crossChainHelper"
import { ENDPOINT_ABI, MESSAGING_LIBRARY_ABI, USER_APPLICATION_ABI } from "../constants/abi"
} 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
Expand Down
6 changes: 3 additions & 3 deletions packages/ua-utils/src/tasks/wireAll.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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)) {
Expand Down
10 changes: 5 additions & 5 deletions packages/ua-utils/src/utils/crossChainHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ 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 { 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"
const path = require("path")
const fs = require("fs")
import path from "path"
import fs from "fs"
import { writeFile } from "fs/promises"

export interface ExecutableTransaction {
Expand Down Expand Up @@ -300,7 +300,7 @@ export const getDeploymentAddresses = (network: string, throwIfMissing: boolean
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))
const data = JSON.parse(fs.readFileSync(filepath, "utf8"))
const contractName = file.split(".")[0]
deploymentAddresses[contractName] = data.address
})
Expand Down
4 changes: 2 additions & 2 deletions packages/ua-utils/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { defineConfig } from "tsup"

export default defineConfig({
entry: ["src/index.ts"],
outDir: "./dist",
entry: ["src/tasks/index.ts"],
outDir: "./dist/tasks",
clean: true,
dts: true,
sourcemap: true,
Expand Down

0 comments on commit d5d84dc

Please sign in to comment.