Commit 5df01469 authored by aniket-engg's avatar aniket-engg Committed by Aniket

get compiler version using compilation result

parent b3a5c1a6
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import { FunctionDefinitionAstNode, ModifierDefinitionAstNode, ParameterListAstNode, ForStatementAstNode, import { FunctionDefinitionAstNode, ModifierDefinitionAstNode, ParameterListAstNode, ForStatementAstNode,
WhileStatementAstNode, VariableDeclarationAstNode, ContractDefinitionAstNode, InheritanceSpecifierAstNode, WhileStatementAstNode, VariableDeclarationAstNode, ContractDefinitionAstNode, InheritanceSpecifierAstNode,
MemberAccessAstNode, BinaryOperationAstNode, FunctionCallAstNode, ExpressionStatementAstNode, UnaryOperationAstNode, MemberAccessAstNode, BinaryOperationAstNode, FunctionCallAstNode, ExpressionStatementAstNode, UnaryOperationAstNode,
IdentifierAstNode, IndexAccessAstNode, BlockAstNode, AssignmentAstNode, InlineAssemblyAstNode, IfStatementAstNode, CompiledContractObj, ABIParameter } from "types" IdentifierAstNode, IndexAccessAstNode, BlockAstNode, AssignmentAstNode, InlineAssemblyAstNode, IfStatementAstNode, CompiledContractObj, ABIParameter, CompilationResult, CompiledContract } from "types"
import { util } from 'remix-lib' import { util } from 'remix-lib'
type SpecialObjDetail = { type SpecialObjDetail = {
...@@ -1122,6 +1122,17 @@ function getTypeStringFromComponents(components: ABIParameter[]) { ...@@ -1122,6 +1122,17 @@ function getTypeStringFromComponents(components: ABIParameter[]) {
return typeString return typeString
} }
function getCompilerVersion(contractFiles: CompiledContractObj): string {
const fileNames: string[] = Object.keys(contractFiles)
const contracts = contractFiles[fileNames[0]]
const contractNames: string[] = Object.keys(contracts)
const contract: CompiledContract = contracts[contractNames[0]]
const metadata = JSON.parse(contract.metadata)
const compilerVersion: string = metadata.compiler.version
if(!compilerVersion.includes('nightly')) return 'v' + compilerVersion.split('+commit')[0]
else return 'develop'
}
const helpers = { const helpers = {
expressionTypeDescription, expressionTypeDescription,
nodeType, nodeType,
...@@ -1158,6 +1169,7 @@ export { ...@@ -1158,6 +1169,7 @@ export {
getFunctionDefinitionReturnParameterPart, getFunctionDefinitionReturnParameterPart,
getUnAssignedTopLevelBinOps, getUnAssignedTopLevelBinOps,
getMethodParamsSplittedTypeDesc, getMethodParamsSplittedTypeDesc,
getCompilerVersion,
// #################### Complex Node Identification // #################### Complex Node Identification
isDeleteOfDynamicArray, isDeleteOfDynamicArray,
......
...@@ -8,6 +8,11 @@ export interface AnalyzerModule { ...@@ -8,6 +8,11 @@ export interface AnalyzerModule {
report: ReportFunction report: ReportFunction
} }
// This version signifies the module support for Solidity version.
// start will be minimum at 0.4.12 as since that version Solidity exports latest AST
// end should be a version in which analysis feature got deprecated.
// This will be helpful in version based analysis in future.
export interface SupportedVersion { export interface SupportedVersion {
start: string start: string
end?: string end?: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment