Skip to content

Commit

Permalink
chore: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
alfetopito committed Dec 17, 2024
1 parent 24ee647 commit 4038e63
Showing 1 changed file with 1 addition and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useFetchFile } from '@cowprotocol/common-hooks'
import { environmentName, hashCode, isInjectedWidget } from '@cowprotocol/common-utils'
import { hashCode, isInjectedWidget } from '@cowprotocol/common-utils'
import { SupportedChainId as ChainId } from '@cowprotocol/cow-sdk'
import { ClosableBanner } from '@cowprotocol/ui'
import { useWalletInfo } from '@cowprotocol/wallet'
Expand All @@ -11,16 +10,9 @@ import { GlobalWarning } from 'common/pure/GlobalWarning'

import { markdownComponents } from '../../Markdown/components'

// Announcement content: Modify this repository to edit the announcement
const ANNOUNCEMENTS_MARKDOWN_BASE_URL = 'https://raw.githubusercontent.com/cowprotocol/cowswap-banner/main' //

const BANNER_STORAGE_KEY = 'announcementBannerClosed/'

const PRODUCTION_ENVS: (typeof environmentName)[] = ['production', 'staging', 'ens']

function getAnnouncementUrl(chainId: number, env?: 'production' | 'barn') {
return `${ANNOUNCEMENTS_MARKDOWN_BASE_URL}${env ? `/${env}` : ''}/announcements-${chainId}.md`
}

function useGetCmsAnnouncement(chainId: number): string | undefined {
const critical = useCriticalAnnouncements(chainId)
Expand All @@ -40,30 +32,6 @@ function useGetCmsAnnouncement(chainId: number): string | undefined {
return
}

// TODO: should it be kept as a fallback?
function useGetAnnouncement(chainId: number): string | undefined {
const env = PRODUCTION_ENVS.includes(environmentName) ? 'production' : 'barn'

// Fetches global announcement
const { file, error } = useFetchFile(getAnnouncementUrl(chainId))
// Fetches env announcement
const { file: envFile, error: envError } = useFetchFile(getAnnouncementUrl(chainId, env))

const announcementText = error ? undefined : file?.trim()

if (error) {
console.error('[URLWarning] Error getting the announcement text: ', error)
}

const envAnnouncementText = envError ? undefined : envFile?.trim()

if (envError) {
console.error(`[URLWarning] Error getting the env ${env} announcement text: `, envError)
}

return announcementText || envAnnouncementText
}

export function URLWarning() {
const { chainId = ChainId.MAINNET } = useWalletInfo()

Expand Down

0 comments on commit 4038e63

Please sign in to comment.