Skip to content

Commit 53fb460

Browse files
authored
feat: add tempo-vote support for governance actions (#1900)
1 parent c5ce771 commit 53fb460

File tree

23 files changed

+95
-50
lines changed

23 files changed

+95
-50
lines changed

apps/browser-extension-wallet/.env.defaults

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ GOV_TOOLS_URL_MAINNET=https://gov.tools
5757
GOV_TOOLS_URL_PREPROD=https://preprod.gov.tools
5858
GOV_TOOLS_URL_PREVIEW=https://preview.gov.tools
5959
GOV_TOOLS_URL_SANCHONET=
60+
TEMPO_VOTE_URL_MAINNET=https://tempo.vote
61+
TEMPO_VOTE_URL_PREPROD=https://preprod.tempo.vote
62+
TEMPO_VOTE_URL_PREVIEW=https://preview.tempo.vote
63+
TEMPO_VOTE_URL_SANCHONET=https://sanchonet.tempo.vote
6064

6165
# events tracking
6266
POSTHOG_HOST=https://e.lw.iog.io

apps/browser-extension-wallet/.env.developerpreview

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ GOV_TOOLS_URL_MAINNET=https://gov.tools
5555
GOV_TOOLS_URL_PREPROD=https://preprod.gov.tools
5656
GOV_TOOLS_URL_PREVIEW=https://preview.gov.tools
5757
GOV_TOOLS_URL_SANCHONET=
58+
TEMPO_VOTE_URL_MAINNET=https://tempo.vote
59+
TEMPO_VOTE_URL_PREPROD=https://preprod.tempo.vote
60+
TEMPO_VOTE_URL_PREVIEW=https://preview.tempo.vote
61+
TEMPO_VOTE_URL_SANCHONET=https://sanchonet.tempo.vote
5862

5963
# events tracking
6064
POSTHOG_HOST=https://e.lw.iog.io

apps/browser-extension-wallet/.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ GOV_TOOLS_URL_MAINNET=https://gov.tools
5454
GOV_TOOLS_URL_PREPROD=https://preprod.gov.tools
5555
GOV_TOOLS_URL_PREVIEW=https://preview.gov.tools
5656
GOV_TOOLS_URL_SANCHONET=
57+
TEMPO_VOTE_URL_MAINNET=https://tempo.vote
58+
TEMPO_VOTE_URL_PREPROD=https://preprod.tempo.vote
59+
TEMPO_VOTE_URL_PREVIEW=https://preview.tempo.vote
60+
TEMPO_VOTE_URL_SANCHONET=https://sanchonet.tempo.vote
61+
5762
# events tracking
5863
POSTHOG_HOST=https://e.lw.iog.io
5964
# set this variable to true only in release packages. By having this set to false, we ensure that we will not be using Post Hog production projects tokens in development stage

apps/browser-extension-wallet/src/config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type Config = {
3333
SAVED_PRICE_DURATION: number;
3434
DEFAULT_SUBMIT_API: string;
3535
GOV_TOOLS_URLS: Record<EnvironmentTypes, string>;
36+
TEMPO_VOTE_URLS: Record<EnvironmentTypes, string>;
3637
SESSION_TIMEOUT: Milliseconds;
3738
POSTHOG_FEATURE_FLAG_CHECK_FREQUENCY_SECONDS: number;
3839
MEMPOOL_URLS: Record<BitcoinNetworks, string>;
@@ -147,6 +148,12 @@ export const config = (): Config => {
147148
Preview: `${process.env.GOV_TOOLS_URL_PREVIEW}`,
148149
Sanchonet: `${process.env.GOV_TOOLS_URL_SANCHONET}`
149150
},
151+
TEMPO_VOTE_URLS: {
152+
Mainnet: `${process.env.TEMPO_VOTE_URL_MAINNET}`,
153+
Preprod: `${process.env.TEMPO_VOTE_URL_PREPROD}`,
154+
Preview: `${process.env.TEMPO_VOTE_URL_PREVIEW}`,
155+
Sanchonet: `${process.env.TEMPO_VOTE_URL_SANCHONET}`
156+
},
150157
// eslint-disable-next-line new-cap
151158
SESSION_TIMEOUT: Milliseconds(
152159
!Number.isNaN(Number.parseInt(process.env.SESSION_TIMEOUT))

apps/browser-extension-wallet/src/features/delegation/components/DelegationLayout.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useWalletStore } from '@src/stores';
1515
import { Box } from '@input-output-hk/lace-ui-toolkit';
1616
import { useExternalLinkOpener } from '@providers';
1717
import { useRewardAccountsData } from '@src/views/browser-view/features/staking/hooks';
18-
import { config } from '@src/config';
18+
import { walletRoutePaths } from '@routes';
1919

2020
const { Text } = Typography;
2121

@@ -73,10 +73,8 @@ export const DelegationLayout = ({
7373
cardanoCoin
7474
}: DelegationLayoutProps): React.ReactElement => {
7575
const { t } = useTranslation();
76-
const { environmentName } = useWalletStore();
7776
const totalResultCount = useWalletStore(({ stakePoolSearchResults }) => stakePoolSearchResults?.totalResultCount);
7877
const openExternalLink = useExternalLinkOpener();
79-
const { GOV_TOOLS_URLS } = config();
8078
const showExpandView = hasNoFunds || (!hasNoFunds && !isDelegating) || isDelegating;
8179

8280
const stakePoolSearchTranslations = {
@@ -102,7 +100,7 @@ export const DelegationLayout = ({
102100
<Box mt="$16">
103101
<RegisterAsDRepBanner
104102
openExternalLink={openExternalLink}
105-
govToolUrl={GOV_TOOLS_URLS[environmentName]}
103+
votingCenterUrl={walletRoutePaths.voting}
106104
popupView
107105
/>
108106
</Box>

apps/browser-extension-wallet/src/features/delegation/components/MultiDelegationStakingPopup.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ import { withSignTxConfirmation } from '@lib/wallet-api-ui';
3636
import { isMultidelegationSupportedByDevice } from '@views/browser/features/staking';
3737
import { useSecrets, useSignPolicy } from '@lace/core';
3838
import { useRewardAccountsData } from '@src/views/browser-view/features/staking/hooks';
39-
import { config } from '@src/config';
4039
import { parseError } from '@src/utils/parse-error';
4140
import { getParentWalletCIP1854Account } from '@lib/scripts/background/util';
4241
import { useObservable } from '@lace/common';
42+
import { walletRoutePaths } from '@routes';
4343

4444
export const MultiDelegationStakingPopup = (): JSX.Element => {
4545
const { t } = useTranslation();
@@ -124,8 +124,6 @@ export const MultiDelegationStakingPopup = (): JSX.Element => {
124124
fetchNetworkInfo();
125125
}, [fetchNetworkInfo, blockchainProvider]);
126126

127-
const { GOV_TOOLS_URLS } = config();
128-
129127
return (
130128
<OutsideHandlesProvider
131129
{...{
@@ -175,7 +173,7 @@ export const MultiDelegationStakingPopup = (): JSX.Element => {
175173
sharedWalletKey: parentMultiSigAccount?.extendedAccountPublicKey,
176174
coSigners: wallet?.metadata?.coSigners,
177175
useRewardAccountsData,
178-
govToolUrl: GOV_TOOLS_URLS[environmentName],
176+
votingCenterUrl: walletRoutePaths.voting,
179177
parseError
180178
}}
181179
>

apps/browser-extension-wallet/src/features/voting-beta/components/Voting.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { PostHogAction } from '@providers/AnalyticsProvider/analyticsTracker';
1010
export const Voting = (): React.ReactElement => {
1111
const openExternalLink = useExternalLinkOpener();
1212
const { environmentName } = useWalletStore();
13-
const { GOV_TOOLS_URLS } = config();
13+
const { GOV_TOOLS_URLS, TEMPO_VOTE_URLS } = config();
1414
const analytics = useAnalyticsContext();
1515

1616
const openLink = useCallback(
@@ -26,7 +26,12 @@ export const Voting = (): React.ReactElement => {
2626
<ContentLayout>
2727
<div className={styles.activitiesContainer}>
2828
<div className={styles.emptyState}>
29-
<VotingCenterBanner openExternalLink={openLink} govToolUrl={GOV_TOOLS_URLS[environmentName]} popupView />
29+
<VotingCenterBanner
30+
openExternalLink={openLink}
31+
govToolUrl={GOV_TOOLS_URLS[environmentName]}
32+
tempoVoteUrl={TEMPO_VOTE_URLS[environmentName]}
33+
popupView
34+
/>
3035
</div>
3136
</div>
3237
</ContentLayout>

apps/browser-extension-wallet/src/views/browser-view/features/staking/components/Staking.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import { useObservable } from '@lace/common';
2424
import { fetchPoolsInfo } from '../utils';
2525
import { Box } from '@input-output-hk/lace-ui-toolkit';
2626
import { useExternalLinkOpener } from '@providers';
27-
import { config } from '@src/config';
2827
import { useRewardAccountsData } from '../hooks';
28+
import { walletRoutePaths } from '@routes';
2929

3030
const stepsWithExitConfirmation = new Set([Sections.CONFIRMATION, Sections.SIGN, Sections.FAIL_TX]);
3131

@@ -41,8 +41,7 @@ export const Staking = (): React.ReactElement => {
4141
blockchainProvider,
4242
walletInfo,
4343
inMemoryWallet,
44-
walletUI: { cardanoCoin },
45-
environmentName
44+
walletUI: { cardanoCoin }
4645
} = useWalletStore();
4746
const { fetchStakePools } = useWalletStore(stakePoolResultsSelector);
4847
const { priceResult } = useFetchCoinPrice();
@@ -68,7 +67,6 @@ export const Staking = (): React.ReactElement => {
6867

6968
const { areAllRegisteredStakeKeysWithoutVotingDelegation, poolIdToRewardAccountsMap } = useRewardAccountsData();
7069
const showRegisterAsDRepBanner = !hasNoFunds && areAllRegisteredStakeKeysWithoutVotingDelegation;
71-
const { GOV_TOOLS_URLS } = config();
7270

7371
const openDelagationConfirmation = useCallback(() => {
7472
setSection();
@@ -119,7 +117,7 @@ export const Staking = (): React.ReactElement => {
119117
<>
120118
{showRegisterAsDRepBanner && (
121119
<Box mb="$56">
122-
<RegisterAsDRepBanner openExternalLink={openExternalLink} govToolUrl={GOV_TOOLS_URLS[environmentName]} />
120+
<RegisterAsDRepBanner openExternalLink={openExternalLink} votingCenterUrl={walletRoutePaths.voting} />
123121
</Box>
124122
)}
125123
<div>

apps/browser-extension-wallet/src/views/browser-view/features/staking/components/StakingContainer.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ import { useWalletActivities } from '@hooks/useWalletActivities';
2929
import { useSubmitingState } from '@views/browser/features/send-transaction';
3030
import { useSecrets, useSignPolicy } from '@lace/core';
3131
import { useRewardAccountsData } from '../hooks';
32-
import { config } from '@src/config';
3332
import { parseError } from '@src/utils/parse-error';
3433
import { useObservable } from '@lace/common';
3534
import { getParentWalletCIP1854Account } from '@lib/scripts/background/util';
35+
import { walletRoutePaths } from '@routes';
3636

3737
export const StakingContainer = (): React.ReactElement => {
3838
// TODO: LW-7575 Remove old staking in post-MVP of multi delegation staking.
@@ -111,7 +111,6 @@ export const StakingContainer = (): React.ReactElement => {
111111
const sharedWalletKey = parentMultiSigAccount?.extendedAccountPublicKey;
112112
const coSigners = wallet?.metadata?.coSigners;
113113
const signPolicy = useSignPolicy(wallet, 'staking');
114-
const { GOV_TOOLS_URLS } = config();
115114

116115
return (
117116
<Layout>
@@ -159,7 +158,7 @@ export const StakingContainer = (): React.ReactElement => {
159158
sharedWalletKey,
160159
coSigners,
161160
useRewardAccountsData,
162-
govToolUrl: GOV_TOOLS_URLS[environmentName],
161+
votingCenterUrl: walletRoutePaths.voting,
163162
parseError
164163
}}
165164
>

apps/browser-extension-wallet/src/views/browser-view/features/voting-beta/components/VotingCenterBanner/VotingCenterBanner.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-non-null-assertion */
2-
import { Box, Button, Flex } from '@input-output-hk/lace-ui-toolkit';
2+
import { Button, Flex } from '@input-output-hk/lace-ui-toolkit';
33
import cn from 'classnames';
44
import React from 'react';
55
import { Trans, useTranslation } from 'react-i18next';
@@ -11,9 +11,15 @@ type props = {
1111
popupView?: boolean;
1212
openExternalLink: (url: string) => void;
1313
govToolUrl: string;
14+
tempoVoteUrl: string;
1415
};
1516

16-
export const VotingCenterBanner = ({ popupView, openExternalLink, govToolUrl }: props): React.ReactElement => {
17+
export const VotingCenterBanner = ({
18+
popupView,
19+
openExternalLink,
20+
govToolUrl,
21+
tempoVoteUrl
22+
}: props): React.ReactElement => {
1723
const { t } = useTranslation();
1824
const btnWidth = popupView ? '$fill' : '$auto';
1925

@@ -36,14 +42,20 @@ export const VotingCenterBanner = ({ popupView, openExternalLink, govToolUrl }:
3642
/>
3743
)}
3844
</div>
39-
<Box w={btnWidth} mt="$20" h="$48">
45+
<Flex gap="$16" w={btnWidth} mt="$20" h="$48">
4046
<Button.CallToAction
4147
w={btnWidth}
4248
onClick={() => openExternalLink(govToolUrl)}
4349
data-testid="voting-center-gov-tool-button"
44-
label={t('browserView.voting-beta.modal.cta')}
50+
label={t('browserView.voting-beta.modal.govTool.cta')}
4551
/>
46-
</Box>
52+
<Button.CallToAction
53+
w={btnWidth}
54+
onClick={() => openExternalLink(tempoVoteUrl)}
55+
data-testid="voting-center-tempo-vote-button"
56+
label={t('browserView.voting-beta.modal.tempoVote.cta')}
57+
/>
58+
</Flex>
4759
</Flex>
4860
</div>
4961
);

0 commit comments

Comments
 (0)