Save proxy layout data

pull/3187/head
Praise Disu 2 years ago committed by Praise Disu
parent 79aa5af188
commit 5d86c569a9
  1. 33
      apps/remix-ide/src/blockchain/blockchain.js
  2. 1
      libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts

@ -161,6 +161,7 @@ export class Blockchain extends Plugin {
}
async runProxyTx (proxyData, implementationContractObject) {
const args = { useCall: false, data: proxyData }
let networkInfo
const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => {
@ -170,18 +171,40 @@ export class Blockchain extends Plugin {
}
const continueCb = (error, continueTxExecution, cancelCb) => { continueTxExecution() }
const promptCb = (okCb, cancelCb) => { okCb() }
const finalCb = (error, txResult, address, returnValue) => {
const finalCb = async (error, txResult, address, returnValue) => {
if (error) {
const log = logBuilder(error)
_paq.push(['trackEvent', 'blockchain', 'Deploy With Proxy', 'Proxy deployment failed: ' + error])
return this.call('terminal', 'logHtml', log)
}
if (networkInfo.name === 'VM') {
this.call('fileManager', 'exists', '.deploys', (error, exists) => {
this.config.set('vm/proxy', address)
const hasPreviousDeploys = await this.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${networkInfo.name}.json`)
// make deploys folder read only.
if (hasPreviousDeploys) {
const deployments = await this.call('fileManager', 'readFile', `.deploys/upgradeable-contracts/${networkInfo.name}.json`)
const parsedDeployments = JSON.parse(deployments)
parsedDeployments.deployments.push({
fork: networkInfo.currentFork,
proxyAddress: address,
implementationAddress: implementationContractObject.implementationAddress,
layout: implementationContractObject.contract.object.storageLayout,
date: new Date().toISOString()
})
await this.call('fileManager', 'writeFile', `.deploys/upgradeable-contracts/${networkInfo.name}.json`, JSON.stringify(parsedDeployments, null, 2))
} else {
this.config.set(`${networkInfo.name}/${networkInfo.currentFork}/${networkInfo.id}/proxy`, address)
await this.call('fileManager', 'writeFile', `.deploys/upgradeable-contracts/${networkInfo.name}.json`, JSON.stringify({
id: networkInfo.id,
network: networkInfo.name,
deployments: [{
fork: networkInfo.currentFork,
proxyAddress: address,
implementationAddress: implementationContractObject.implementationAddress,
layout: implementationContractObject.contract.object.storageLayout,
date: new Date().toISOString()
}]
}, null, 2))
}
_paq.push(['trackEvent', 'blockchain', 'Deploy With Proxy', 'Proxy deployment successful'])
this.call('udapp', 'addInstance', addressToString(address), implementationContractObject.abi, implementationContractObject.name)

@ -101,6 +101,7 @@ export class OpenZeppelinProxy extends Plugin {
// re-use implementation contract's ABI for UI display in udapp and change name to proxy name.
implementationContractObject.name = proxyName
implementationContractObject.implementationAddress = implAddress
this.blockchain.deployProxy(data, implementationContractObject)
}

Loading…
Cancel
Save