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.
feat: withdraw modal 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 feat: fetch certs fix: check fix: certs fix: split actions feat: better modal flow feat: sd fix: tests fix: tests fix: texts
- Loading branch information
1 parent
560819f
commit c28de20
Showing
23 changed files
with
398 additions
and
56 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
2 changes: 1 addition & 1 deletion
2
packages/suite/src/actions/wallet/constants/cardanoStakingConstants.ts
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,6 +1,6 @@ | ||
export const ADD_PENDING_STAKE_TX = '@cardano-staking/set-pending-stake-tx'; | ||
export const REMOVE_PENDING_STAKE_TX = '@cardano-staking/remove-pending-stake-tx'; | ||
export const IS_LOADING = '@cardano-staking/is-loading'; | ||
export const SET_TREZOR_POOLS = '@cardano-staking/set-trezor-pools'; | ||
export const SET_TREZOR_DATA = '@cardano-staking/set-trezor-data'; | ||
export const SET_FETCH_LOADING = '@cardano-staking/set-fetch-loading'; | ||
export const SET_FETCH_ERROR = '@cardano-staking/set-fetch-error'; |
156 changes: 156 additions & 0 deletions
156
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,156 @@ | ||
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 { useCardanoStaking } from 'src/hooks/wallet/useCardanoStaking'; | ||
|
||
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; | ||
}; | ||
|
||
export const CardanoWithdrawModal = ({ onCancel }: Props) => { | ||
const { voteAbstain, voteDelegate } = useCardanoStaking(); | ||
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; | ||
|
||
return ( | ||
<NewModal onCancel={onCancel}> | ||
<StyledH2> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_TITLE" | ||
defaultMessage="Withdraw your rewards" | ||
/> | ||
</StyledH2> | ||
<Row> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_DESCRIPTION" | ||
defaultMessage="When withdrawing your rewards, you can choose to support the Cardano ecosystem by delegating your community voting rights. This helps strengthen the network’s resilience, sustainability, and community-driven governance. If you prefer, you can easily opt out of governance." | ||
/> | ||
</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={() => voteDelegate()}> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_BUTTON_DELEGATE" | ||
defaultMessage="Delegate" | ||
/> | ||
</Button> | ||
<LeftPadding10> | ||
<Button onClick={() => voteAbstain()} variant="tertiary"> | ||
<FormattedMessage | ||
id="TR_CARDANO_WITHDRAW_MODAL_BUTTON_ABSTAIN" | ||
defaultMessage="Opt Out" | ||
/> | ||
</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.