Use new solc build file structure

pull/5370/head
ioedeveloper 2 years ago committed by Aniket
parent 8091ba5717
commit cb84111637
  1. 15
      apps/remix-ide/src/blockchain/blockchain.js
  2. 18
      libs/remix-core-plugin/src/types/contract.ts
  3. 22
      libs/remix-ui/run-tab/src/lib/actions/deploy.ts

@ -242,7 +242,10 @@ export class Blockchain extends Plugin {
if (hasPreviousDeploys) {
const deployments = await this.call('fileManager', 'readFile', `.deploys/upgradeable-contracts/${networkName}/UUPS.json`)
const parsedDeployments = JSON.parse(deployments)
const oldImplementationAddress = parsedDeployments.deployments[proxyAddress].implementationAddress
const hasPreviousBuild = await this.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${networkName}/solc-${oldImplementationAddress}.json`)
if (hasPreviousBuild) await this.call('fileManager', 'remove', `.deploys/upgradeable-contracts/${networkName}/solc-${oldImplementationAddress}.json`)
parsedDeployments.deployments[proxyAddress] = {
date: new Date().toISOString(),
contractName: contractName,
@ -251,8 +254,16 @@ export class Blockchain extends Plugin {
solcOutput: contractObject.compiler.data,
solcInput: contractObject.compiler.source
}
await this.call('fileManager', 'writeFile', `.deploys/upgradeable-contracts/${networkName}/solc-${implementationAddress}.json`, JSON.stringify({
solcInput: contractObject.compiler.source,
solcOutput: contractObject.compiler.data
}, null, 2))
await this.call('fileManager', 'writeFile', `.deploys/upgradeable-contracts/${networkName}/UUPS.json`, JSON.stringify(parsedDeployments, null, 2))
} else {
await this.call('fileManager', 'writeFile', `.deploys/upgradeable-contracts/${networkName}/solc-${implementationAddress}.json`, JSON.stringify({
solcInput: contractObject.compiler.source,
solcOutput: contractObject.compiler.data
}, null, 2))
await this.call('fileManager', 'writeFile', `.deploys/upgradeable-contracts/${networkName}/UUPS.json`, JSON.stringify({
id: networkInfo.id,
network: networkInfo.name,
@ -261,9 +272,7 @@ export class Blockchain extends Plugin {
date: new Date().toISOString(),
contractName: contractName,
fork: networkInfo.currentFork,
implementationAddress: implementationAddress,
solcInput: contractObject.compiler.source,
solcOutput: contractObject.compiler.data
implementationAddress: implementationAddress
}
}
}, null, 2))

@ -1,3 +1,4 @@
import { SolcInput, SolcOutput } from "@openzeppelin/upgrades-core"
export interface FuncABI {
name: string,
type: string,
@ -185,14 +186,6 @@ export interface ContractSources {
}
}
export interface ContractSourcesContent {
sources: {
[source in string]: {
content?: string
}
}
}
export interface NetworkDeploymentFile {
id: string,
network: string,
@ -201,9 +194,12 @@ export interface ContractSources {
date: Date,
contractName: string,
fork: string,
implementationAddress: string,
solcInput: ContractSourcesContent,
solcOutput: ContractSources
implementationAddress: string
}
}[]
}
export interface SolcBuildFile {
solcInput: SolcInput,
solcOutput: SolcOutput
}

@ -1,4 +1,4 @@
import { ContractData, FuncABI, NetworkDeploymentFile } from "@remix-project/core-plugin"
import { ContractData, FuncABI, NetworkDeploymentFile, SolcBuildFile } from "@remix-project/core-plugin"
import { RunTab } from "../types/run-tab"
import { CompilerAbstract as CompilerAbstractType } from '@remix-project/remix-solidity'
import * as remixLib from '@remix-project/remix-lib'
@ -351,7 +351,9 @@ export const getNetworkProxyAddresses = async (plugin: RunTab, dispatch: React.D
const deployments = []
for (const proxyAddress in Object.keys(parsedNetworkFile.deployments)) {
if (parsedNetworkFile.deployments[proxyAddress].solcInput && parsedNetworkFile.deployments[proxyAddress].solcOutput) deployments.push({ address: proxyAddress, date: parsedNetworkFile.deployments[proxyAddress].date })
const solcBuildExists = await plugin.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${identifier}/solc-${parsedNetworkFile.deployments[proxyAddress].implementationAddress}.json`)
if (solcBuildExists) deployments.push({ address: proxyAddress, date: parsedNetworkFile.deployments[proxyAddress].date })
}
dispatch(fetchProxyDeploymentsSuccess(deployments))
} else {
@ -369,19 +371,21 @@ export const isValidContractUpgrade = async (plugin: RunTab, dispatch: React.Dis
const networkFile: string = await plugin.call('fileManager', 'readFile', `.deploys/upgradeable-contracts/${identifier}/UUPS.json`)
const parsedNetworkFile: NetworkDeploymentFile = JSON.parse(networkFile)
if (parsedNetworkFile.deployments[proxyAddress] && parsedNetworkFile.deployments[proxyAddress].solcInput) {
try {
const oldImpl = new UpgradeableContract(parsedNetworkFile.deployments[proxyAddress].contractName, parsedNetworkFile.deployments[proxyAddress].solcInput, parsedNetworkFile.deployments[proxyAddress].solcOutput, { kind: 'uups' })
if (parsedNetworkFile.deployments[proxyAddress]) {
const solcBuildExists = await plugin.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${identifier}/solc-${parsedNetworkFile.deployments[proxyAddress].implementationAddress}.json`)
if (solcBuildExists) {
const solcFile: string = await plugin.call('fileManager', 'readFile', `.deploys/upgradeable-contracts/${identifier}/solc-${parsedNetworkFile.deployments[proxyAddress].implementationAddress}.json`)
const parsedSolcFile: SolcBuildFile = JSON.parse(solcFile)
const oldImpl = new UpgradeableContract(parsedNetworkFile.deployments[proxyAddress].contractName, parsedSolcFile.solcInput, parsedSolcFile.solcOutput, { kind: 'uups' })
const newImpl = new UpgradeableContract(newContractName, solcInput, solcOutput, { kind: 'uups' })
const report = oldImpl.getStorageUpgradeReport(newImpl, { kind: 'uups' })
console.log('report: ', report)
} catch (e) {
console.log('e: ', e)
return report
} else {
return { success: false, error: 'Previous contract implementation not available for upgrade comparison.' }
}
} else {
return { success: false, error: 'Previous contract implementation not available for upgrade comparison.' }
}

Loading…
Cancel
Save