Skip to content

Commit ba63f08

Browse files
DominikGuzeiszymonmaslowskiprzemyslaw-wlodek
authored
feat: add governance voting tab [LW-11519] (#3240)
* feat: Add navigation with governance to voting page [LW-11519] * feat: add delegate votes API call and integrate it with mobx voting store * feat: Add governance voting form [LW-11519] * feat: voting power delegation confirmation dialog * chore: Add changelog entry [LW-11519] * feat: useconstructTx endpoint to calculate fee and for HWs, fix validation in form, improve styling * feat: Recognize and style voting transactions [LW-11519] * feat: redirect the user to the wallet of coice after successfull VP delegation * feat: add i18n to confirmation dialog and handle API error cases * feat: Track successfully casted votes [LW-11519] * feat: add final translations [LW-11519] * fix: Catch send error for staking conway wallets which have not registered voting rights yet [LW-11518] * feat: add HW support for VP delegation (#3243) * feat: add ledger support for VP delegation * feat: add trezor support for VP delegation --------- Signed-off-by: Dominik Guzei <[email protected]> Co-authored-by: Szymon Masłowski <[email protected]> Co-authored-by: Przemysław Włodek <[email protected]>
1 parent a852174 commit ba63f08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2113
-153
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

33
## vNext
44

5+
### Features
6+
7+
- Added Cardano governance voting tab ([PR 3240](https://github.com/input-output-hk/daedalus/pull/3240))
8+
59
### Chores
610

711
- Update `cardano-node` to 10.1.2 via `cardano-wallet` v2024-11-18 ([PR 3229](https://github.com/input-output-hk/daedalus/pull/3229))
812

13+
### Fixes
14+
15+
- Handle createTransaction error when Conway era wallet has staking rewards but has not participated in governance yet ([PR 3237](https://github.com/input-output-hk/daedalus/pull/3237)
16+
917
## 6.0.2
1018

1119
### Fixes
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { bech32, Decoded } from 'bech32';
2+
3+
const MAX_BECH32_LENGTH_LIMIT = 1023;
4+
5+
const isOneOf = <T>(target: T, options: T | T[]) =>
6+
(Array.isArray(options) && options.includes(target)) || target === options;
7+
8+
export const assertIsBech32WithPrefix = (
9+
target: string,
10+
prefix: string | string[],
11+
expectedDecodedLength?: number | number[]
12+
): void => {
13+
let decoded: Decoded;
14+
try {
15+
decoded = bech32.decode(target, MAX_BECH32_LENGTH_LIMIT);
16+
} catch (error) {
17+
throw new Error(
18+
`expected bech32-encoded string with '${prefix}' prefix; ${error}`
19+
);
20+
}
21+
if (!isOneOf(decoded.prefix, prefix)) {
22+
throw new Error(
23+
`expected bech32 prefix '${prefix}', got '${decoded.prefix}''`
24+
);
25+
}
26+
if (
27+
expectedDecodedLength &&
28+
!isOneOf(decoded.words.length, expectedDecodedLength)
29+
) {
30+
throw new Error(
31+
`expected decoded length of '${expectedDecodedLength}', got '${decoded.words.length}'`
32+
);
33+
}
34+
};

source/renderer/app/Routes.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import VotingRegistrationPage from './containers/voting/VotingRegistrationPage';
3636
import { IS_STAKING_INFO_PAGE_AVAILABLE } from './config/stakingConfig';
3737
import AnalyticsConsentPage from './containers/profile/AnalyticsConsentPage';
3838
import TrackedRoute from './analytics/TrackedRoute';
39+
import Voting from './containers/voting/Voting';
40+
import VotingGovernancePage from './containers/voting/VotingGovernancePage';
3941

4042
export const Routes = withRouter(() => (
4143
<Route path={ROUTES.ROOT}>
@@ -205,11 +207,20 @@ export const Routes = withRouter(() => (
205207
component={RedeemItnRewardsContainer}
206208
/>
207209
</Route>
208-
<TrackedRoute
209-
pageTitle="Voting Registration"
210-
path={ROUTES.VOTING.REGISTRATION}
211-
component={VotingRegistrationPage}
212-
/>
210+
<Route path={ROUTES.VOTING.ROOT}>
211+
<Voting>
212+
<TrackedRoute
213+
pageTitle="Voting Registration"
214+
path={ROUTES.VOTING.REGISTRATION}
215+
component={VotingRegistrationPage}
216+
/>
217+
<TrackedRoute
218+
pageTitle="Voting Governance"
219+
path={ROUTES.VOTING.GOVERNANCE}
220+
component={VotingGovernancePage}
221+
/>
222+
</Voting>
223+
</Route>
213224
</Switch>
214225
</Root>
215226
</Route>

source/renderer/app/analytics/MatomoAnalyticsTracker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export class MatomoAnalyticsTracker implements AnalyticsTracker {
3434
return this.#analyticsClient.sendPageNavigationEvent(pageTitle);
3535
}
3636

37-
sendEvent(category: string, name: string, action?: string) {
38-
return this.#analyticsClient.sendEvent(category, name, action);
37+
sendEvent(category: string, name: string, action?: string, value?: number) {
38+
return this.#analyticsClient.sendEvent(category, name, action, value);
3939
}
4040

4141
async #enableTrackingIfAccepted() {

source/renderer/app/analytics/MatomoClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ export class MatomoClient implements AnalyticsClient {
4444
sendEvent = async (
4545
category: string,
4646
action: string,
47-
name?: string
47+
name?: string,
48+
value?: number
4849
): Promise<void> => {
4950
this.matomoTracker.track({
5051
_id: this.userId,
5152
ca: 1,
5253
e_c: category,
5354
e_a: action,
5455
e_n: name,
56+
e_v: value,
5557
url: this.getAnalyticsURL(),
5658
});
5759
};

source/renderer/app/analytics/types.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
export interface AnalyticsClient {
22
sendPageNavigationEvent(pageTitle: string): Promise<void>;
3-
sendEvent(category: string, action: string, name?: string): Promise<void>;
3+
sendEvent(
4+
category: string,
5+
action: string,
6+
name?: string,
7+
value?: number
8+
): Promise<void>;
49
}
510

611
export enum AnalyticsAcceptanceStatus {
@@ -13,7 +18,12 @@ export interface AnalyticsTracker {
1318
enableTracking(): Promise<void>;
1419
disableTracking(): void;
1520
sendPageNavigationEvent(pageTitle: string): void;
16-
sendEvent(category: EventCategories, name: string, action?: string): void;
21+
sendEvent(
22+
category: EventCategories,
23+
name: string,
24+
action?: string,
25+
value?: number
26+
): void;
1727
}
1828

1929
export enum EventCategories {

0 commit comments

Comments
 (0)