fallback correctly

pull/4143/head
filip mertens 1 year ago
parent 7ddc228bf1
commit f39deac1ff
  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