From fe0116af38a2c34330671459b71c05b8da7009a5 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 16 Oct 2023 18:54:07 +0200 Subject: [PATCH] fallback correctly --- .../src/lib/openzeppelin-proxy.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts b/libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts index 55cbc92aac..0e3dd1d7d8 100644 --- a/libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts +++ b/libs/remix-core-plugin/src/lib/openzeppelin-proxy.ts @@ -128,13 +128,19 @@ export class OpenZeppelinProxy extends Plugin { newImplementationContractObject.name = proxyName await this.blockchain.runTx(args, () => { }, () => { }, () => { }, async (error, txResult, _address, returnValue) => { + let version = '4.8.3' 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')) { + const fnData = await this.blockchain.getEncodedFunctionHex([newImplAddress, "0x"], UUPSupgradeToAndCallAbi) const data = {