fix linting for remix-core-plugin

pull/4771/head
lianahus 7 months ago
parent c8b3f2a8b6
commit f332b41fa5
  1. 20
      libs/remix-core-plugin/src/lib/compiler-artefacts.ts
  2. 4
      libs/remix-core-plugin/src/lib/compiler-content-imports.ts
  3. 4
      libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts
  4. 10
      libs/remix-core-plugin/src/lib/compiler-metadata.ts
  5. 1
      libs/remix-core-plugin/src/lib/constants/uups.ts
  6. 2
      libs/remix-core-plugin/src/lib/gist-handler.ts
  7. 4
      libs/remix-core-plugin/src/lib/openzeppelin-proxy.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. <filename>:<contractname> e.g: contracts/1_Storage.sol:Storage
* @param name contract name or fully qualified name i.e. <filename>:<contractname> 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 {

@ -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()) {

@ -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(

@ -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)
}

@ -140,7 +140,6 @@ export const UUPSupgradeAbi = {
"type": "function"
}
export const UUPSupgradeToAndCallAbi = {
"inputs": [
{

@ -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`,

@ -88,7 +88,7 @@ export class OpenZeppelinProxy extends Plugin {
}
async deployUUPSProxy(implAddress: string, _data: string, implementationContractObject): Promise<void> {
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.

Loading…
Cancel
Save