fix debugging with source location

pull/2894/head
yann300 2 years ago
parent 39491cd18c
commit 1368b66620
  1. 10
      libs/remix-core-plugin/src/lib/compiler-artefacts.ts
  2. 4
      libs/remixd/src/services/foundryClient.ts
  3. 2
      libs/remixd/src/services/hardhatClient.ts
  4. 23
      libs/remixd/src/services/truffleClient.ts

@ -63,6 +63,16 @@ export class CompilerArtefacts extends Plugin {
this.compilersArtefacts.__last = new CompilerAbstract(languageVersion, data, source) this.compilersArtefacts.__last = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data) saveCompilationPerFileResult(file, source, languageVersion, data)
}) })
this.on('truffle', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts.__last = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
})
this.on('foundry', 'compilationFinished', (file, source, languageVersion, data) => {
this.compilersArtefacts.__last = new CompilerAbstract(languageVersion, data, source)
saveCompilationPerFileResult(file, source, languageVersion, data)
})
} }
/** /**

@ -81,7 +81,7 @@ export class FoundryClient extends PluginClient {
this.call('terminal', 'log', 'receiving compilation result from foundry') this.call('terminal', 'log', 'receiving compilation result from foundry')
this.warnlog = true this.warnlog = true
} }
this.emit('compilationFinished', '', compilationResult.input, 'soljson', compilationResult.output, compilationResult.solcVersion) this.emit('compilationFinished', '', { sources: compilationResult.input } , 'soljson', compilationResult.output, compilationResult.solcVersion)
} }
this.watcher.on('change', async (f: string) => processArtifact()) this.watcher.on('change', async (f: string) => processArtifact())
this.watcher.on('add', async (f: string) => processArtifact()) this.watcher.on('add', async (f: string) => processArtifact())
@ -123,6 +123,8 @@ export class FoundryClient extends PluginClient {
} }
if (!compilationResultPart.output['contracts'][contentJSON.ast.absolutePath]) compilationResultPart.output['contracts'][contentJSON.ast.absolutePath] = {} if (!compilationResultPart.output['contracts'][contentJSON.ast.absolutePath]) compilationResultPart.output['contracts'][contentJSON.ast.absolutePath] = {}
// delete contentJSON['ast'] // delete contentJSON['ast']
contentJSON.bytecode.object = contentJSON.bytecode.object.replace('0x', '')
contentJSON.deployedBytecode.object = contentJSON.deployedBytecode.object.replace('0x', '')
compilationResultPart.output['contracts'][contentJSON.ast.absolutePath][contractName] = { compilationResultPart.output['contracts'][contentJSON.ast.absolutePath][contractName] = {
abi: contentJSON.abi, abi: contentJSON.abi,
evm: { evm: {

@ -71,7 +71,7 @@ export class HardhatClient extends PluginClient {
this.call('terminal', 'log', 'receiving compilation result from hardhat') this.call('terminal', 'log', 'receiving compilation result from hardhat')
this.warnlog = true this.warnlog = true
} }
this.emit('compilationFinished', '', compilationResult.input, 'soljson', compilationResult.output, compilationResult.solcVersion) this.emit('compilationFinished', '', { sources: compilationResult.input.sources }, 'soljson', compilationResult.output, compilationResult.solcVersion)
} }
} }

@ -84,7 +84,7 @@ export class TruffleClient extends PluginClient {
this.call('terminal', 'log', 'receiving compilation result from truffle') this.call('terminal', 'log', 'receiving compilation result from truffle')
this.warnLog = true this.warnLog = true
} }
this.emit('compilationFinished', '', compilationResult.input, 'soljson', compilationResult.output, compilationResult.solcVersion) this.emit('compilationFinished', '', { sources: compilationResult.input }, 'soljson', compilationResult.output, compilationResult.solcVersion)
} }
this.watcher.on('change', async (f: string) => processArtifact()) this.watcher.on('change', async (f: string) => processArtifact())
this.watcher.on('add', async (f: string) => processArtifact()) this.watcher.on('add', async (f: string) => processArtifact())
@ -99,23 +99,28 @@ export class TruffleClient extends PluginClient {
compilationResultPart.solcVersion = contentJSON.compiler.version compilationResultPart.solcVersion = contentJSON.compiler.version
compilationResultPart.input[path] = { content: contentJSON.source } compilationResultPart.input[path] = { content: contentJSON.source }
// extract data // extract data
if (!compilationResultPart.output['sources'][contentJSON.ast.absolutePath]) compilationResultPart.output['sources'][contentJSON.ast.absolutePath] = {} const relPath = utils.relativePath(contentJSON.ast.absolutePath, this.currentSharedFolder)
compilationResultPart.output['sources'][contentJSON.ast.absolutePath] = { if (!compilationResultPart.output['sources'][relPath]) compilationResultPart.output['sources'][relPath] = {}
ast: contentJSON['ast'],
id: contentJSON['id'] const location = contentJSON.ast.src.split(':')
const id = parseInt(location[location.length - 1])
compilationResultPart.output['sources'][relPath] = {
ast: contentJSON.ast,
id
} }
if (!compilationResultPart.output['contracts'][contentJSON.ast.absolutePath]) compilationResultPart.output['contracts'][contentJSON.ast.absolutePath] = {} if (!compilationResultPart.output['contracts'][relPath]) compilationResultPart.output['contracts'][relPath] = {}
// delete contentJSON['ast'] // delete contentJSON['ast']
compilationResultPart.output['contracts'][contentJSON.ast.absolutePath][contractName] = { compilationResultPart.output['contracts'][relPath][contractName] = {
abi: contentJSON.abi, abi: contentJSON.abi,
evm: { evm: {
bytecode: { bytecode: {
object: contentJSON.bytecode, object: contentJSON.bytecode.replace('0x', ''),
sourceMap: contentJSON.sourceMap, sourceMap: contentJSON.sourceMap,
linkReferences: contentJSON.linkReferences linkReferences: contentJSON.linkReferences
}, },
deployedBytecode: { deployedBytecode: {
object: contentJSON.deployedBytecode, object: contentJSON.deployedBytecode.replace('0x', ''),
sourceMap: contentJSON.deployedSourceMap, sourceMap: contentJSON.deployedSourceMap,
linkReferences: contentJSON.deployedLinkReferences linkReferences: contentJSON.deployedLinkReferences
} }

Loading…
Cancel
Save