-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract getVerificationType from Tenderly.ts (#251)
### TL;DR Extracted verification type logic into separate utility functions to improve code organization and testability. ### What changed? - Created new utility functions `getVerificationType` and `isVerificationOnVnet` - Moved verification type logic from private methods in the Tenderly class to standalone functions - Updated all verification-related method calls to use the new utility functions - Created new utility files to house the extracted functions ### How to test? 1. Run existing verification tests to ensure they pass with the new utility functions 2. Test verification on different network types (devnet, fork, private, public) 3. Verify that contract verification still works as expected across all scenarios ### Why make this change? The verification type logic was previously embedded within the Tenderly class as private methods, making it difficult to test and reuse. By extracting these functions, we improve: - Code modularity and reusability - Testing capabilities - Separation of concerns - Maintainability of verification-related logic
- Loading branch information
Showing
3 changed files
with
47 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/tenderly-hardhat/src/utils/get-verification-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { isTenderlyNetworkConfig } from "./util"; | ||
import { VERIFICATION_TYPES } from "../constants"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { TenderlyNetwork } from "../TenderlyNetwork"; | ||
|
||
export async function getVerificationType( | ||
hre: HardhatRuntimeEnvironment, | ||
tenderlyNetwork: TenderlyNetwork | ||
): Promise<string> { | ||
if (isTenderlyNetworkConfig(hre.network.config)) { | ||
return tenderlyNetwork.devnetID !== undefined | ||
? VERIFICATION_TYPES.DEVNET | ||
: VERIFICATION_TYPES.FORK; | ||
} | ||
|
||
const priv = hre.config.tenderly?.privateVerification; | ||
if ( | ||
priv !== undefined && | ||
priv && | ||
!isTenderlyNetworkConfig(hre.network.config) | ||
) { | ||
return VERIFICATION_TYPES.PRIVATE; | ||
} | ||
|
||
return VERIFICATION_TYPES.PUBLIC; | ||
} | ||
|
||
export async function isVerificationOnVnet(verificationType: string): Promise<boolean> { | ||
return ( | ||
verificationType === VERIFICATION_TYPES.DEVNET || | ||
verificationType === VERIFICATION_TYPES.FORK | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { | ||
getVerificationType, | ||
isVerificationOnVnet | ||
} from "./get-verification-type"; |