diff --git a/bun.lockb b/bun.lockb index ae25295b..5f516548 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index b91873a4..72476495 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "README.md" ], "scripts": { - "fetch:deployment": "bun run ./scripts/fetch:deployment.ts && bun run lint --apply-unsafe", "format": "biome format . --write", "lint": "biome check .", "lint:fix": "bun run lint --apply", @@ -74,7 +73,9 @@ "cjs:watch:aliases": "tsc-alias -p ./tsconfig/tsconfig.cjs.json --watch", "build:cjs": "tsc --project ./tsconfig/tsconfig.cjs.json && tsc-alias -p ./tsconfig/tsconfig.cjs.json && echo > ./dist/_cjs/package.json '{\"type\":\"commonjs\"}'", "build:esm": "tsc --project ./tsconfig/tsconfig.esm.json && tsc-alias -p ./tsconfig/tsconfig.esm.json && echo > ./dist/_esm/package.json '{\"type\": \"module\",\"sideEffects\":false}'", - "build:types": "tsc --project ./tsconfig/tsconfig.types.json && tsc-alias -p ./tsconfig/tsconfig.types.json" + "build:types": "tsc --project ./tsconfig/tsconfig.types.json && tsc-alias -p ./tsconfig/tsconfig.types.json", + "fetch:deployment": "bun run ./scripts/fetch:deployment.ts && bun run lint --apply-unsafe", + "fetch:deployment:raw": "bun run ./scripts/fetch:deployment.ts" }, "devDependencies": { "@biomejs/biome": "1.6.0", @@ -88,6 +89,7 @@ "@size-limit/esbuild-why": "^11", "@size-limit/preset-small-lib": "^11", "@types/bun": "latest", + "@types/yargs": "^17.0.33", "@vitest/coverage-v8": "^1.3.1", "buffer": "^6.0.3", "concurrently": "^8.2.2", @@ -105,7 +107,8 @@ "tsc-alias": "^1.8.8", "tslib": "^2.6.3", "typedoc": "^0.25.9", - "vitest": "^1.3.1" + "vitest": "^1.3.1", + "yargs": "^17.7.2" }, "peerDependencies": { "typescript": "^5", diff --git a/scripts/fetch:deployment.ts b/scripts/fetch:deployment.ts index 009200c0..9c6c5213 100644 --- a/scripts/fetch:deployment.ts +++ b/scripts/fetch:deployment.ts @@ -1,17 +1,26 @@ import fs from "node:fs" -import { STARTING_PORT } from "../tests/src/testUtils" -const pathToDeployment = "../node_modules/nexus/deployments" // "../../nexus/deployments" also potentially useful -const deploymentChainName = `anvil-${STARTING_PORT}` -const abisInSrc = ["K1ValidatorFactory", "Nexus", "K1Validator"] +import { hideBin } from "yargs/helpers" +import yargs from "yargs/yargs" -const relativePath = `${__dirname}/${pathToDeployment}/${deploymentChainName}` +type FetchDetails = { + nexusDeploymentPath: string + chainName: string + forSrc: string[] +} +const { + nexusDeploymentPath = "../node_modules/nexus/deployments", + chainName = "anvil-55000", + forSrc = ["K1ValidatorFactory", "Nexus", "K1Validator"] +} = yargs(hideBin(process.argv)).argv as unknown as FetchDetails type DeployedContract = { address: string } export const getDeployments = async () => { + const relativePath = `${__dirname}/${nexusDeploymentPath}/${chainName}` + console.log("Fetching deployments from:", relativePath) const files = fs.readdirSync(relativePath) const deployedContracts: Record = {} @@ -28,7 +37,7 @@ export const getDeployments = async () => { ) const { address, abi } = JSON.parse(contents) - const isForCore = abisInSrc.includes(name) + const isForCore = forSrc.includes(name) if (isForCore) { coreFiles.push(name) } else { diff --git a/src/__contracts/addresses.ts b/src/__contracts/addresses.ts index de6a5599..8950437c 100644 --- a/src/__contracts/addresses.ts +++ b/src/__contracts/addresses.ts @@ -1,3 +1,5 @@ +// The contents of this folder is auto-generated. Please do not edit as your changes are likely to be overwritten + import type { Hex } from "viem" export const addresses: Record = { Nexus: "0x776d63154D2aa9256D72C420416c930F3B735464", diff --git a/tests/src/README.md b/tests/src/README.md index 5122bf7c..40d4981f 100644 --- a/tests/src/README.md +++ b/tests/src/README.md @@ -17,6 +17,17 @@ The script performs the following: - **Addresses**: Moved to `./src/addresses.ts` - **Additional Fixtures**: Copied to `tests__/contracts` +The script accepts a number of args from the command line: + - nexusDeploymentPath (default: "../node_modules/nexus/deployments") + - chainName (default: "anvil-55000") + - forSrc (default: ["K1ValidatorFactory", "Nexus", "K1Validator"]); + +Example usage: +```bash +bun run fetch:deployment:raw --chainName="anvil-52878" -forSrc=K1Validator -forSrc=Nexus --nexusDeploymentPath=../../nexus/deployments +bun run lint --apply-unsafe +``` + > **Note**: > - Do not edit these files manually; they will be overridden if/when a new Nexus deployment occurs. > - Avoid hardcoding important addresses (e.g., `const K1_VALIDATOR_ADDRESS = "0x"`). Use `./src/addresses.ts` instead. diff --git a/tests/src/__contracts/mockAddresses.ts b/tests/src/__contracts/mockAddresses.ts index 48c56377..64cc26a3 100644 --- a/tests/src/__contracts/mockAddresses.ts +++ b/tests/src/__contracts/mockAddresses.ts @@ -1,3 +1,5 @@ +// The contents of this folder is auto-generated. Please do not edit as your changes are likely to be overwritten + import type { Hex } from "viem" export const mockAddresses: Record = { MockHook: "0xAB9733982E5b98bdDc4f00314E8EA4911A9D1BA5", diff --git a/tests/src/testUtils.ts b/tests/src/testUtils.ts index 5913a7d8..140bc473 100644 --- a/tests/src/testUtils.ts +++ b/tests/src/testUtils.ts @@ -211,7 +211,6 @@ export const toConfiguredAnvil = async ({ return instance } -export const STARTING_PORT = 55000 const portOptions = { exclude: [] as number[] } export const initAnvilPayload = async (): Promise => { const rpcPort = await getPort(portOptions)