From 3ccd4eb97085a2f7c0fd4a1a6dfc7db3ec8aca95 Mon Sep 17 00:00:00 2001 From: dule-git <61541725+dule-git@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:03:20 +0200 Subject: [PATCH] Propagate hardhat-tenderly version through env (#214) * initional hardhat-ignition example * added hardhat-tenderly to ignition project * propagate hardhat-tenderly version through env * changeset version --- .changeset/eighty-otters-bow.md | 7 +++++++ packages/hre-extender-v1/src/setup.ts | 5 +++-- packages/hre-extender-v2/src/setup.ts | 5 +++-- packages/tenderly-core/package.json | 2 +- .../src/internal/core/services/TenderlyApiService.ts | 8 ++++++-- .../internal/core/services/hardhat-tenderly-version.ts | 2 -- packages/tenderly-core/version-generator.js | 9 --------- 7 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 .changeset/eighty-otters-bow.md delete mode 100644 packages/tenderly-core/src/internal/core/services/hardhat-tenderly-version.ts delete mode 100644 packages/tenderly-core/version-generator.js diff --git a/.changeset/eighty-otters-bow.md b/.changeset/eighty-otters-bow.md new file mode 100644 index 00000000..39def38f --- /dev/null +++ b/.changeset/eighty-otters-bow.md @@ -0,0 +1,7 @@ +--- +"@tenderly/hardhat-tenderly": patch +"@tenderly/api-client": patch +"@tenderly/hardhat-integration": patch +--- + +Restructured internal packages diff --git a/packages/hre-extender-v1/src/setup.ts b/packages/hre-extender-v1/src/setup.ts index 6c736941..a2571461 100644 --- a/packages/hre-extender-v1/src/setup.ts +++ b/packages/hre-extender-v1/src/setup.ts @@ -24,8 +24,9 @@ const tenderlyService = new TenderlyService(PLUGIN_NAME); export function setup(cfg: { automaticVerifications: boolean } = { automaticVerifications: true }) { extendEnvironment(async (hre: HardhatRuntimeEnvironment) => { - process.env.TENDERLY_AUTOMATIC_VERIFICATION = cfg.automaticVerifications - process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications + process.env.TENDERLY_AUTOMATIC_VERIFICATION = cfg.automaticVerifications ? "true": "false" + process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications ? "true": "false" + process.env.HARDHAT_TENDERLY_VERSION = require("../package.json").version; hre.tenderly = lazyObject(() => new Tenderly(hre)); diff --git a/packages/hre-extender-v2/src/setup.ts b/packages/hre-extender-v2/src/setup.ts index 92572c8f..f58dcf11 100644 --- a/packages/hre-extender-v2/src/setup.ts +++ b/packages/hre-extender-v2/src/setup.ts @@ -31,8 +31,9 @@ const tenderlyService = new TenderlyService(PLUGIN_NAME); export function setup(cfg: { automaticVerifications: boolean } = { automaticVerifications: true }) { extendEnvironment(async (hre: HardhatRuntimeEnvironment) => { - process.env.TENDERLY_AUTOMATIC_VERIFICATION = cfg.automaticVerifications - process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications + process.env.TENDERLY_AUTOMATIC_VERIFICATION = cfg.automaticVerifications ? "true": "false" + process.env.AUTOMATIC_VERIFICATION_ENABLED = cfg.automaticVerifications ? "true": "false" + process.env.HARDHAT_TENDERLY_VERSION = require("../package.json").version; hre.tenderly = lazyObject(() => new Tenderly(hre)); diff --git a/packages/tenderly-core/package.json b/packages/tenderly-core/package.json index 940e071a..13697752 100644 --- a/packages/tenderly-core/package.json +++ b/packages/tenderly-core/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/Tenderly/hardhat-tenderly.git" }, "scripts": { - "build": "rm -rf build-test && rm -f tsconfig.tsbuildinfo && node version-generator.js && tsc --build .", + "build": "rm -rf build-test && rm -f tsconfig.tsbuildinfo && tsc --build .", "clean": "rm -rf node_modules && rm -rf build-test && rm -rf common && rm -rf internal && rm -rf types && rm -rf utils && rm -f tsconfig.tsbuildinfo", "lint": "yarn run prettier --check && yarn run eslint", "lint:fix": "yarn run prettier --write && yarn run eslint --fix", diff --git a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts index 7ae99633..0c4103d3 100644 --- a/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts +++ b/packages/tenderly-core/src/internal/core/services/TenderlyApiService.ts @@ -6,7 +6,7 @@ import { TENDERLY_API_BASE_URL, TENDERLY_JSON_RPC_BASE_URL, } from "../../../common/constants"; -import { HARDHAT_TENDERLY_VERSION } from "./hardhat-tenderly-version"; +import * as dotenv from "dotenv"; export class TenderlyApiService { public static configureInstance( @@ -21,11 +21,15 @@ export class TenderlyApiService { const tdlyConfig = getConfig(); accessKey = tdlyConfig.access_key; } + + dotenv.config(); + const hardhatTenderlyVersion = process.env.HARDHAT_TENDERLY_VERSION; + const params = { baseURL: TENDERLY_API_BASE_URL, headers: { "x-access-key": accessKey, - "x-user-agent": `@tenderly/hardhat-tenderly/${HARDHAT_TENDERLY_VERSION}`, + "x-user-agent": `@tenderly/hardhat-tenderly/${hardhatTenderlyVersion}`, }, }; diff --git a/packages/tenderly-core/src/internal/core/services/hardhat-tenderly-version.ts b/packages/tenderly-core/src/internal/core/services/hardhat-tenderly-version.ts deleted file mode 100644 index db2ebdca..00000000 --- a/packages/tenderly-core/src/internal/core/services/hardhat-tenderly-version.ts +++ /dev/null @@ -1,2 +0,0 @@ -// autogenerated by version-generator.js -export const HARDHAT_TENDERLY_VERSION = "1.0.0"; \ No newline at end of file diff --git a/packages/tenderly-core/version-generator.js b/packages/tenderly-core/version-generator.js deleted file mode 100644 index 7db54821..00000000 --- a/packages/tenderly-core/version-generator.js +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); -const { version } = require('./../tenderly-hardhat/package.json'); - -fs.writeFileSync( - path.resolve(__dirname, 'src/internal/core/services/hardhat-tenderly-version.ts'), - `// autogenerated by version-generator.js\nexport const HARDHAT_TENDERLY_VERSION = "${version}";`, -);