forked from trezor/trezor-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cardano): enable tagged sets in tx serialization fix: drep value feat: modal finalize feat: messages fix: review feat: propagate functions chore: try txs feat: tx flow feat: calculate fee feat: fee fix: pass misc
- Loading branch information
1 parent
ff71c26
commit 0b87bc2
Showing
16 changed files
with
446 additions
and
54 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
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
169 changes: 169 additions & 0 deletions
169
packages/suite/src/components/suite/modals/ReduxModal/CardanoWithdrawModal.tsx
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,169 @@ | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import styled from 'styled-components'; | ||
|
||
import { Button, H2, Icon, Link, NewModal } from '@trezor/components'; | ||
import { borders, typography } from '@trezor/theme'; | ||
|
||
import { useSelector } from 'src/hooks/suite/useSelector'; | ||
|
||
import { HiddenPlaceholder } from '../../HiddenPlaceholder'; | ||
|
||
// eslint-disable-next-line local-rules/no-override-ds-component | ||
export const StyledH2 = styled(H2)` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
margin-bottom: 5px; | ||
`; | ||
|
||
export const Row = styled.div` | ||
display: flex; | ||
width: 100%; | ||
margin-top: 24px; | ||
`; | ||
|
||
export const Line = styled.div` | ||
display: flex; | ||
width: 100%; | ||
`; | ||
|
||
export const LeftPadding10 = styled.div` | ||
padding-left: 10px; | ||
`; | ||
|
||
export const Column = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
max-width: 100%; | ||
`; | ||
|
||
export const Title = styled.div` | ||
display: flex; | ||
color: ${({ theme }) => theme.legacy.TYPE_DARK_GREY}; | ||
${typography.highlight} | ||
align-items: center; | ||
margin-bottom: 16px; | ||
`; | ||
|
||
export const Actions = styled.div` | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
margin-top: 24px; | ||
justify-content: center; | ||
`; | ||
|
||
export const Text = styled.div` | ||
color: ${({ theme }) => theme.legacy.TYPE_LIGHT_GREY}; | ||
margin-bottom: 8px; | ||
margin-top: 8px; | ||
${typography.hint} | ||
`; | ||
|
||
export const Content = styled.div` | ||
display: flex; | ||
overflow: hidden; | ||
padding-left: 10px; | ||
margin-left: -10px; | ||
width: 100%; | ||
`; | ||
|
||
export const Value = styled.div` | ||
${typography.hint} | ||
color: ${({ theme }) => theme.legacy.TYPE_DARK_GREY}; | ||
font-variant-numeric: tabular-nums slashed-zero; | ||
width: fit-content; | ||
background: ${({ theme }) => theme.legacy.BG_LIGHT_GREY}; | ||
border: 1px solid ${({ theme }) => theme.legacy.STROKE_GREY}; | ||
border-radius: ${borders.radii.xs}; | ||
word-break: break-all; | ||
padding: 10px; | ||
display: flex; | ||
`; | ||
|
||
type Props = { | ||
onCancel: () => void; | ||
withdrawAndAbstain: (trezorDRepHex?: string, accountDRepHex?: string) => void; | ||
withdrawAndDelegate: (trezorDRepHex?: string, accountDRepHex?: string) => void; | ||
}; | ||
|
||
export const CardanoWithdrawModal = ({ | ||
onCancel, | ||
withdrawAndAbstain, | ||
withdrawAndDelegate, | ||
}: Props) => { | ||
const account = useSelector(state => state.wallet.selectedAccount.account); | ||
if (!account || account.networkType !== 'cardano') { | ||
throw Error('CardanoWithdrawModal used for other network'); | ||
} | ||
|
||
const cardanoNetwork = account.symbol === 'ada' ? 'mainnet' : 'preview'; | ||
const { trezorDRep } = useSelector(state => state.wallet.cardanoStaking[cardanoNetwork]); | ||
|
||
const trezorDRepBech32 = trezorDRep?.drep.bech32; | ||
const trezorDRepHex = trezorDRep?.drep.hex; | ||
const accountDRepHex = account.misc.staking.drep?.hex; | ||
|
||
return ( | ||
<NewModal onCancel={onCancel}> | ||
<StyledH2> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_TITLE" | ||
defaultMessage="Rewards withdrawal" | ||
/> | ||
</StyledH2> | ||
<Row> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_DESCRIPTION" | ||
defaultMessage="To withdraw your rewards, you must participate in on-chain governance within the | ||
Cardano ecosystem. Consider choosing a delegate representative who aligns with our | ||
values, or opt out of governance entirely. We recommend selecting a delegate | ||
representative endorsed by Trezor." | ||
/> | ||
</Row> | ||
<Row> | ||
<Content> | ||
<Column> | ||
<Title> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_SUB_TITLE" | ||
defaultMessage="Delegate Representative (DRep)" | ||
/> | ||
</Title> | ||
<HiddenPlaceholder> | ||
<Value> | ||
{trezorDRepBech32} | ||
<Link href={`https://gov.tools/drep_directory/${trezorDRepBech32}`}> | ||
<LeftPadding10> | ||
<Icon name="link" size={16} /> | ||
</LeftPadding10> | ||
</Link> | ||
</Value> | ||
</HiddenPlaceholder> | ||
</Column> | ||
</Content> | ||
</Row> | ||
<Row> | ||
<Button onClick={() => withdrawAndDelegate(trezorDRepHex, accountDRepHex)}> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_BUTTON_DELEGATE" | ||
defaultMessage="Withdraw And Delegate" | ||
/> | ||
</Button> | ||
<LeftPadding10> | ||
<Button | ||
onClick={() => withdrawAndAbstain(trezorDRepHex, accountDRepHex)} | ||
variant="tertiary" | ||
> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_BUTTON_ABSTAIN" | ||
defaultMessage="Withdraw And Abstain" | ||
/> | ||
</Button> | ||
</LeftPadding10> | ||
</Row> | ||
</NewModal> | ||
); | ||
}; |
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.