|
|
|
@ -45,24 +45,31 @@ export function normalizeContractPath(contractPath: string): string[] { |
|
|
|
|
return [folders,resultingPath, filename] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function parseErrorString(errorString) { |
|
|
|
|
function parseErrorString(errorStructure: string[]) { |
|
|
|
|
// Split the string into lines
|
|
|
|
|
console.log(errorString) |
|
|
|
|
return |
|
|
|
|
let lines = errorString.trim().split('\n') |
|
|
|
|
// Extract the line number and message
|
|
|
|
|
let message = errorString.trim() |
|
|
|
|
let targetLine = lines[2].split(',') |
|
|
|
|
let tline = lines[2].trim().split(' ')[1].split(':') |
|
|
|
|
console.log(errorStructure) |
|
|
|
|
let errorType = '' |
|
|
|
|
let message = '' |
|
|
|
|
let tline = '' |
|
|
|
|
errorStructure.forEach(errorMsg => { |
|
|
|
|
const choppedup = errorMsg.split(': ') |
|
|
|
|
errorType = choppedup[0].trim().split('\n')[1] |
|
|
|
|
message = choppedup[1] |
|
|
|
|
if (errorStructure.length > 2) { |
|
|
|
|
console.log(choppedup[2].split(',')[1]) |
|
|
|
|
} |
|
|
|
|
console.log(choppedup) |
|
|
|
|
}) |
|
|
|
|
let lines = errorStructure[0].trim().split('\n') |
|
|
|
|
|
|
|
|
|
const errorObject = { |
|
|
|
|
status: 'failed', |
|
|
|
|
message: message, |
|
|
|
|
column: tline[1], |
|
|
|
|
line: tline[0] |
|
|
|
|
message: `${errorType} - ${message}`, |
|
|
|
|
column: '', |
|
|
|
|
line: '' |
|
|
|
|
} |
|
|
|
|
message = null |
|
|
|
|
targetLine = null |
|
|
|
|
// targetLine = null
|
|
|
|
|
lines = null |
|
|
|
|
tline = null |
|
|
|
|
return errorObject |
|
|
|
@ -152,10 +159,10 @@ const updatePragmaDeclaration = (content: string) => { |
|
|
|
|
const pragma = '# pragma version ~=0.4.0' |
|
|
|
|
|
|
|
|
|
if (oldPragmaFound) { |
|
|
|
|
console.log('found old pragma') |
|
|
|
|
// oldPragmaDeclaration.forEach(declaration => {
|
|
|
|
|
// content = content.replace(declaration, '# pragma version ~=0.4.0')
|
|
|
|
|
// content = content.replace(declaration, '# pragma version >0.3.10')
|
|
|
|
|
// })
|
|
|
|
|
return content |
|
|
|
|
} |
|
|
|
|
if (!pragmaFound) { |
|
|
|
|
content = `${pragma}\n\n${content}` |
|
|
|
@ -183,7 +190,6 @@ export async function compile(url: string, contract: Contract): Promise<any> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const cleanedUpContent = fixContractContent(contract.content) |
|
|
|
|
// console.log('cleanedUp', cleanedUpContent)
|
|
|
|
|
|
|
|
|
|
let contractName = contract['name'] |
|
|
|
|
const compilePackage = { |
|
|
|
@ -204,7 +210,6 @@ export async function compile(url: string, contract: Contract): Promise<any> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const compileCode = response.data |
|
|
|
|
console.log('compileCode', compileCode) |
|
|
|
|
contractName = null |
|
|
|
|
response = null |
|
|
|
|
let result: any |
|
|
|
|