From f332b41fa5555d80d565165019ab1257d0201e80 Mon Sep 17 00:00:00 2001 From: lianahus Date: Tue, 30 Apr 2024 10:16:43 +0200 Subject: [PATCH] fix linting for remix-core-plugin --- .../src/lib/compiler-artefacts.ts | 20 +++++++++---------- .../src/lib/compiler-content-imports.ts | 4 ++-- .../src/lib/compiler-fetch-and-compile.ts | 4 ++-- .../src/lib/compiler-metadata.ts | 10 +++++----- .../src/lib/constants/uups.ts | 1 - .../remix-core-plugin/src/lib/gist-handler.ts | 2 +- .../src/lib/openzeppelin-proxy.ts | 4 ++-- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/compiler-artefacts.ts b/libs/remix-core-plugin/src/lib/compiler-artefacts.ts index 698b03c0d3..d008795aec 100644 --- a/libs/remix-core-plugin/src/lib/compiler-artefacts.ts +++ b/libs/remix-core-plugin/src/lib/compiler-artefacts.ts @@ -78,9 +78,9 @@ export class CompilerArtefacts extends Plugin { saveCompilationPerFileResult(file, source, languageVersion, data) }) } - + /** - * Get artefacts for last compiled contract + * Get artefacts for last compiled contract * * @returns last compiled contract compiler abstract */ getLastCompilationResult () { @@ -120,14 +120,14 @@ export class CompilerArtefacts extends Plugin { /** * Get a particular contract output/artefacts from a compiler output of a Solidity file compilation - * @param compilerOutput compiler output + * @param compilerOutput compiler output * @param contractName contract name * @returns arefacts object, with fully qualified name (e.g; contracts/1_Storage.sol:Storage) as key */ _getAllContractArtefactsfromOutput (compilerOutput, contractName) { const contractArtefacts = {} for (const filename in compilerOutput) { - if(Object.keys(compilerOutput[filename]).includes(contractName)) contractArtefacts[filename + ':' + contractName] = compilerOutput[filename][contractName] + if (Object.keys(compilerOutput[filename]).includes(contractName)) contractArtefacts[filename + ':' + contractName] = compilerOutput[filename][contractName] } return contractArtefacts } @@ -141,10 +141,10 @@ export class CompilerArtefacts extends Plugin { */ async _populateAllContractArtefactsFromFE (path, contractName, contractArtefacts) { const dirList = await this.call('fileManager', 'dirList', path) - if(dirList && dirList.length) { + if (dirList && dirList.length) { for (const dirPath of dirList) { // check if directory contains an 'artifacts' folder and a 'build-info' folder inside 'artifacts' - if(dirPath === path + '/artifacts' && await this.call('fileManager', 'exists', dirPath + '/build-info')) { + if (dirPath === path + '/artifacts' && await this.call('fileManager', 'exists', dirPath + '/build-info')) { const buildFileList = await this.call('fileManager', 'fileList', dirPath + '/build-info') // process each build-info file to populate the artefacts for contractName for (const buildFile of buildFileList) { @@ -156,13 +156,13 @@ export class CompilerArtefacts extends Plugin { Object.assign(contractArtefacts, artefacts) } } else await this._populateAllContractArtefactsFromFE (dirPath, contractName, contractArtefacts) - } + } } else return } /** * Get artefacts for a contract (called by script-runner) - * @param name contract name or fully qualified name i.e. : e.g: contracts/1_Storage.sol:Storage + * @param name contract name or fully qualified name i.e. : e.g: contracts/1_Storage.sol:Storage * @returns artefacts for the contract */ async getArtefactsByContractName (name) { @@ -173,12 +173,12 @@ export class CompilerArtefacts extends Plugin { const nameArr = fullyQualifiedName.split(':') const filename = nameArr[0] const contract = nameArr[1] - if(Object.keys(contractsDataByFilename).includes(filename) && contractsDataByFilename[filename][contract]) + if (Object.keys(contractsDataByFilename).includes(filename) && contractsDataByFilename[filename][contract]) return contractsDataByFilename[filename][contract] else { const allContractsData = {} await this._populateAllContractArtefactsFromFE ('contracts', contract, allContractsData) - if(allContractsData[fullyQualifiedName]) return { fullyQualifiedName, artefact: allContractsData[fullyQualifiedName]} + if (allContractsData[fullyQualifiedName]) return { fullyQualifiedName, artefact: allContractsData[fullyQualifiedName] } else throw new Error(`Could not find artifacts for ${fullyQualifiedName}. Compile contract to generate artifacts.`) } } else { diff --git a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts index 649044250e..54f99a2984 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -44,7 +44,7 @@ export class CompilerImports extends Plugin { return {} } }) - + } onActivation(): void { @@ -155,7 +155,7 @@ export class CompilerImports extends Plugin { if (targetPath && this.currentRequest) { const canCall = await this.askUserPermission('resolveAndSave', 'This action will update the path ' + targetPath) if (!canCall) throw new Error('No permission to update ' + targetPath) - } + } const provider = await this.call('fileManager', 'getProviderOf', url) if (provider) { if (provider.type === 'localhost' && !provider.isConnected()) { diff --git a/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts b/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts index da73f7af52..fd9e738623 100644 --- a/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts +++ b/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts @@ -155,7 +155,7 @@ export class FetchAndCompile extends Plugin { this.call('notification', 'toast', e.message) setTimeout(_ => this.emit('notFound', contractAddress), 0) // plugin framework returns a time out error although it actually didn't find the source... this.unresolvedAddresses.push(contractAddress) - return localCompilation() + return localCompilation() } } @@ -176,7 +176,7 @@ export class FetchAndCompile extends Plugin { } } const { settings, compilationTargets } = data - + try { setTimeout(_ => this.emit('compiling', settings), 0) const compData = await compile( diff --git a/libs/remix-core-plugin/src/lib/compiler-metadata.ts b/libs/remix-core-plugin/src/lib/compiler-metadata.ts index b45daeb5f0..10fdf7a06a 100644 --- a/libs/remix-core-plugin/src/lib/compiler-metadata.ts +++ b/libs/remix-core-plugin/src/lib/compiler-metadata.ts @@ -78,19 +78,19 @@ export class CompilerMetadata extends Plugin { solcLongVersion, input }) - const id = createHash('md5').update(Buffer.from(json)).digest().toString('hex') - const buildFilename = this.joinPath(path, this.innerPath, 'build-info/' + id + '.json') + const id = createHash('md5').update(Buffer.from(json)).digest().toString('hex') + const buildFilename = this.joinPath(path, this.innerPath, 'build-info/' + id + '.json') // If there are no file in buildInfoNames,it means compilation is running first time after loading Remix if (!this.buildInfoNames[filePath]) { // Check the existing build-info and delete all the previous build files for compiled file await this.removeStoredBuildInfo(input, path, filePath) this.buildInfoNames[filePath] = buildFilename - const buildData = {id, _format: format, solcVersion, solcLongVersion, input, output} + const buildData = { id, _format: format, solcVersion, solcLongVersion, input, output } await this.call('fileManager', 'writeFile', buildFilename, JSON.stringify(buildData, null, '\t')) } else if (this.buildInfoNames[filePath] && this.buildInfoNames[filePath] !== buildFilename) { await this.call('fileManager', 'remove', this.buildInfoNames[filePath]) this.buildInfoNames[filePath] = buildFilename - const buildData = {id, _format: format, solcVersion, solcLongVersion, input, output} + const buildData = { id, _format: format, solcVersion, solcLongVersion, input, output } await this.call('fileManager', 'writeFile', buildFilename, JSON.stringify(buildData, null, '\t')) } } @@ -136,7 +136,7 @@ export class CompilerMetadata extends Plugin { }, abi: contract.object.abi } - await this.call('fileManager', 'writeFile', fileName, JSON.stringify(data, null, '\t')) + await this.call('fileManager', 'writeFile', fileName, JSON.stringify(data, null, '\t')) this.emit('artefactsUpdated', fileName, contract) } diff --git a/libs/remix-core-plugin/src/lib/constants/uups.ts b/libs/remix-core-plugin/src/lib/constants/uups.ts index 2b54aaa86a..52689b7fbe 100644 --- a/libs/remix-core-plugin/src/lib/constants/uups.ts +++ b/libs/remix-core-plugin/src/lib/constants/uups.ts @@ -140,7 +140,6 @@ export const UUPSupgradeAbi = { "type": "function" } - export const UUPSupgradeToAndCallAbi = { "inputs": [ { diff --git a/libs/remix-core-plugin/src/lib/gist-handler.ts b/libs/remix-core-plugin/src/lib/gist-handler.ts index 83c932d4c6..7d71742552 100644 --- a/libs/remix-core-plugin/src/lib/gist-handler.ts +++ b/libs/remix-core-plugin/src/lib/gist-handler.ts @@ -117,7 +117,7 @@ export class GistHandler extends Plugin { const gistIdWorkspace = 'gist ' + gistId const workspaces = await this.call('filePanel', 'getWorkspaces') const found = workspaces.find((workspace) => workspace.name === gistIdWorkspace) - if (found) { + if (found) { await this.call('notification', 'alert', { id: 'gistAlert', message: `workspace "${gistIdWorkspace}" already exists`, diff --git a/libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts b/libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts index 661ead7a6f..5f16219aa8 100644 --- a/libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts +++ b/libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts @@ -88,7 +88,7 @@ export class OpenZeppelinProxy extends Plugin { } async deployUUPSProxy(implAddress: string, _data: string, implementationContractObject): Promise { - + const args = [implAddress, _data] const constructorData = await this.blockchain.getEncodedParams(args, UUPSfunAbi) const proxyName = 'ERC1967Proxy' @@ -109,7 +109,7 @@ export class OpenZeppelinProxy extends Plugin { data.dataHex = UUPSBytecode + constructorData.replace('0x', '') data.funAbi = UUPSfunAbi this.call('terminal', 'logHtml', `Deploying ERC1967 < 5.0.0 as proxy...`) - }else{ + } else { this.call('terminal', 'logHtml', `Deploying ERC1967 >= 5.0.0 as proxy...`) } // re-use implementation contract's ABI for UI display in udapp and change name to proxy name.