-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1590 from Giveth/add-fox-xdai-regen-farm
Add fox xdai regen farm
- Loading branch information
Showing
24 changed files
with
524 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
{ | ||
"cSpell.words": [ | ||
"giveth", | ||
"merkle", | ||
"xdai", | ||
"GIVpower", | ||
"GIVback", | ||
"GIVeconomy", | ||
"giveth", | ||
"GIVfarm", | ||
"GIVback", | ||
"GIVpower", | ||
"GIVstream", | ||
"HONEYSWAP", | ||
"merkle", | ||
"SUSHISWAP", | ||
"xdai" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { | ||
IconInfo16, | ||
neutralColors, | ||
brandColors, | ||
Caption, | ||
Button, | ||
} from '@giveth/ui-design-system'; | ||
import { useWeb3React } from '@web3-react/core'; | ||
import { InjectedConnector } from '@web3-react/injected-connector'; | ||
import styled from 'styled-components'; | ||
import { switchNetwork } from '@/lib/metamask'; | ||
import { Flex } from './styled-components/Flex'; | ||
import config from '@/configuration'; | ||
|
||
interface IChangeNetworkModal { | ||
network: number; | ||
} | ||
|
||
export const DAOChangeNetworkModal = ({ network }: IChangeNetworkModal) => { | ||
const { account, activate } = useWeb3React(); | ||
const networkLabel = | ||
network === config.XDAI_NETWORK_NUMBER ? 'Gnosis chain' : 'Mainnet'; | ||
|
||
const checkWalletAndSwitchNetwork = async (network: number) => { | ||
if (!account) { | ||
await activate(new InjectedConnector({})); | ||
await switchNetwork(network); | ||
} | ||
if (account) { | ||
await switchNetwork(network); | ||
} | ||
}; | ||
return ( | ||
<DAOChangeNetworkModalContainer> | ||
<Flex gap='16px'> | ||
<IconInfo16 /> | ||
<Title>Switch network</Title> | ||
</Flex> | ||
<Desc>This RegenFarm is only available on {networkLabel}</Desc> | ||
<ChangeButton | ||
buttonType='texty' | ||
label={`Switch to ${networkLabel}`} | ||
onClick={() => checkWalletAndSwitchNetwork(network)} | ||
/> | ||
</DAOChangeNetworkModalContainer> | ||
); | ||
}; | ||
|
||
const DAOChangeNetworkModalContainer = styled.div` | ||
background-color: ${neutralColors.gray[100]}; | ||
color: ${brandColors.giv[300]}; | ||
border: 1px solid ${brandColors.giv[300]}; | ||
border-radius: 8px; | ||
width: 320px; | ||
z-index: 4; | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
opacity: 2; | ||
padding: 16px; | ||
`; | ||
|
||
const Title = styled(Caption)` | ||
font-weight: bold; | ||
`; | ||
|
||
const Desc = styled(Caption)` | ||
margin-left: 32px; | ||
margin-bottom: 16px; | ||
`; | ||
|
||
const ChangeButton = styled(Button)` | ||
color: ${brandColors.giv[300]}; | ||
margin-left: auto; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React, { FC } from 'react'; | ||
import { useWeb3React } from '@web3-react/core'; | ||
import { H4 } from '@giveth/ui-design-system'; | ||
import styled from 'styled-components'; | ||
import { | ||
givEconomySupportedNetworks, | ||
regenFarmStreamCardCol, | ||
} from '@/lib/constants/constants'; | ||
import StakingPoolCard from './cards/StakingPoolCard'; | ||
import { Row, Col } from './Grid'; | ||
import { PoolRow } from './homeTabs/GIVfarm.sc'; | ||
import config from '@/configuration'; | ||
import { RegenFarmConfig } from '@/types/config'; | ||
import { DAOChangeNetworkModal } from './DAOChangeNetworkModal'; | ||
import { DAOContainer, DAOChangeNetwork } from './givfarm/GIVfrens.sc'; | ||
import { RegenStreamCard } from './givfarm/RegenStreamCard'; | ||
|
||
interface IRegenFarmProps { | ||
regenFarm: RegenFarmConfig; | ||
} | ||
|
||
export const RegenFarm: FC<IRegenFarmProps> = ({ regenFarm }) => { | ||
const { chainId } = useWeb3React(); | ||
const { pools } = regenFarm; | ||
|
||
return ( | ||
<PoolRow> | ||
<DAOContainer key={`regenStream_${regenFarm.type}`} xs={12}> | ||
<DaoTitle>{regenFarm.title}</DaoTitle> | ||
<Row> | ||
{pools.map((poolStakingConfig, idx) => ( | ||
<Col key={idx} xs={12} sm={6} lg={4}> | ||
<StakingPoolCard | ||
poolStakingConfig={poolStakingConfig} | ||
regenStreamConfig={regenFarm} | ||
/> | ||
</Col> | ||
))} | ||
<Col | ||
xs={12} | ||
sm={regenFarmStreamCardCol.sm[pools.length]} // TODO: use mod() | ||
lg={regenFarmStreamCardCol.lg[pools.length]} // TODO: use mod() | ||
> | ||
{regenFarm && ( | ||
<RegenStreamCard | ||
streamConfig={regenFarm} | ||
network={ | ||
givEconomySupportedNetworks.includes( | ||
chainId as number, | ||
) | ||
? (chainId as number) | ||
: config.MAINNET_NETWORK_NUMBER | ||
} | ||
/> | ||
)} | ||
</Col> | ||
</Row> | ||
{chainId !== config.MAINNET_NETWORK_NUMBER && | ||
chainId !== config.XDAI_NETWORK_NUMBER && ( | ||
<> | ||
<DAOChangeNetwork /> | ||
<DAOChangeNetworkModal | ||
network={config.MAINNET_NETWORK_NUMBER} | ||
/> | ||
</> | ||
)} | ||
</DAOContainer> | ||
</PoolRow> | ||
); | ||
}; | ||
|
||
const DaoTitle = styled(H4)` | ||
margin-top: 32px; | ||
margin-bottom: 24px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
7927cc8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
giveth-dapps-v2 – ./
giveth-dapps-v2-givethio.vercel.app
giveth.io
www.giveth.io
giveth-dapps-v2-git-main-givethio.vercel.app