Skip to content

Commit

Permalink
Separate conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Sep 9, 2024
1 parent a1d7379 commit 3bd8baa
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions packages/core/src/utils/make-namespaced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function makeNamespacedInput(input: SolcInput, output: SolcOutput, solcVe
function tryRemoveNonStructNatSpec(origContent: string, solcVersion: string | undefined): string {
const natSpecRemovals: Modification[] = [];

if (solcVersion !== undefined && slangSupportsPlatformAndVersion(solcVersion)) {
if (solcVersion !== undefined && tryRequire('@nomicfoundation/slang') && slangSupportsVersion(solcVersion)) {
/* eslint-disable @typescript-eslint/no-var-requires */
const { Language } = require('@nomicfoundation/slang/language');
const { NonterminalKind, TerminalKind } = require('@nomicfoundation/slang/kinds');
Expand Down Expand Up @@ -217,19 +217,12 @@ function tryRequire(id: string) {
return false;
}

/**
* Whether Slang is supported for the current platform and the given compiler version.
*/
function slangSupportsPlatformAndVersion(solcVersion: string): boolean {
if (tryRequire('@nomicfoundation/slang')) {
/* eslint-disable @typescript-eslint/no-var-requires */
const { Language } = require('@nomicfoundation/slang/language');
/* eslint-enable @typescript-eslint/no-var-requires */
function slangSupportsVersion(solcVersion: string): boolean {
/* eslint-disable @typescript-eslint/no-var-requires */
const { Language } = require('@nomicfoundation/slang/language');
/* eslint-enable @typescript-eslint/no-var-requires */

return Language.supportedVersions().includes(solcVersion);
} else {
return false;
}
return Language.supportedVersions().includes(solcVersion);
}

interface Modification {
Expand Down

0 comments on commit 3bd8baa

Please sign in to comment.