|
|
|
@ -24,7 +24,7 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}: |
|
|
|
|
async function compileContract() { |
|
|
|
|
resetCompilerState() |
|
|
|
|
try { |
|
|
|
|
// await remixClient.discardHighlight()
|
|
|
|
|
await remixClient.discardHighlight() |
|
|
|
|
let _contract: any |
|
|
|
|
try { |
|
|
|
|
_contract = await remixClient.getContract() |
|
|
|
@ -44,26 +44,26 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}: |
|
|
|
|
setOutput(_contract.name, {status: 'failed', message: e.message}) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
console.log({ output }) |
|
|
|
|
const compileReturnType = () => { |
|
|
|
|
const t: any = toStandardOutput(contract, output) |
|
|
|
|
const temp = _.merge(t['contracts'][contract]) |
|
|
|
|
const normal = normalizeContractPath(contract)[2] |
|
|
|
|
const abi = temp[normal]['abi'] |
|
|
|
|
const evm = _.merge(temp[normal]['evm']) |
|
|
|
|
const dpb = evm.deployedBytecode |
|
|
|
|
const runtimeBytecode = evm.bytecode |
|
|
|
|
// console.log({ output })
|
|
|
|
|
// const compileReturnType = () => {
|
|
|
|
|
// const t: any = toStandardOutput(contract, output)
|
|
|
|
|
// const temp = _.merge(t['contracts'][contract])
|
|
|
|
|
// const normal = normalizeContractPath(contract)[2]
|
|
|
|
|
// const abi = temp[normal]['abi']
|
|
|
|
|
// const evm = _.merge(temp[normal]['evm'])
|
|
|
|
|
// const dpb = evm.deployedBytecode
|
|
|
|
|
// const runtimeBytecode = evm.bytecode
|
|
|
|
|
|
|
|
|
|
const result = { |
|
|
|
|
contractName: normal, |
|
|
|
|
abi: abi, |
|
|
|
|
bytecode: dpb, |
|
|
|
|
runtimeBytecode: runtimeBytecode, |
|
|
|
|
ir: '' |
|
|
|
|
} |
|
|
|
|
return result |
|
|
|
|
} |
|
|
|
|
setOutput(_contract.name, compileReturnType()) |
|
|
|
|
// const result = {
|
|
|
|
|
// contractName: normal,
|
|
|
|
|
// abi: abi,
|
|
|
|
|
// bytecode: dpb,
|
|
|
|
|
// runtimeBytecode: runtimeBytecode,
|
|
|
|
|
// ir: ''
|
|
|
|
|
// }
|
|
|
|
|
// return result
|
|
|
|
|
// }
|
|
|
|
|
// setOutput(_contract.name, compileReturnType())
|
|
|
|
|
|
|
|
|
|
// ERROR
|
|
|
|
|
if (isCompilationError(output)) { |
|
|
|
@ -73,7 +73,7 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}: |
|
|
|
|
start: {line: line - 1, column: 10}, |
|
|
|
|
end: {line: line - 1, column: 10} |
|
|
|
|
} |
|
|
|
|
// remixClient.highlight(lineColumnPos as any, _contract.name, '#e0b4b4')
|
|
|
|
|
remixClient.highlight(lineColumnPos as any, _contract.name, '#e0b4b4') |
|
|
|
|
} else { |
|
|
|
|
const regex = output?.message?.match(/line ((\d+):(\d+))+/g) |
|
|
|
|
const errors = output?.message?.split(/line ((\d+):(\d+))+/g) // extract error message
|
|
|
|
@ -93,7 +93,7 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}: |
|
|
|
|
start: {line: parseInt(location[0]) - 1, column: 10}, |
|
|
|
|
end: {line: parseInt(location[0]) - 1, column: 10} |
|
|
|
|
} |
|
|
|
|
// remixClient.highlight(lineColumnPos as any, _contract.name, message)
|
|
|
|
|
remixClient.highlight(lineColumnPos as any, _contract.name, message) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -101,7 +101,7 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}: |
|
|
|
|
throw new Error(output.message) |
|
|
|
|
} |
|
|
|
|
// SUCCESS
|
|
|
|
|
// remixClient.discardHighlight()
|
|
|
|
|
remixClient.discardHighlight() |
|
|
|
|
remixClient.changeStatus({ |
|
|
|
|
key: 'succeed', |
|
|
|
|
type: 'success', |
|
|
|
@ -109,10 +109,7 @@ function CompilerButton({contract, setOutput, compilerUrl, resetCompilerState}: |
|
|
|
|
}) |
|
|
|
|
const data = toStandardOutput(_contract.name, output) |
|
|
|
|
remixClient.compilationFinish(_contract.name, _contract.content, data) |
|
|
|
|
|
|
|
|
|
//map data to compilation details shape
|
|
|
|
|
|
|
|
|
|
remixClient.call('compilationDetails' as any, 'showDetails', data) |
|
|
|
|
// remixClient.call('compilationDetails' as any, 'showDetails', data)
|
|
|
|
|
} catch (err: any) { |
|
|
|
|
remixClient.changeStatus({ |
|
|
|
|
key: 'failed', |
|
|
|
|