Skip to content

Commit b5a7b75

Browse files
authored
feat: add API to determine latest supported Solidity version (#1248)
1 parent 92e0741 commit b5a7b75

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

.changeset/shy-humans-shine.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nomicfoundation/edr": minor
3+
---
4+
5+
Added an API that reports the latest supported Solidity version for source instrumentation

crates/edr_instrument/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
use semver::Version;
2+
use slang_solidity::utils::LanguageFacts;
3+
14
/// Types for instrumenting code for the purpose of code coverage.
25
pub mod coverage;
6+
7+
/// The latest version of `Solidity` supported by `edr_instrument`.
8+
pub const LATEST_SUPPORTED_SOLIDITY_VERSION: Version = LanguageFacts::LATEST_VERSION;

crates/edr_napi/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ export interface InstrumentationMetadata {
450450
* code.
451451
*/
452452
export declare function addStatementCoverageInstrumentation(sourceCode: string, sourceId: string, solidityVersion: string, coverageLibraryPath: string): InstrumentationResult
453+
/** Retrieves the latest version of `Solidity` supported for instrumentation. */
454+
export declare function latestSupportedSolidityVersion(): string
453455
/** Ethereum execution log. */
454456
export interface ExecutionLog {
455457
address: Uint8Array

crates/edr_napi/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310310
throw new Error(`Failed to load native binding`)
311311
}
312312

313-
const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OSAKA, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, addStatementCoverageInstrumentation, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace, getLatestSupportedSolcVersion } = nativeBinding
313+
const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OSAKA, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, addStatementCoverageInstrumentation, latestSupportedSolidityVersion, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace, getLatestSupportedSolcVersion } = nativeBinding
314314

315315
module.exports.GENERIC_CHAIN_TYPE = GENERIC_CHAIN_TYPE
316316
module.exports.genericChainProviderFactory = genericChainProviderFactory
@@ -361,6 +361,7 @@ module.exports.EdrContext = EdrContext
361361
module.exports.ContractDecoder = ContractDecoder
362362
module.exports.GasReportExecutionStatus = GasReportExecutionStatus
363363
module.exports.addStatementCoverageInstrumentation = addStatementCoverageInstrumentation
364+
module.exports.latestSupportedSolidityVersion = latestSupportedSolidityVersion
364365
module.exports.Precompile = Precompile
365366
module.exports.precompileP256Verify = precompileP256Verify
366367
module.exports.ProviderFactory = ProviderFactory

crates/edr_napi/src/instrument.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,9 @@ pub fn add_statement_coverage_instrumentation(
107107
)
108108
})
109109
}
110+
111+
/// Retrieves the latest version of `Solidity` supported for instrumentation.
112+
#[napi(catch_unwind)]
113+
pub fn latest_supported_solidity_version() -> String {
114+
edr_instrument::LATEST_SUPPORTED_SOLIDITY_VERSION.to_string()
115+
}

0 commit comments

Comments
 (0)