Skip to content

Commit

Permalink
Feat/the end (#241)
Browse files Browse the repository at this point in the history
* feat: add shutdown banner 🚧 WIP

* feat: reword and restyle banner

* feat: add link to announcement

* refactor: wording

* fix: lint formatting

* fix: lint formatting

* feat: update link

---------

Co-authored-by: Dimitri <69167058+dimsome@users.noreply.github.com>
  • Loading branch information
toniocodo and dimsome committed Apr 28, 2023
1 parent 39c7562 commit ff397f8
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 31 deletions.
9 changes: 0 additions & 9 deletions apps/governance/src/app/context/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { useQuestsQuery } from '@apps/artifacts/graphql/questbook'
import { useStakingQuery as useStakingQueryHook } from '@apps/artifacts/graphql/staking'
import { useAccount } from '@apps/base/context/account'
import { useApolloClients } from '@apps/base/context/apollo'
import { useIdlePollInterval } from '@apps/hooks'
import { composedComponent } from '@apps/react-utils'
Expand All @@ -13,20 +11,13 @@ import type { FC } from 'react'

const StakingAccountQueryUpdater: FC = () => {
const clients = useApolloClients()
const account = useAccount()
const pollIntervalStaking = useIdlePollInterval(30e3)
const pollIntervalQuest = useIdlePollInterval(60e3)

// Poll and cache
useStakingQueryHook({
client: clients.staking,
pollInterval: pollIntervalStaking,
})
useQuestsQuery({
variables: { userId: account ?? '', hasUser: !!account },
client: clients.questbook,
pollInterval: pollIntervalQuest,
})

return null
}
Expand Down
11 changes: 9 additions & 2 deletions apps/governance/src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect } from 'react'
import { useEffect, useLayoutEffect } from 'react'

import { useBaseCtx } from '@apps/base'
import { MessageHandler, useBaseCtx } from '@apps/base'
import { useBannerMessage } from '@apps/base/context/banner'
import { useUnsupportedNetwork } from '@apps/base/hooks'
import { APP_NAME } from '@apps/types'
import { Redirect, Route, Switch } from 'react-router-dom'
Expand Down Expand Up @@ -35,8 +36,14 @@ const GovernanceRoutes: FC = () => {

export const GovernanceApp: FC = () => {
const [, setBaseCtx] = useBaseCtx()
const [, setBannerMessage] = useBannerMessage()

useUnsupportedNetwork()

useLayoutEffect(() => {
setBannerMessage(MessageHandler.shutdown)
}, [setBannerMessage])

useEffect(() => {
const navItems = [
{ title: 'Stake', path: '/stake' },
Expand Down
21 changes: 4 additions & 17 deletions apps/protocol/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ChainIds, useChainIdCtx, useNetwork } from '@apps/base/context/network'
import { useUnsupportedNetwork } from '@apps/base/hooks'
import { useURLQuery } from '@apps/hooks'
import { useSelectedMassetState } from '@apps/masset-hooks'
import { useSelectedMasset, useSelectedMassetConfig, useSelectedMassetName } from '@apps/masset-provider'
import { useSelectedMasset, useSelectedMassetName } from '@apps/masset-provider'
import { APP_NAME } from '@apps/types'
import { Redirect, Route, Switch, useHistory } from 'react-router-dom'
import { useEffectOnce } from 'react-use'
Expand Down Expand Up @@ -71,12 +71,10 @@ const ProtocolRoutes: FC = () => {
export const ProtocolApp: FC = () => {
const massetState = useSelectedMassetState()
const massetName = useSelectedMassetName()
const massetConfig = useSelectedMassetConfig()
const hasFeederPools = massetState?.hasFeederPools
const [, setBannerMessage] = useBannerMessage()
const { undergoingRecol } = useSelectedMassetState() ?? {}
const urlQuery = useURLQuery()
const [chainId, setChainId] = useChainIdCtx()
const [, setChainId] = useChainIdCtx()
const [, setBaseCtx] = useBaseCtx()

useUnsupportedNetwork()
Expand All @@ -96,19 +94,8 @@ export const ProtocolApp: FC = () => {

// Handle message prioritisation:
useLayoutEffect(() => {
// let message: BannerMessageProps | undefined
// const isPolygon = chainId === ChainIds.MaticMainnet

// if (isPolygon) {
// message = MessageHandler.graph
// }

// if (undergoingRecol) {
// message = (undergoingRecol && MessageHandler.recollat(massetConfig)) || undefined
// }

setBannerMessage(MessageHandler.renbtc)
}, [chainId, massetConfig, setBannerMessage, undergoingRecol])
setBannerMessage(MessageHandler.shutdown)
}, [setBannerMessage])

useLayoutEffect(() => {
const network = urlQuery.get('network')
Expand Down
2 changes: 1 addition & 1 deletion libs/base/src/lib/components/layout/BannerMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const Container = styled.div<{ statusColor: string | undefined }>`
text-align: center;
font-size: 0.75rem;
line-height: 1.5rem;
border-bottom: 1px solid ${({ statusColor }) => statusColor};
overflow-wrap: normal;
display: none;
Expand All @@ -35,6 +34,7 @@ export const BannerMessage: FC = () => {
{
warning: Color.yellowTransparent,
info: Color.coolBlueTransparent,
none: 'transparent',
}[status]

return bannerMessage ? <Container statusColor={statusColor}>{content}</Container> : null
Expand Down
2 changes: 1 addition & 1 deletion libs/base/src/lib/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ export const Layout: FC = ({ children }) => {
<ModalDataProvider>
<ModalProvider rootComponent={TransitionGroup}>
<Background />
<BannerMessage />
<AppBar />
<BannerMessage />
<Container>
<Main>{children}</Main>
</Container>
Expand Down
51 changes: 51 additions & 0 deletions libs/base/src/lib/components/layout/MessageHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react'

import { ReactComponent as WarningIcon } from '@apps/icons/warning-alt.svg'
import styled from 'styled-components'

import type { MassetConfig } from '@apps/masset-provider'

import type { BannerMessageProps } from '../../context/BannerProvider'
Expand All @@ -9,8 +12,30 @@ interface Props {
graph: BannerMessageProps
olympus: BannerMessageProps
renbtc: BannerMessageProps
shutdown: BannerMessageProps
}

const Container = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 2rem;
`

const Modal = styled.div`
padding: 2rem;
display: flex;
max-width: 968px;
flex-direction: column;
align-items: center;
gap: 1rem;
backdrop-filter: blur(2px);
border-radius: 1rem;
border: 1px solid #fac371;
font-size: 1rem;
`

export const MessageHandler: Props = {
recollat: (massetConfig: MassetConfig) => ({
status: 'warning',
Expand Down Expand Up @@ -65,4 +90,30 @@ export const MessageHandler: Props = {
</p>
),
},
shutdown: {
status: 'none',
content: (
<Container>
<Modal>
<WarningIcon />
<p>mStable has been aquired by dHedge. Following the outlined aquisition update, certain mStable products will be sunset.</p>
<p>
The contracts will always remain live and allow for withdrawals. However, it is recommended to withdraw remaining assets from
the contracts since value accrual has been disabled.
</p>
<p>
All products, except for mUSD on Ethereum mainnet and Polygon, are being sunset. Staking MTA and governance has been disabled,
and staked assets are unlocked. Use the withdrawal app to access remaining funds.
</p>
<a
href="https://medium.com/mstable/mstable-acquisition-completed-by-dhedge-the-next-chapter-of-defi-yield-vaults-begins-79a326157132"
target="_blank"
rel="noopener noreferrer"
>
Read the Announcement
</a>
</Modal>
</Container>
),
},
}
2 changes: 1 addition & 1 deletion libs/base/src/lib/context/BannerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ReactElement } from 'react'

export interface BannerMessageProps {
content: ReactElement
status: 'warning' | 'info'
status: 'warning' | 'info' | 'none'
}

export const [useBannerMessage, BannerProvider] = createStateContext<BannerMessageProps | undefined>(undefined)
11 changes: 11 additions & 0 deletions libs/icons/src/lib/warning-alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ff397f8

Please sign in to comment.