fallback correctly

pull/5370/head
filip mertens 1 year ago
parent 3e7d3b7bf6
commit 864761e2b0
  1. 14
      libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts

@ -128,13 +128,19 @@ export class OpenZeppelinProxy extends Plugin {
newImplementationContractObject.name = proxyName newImplementationContractObject.name = proxyName
await this.blockchain.runTx(args, () => { }, () => { }, () => { }, async (error, txResult, _address, returnValue) => { await this.blockchain.runTx(args, () => { }, () => { }, () => { }, async (error, txResult, _address, returnValue) => {
let version = '4.8.3'
if (error) { if (error) {
throw new Error(`error: ${error.message ? error.message : error}`) console.log(`error: ${error.message ? error.message : error}`)
console.log(`Will use old version of the proxy...`)
}else{
const response = txFormat.decodeResponse(returnValue, GETUUPSProxyVersionAbi)
version = response[0].split('string: ')[1]
// check if version is >= 5.0.0
console.log('version', response)
} }
const response = txFormat.decodeResponse(returnValue, GETUUPSProxyVersionAbi)
const version = response[0].split('string: ')[1]
// check if version is >= 5.0.0
if (semver.gte(version, '5.0.0')) { if (semver.gte(version, '5.0.0')) {
const fnData = await this.blockchain.getEncodedFunctionHex([newImplAddress, "0x"], UUPSupgradeToAndCallAbi) const fnData = await this.blockchain.getEncodedFunctionHex([newImplAddress, "0x"], UUPSupgradeToAndCallAbi)
const data = { const data = {

Loading…
Cancel
Save