|
|
@ -170,7 +170,7 @@ 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) |
|
|
|
|
|
|
|
|
|
|
@ -179,6 +179,7 @@ export class Blockchain extends Plugin { |
|
|
|
} |
|
|
|
} |
|
|
|
if (networkInfo.name === 'VM') this.config.set('vm/proxy', address) |
|
|
|
if (networkInfo.name === 'VM') this.config.set('vm/proxy', address) |
|
|
|
else this.config.set(`${networkInfo.name}/${networkInfo.currentFork}/${networkInfo.id}/proxy`, address) |
|
|
|
else this.config.set(`${networkInfo.name}/${networkInfo.currentFork}/${networkInfo.id}/proxy`, address) |
|
|
|
|
|
|
|
await this.saveDeployedContractStorageLayout(implementationContractObject, address, networkInfo) |
|
|
|
_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) |
|
|
|
} |
|
|
|
} |
|
|
@ -209,25 +210,61 @@ export class Blockchain extends Plugin { |
|
|
|
|
|
|
|
|
|
|
|
async runUpgradeTx (proxyAddress, data, newImplementationContractObject) { |
|
|
|
async runUpgradeTx (proxyAddress, data, newImplementationContractObject) { |
|
|
|
const args = { useCall: false, data, to: proxyAddress } |
|
|
|
const args = { useCall: false, data, to: proxyAddress } |
|
|
|
|
|
|
|
let networkInfo |
|
|
|
const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => { |
|
|
|
const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => { |
|
|
|
// continue using original authorization given by user
|
|
|
|
// continue using original authorization given by user
|
|
|
|
|
|
|
|
networkInfo = network |
|
|
|
continueTxExecution(null) |
|
|
|
continueTxExecution(null) |
|
|
|
} |
|
|
|
} |
|
|
|
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', 'Upgrade With Proxy', 'Upgrade failed']) |
|
|
|
_paq.push(['trackEvent', 'blockchain', 'Upgrade With Proxy', 'Upgrade failed']) |
|
|
|
return this.call('terminal', 'logHtml', log) |
|
|
|
return this.call('terminal', 'logHtml', log) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
await this.saveDeployedContractStorageLayout(newImplementationContractObject, proxyAddress, networkInfo) |
|
|
|
_paq.push(['trackEvent', 'blockchain', 'Upgrade With Proxy', 'Upgrade Successful']) |
|
|
|
_paq.push(['trackEvent', 'blockchain', 'Upgrade With Proxy', 'Upgrade Successful']) |
|
|
|
this.call('udapp', 'addInstance', addressToString(proxyAddress), newImplementationContractObject.abi, newImplementationContractObject.name) |
|
|
|
this.call('udapp', 'addInstance', addressToString(proxyAddress), newImplementationContractObject.abi, newImplementationContractObject.name) |
|
|
|
} |
|
|
|
} |
|
|
|
this.runTx(args, confirmationCb, continueCb, promptCb, finalCb) |
|
|
|
this.runTx(args, confirmationCb, continueCb, promptCb, finalCb) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async saveDeployedContractStorageLayout (contractObject, proxyAddress, networkInfo) { |
|
|
|
|
|
|
|
const { contractName, implementationAddress, contract } = contractObject |
|
|
|
|
|
|
|
const hasPreviousDeploys = await this.call('fileManager', 'exists', `.deploys/upgradeable-contracts/${networkInfo.name}/UUPS.json`) |
|
|
|
|
|
|
|
// TODO: make deploys folder read only.
|
|
|
|
|
|
|
|
if (hasPreviousDeploys) { |
|
|
|
|
|
|
|
const deployments = await this.call('fileManager', 'readFile', `.deploys/upgradeable-contracts/${networkInfo.name}/UUPS.json`) |
|
|
|
|
|
|
|
const parsedDeployments = JSON.parse(deployments) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parsedDeployments.deployments[proxyAddress] = { |
|
|
|
|
|
|
|
date: new Date().toISOString(), |
|
|
|
|
|
|
|
contractName: contractName, |
|
|
|
|
|
|
|
fork: networkInfo.currentFork, |
|
|
|
|
|
|
|
implementationAddress: implementationAddress, |
|
|
|
|
|
|
|
layout: contract.object.storageLayout |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await this.call('fileManager', 'writeFile', `.deploys/upgradeable-contracts/${networkInfo.name}/UUPS.json`, JSON.stringify(parsedDeployments, null, 2)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
await this.call('fileManager', 'writeFile', `.deploys/upgradeable-contracts/${networkInfo.name}/UUPS.json`, JSON.stringify({ |
|
|
|
|
|
|
|
id: networkInfo.id, |
|
|
|
|
|
|
|
network: networkInfo.name, |
|
|
|
|
|
|
|
deployments: { |
|
|
|
|
|
|
|
[proxyAddress]: { |
|
|
|
|
|
|
|
date: new Date().toISOString(), |
|
|
|
|
|
|
|
contractName: contractName, |
|
|
|
|
|
|
|
fork: networkInfo.currentFork, |
|
|
|
|
|
|
|
implementationAddress: implementationAddress, |
|
|
|
|
|
|
|
layout: contract.object.storageLayout |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, null, 2)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async getEncodedFunctionHex (args, funABI) { |
|
|
|
async getEncodedFunctionHex (args, funABI) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
txFormat.encodeFunctionCall(args, funABI, (error, data) => { |
|
|
|
txFormat.encodeFunctionCall(args, funABI, (error, data) => { |
|
|
|