Skip to content

Commit 4c86612

Browse files
Lucasdanielmain
andauthored
[DDW-675] Catalyst dynamic content (#2856)
Co-authored-by: Daniel Main <[email protected]>
1 parent 2a37312 commit 4c86612

36 files changed

+580
-317
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
## vNext
44

55
### Features
6+
67
- Improved stake pool searchbar ([PR 2847](https://github.com/input-output-hk/daedalus/pull/2847))
8+
- Implemented catalyst dynamic content ([PR 2856](https://github.com/input-output-hk/daedalus/pull/2856))
79

810
## 4.9.0-FC1
911

source/renderer/app/api/api.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { getPublicKey } from './transactions/requests/getPublicKey';
4040
import { getICOPublicKey } from './transactions/requests/getICOPublicKey';
4141
// Voting requests
4242
import { createWalletSignature } from './voting/requests/createWalletSignature';
43+
import { getCatalystFund } from './voting/requests/getCatalystFund';
4344
// Wallets requests
4445
import { updateSpendingPassword } from './wallets/requests/updateSpendingPassword';
4546
import { updateByronSpendingPassword } from './wallets/requests/updateByronSpendingPassword';
@@ -204,6 +205,8 @@ import type {
204205
import type {
205206
CreateVotingRegistrationRequest,
206207
CreateWalletSignatureRequest,
208+
GetCatalystFundResponse,
209+
CatalystFund,
207210
} from './voting/types';
208211
import type { StakePoolProps } from '../domains/StakePool';
209212
import type { FaultInjectionIpcRequest } from '../../../common/types/cardano-node.types';
@@ -2931,6 +2934,42 @@ export default class AdaApi {
29312934
fakeStakePoolsJson: Array<StakePool>
29322935
) => void;
29332936
setStakePoolsFetchingFailed: () => void;
2937+
getCatalystFund = async (): Promise<CatalystFund> => {
2938+
logger.debug('AdaApi::getCatalystFund called', {});
2939+
2940+
try {
2941+
const catalystFund = await getCatalystFund();
2942+
2943+
logger.debug('AdaApi::getCatalystFund success', {
2944+
catalystFund,
2945+
});
2946+
2947+
return {
2948+
current: {
2949+
number: catalystFund.id + 1,
2950+
startTime: new Date(catalystFund.fund_start_time),
2951+
endTime: new Date(catalystFund.fund_end_time),
2952+
resultsTime: new Date(
2953+
catalystFund.chain_vote_plans?.[0]?.chain_committee_end_time
2954+
),
2955+
registrationSnapshotTime: new Date(
2956+
catalystFund.registration_snapshot_time
2957+
),
2958+
},
2959+
next: {
2960+
number: catalystFund.id + 2,
2961+
startTime: new Date(catalystFund.next_fund_start_time),
2962+
registrationSnapshotTime: new Date(
2963+
catalystFund.next_registration_snapshot_time
2964+
),
2965+
},
2966+
};
2967+
} catch (error) {
2968+
logger.error('AdaApi::getCatalystFund error', {
2969+
error,
2970+
});
2971+
}
2972+
};
29342973
} // ========== TRANSFORM SERVER DATA INTO FRONTEND MODELS =========
29352974

29362975
const _createWalletFromServerData = action(
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { externalRequest } from '../../utils/externalRequest';
2+
import { MAINNET_SERVICING_STATION_URL } from '../../../config/urlsConfig';
3+
import { GetCatalystFundResponse } from '../types';
4+
5+
export const getCatalystFund = (): Promise<GetCatalystFundResponse> =>
6+
externalRequest({
7+
hostname: MAINNET_SERVICING_STATION_URL,
8+
path: '/api/v0/fund',
9+
method: 'GET',
10+
protocol: 'https',
11+
});

source/renderer/app/api/voting/types.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,29 @@ export type SignatureParams = {
2727
passphrase: string;
2828
};
2929
};
30+
export type GetCatalystFundResponse = {
31+
id: number;
32+
fund_end_time: string;
33+
fund_name: string;
34+
fund_start_time: string;
35+
next_fund_start_time: string;
36+
next_registration_snapshot_time: string;
37+
registration_snapshot_time: string;
38+
chain_vote_plans: Array<{
39+
chain_committee_end_time: string;
40+
}>;
41+
};
42+
export type CatalystFund = {
43+
current: {
44+
number: number;
45+
startTime: Date;
46+
endTime: Date;
47+
resultsTime: Date;
48+
registrationSnapshotTime: Date;
49+
};
50+
next: {
51+
number: number;
52+
startTime: Date;
53+
registrationSnapshotTime: Date;
54+
};
55+
};

source/renderer/app/components/voting/VotingNoWallets.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { ButtonSkin } from 'react-polymorph/lib/skins/simple/ButtonSkin';
88
import styles from './VotingNoWallets.scss';
99
// @ts-ignore ts-migrate(2307) FIXME: Cannot find module '../../assets/images/attention-... Remove this comment to see the full error message
1010
import icon from '../../assets/images/attention-big-thin.inline.svg';
11-
import { NEXT_VOTING_FUND_NUMBER } from '../../config/votingConfig';
1211

1312
const messages = defineMessages({
1413
headLine: {
@@ -33,6 +32,7 @@ const messages = defineMessages({
3332
type Props = {
3433
onGoToCreateWalletClick: (...args: Array<any>) => any;
3534
minVotingFunds: number;
35+
nextFundNumber: number;
3636
};
3737
export default class VotingNoWallets extends Component<Props> {
3838
static contextTypes = {
@@ -41,13 +41,17 @@ export default class VotingNoWallets extends Component<Props> {
4141

4242
render() {
4343
const { intl } = this.context;
44-
const { onGoToCreateWalletClick, minVotingFunds } = this.props;
44+
const {
45+
onGoToCreateWalletClick,
46+
minVotingFunds,
47+
nextFundNumber,
48+
} = this.props;
4549
return (
4650
<div className={styles.component}>
4751
<SVGInline svg={icon} className={styles.icon} />
4852
<h1>
4953
{intl.formatMessage(messages.headLine, {
50-
nextVotingFundNumber: NEXT_VOTING_FUND_NUMBER,
54+
nextVotingFundNumber: nextFundNumber,
5155
})}
5256
</h1>
5357
<p>

source/renderer/app/components/voting/VotingRegistrationDialogWizard.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Props = {
4242
onRestart: (...args: Array<any>) => any;
4343
onExternalLinkClick: (...args: Array<any>) => any;
4444
hwDeviceStatus: HwDeviceStatus;
45+
nextFundNumber: number;
4546
};
4647

4748
@observer
@@ -75,6 +76,7 @@ class VotingRegistrationDialogWizard extends Component<Props> {
7576
hwDeviceStatus,
7677
isTrezor,
7778
isHardwareWallet,
79+
nextFundNumber,
7880
} = this.props;
7981
const selectedWalletId = get(selectedWallet, 'id', null);
8082
let content = null;
@@ -93,6 +95,7 @@ class VotingRegistrationDialogWizard extends Component<Props> {
9395
onSelectWallet={onSelectWallet}
9496
isWalletAcceptable={isWalletAcceptable}
9597
getStakePoolById={getStakePoolById}
98+
nextFundNumber={nextFundNumber}
9699
/>
97100
);
98101
break;
@@ -114,6 +117,7 @@ class VotingRegistrationDialogWizard extends Component<Props> {
114117
selectedWallet={selectedWallet}
115118
isTrezor={isTrezor}
116119
isHardwareWallet={isHardwareWallet}
120+
nextFundNumber={nextFundNumber}
117121
/>
118122
);
119123
break;
@@ -130,6 +134,7 @@ class VotingRegistrationDialogWizard extends Component<Props> {
130134
transactionError={transactionError}
131135
onConfirm={onContinue}
132136
onRestart={onRestart}
137+
nextFundNumber={nextFundNumber}
133138
/>
134139
);
135140
break;
@@ -141,6 +146,7 @@ class VotingRegistrationDialogWizard extends Component<Props> {
141146
onClose={onClose}
142147
stepsList={stepsList}
143148
activeStep={activeStep}
149+
nextFundNumber={nextFundNumber}
144150
/>
145151
);
146152
break;
@@ -153,6 +159,7 @@ class VotingRegistrationDialogWizard extends Component<Props> {
153159
onDownloadPDF={onDownloadPDF}
154160
stepsList={stepsList}
155161
activeStep={activeStep}
162+
nextFundNumber={nextFundNumber}
156163
/>
157164
);
158165
break;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineMessages } from 'react-intl';
2+
3+
export const messages = defineMessages({
4+
title: {
5+
id: 'voting.apiError.title',
6+
defaultMessage: '!!!Catalyst API unavailable',
7+
description: 'Title',
8+
},
9+
description1: {
10+
id: 'voting.apiError.description1',
11+
defaultMessage:
12+
'!!!Unable to communicate with the API that retrieves the Catalyst date information.',
13+
description: 'Description 1',
14+
},
15+
description2: {
16+
id: 'voting.apiError.description2',
17+
defaultMessage: '!!!Please, try again later.',
18+
description: 'Description 2',
19+
},
20+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@import '../votingConfig';
2+
3+
.root {
4+
@extend %regularText;
5+
align-items: start;
6+
background-color: var(--theme-button-flat-background-color);
7+
border-radius: 5px;
8+
color: var(--theme-button-flat-text-color);
9+
display: flex;
10+
flex-direction: column;
11+
padding: 20px;
12+
width: 100%;
13+
14+
.title {
15+
font-family: var(--font-semibold);
16+
font-size: 18px;
17+
line-height: 1.33;
18+
margin-bottom: 11px;
19+
}
20+
21+
.description2 {
22+
font-family: var(--font-medium);
23+
}
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { injectIntl } from 'react-intl';
3+
import type { Intl } from '../../../types/i18nTypes';
4+
import styles from './ApiError.scss';
5+
import { messages } from './ApiError.messages';
6+
7+
type Props = {
8+
intl: Intl;
9+
};
10+
11+
function ApiError({ intl }: Props) {
12+
return (
13+
<section className={styles.root}>
14+
<h1 className={styles.title}>{intl.formatMessage(messages.title)}</h1>
15+
<span className={styles.description1}>
16+
{intl.formatMessage(messages.description1)}
17+
</span>
18+
<span className={styles.description2}>
19+
{intl.formatMessage(messages.description2)}
20+
</span>
21+
</section>
22+
);
23+
}
24+
25+
export default injectIntl(ApiError);

source/renderer/app/components/voting/voting-info/CurrentPhase.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
.fundName {
1414
color: var(--theme-button-flat-text-color);
15-
font-family: var(--font-bold);
15+
font-family: var(--font-semibold);
1616
font-size: 18px;
1717
line-height: 1.33;
1818
margin-bottom: 11px;

0 commit comments

Comments
 (0)