From d9ae37ebb2a4c7feb5d0d275a5e1ae876dba32a9 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 22 Aug 2023 09:01:54 -0700 Subject: [PATCH] Change relayer version validating to save backwards compatibility with on Ethereum Mainnet with old Tornado versions --- store/relayer.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/store/relayer.js b/store/relayer.js index e9a9020..1722433 100644 --- a/store/relayer.js +++ b/store/relayer.js @@ -240,21 +240,19 @@ export const actions = { throw new Error(this.app.i18n.t('canNotFetchStatusFromTheRelayer')) } - const hasEnabledLightProxy = rootGetters['application/hasEnabledLightProxy'] - - const getIsUpdated = () => { + const isRelayerUpdated = () => { const relayerVersion = response.data.version - const { major, prerelease } = parseSemanticVersion(relayerVersion) + const { major, patch, prerelease } = parseSemanticVersion(relayerVersion) + // Save backwards compatibility with V4 relayers for Ethereum Mainnet + const requiredMajor = netId === 1 ? '4' : '5' + const isUpdatedMajor = major === requiredMajor - const minimalMajorVersion = 5 - const isMajorVersionUpdated = Number(major) >= minimalMajorVersion - if (prerelease && Number(major) === 5 && hasEnabledLightProxy) return false - - return isMajorVersionUpdated + if (prerelease) return false + return isUpdatedMajor && Number(patch) >= 4 // Patch checking - also backwards compatibility } - if (!getIsUpdated()) { + if (!isRelayerUpdated()) { throw new Error('Outdated version.') }