Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/yoroi-extension/app/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ import { DappCenterContextProvider } from './UI/features/dapp-center/module/Dapp
// $FlowIgnore: suppressing this error
import GovernanceOptionsPage from './UI/pages/Governance/GovernanceOptionsPage';
// $FlowIgnore: suppressing this error
import GovernanceStatusPage from './UI/pages/Governance/GovernanceStatusPage';
// $FlowIgnore: suppressing this error
import PortfolioDappsPage from './UI/pages/portfolio/PortfolioDappsPage';
// $FlowIgnore: suppressing this error
import NftsPage from './UI/pages/nfts/NftsPage';
Expand Down Expand Up @@ -253,8 +251,7 @@ export const YoroiRoutes = (stores: StoresMap): Node => {
</Route>

<Route element={<GovernanceSubpages stores={stores} />}>
<Route path={ROUTES.GOVERNANCE.ROOT} element={<GovernanceStatusPage stores={stores} />} />
<Route path={ROUTES.GOVERNANCE.OPTIONS} element={<GovernanceOptionsPage stores={stores} />} />
<Route path={ROUTES.GOVERNANCE.ROOT} element={<GovernanceOptionsPage stores={stores} />} />
</Route>
<Route element={<StakingSubpages stores={stores} />}>
<Route path={ROUTES.STAKING_REVAMP.ROOT} element={<StakingPageRevamp stores={stores} />} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { BannerType } from '../../common/constants';
import { BringBanner } from './BringBanner';
import { UsdaBanner } from './UsdaBanner';
import { MidnightPhase2Banner } from './MidnightPhase2Banner';
import { RewardsBanner } from './RewardsBanner';
import { observer } from 'mobx-react';

import { useGovernanceStatusState } from '../../features/governace/common/hooks/useGovernanceStatusState';
Expand All @@ -31,7 +30,6 @@ export const BannerVisibilityManager = observer(({ stores, intl }) => {

return (
<>
{visible === BannerType.Rewards && <RewardsBanner stores={stores} onClose={() => dismiss(BannerType.Rewards)} />}
{visible === BannerType.MidnightPhase2 && <MidnightPhase2Banner onClose={() => dismiss(BannerType.MidnightPhase2)} />}
{visible === BannerType.DRep && (
<DrepPromotionBanner onClose={() => dismiss(BannerType.DRep)} stores={stores} intl={intl} />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const StatusSkeletonScreen = () => {
export const OptionsSkeletonScreen = () => {
return (
<CardsRow>
{[...Array(4)].map((_, idx) => (
{[...Array(3)].map((_, idx) => (
<Stack
width={294}
height={320}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import { NotEnoughMoneyToSendError } from '../../../../../api/common/errors';
import { dRepToMaybeCredentialHex } from '../../../../../api/ada/lib/cardanoCrypto/utils';
import { TransactionResult } from '../../../transaction-review/common/types';
import { useGovernance } from '../../module/GovernanceContextProvider';
import { useTxReviewModal } from '../../../transaction-review/module/ReviewTxProvider';
Expand All @@ -13,20 +12,17 @@ type UseGovernanceDelegationResult = {
error: string | null;
setError: (value: string | null) => void;

// 1) direct delegation to a specific DRep (Yoroi or any other)
delegateToDrep: (drepID: string) => Promise<void>;

// 2) open modal to choose DRep id & delegate
// 1) open modal to choose DRep id & delegate
openDelegateModalForCustomDrep: () => void;

// 3) always abstain
// 2) always abstain
delegateToAbstain: () => Promise<void>;

// 4) always no-confidence
// 3) always no-confidence
delegateToNoConfidence: () => Promise<void>;
};

export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationResult => {
export const useGovernanceDelegation = (): UseGovernanceDelegationResult => {
const [error, setError] = React.useState<string | null>(null);
const [loadingUnsignTx, setLoadingUnsignTx] = React.useState<boolean>(false);

Expand All @@ -41,7 +37,6 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
stopLoadingTxReview,
changePasswordInputValue,
showTxResultModal,
setDrepId,
setUnsignedTx,
drepCredentialHex,
} = useTxReviewModal();
Expand Down Expand Up @@ -105,20 +100,7 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
[createDrepDelegationTransaction, openTxReviewModal, signGovernanceTx, strings]
);

/** 1) Delegate to a specific DRep (Yoroi or any other) */
const delegateToDrep = React.useCallback(
async (drepID: string) => {
const vote: Vote = { kind: 'delegate', drepID };
const dRepCredentialHex: string | null = dRepToMaybeCredentialHex(drepID);

governanceVoteChanged(vote);
setDrepId({ drepID });
await createUnsignTx(dRepCredentialHex);
},
[governanceVoteChanged, setDrepId, createUnsignTx]
);

/** 2) Open modal to choose a custom DRep */
/** 1) Open modal to choose a custom DRep */
const openDelegateModalForCustomDrep = React.useCallback(() => {
if (!governanceManager) {
return;
Expand Down Expand Up @@ -161,7 +143,7 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
signGovernanceTx,
]);

/** 3) Always abstain */
/** 2) Always abstain */
const delegateToAbstain = React.useCallback(async () => {
const vote: Vote = { kind: DREP_ALWAYS_ABSTAIN };

Expand All @@ -170,7 +152,7 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
await createUnsignTx(DREP_ALWAYS_ABSTAIN);
}, [governanceVoteChanged, createUnsignTx]);

/** 4) Always no-confidence */
/** 3) Always no-confidence */
const delegateToNoConfidence = React.useCallback(async () => {
const vote: Vote = { kind: DREP_ALWAYS_NO_CONFIDENCE };

Expand All @@ -182,7 +164,6 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
loadingUnsignTx,
error,
setError,
delegateToDrep,
openDelegateModalForCustomDrep,
delegateToAbstain,
delegateToNoConfidence,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,6 @@ export const messages = Object.freeze(
defaultMessage:
'!!!You are designating someone else to cast your vote on your behalf for all proposals now and in the future.',
},
delegateToYoroi: {
id: 'governance.delegateToYoroi',
defaultMessage:
'!!!Support the Commercial and Technical adoption of the Cardano roadmap.\nPlease note Yoroi is part of the EMURGO Group.',
},
yoroiVotingRecordLink: {
id: 'governance.yoroiVotingRecordLink',
defaultMessage: '!!!See Yoroi’s voting record',
},
total: {
id: 'wallet.send.confirmationDialog.totalLabel',
defaultMessage: '!!!Total',
Expand Down Expand Up @@ -168,7 +159,8 @@ export const messages = Object.freeze(
},
chooseDelegationOption: {
id: 'governance.chooseDelegationOption',
defaultMessage: '!!!Your delegation to DReps helps shaping Cardano’s future. You may change your governance status at any time.',
defaultMessage:
'!!!Your delegation to DReps helps shaping Cardano’s future. You may change your governance status at any time.',
},
exploreOtherDRepsOrAbstain: {
id: 'governance.exploreOtherDRepsOrAbstain',
Expand All @@ -182,27 +174,10 @@ export const messages = Object.freeze(
id: 'governance.learnMoreLabel',
defaultMessage: '!!!Learn more about delegation options',
},
yoroiDRep: {
id: 'governance.yoroiDRep',
defaultMessage: '!!!Yoroi DRep',
},
yoroiTestnetDRep: {
id: 'governance.yoroiTestnetDRep',
defaultMessage: '!!!Testnet DRep',
},
yoroiDRepInfo: {
id: 'governance.yoroiDRepInfo',
defaultMessage:
'!!!Support the Commercial and Technical adoption of the Cardano roadmap. Please note Yoroi is part of the EMURGO Group.',
},
drepStatus: {
id: 'governance.drepStatus',
defaultMessage: '!!!DRep Status',
},
yoroiVotingRecord: {
id: 'governance.yoroiVotingRecord',
defaultMessage: '!!!Yoroi Voting Record',
},
backToDashboard: {
id: 'governance.backToDashboard',
defaultMessage: '!!!Back to dashboard',
Expand All @@ -211,19 +186,10 @@ export const messages = Object.freeze(
id: 'governance.chooseVotingPower',
defaultMessage: '!!!Choose How to Use Your Voting Power',
},
letYoroiDRepVoteForYou: {
id: 'governance.letYoroiDRepVoteForYou',
defaultMessage:
'!!!You can let Yoroi’s DRep vote for you, pick another DRep using their ID, or choose to abstain or show no confidence.',
},
delegateLabel: {
id: 'global.labels.delegate',
defaultMessage: '!!!Delegate',
},
otherDReps: {
id: 'governance.otherDReps',
defaultMessage: '!!!Other DReps',
},
designatedSomeoneElse: {
id: 'governance.designatedSomeoneElse',
defaultMessage:
Expand All @@ -241,10 +207,6 @@ export const messages = Object.freeze(
id: 'governance.changeToDrep',
defaultMessage: '!!!Change to DRep',
},
delegateToOtherDrep: {
id: 'governance.delegateToOtherDrep',
defaultMessage: '!!!Delegate to other DRep',
},
delegatingLabel: {
id: 'governance.delegatingLabel',
defaultMessage: '!!!Delegateing',
Expand Down Expand Up @@ -306,32 +268,23 @@ export const useStrings = () => {
goToGovernance: intl.formatMessage(messages.goToGovernance),
goToFaucet: intl.formatMessage(globalMessages.goToFaucetButton),
notEnoughMoneyToSendError: intl.formatMessage(globalMessages.notEnoughMoneyToSendError),
delegateToYoroi: intl.formatMessage(messages.delegateToYoroi),
yoroiVotingRecordLink: intl.formatMessage(messages.yoroiVotingRecordLink),
// New Strings
delegationOptions: intl.formatMessage(messages.delegationOptions),
chooseDelegationOption: intl.formatMessage(messages.chooseDelegationOption),
exploreOtherDRepsOrAbstain: intl.formatMessage(messages.exploreOtherDRepsOrAbstain),
browseAdditionalDelegation: intl.formatMessage(messages.browseAdditionalDelegation),
learnMoreLabel: intl.formatMessage(messages.learnMoreLabel),
yoroiDRep: intl.formatMessage(messages.yoroiDRep),
yoroiDRepInfo: intl.formatMessage(messages.yoroiDRepInfo),
drepStatus: intl.formatMessage(messages.drepStatus),
yoroiVotingRecord: intl.formatMessage(messages.yoroiVotingRecord),
backToDashboard: intl.formatMessage(messages.backToDashboard),
chooseVotingPower: intl.formatMessage(messages.chooseVotingPower),
letYoroiDRepVoteForYou: intl.formatMessage(messages.letYoroiDRepVoteForYou),
delegateLabel: intl.formatMessage(messages.delegateLabel),
otherDReps: intl.formatMessage(messages.otherDReps),
designatedSomeoneElse: intl.formatMessage(messages.designatedSomeoneElse),
chooseAbstain: intl.formatMessage(messages.chooseAbstain),
chooseNoConfidence: intl.formatMessage(messages.chooseNoConfidence),
changeToDrep: intl.formatMessage(messages.changeToDrep),
delegateToOtherDrep: intl.formatMessage(messages.delegateToOtherDrep),
delegatingLabel: intl.formatMessage(messages.delegatingLabel),
delegationStatus: intl.formatMessage(messages.delegationStatus),
votingPowerInfo: intl.formatMessage(messages.votingPowerInfo),
yoroiTestnetDRep: intl.formatMessage(messages.yoroiTestnetDRep),
delegatingInGovernance: intl.formatMessage(messages.delegatingInGovernance),
}).current;
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export const useNavigateTo = () => {

return React.useRef({
selectRevampStatus: () => navigate(ROUTES.GOVERNANCE.ROOT),
selectRevampOptions: () => navigate(ROUTES.GOVERNANCE.OPTIONS),
}).current;
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Box, Typography, Stack } from '@mui/material';
import { Box, Typography } from '@mui/material';
import { styled } from '@mui/system';
import { Icon } from '../../../../components';
import { useNavigateTo } from '../../common/useNavigateTo';
import { useStrings } from '../../common/hooks/useStrings';
import { useTheme } from '@mui/material/styles';
import { DrepOptionsCard } from './DrepOptionsCard';
import { useGovernance } from '../../module/GovernanceContextProvider';
import { useGovernanceDelegationToYoroiDrep } from '../../common/hooks/useGovernanceDelegationToYoroiDrep';
import { useGovernanceDelegation } from '../../common/hooks/useGovernanceDelegation';
import { useGovernanceStatusState } from '../../common/hooks/useGovernanceStatusState';
import { useGovernanceDelegationStatus } from '../../common/hooks/useGovernanceDelegationStatus';
import { GOVERNANCE_STATUS } from '../../common/constants';
Expand All @@ -15,13 +13,11 @@ import { OptionsSkeletonScreen } from '../../common/SkeletonCardLoaders';
interface DRepOptionsScreenProps {}

export const DRepOptions: React.FC<DRepOptionsScreenProps> = () => {
const navigateTo = useNavigateTo();
const strings = useStrings();
const theme: any = useTheme();

const { submitedTransactions } = useGovernance();
const { loadingUnsignTx, openDelegateModalForCustomDrep, delegateToAbstain, delegateToNoConfidence } =
useGovernanceDelegationToYoroiDrep();
useGovernanceDelegation();
const isPendingDrepDelegationTx = submitedTransactions.length > 0 && submitedTransactions[0]?.isDrepDelegation === true;

const { governanceStatusState: cardState, governanceStatus } = useGovernanceStatusState();
Expand All @@ -31,10 +27,6 @@ export const DRepOptions: React.FC<DRepOptionsScreenProps> = () => {
isDelegated,
});

const onBack = () => {
navigateTo.selectRevampStatus();
};

const drepOptionsConfig = [
{
key: 'others',
Expand Down Expand Up @@ -73,13 +65,6 @@ export const DRepOptions: React.FC<DRepOptionsScreenProps> = () => {

return (
<Container>
<Stack direction="row" alignSelf="flex-start" spacing={6} sx={{ cursor: 'pointer' }} onClick={onBack}>
<Icon.LeftArrow fill={theme.palette.ds.el_gray_medium} />
<Typography variant="body1" fontWeight={500} textTransform="uppercase">
{strings.backToDashboard}
</Typography>
</Stack>

<TitleSection>
<Typography variant="h5">{strings.chooseVotingPower}</Typography>
<Typography variant="body1" color="ds.text_gray_low">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export const DrepOptionsCard: React.FC<ActionCardProps> = ({
<ActionCardContainer status={status} isCardDelegated={isDelegated} pending={pending}>
<CardWrapper>
<CardTitleRow>
<CardIcon isDelegated={isDelegated}>
{icon}
</CardIcon>
<CardIcon isDelegated={isDelegated}>{icon}</CardIcon>
<Typography variant="h5">{title}</Typography>
</CardTitleRow>

Expand Down
Loading
Loading