patch flattener contract naming length

pull/5370/head
Joseph Izang 2 years ago committed by Aniket
parent 99a5613a9c
commit 40deffc009
  1. 3
      apps/remix-ide/src/app/plugins/contractFlattener.tsx
  2. 12
      apps/remix-ide/src/app/plugins/solidity-umlgen.tsx

@ -39,6 +39,7 @@ export class ContractFlattener extends Plugin {
* @returns {Promise<void>}
*/
async flattenContract (source: any, filePath: string, data: any) {
const filename = filePath.split('/')[1].split('.')[0]
const ast = data.sources
const dependencyGraph = getDependencyGraph(ast, filePath)
const sorted = dependencyGraph.isEmpty()
@ -46,7 +47,7 @@ export class ContractFlattener extends Plugin {
: dependencyGraph.sort().reverse()
const sources = source.sources
const result = concatSourceFiles(sorted, sources)
await this.call('fileManager', 'writeFile', `${filePath}_flattened.sol`, result)
await this.call('fileManager', 'writeFile', `contracts/${filename}_flattened.sol`, result)
_paq.push(['trackEvent', 'plugin', 'contractFlattener', 'flattenAContract'])
}
}

@ -69,16 +69,16 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen {
}
onActivation(): void {
this.on('solidity', 'compilationFinished', async (file, source, languageVersion, data, input, version) => {
this.on('solidity', 'compilationFinished', async (file: string, source, languageVersion, data, input, version) => {
const currentTheme: ThemeQualityType = await this.call('theme', 'currentTheme')
this.currentlySelectedTheme = currentTheme.quality
this.themeName = currentTheme.name
let result = ''
try {
if (data.sources && Object.keys(data.sources).length > 1) { // we should flatten first as there are multiple asts
result = await this.flattenContract(source, this.currentFile, data)
result = await this.flattenContract(source, file, data)
}
const ast = result.length > 1 ? parser.parse(result) : parser.parse(source.sources[this.currentFile].content)
const ast = result.length > 1 ? parser.parse(result) : parser.parse(source.sources[file].content)
const umlClasses = convertAST2UmlClasses(ast, this.currentFile)
const umlDot = convertUmlClasses2Dot(umlClasses)
const payload = vizRenderStringSync(umlDot)
@ -117,7 +117,7 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen {
generateCustomAction = async (action: customAction) => {
this.updatedSvg = this.updatedSvg.startsWith('<?xml') ? '' : this.updatedSvg
this.currentFile = action.path[0]
this.currentFile = action.path[0].split('/')[1]
_paq.push(['trackEvent', 'solidityumlgen', 'activated'])
await this.generateUml(action.path[0])
}
@ -136,12 +136,14 @@ export class SolidityUmlGen extends ViewPlugin implements ISolidityUmlGen {
* @returns {Promise<string>}
*/
async flattenContract (source: any, filePath: string, data: any) {
let filename = filePath.split('/')[1].split('.')[0]
const dependencyGraph = getDependencyGraph(data.sources, filePath)
const sorted = dependencyGraph.isEmpty()
? [filePath]
: dependencyGraph.sort().reverse()
const result = concatSourceFiles(sorted, source.sources)
await this.call('fileManager', 'writeFile', `${filePath}_flattened.sol`, result)
await this.call('fileManager', 'writeFile', `contracts/${filename}_flattened.sol`, result)
filename = null
return result
}

Loading…
Cancel
Save