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