Skip to content

Commit 485ab78

Browse files
added option to change deploymentsDir, always persistingArtifacts and conformed errors messages
1 parent db1e743 commit 485ab78

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

src/Tenderly.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import * as fs from "fs-extra";
2+
import { HardhatPluginError } from "hardhat/plugins";
23
import { HardhatRuntimeEnvironment } from "hardhat/types";
34
import { sep } from "path";
45

56
import { DefaultChainId, NetworkMap, PluginName } from "./index";
7+
import { CONTRACTS_NOT_DETECTED } from "./tenderly/errors";
68
import { TenderlyService } from "./tenderly/TenderlyService";
79
import {
810
ContractByName,
@@ -17,8 +19,6 @@ import {
1719
getContracts,
1820
resolveDependencies
1921
} from "./util";
20-
import {CONTRACTS_NOT_DETECTED} from "./tenderly/errors";
21-
import {HardhatPluginError} from "hardhat/plugins";
2222

2323
export class Tenderly {
2424
public env: HardhatRuntimeEnvironment;
@@ -184,7 +184,9 @@ export class Tenderly {
184184
if (chainID === undefined) {
185185
chainID = DefaultChainId;
186186
}
187-
const destPath = `deployments${sep}${network!.toLowerCase()}_${chainID}${sep}`;
187+
const deploymentsFolder =
188+
this.env.config?.tenderly?.deploymentsDir || "deployments";
189+
const destPath = `${deploymentsFolder}${sep}${network!.toLowerCase()}_${chainID}${sep}`;
188190
const contractDataPath = `${this.env.config.paths.artifacts}${sep}${sourcePath}${sep}${name}.json`;
189191
const contractData = JSON.parse(
190192
fs.readFileSync(contractDataPath).toString()

src/tenderly/TenderlyService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class TenderlyService {
141141
return;
142142
}
143143

144-
if (responseData.contracts.length) {
144+
if (!responseData.contracts?.length) {
145145
console.log(NO_NEW_CONTRACTS_VERIFIED_ERROR);
146146
return;
147147
}

src/tenderly/errors.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { PluginName } from "../index";
1+
const Plugin = "hardhat-tenderly";
22

3-
export const BYTECODE_MISMATCH_ERROR = `Error in ${PluginName}: Contract verification failed, bytecode mismatch detected. This can occur if compiler details or source is different compared to the deployed contract.`;
4-
export const NO_VERIFIABLE_CONTRACTS_ERROR = `${PluginName}: Contracts are not eligible for verification.`;
5-
export const NO_NEW_CONTRACTS_VERIFIED_ERROR = `${PluginName}: No new contracts have been verified.`;
6-
export const API_REQUEST_ERROR = `Error in ${PluginName}: Verification failed. There was an error during the API request, please contact support with the above error.`;
3+
export const BYTECODE_MISMATCH_ERROR = `Error in ${Plugin}: Contract verification failed, bytecode mismatch detected. This can occur if compiler details or source is different compared to the deployed contract.`;
4+
export const NO_VERIFIABLE_CONTRACTS_ERROR = `${Plugin}: Contracts are not eligible for verification.`;
5+
export const NO_NEW_CONTRACTS_VERIFIED_ERROR = `${Plugin}: No new contracts have been verified.`;
6+
export const API_REQUEST_ERROR = `Error in ${Plugin}: Verification failed. There was an error during the API request, please contact support with the above error.`;
77
export const CONTRACTS_NOT_DETECTED = `"Could not detect any contracts inside hardhat project. Make sure you have some contracts under ./contracts directory."`;

src/tenderly/ethers/Contract.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ export class TdlyContract {
2929

3030
public async deployed(): Promise<Contract> {
3131
const contract = await this.nativeContract.deployed();
32-
33-
await this.tenderly.verify({
32+
const contPair = {
3433
name: this.contractName,
3534
address: contract.address
36-
});
35+
};
36+
await this.tenderly.persistArtifacts(contPair);
37+
await this.tenderly.verify(contPair);
3738
return contract;
3839
}
3940
}

src/tenderly/types/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface TenderlyConfig {
1616
username: string;
1717
forkNetwork: string;
1818
privateVerification?: boolean;
19+
deploymentsDir?: string;
1920
}
2021

2122
export interface Metadata {

0 commit comments

Comments
 (0)