Save proxy layout data

pull/5370/head
Praise Disu 2 years ago committed by Praise Disu
parent 3888f0ac74
commit f476cbe425
  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) { async runProxyTx (proxyData, implementationContractObject) {
const args = { useCall: false, data: proxyData } const args = { useCall: false, data: proxyData }
let networkInfo let networkInfo
const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => { const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => {
@ -170,18 +171,40 @@ export class Blockchain extends Plugin {
} }
const continueCb = (error, continueTxExecution, cancelCb) => { continueTxExecution() } const continueCb = (error, continueTxExecution, cancelCb) => { continueTxExecution() }
const promptCb = (okCb, cancelCb) => { okCb() } const promptCb = (okCb, cancelCb) => { okCb() }
const finalCb = (error, txResult, address, returnValue) => { const finalCb = async (error, txResult, address, returnValue) => {
if (error) { if (error) {
const log = logBuilder(error) const log = logBuilder(error)
_paq.push(['trackEvent', 'blockchain', 'Deploy With Proxy', 'Proxy deployment failed: ' + error]) _paq.push(['trackEvent', 'blockchain', 'Deploy With Proxy', 'Proxy deployment failed: ' + error])
return this.call('terminal', 'logHtml', log) return this.call('terminal', 'logHtml', log)
} }
if (networkInfo.name === 'VM') { const hasPreviousDeploys = await this.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${networkInfo.name}.json`)
this.call('fileManager', 'exists', '.deploys', (error, exists) => {
this.config.set('vm/proxy', address) // 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 { } 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']) _paq.push(['trackEvent', 'blockchain', 'Deploy With Proxy', 'Proxy deployment successful'])
this.call('udapp', 'addInstance', addressToString(address), implementationContractObject.abi, implementationContractObject.name) 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. // re-use implementation contract's ABI for UI display in udapp and change name to proxy name.
implementationContractObject.name = proxyName implementationContractObject.name = proxyName
implementationContractObject.implementationAddress = implAddress
this.blockchain.deployProxy(data, implementationContractObject) this.blockchain.deployProxy(data, implementationContractObject)
} }

Loading…
Cancel
Save