Skip to content

Commit 3a14993

Browse files
authored
Merge pull request #4502 from Emurgo/ruslan/post-governance-rework
post governance-rework
2 parents ee09782 + b857863 commit 3a14993

File tree

19 files changed

+27
-706
lines changed

19 files changed

+27
-706
lines changed

packages/yoroi-extension/app/Routes.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ import { DappCenterContextProvider } from './UI/features/dapp-center/module/Dapp
4747
// $FlowIgnore: suppressing this error
4848
import GovernanceOptionsPage from './UI/pages/Governance/GovernanceOptionsPage';
4949
// $FlowIgnore: suppressing this error
50-
import GovernanceStatusPage from './UI/pages/Governance/GovernanceStatusPage';
51-
// $FlowIgnore: suppressing this error
5250
import PortfolioDappsPage from './UI/pages/portfolio/PortfolioDappsPage';
5351
// $FlowIgnore: suppressing this error
5452
import NftsPage from './UI/pages/nfts/NftsPage';
@@ -253,8 +251,7 @@ export const YoroiRoutes = (stores: StoresMap): Node => {
253251
</Route>
254252

255253
<Route element={<GovernanceSubpages stores={stores} />}>
256-
<Route path={ROUTES.GOVERNANCE.ROOT} element={<GovernanceStatusPage stores={stores} />} />
257-
<Route path={ROUTES.GOVERNANCE.OPTIONS} element={<GovernanceOptionsPage stores={stores} />} />
254+
<Route path={ROUTES.GOVERNANCE.ROOT} element={<GovernanceOptionsPage stores={stores} />} />
258255
</Route>
259256
<Route element={<StakingSubpages stores={stores} />}>
260257
<Route path={ROUTES.STAKING_REVAMP.ROOT} element={<StakingPageRevamp stores={stores} />} />

packages/yoroi-extension/app/UI/common/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export enum BannerType {
1212
BuyAda = 'buyAdaBanner',
1313
Bring = 'bringBanner',
1414
Usda = 'usdaBanner',
15-
Rewards = 'rewardsBanner',
1615
}
1716

1817
export const SUPPORT_CRISP_CHATBOX_URL = 'https://emurgo.github.io/yoroi-crisp-support/';

packages/yoroi-extension/app/UI/common/hooks/useBannersQueue.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,13 @@ import LocalStorageApi from '../../../api/localStorage';
33
import { BannerType, DREP_BANNER_MIN_ADA } from '../constants';
44
import { useLocation } from 'react-router';
55

6-
export function useBannerQueue({ bannersRemoteConfig, walletBalance, walletId, currentlyDelegating, governanceStatus }) {
6+
export function useBannerQueue({ bannersRemoteConfig, walletBalance, walletId }) {
77
const localStorage = new LocalStorageApi();
88
const [visible, setVisible] = useState<BannerType | null>(null);
99
const [evaluationKey, setEvaluationKey] = useState(0);
1010
const location = useLocation();
1111

1212
const resolveBanner = useCallback(async () => {
13-
if (
14-
governanceStatus.status === 'none' &&
15-
!currentlyDelegating &&
16-
walletBalance > 5 &&
17-
bannersRemoteConfig?.earnRewardsWithYoroi?.display === true
18-
) {
19-
return BannerType.Rewards;
20-
}
2113
if (
2214
(await localStorage.getMidnightBannerPhase2Closed()) === undefined &&
2315
bannersRemoteConfig?.midnightPhase2Announcement.display === true
@@ -32,26 +24,14 @@ export function useBannerQueue({ bannersRemoteConfig, walletBalance, walletId, c
3224
}
3325

3426
return null;
35-
}, [bannersRemoteConfig, governanceStatus.status, walletBalance, currentlyDelegating, location.search]);
27+
}, [bannersRemoteConfig, walletBalance, location.search]);
3628

3729
useEffect(() => {
3830
resolveBanner().then(setVisible);
39-
}, [
40-
bannersRemoteConfig,
41-
walletId,
42-
walletBalance,
43-
evaluationKey,
44-
resolveBanner,
45-
currentlyDelegating,
46-
location.search,
47-
governanceStatus.status,
48-
]);
31+
}, [bannersRemoteConfig, walletId, walletBalance, evaluationKey, resolveBanner, location.search]);
4932

5033
const dismiss = async type => {
5134
switch (type) {
52-
case BannerType.Rewards:
53-
setVisible(null);
54-
break;
5535
case BannerType.MidnightPhase2:
5636
setVisible(null);
5737
await localStorage.setMidnightBannerPhase2Closed('true');

packages/yoroi-extension/app/UI/components/Banners/BannerVisibilityManager.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,21 @@ import { BannerType } from '../../common/constants';
88
import { BringBanner } from './BringBanner';
99
import { UsdaBanner } from './UsdaBanner';
1010
import { MidnightPhase2Banner } from './MidnightPhase2Banner';
11-
import { RewardsBanner } from './RewardsBanner';
1211
import { observer } from 'mobx-react';
1312

14-
import { useGovernanceStatusState } from '../../features/governace/common/hooks/useGovernanceStatusState';
15-
1613
export const BannerVisibilityManager = observer(({ stores, intl }) => {
1714
const selectedWallet = stores.wallets.selectedOrFail;
18-
const currentlyDelegating = stores.delegation.isCurrentlyDelegating(selectedWallet.publicDeriverId);
19-
const { governanceStatus } = useGovernanceStatusState();
20-
2115
const { data } = useYoroiRemoteConfig();
2216
const { visible, dismiss } = useBannerQueue({
2317
walletBalance: Number(
2418
selectedWallet.balance.getDefaultEntry().amount.shiftedBy(-primaryTokenInfoMainnet.decimals).toString()
2519
),
2620
bannersRemoteConfig: data?.banners,
27-
currentlyDelegating,
2821
walletId: selectedWallet.publicDeriverId,
29-
governanceStatus,
3022
});
3123

3224
return (
3325
<>
34-
{visible === BannerType.Rewards && <RewardsBanner stores={stores} onClose={() => dismiss(BannerType.Rewards)} />}
3526
{visible === BannerType.MidnightPhase2 && <MidnightPhase2Banner onClose={() => dismiss(BannerType.MidnightPhase2)} />}
3627
{visible === BannerType.DRep && (
3728
<DrepPromotionBanner onClose={() => dismiss(BannerType.DRep)} stores={stores} intl={intl} />

packages/yoroi-extension/app/UI/components/Banners/RewardsBanner.tsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

packages/yoroi-extension/app/UI/features/governace/common/SkeletonCardLoaders.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const StatusSkeletonScreen = () => {
5353
export const OptionsSkeletonScreen = () => {
5454
return (
5555
<CardsRow>
56-
{[...Array(4)].map((_, idx) => (
56+
{[...Array(3)].map((_, idx) => (
5757
<Stack
5858
width={294}
5959
height={320}

packages/yoroi-extension/app/UI/features/governace/common/hooks/useGovernanceDelegationToYoroiDrep.tsx renamed to packages/yoroi-extension/app/UI/features/governace/common/hooks/useGovernanceDelegation.tsx

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
22
import { NotEnoughMoneyToSendError } from '../../../../../api/common/errors';
3-
import { dRepToMaybeCredentialHex } from '../../../../../api/ada/lib/cardanoCrypto/utils';
43
import { TransactionResult } from '../../../transaction-review/common/types';
54
import { useGovernance } from '../../module/GovernanceContextProvider';
65
import { useTxReviewModal } from '../../../transaction-review/module/ReviewTxProvider';
@@ -13,20 +12,17 @@ type UseGovernanceDelegationResult = {
1312
error: string | null;
1413
setError: (value: string | null) => void;
1514

16-
// 1) direct delegation to a specific DRep (Yoroi or any other)
17-
delegateToDrep: (drepID: string) => Promise<void>;
18-
19-
// 2) open modal to choose DRep id & delegate
15+
// 1) open modal to choose DRep id & delegate
2016
openDelegateModalForCustomDrep: () => void;
2117

22-
// 3) always abstain
18+
// 2) always abstain
2319
delegateToAbstain: () => Promise<void>;
2420

25-
// 4) always no-confidence
21+
// 3) always no-confidence
2622
delegateToNoConfidence: () => Promise<void>;
2723
};
2824

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

@@ -41,7 +37,6 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
4137
stopLoadingTxReview,
4238
changePasswordInputValue,
4339
showTxResultModal,
44-
setDrepId,
4540
setUnsignedTx,
4641
drepCredentialHex,
4742
} = useTxReviewModal();
@@ -105,20 +100,7 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
105100
[createDrepDelegationTransaction, openTxReviewModal, signGovernanceTx, strings]
106101
);
107102

108-
/** 1) Delegate to a specific DRep (Yoroi or any other) */
109-
const delegateToDrep = React.useCallback(
110-
async (drepID: string) => {
111-
const vote: Vote = { kind: 'delegate', drepID };
112-
const dRepCredentialHex: string | null = dRepToMaybeCredentialHex(drepID);
113-
114-
governanceVoteChanged(vote);
115-
setDrepId({ drepID });
116-
await createUnsignTx(dRepCredentialHex);
117-
},
118-
[governanceVoteChanged, setDrepId, createUnsignTx]
119-
);
120-
121-
/** 2) Open modal to choose a custom DRep */
103+
/** 1) Open modal to choose a custom DRep */
122104
const openDelegateModalForCustomDrep = React.useCallback(() => {
123105
if (!governanceManager) {
124106
return;
@@ -161,7 +143,7 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
161143
signGovernanceTx,
162144
]);
163145

164-
/** 3) Always abstain */
146+
/** 2) Always abstain */
165147
const delegateToAbstain = React.useCallback(async () => {
166148
const vote: Vote = { kind: DREP_ALWAYS_ABSTAIN };
167149

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

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

@@ -182,7 +164,6 @@ export const useGovernanceDelegationToYoroiDrep = (): UseGovernanceDelegationRes
182164
loadingUnsignTx,
183165
error,
184166
setError,
185-
delegateToDrep,
186167
openDelegateModalForCustomDrep,
187168
delegateToAbstain,
188169
delegateToNoConfidence,

packages/yoroi-extension/app/UI/features/governace/common/hooks/useIsGovernanceAllowed.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { useGovernance } from '../../module/GovernanceContextProvider';
44
export const useIsGovernanceAllowed = () => {
55
const { governanceStatus, walletAdaBalance, networkId } = useGovernance();
66

7-
const isParticipating = governanceStatus.status != null && governanceStatus.status !== 'none';
7+
const isLoading = governanceStatus.status === null;
8+
const isParticipating = !isLoading && governanceStatus.status !== 'none';
89

910
const hasZeroAda = walletAdaBalance !== null && walletAdaBalance === 0;
1011
const isTestnet = networkId !== networks.CardanoMainnet.NetworkId;
1112

12-
const isNotAllowed = !isParticipating && hasZeroAda;
13+
const isNotAllowed = !isLoading && !isParticipating && hasZeroAda;
1314

1415
return {
1516
isNotAllowed,

packages/yoroi-extension/app/UI/features/governace/common/hooks/useStrings.tsx

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,6 @@ export const messages = Object.freeze(
106106
defaultMessage:
107107
'!!!You are designating someone else to cast your vote on your behalf for all proposals now and in the future.',
108108
},
109-
delegateToYoroi: {
110-
id: 'governance.delegateToYoroi',
111-
defaultMessage:
112-
'!!!Support the Commercial and Technical adoption of the Cardano roadmap.\nPlease note Yoroi is part of the EMURGO Group.',
113-
},
114-
yoroiVotingRecordLink: {
115-
id: 'governance.yoroiVotingRecordLink',
116-
defaultMessage: '!!!See Yoroi’s voting record',
117-
},
118109
total: {
119110
id: 'wallet.send.confirmationDialog.totalLabel',
120111
defaultMessage: '!!!Total',
@@ -168,7 +159,8 @@ export const messages = Object.freeze(
168159
},
169160
chooseDelegationOption: {
170161
id: 'governance.chooseDelegationOption',
171-
defaultMessage: '!!!Your delegation to DReps helps shaping Cardano’s future. You may change your governance status at any time.',
162+
defaultMessage:
163+
'!!!Your delegation to DReps helps shaping Cardano’s future. You may change your governance status at any time.',
172164
},
173165
exploreOtherDRepsOrAbstain: {
174166
id: 'governance.exploreOtherDRepsOrAbstain',
@@ -182,27 +174,10 @@ export const messages = Object.freeze(
182174
id: 'governance.learnMoreLabel',
183175
defaultMessage: '!!!Learn more about delegation options',
184176
},
185-
yoroiDRep: {
186-
id: 'governance.yoroiDRep',
187-
defaultMessage: '!!!Yoroi DRep',
188-
},
189-
yoroiTestnetDRep: {
190-
id: 'governance.yoroiTestnetDRep',
191-
defaultMessage: '!!!Testnet DRep',
192-
},
193-
yoroiDRepInfo: {
194-
id: 'governance.yoroiDRepInfo',
195-
defaultMessage:
196-
'!!!Support the Commercial and Technical adoption of the Cardano roadmap. Please note Yoroi is part of the EMURGO Group.',
197-
},
198177
drepStatus: {
199178
id: 'governance.drepStatus',
200179
defaultMessage: '!!!DRep Status',
201180
},
202-
yoroiVotingRecord: {
203-
id: 'governance.yoroiVotingRecord',
204-
defaultMessage: '!!!Yoroi Voting Record',
205-
},
206181
backToDashboard: {
207182
id: 'governance.backToDashboard',
208183
defaultMessage: '!!!Back to dashboard',
@@ -211,19 +186,10 @@ export const messages = Object.freeze(
211186
id: 'governance.chooseVotingPower',
212187
defaultMessage: '!!!Choose How to Use Your Voting Power',
213188
},
214-
letYoroiDRepVoteForYou: {
215-
id: 'governance.letYoroiDRepVoteForYou',
216-
defaultMessage:
217-
'!!!You can let Yoroi’s DRep vote for you, pick another DRep using their ID, or choose to abstain or show no confidence.',
218-
},
219189
delegateLabel: {
220190
id: 'global.labels.delegate',
221191
defaultMessage: '!!!Delegate',
222192
},
223-
otherDReps: {
224-
id: 'governance.otherDReps',
225-
defaultMessage: '!!!Other DReps',
226-
},
227193
designatedSomeoneElse: {
228194
id: 'governance.designatedSomeoneElse',
229195
defaultMessage:
@@ -241,10 +207,6 @@ export const messages = Object.freeze(
241207
id: 'governance.changeToDrep',
242208
defaultMessage: '!!!Change to DRep',
243209
},
244-
delegateToOtherDrep: {
245-
id: 'governance.delegateToOtherDrep',
246-
defaultMessage: '!!!Delegate to other DRep',
247-
},
248210
delegatingLabel: {
249211
id: 'governance.delegatingLabel',
250212
defaultMessage: '!!!Delegateing',
@@ -306,32 +268,23 @@ export const useStrings = () => {
306268
goToGovernance: intl.formatMessage(messages.goToGovernance),
307269
goToFaucet: intl.formatMessage(globalMessages.goToFaucetButton),
308270
notEnoughMoneyToSendError: intl.formatMessage(globalMessages.notEnoughMoneyToSendError),
309-
delegateToYoroi: intl.formatMessage(messages.delegateToYoroi),
310-
yoroiVotingRecordLink: intl.formatMessage(messages.yoroiVotingRecordLink),
311271
// New Strings
312272
delegationOptions: intl.formatMessage(messages.delegationOptions),
313273
chooseDelegationOption: intl.formatMessage(messages.chooseDelegationOption),
314274
exploreOtherDRepsOrAbstain: intl.formatMessage(messages.exploreOtherDRepsOrAbstain),
315275
browseAdditionalDelegation: intl.formatMessage(messages.browseAdditionalDelegation),
316276
learnMoreLabel: intl.formatMessage(messages.learnMoreLabel),
317-
yoroiDRep: intl.formatMessage(messages.yoroiDRep),
318-
yoroiDRepInfo: intl.formatMessage(messages.yoroiDRepInfo),
319277
drepStatus: intl.formatMessage(messages.drepStatus),
320-
yoroiVotingRecord: intl.formatMessage(messages.yoroiVotingRecord),
321278
backToDashboard: intl.formatMessage(messages.backToDashboard),
322279
chooseVotingPower: intl.formatMessage(messages.chooseVotingPower),
323-
letYoroiDRepVoteForYou: intl.formatMessage(messages.letYoroiDRepVoteForYou),
324280
delegateLabel: intl.formatMessage(messages.delegateLabel),
325-
otherDReps: intl.formatMessage(messages.otherDReps),
326281
designatedSomeoneElse: intl.formatMessage(messages.designatedSomeoneElse),
327282
chooseAbstain: intl.formatMessage(messages.chooseAbstain),
328283
chooseNoConfidence: intl.formatMessage(messages.chooseNoConfidence),
329284
changeToDrep: intl.formatMessage(messages.changeToDrep),
330-
delegateToOtherDrep: intl.formatMessage(messages.delegateToOtherDrep),
331285
delegatingLabel: intl.formatMessage(messages.delegatingLabel),
332286
delegationStatus: intl.formatMessage(messages.delegationStatus),
333287
votingPowerInfo: intl.formatMessage(messages.votingPowerInfo),
334-
yoroiTestnetDRep: intl.formatMessage(messages.yoroiTestnetDRep),
335288
delegatingInGovernance: intl.formatMessage(messages.delegatingInGovernance),
336289
}).current;
337290
};

0 commit comments

Comments
 (0)