Skip to content

Commit

Permalink
Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboydiamonds committed May 15, 2024
1 parent f0d87d1 commit 6c10f92
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 37 deletions.
16 changes: 8 additions & 8 deletions packages/widget/src/components/BridgeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ export const BridgeButton = ({

const tooltipPositionStyle = '-top-8'

if (isBridgePaused) {
return (
<button className={buttonClassName} style={buttonStyle} disabled>
Bridge paused
</button>
)
}

if (!provider || !connectedAddress) {
return (
<Tooltip hoverText="Connect Wallet" positionStyles={tooltipPositionStyle}>
Expand All @@ -64,14 +72,6 @@ export const BridgeButton = ({
)
}

if (isBridgePaused) {
return (
<button className={buttonClassName} style={buttonStyle} disabled>
Bridge paused
</button>
)
}

if (!originChainId) {
return (
<Tooltip
Expand Down
18 changes: 4 additions & 14 deletions packages/widget/src/components/Maintenance/Maintenance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export const useMaintenanceComponents = (
}
})

console.log('pausedChainsList: ', pausedChainsList)

const pausedModulesList: BridgeModulePause[] = pausedModules.map((route) => {
if (!isValidBridgeModule(route.bridgeModuleName)) {
throw new Error(`Invalid module type: ${route.bridgeModuleName}`)
Expand Down Expand Up @@ -76,27 +74,19 @@ export const useMaintenanceComponents = (
)
}

/**
* Hook that maps through pausedChainsList to apply the single event countdown progress logic to each.
*
* @returns A list of objects containing maintenance status and components for each paused chain.
*/
const useMaintenanceCountdownProgresses = () => {
const {
originChainId: bridgeFromChainId,
destinationChainId: bridgeToChainId,
} = useBridgeState()
const { originChainId, destinationChainId } = useBridgeState()

return pausedChainsList?.map((event) => {
return useMaintenanceCountdownProgress({
originChainId: bridgeFromChainId,
destinationChainId: bridgeToChainId,
originChainId,
destinationChainId,
startDate: event.startTimePauseChain,
endDate: event.endTimePauseChain,
pausedFromChains: event.pausedFromChains,
pausedToChains: event.pausedToChains,
progressBarMessage: event.progressBarMessage,
disabled: event.disableCountdown || !event.pauseBridge,
disabled: event.disableCountdown,
})
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useBridgeState } from '@/state/slices/bridge/hooks'
import { getCountdownTimeStatus } from './EventCountdownProgressBar'
import { isChainIncluded } from '@/utils/isChainIncluded'

/**
* Displays a warning message based on selected chains for Bridge / Swap.
* Displays a warning message based on selected chains in Bridge Input
* Able to specify which chains to display warning messages for.
*
* @param startDate Start time to display message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { useEventCountdownProgressBar } from './EventCountdownProgressBar'
import { isChainIncluded } from '@/utils/isChainIncluded'

/**
* A hook that will return a constructed progress bar instance
* and Event status checks to use for pausing Bridge / Swap.
* A hook that will return a constructed progress bar instance and event status.
*
* @param startDate Start time of event to track
* @param endDate End time of event to track
* @param pausedChains A list of chain IDs that is paused for Bridge / Swap
* @param pausedChains A list of chain IDs that are paused
* @param progressBarMessage The message to be displayed alongside the Progress Bar
*/
export const useMaintenanceCountdownProgress = ({
Expand Down
3 changes: 0 additions & 3 deletions packages/widget/src/components/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ export const Widget = ({
useMaintenanceCountdownProgresses,
} = useMaintenanceComponents(chainPause, modulePause)

console.log('chainPause: ', chainPause)
console.log('modulePause:', modulePause)

const maintenanceCountdownProgressInstances =
useMaintenanceCountdownProgresses()

Expand Down
1 change: 0 additions & 1 deletion packages/widget/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BridgeProps } from 'types'
import { Provider } from 'react-redux'
import { Web3Provider } from 'providers/Web3Provider'
import { SynapseProvider } from 'providers/SynapseProvider'
import { useEffect, useState } from 'react'

import { Widget } from '@/components/Widget'
import { store } from '@/state/store'
Expand Down
13 changes: 7 additions & 6 deletions packages/widget/src/utils/getSynapsePauseData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const PAUSED_CHAINS_URL =
'https://raw.githubusercontent.com/synapsecns/sanguine/527d855ce9b1d908874760628d35fb2c4a6ec5dc/packages/synapse-interface/public/pauses/v1/paused-chains.json'
'https://raw.githubusercontent.com/synapsecns/sanguine/test/pauses/packages/synapse-interface/public/pauses/v1/paused-chains.json'
const PAUSED_MODULES_URL =
'https://raw.githubusercontent.com/synapsecns/sanguine/527d855ce9b1d908874760628d35fb2c4a6ec5dc/packages/synapse-interface/public/pauses/v1/paused-bridge-modules.json'

Expand All @@ -12,7 +12,7 @@ enum LocalStorageKey {
export const getSynapsePauseData = () => {
const fetchData = async () => {
try {
console.log('fetching and storing pause data in client browser')
console.log('[Synapse Widget] Fetching pause data')
const chainsData = await fetchJSONData(PAUSED_CHAINS_URL)
const modulesData = await fetchJSONData(PAUSED_MODULES_URL)

Expand All @@ -26,7 +26,10 @@ export const getSynapsePauseData = () => {
)
localStorage.setItem(LocalStorageKey.TIMESTAMP, Date.now().toString())
} catch (error) {
console.error('Failed to fetch paused chains/modules:', error)
console.error(
'[Synapse Widget] Failed to fetch paused chains/modules: ',
error
)
}
}

Expand All @@ -51,8 +54,7 @@ export const getSynapsePauseData = () => {
const millisecondsPerHour = 1000 * 60 * 60 // milliseconds in an hour
const timePastInHours = (currentTime - previousTime) / millisecondsPerHour

// return timePastInHours < 24
return false
return timePastInHours < 24
} else {
return false
}
Expand All @@ -61,7 +63,6 @@ export const getSynapsePauseData = () => {
const isValid = checkIsDataValid()

if (!isValid) {
console.log('refetching synapse pause data')
fetchData()
}

Expand Down

0 comments on commit 6c10f92

Please sign in to comment.