From 3d7a544d668b043cfe8044411f984579d872d09b Mon Sep 17 00:00:00 2001 From: bigboydiamonds <57741810+bigboydiamonds@users.noreply.github.com> Date: Wed, 13 Mar 2024 10:11:38 -0700 Subject: [PATCH] useMetisDowntimeCountdownProgress --- .../Maintenance/Events/EcotoneForkUpgrade.tsx | 2 +- .../Maintenance/Events/MetisUpgrade.tsx | 23 ++++++++++++++++++ .../pages/state-managed-bridge/index.tsx | 24 +++++++++++-------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/packages/synapse-interface/components/Maintenance/Events/EcotoneForkUpgrade.tsx b/packages/synapse-interface/components/Maintenance/Events/EcotoneForkUpgrade.tsx index 51950da9ed..56e1368ffd 100644 --- a/packages/synapse-interface/components/Maintenance/Events/EcotoneForkUpgrade.tsx +++ b/packages/synapse-interface/components/Maintenance/Events/EcotoneForkUpgrade.tsx @@ -57,7 +57,7 @@ export const EcotoneForkWarningMessage = () => { } else return null } -export const useEcotoneForkEventCountdownProgress = () => { +export const useEcotoneForkCountdownProgress = () => { const { fromChainId, toChainId } = useBridgeState() const isChainOptimism = [fromChainId, toChainId].includes(OPTIMISM.id) diff --git a/packages/synapse-interface/components/Maintenance/Events/MetisUpgrade.tsx b/packages/synapse-interface/components/Maintenance/Events/MetisUpgrade.tsx index 44d8e677b4..38d4af00eb 100644 --- a/packages/synapse-interface/components/Maintenance/Events/MetisUpgrade.tsx +++ b/packages/synapse-interface/components/Maintenance/Events/MetisUpgrade.tsx @@ -2,6 +2,7 @@ import { AnnouncementBanner } from '../AnnouncementBanner' import { WarningMessage } from '../../Warning' import { useBridgeState } from '@/slices/bridge/hooks' import { METIS } from '@/constants/chains/master' +import { useEventCountdownProgressBar } from '../EventCountdownProgressBar' /** * Start: 30 min prior to Metis Chain Downtime @ (March 14, 02:00 UTC) @@ -55,3 +56,25 @@ export const MetisDowntimeWarningMessage = () => { ) } else return null } + +export const useMetisDowntimeCountdownProgress = () => { + const { fromChainId, toChainId } = useBridgeState() + + const isChainMetis = [fromChainId, toChainId].includes(METIS.id) + + const { + isPending: isMetisUpgradePending, + EventCountdownProgressBar: MetisUpgradeCountdownProgressBar, + } = useEventCountdownProgressBar( + 'Metis upgrade in progress', + METIS_DOWNTIME_START_DATE, + METIS_DOWNTIME_END_DATE + ) + + return { + isMetisUpgradePending, + MetisUpgradeCountdownProgressBar: isChainMetis + ? MetisUpgradeCountdownProgressBar + : null, + } +} diff --git a/packages/synapse-interface/pages/state-managed-bridge/index.tsx b/packages/synapse-interface/pages/state-managed-bridge/index.tsx index 62240698aa..d986766d91 100644 --- a/packages/synapse-interface/pages/state-managed-bridge/index.tsx +++ b/packages/synapse-interface/pages/state-managed-bridge/index.tsx @@ -92,12 +92,13 @@ import { METIS_DOWNTIME_START_DATE, METIS_DOWNTIME_END_DATE, MetisDowntimeWarningMessage, + useMetisDowntimeCountdownProgress, } from '@/components/Maintenance/Events/MetisUpgrade' import { ECOTONE_FORK_START_DATE, ECOTONE_FORK_END_DATE, EcotoneForkWarningMessage, - useEcotoneForkEventCountdownProgress, + useEcotoneForkCountdownProgress, } from '@/components/Maintenance/Events/EcotoneForkUpgrade' import { OPTIMISM, BASE, METIS } from '@/constants/chains/master' @@ -543,17 +544,20 @@ const StateManagedBridge = () => { // ECOTONE_FORK_END_DATE // ) + // const { + // isPending: isMetisUpgradePending, + // EventCountdownProgressBar: MetisUpgradeCountdownProgressBar, + // } = useEventCountdownProgressBar( + // 'Metis upgrade in progress', + // METIS_DOWNTIME_START_DATE, + // METIS_DOWNTIME_END_DATE + // ) + const { isEcotoneForkUpgradePending, EcotoneForkCountdownProgressBar } = - useEcotoneForkEventCountdownProgress() + useEcotoneForkCountdownProgress() - const { - isPending: isMetisUpgradePending, - EventCountdownProgressBar: MetisUpgradeCountdownProgressBar, - } = useEventCountdownProgressBar( - 'Metis upgrade in progress', - METIS_DOWNTIME_START_DATE, - METIS_DOWNTIME_END_DATE - ) + const { isMetisUpgradePending, MetisUpgradeCountdownProgressBar } = + useMetisDowntimeCountdownProgress() const isBridgePaused = (): boolean => { if (isEcotoneForkUpgradePending) {