Skip to content

Commit ac4c73c

Browse files
nikolaglumacjuan-ciericleverca22disassemblerTomislav Horaček
authored
[DDW-539, DDW-541] Fund3 voting registration (#2315)
* Create PinCode widget * Add containers for Catalyst voting * Add components for Catalyst voting info, add and create routes * Create voting config file and add routes to Sidebar * Add voting icon * Create voting store and add routes to sidebar store and config * Add voting themes styles * Add voting actions for VotingStore * Create PinCode validations * Create voting types file * Add english translations * Add chain-wallet-lib dependency for encryption and key generation * Use chain-wallet-libs plugin to generate a random key. Encrypt derived private key into a QR code. Create a transaction in Cardano Wallet Backend API and send the public key as metadata. Listen to transaction status until it is confirmed by the blockchain. * Display error message when a transaction fails * [VIT-395] Runs translation manager * [VIT-395] Fix builds * [VIT-395] Catalyst newsfeed, state dir and app name * [VIT-395] Fix theme * Add to filter log data votingKey from createVotingRegistrationTransaction * Add Catalyst voting steps Add voting assets Implement voting info view Refactor themes for implement alphabetical order * Fix lint and flow errors * Fix lint and flow errors in createVotingRegistrationTransaction method * Add comment for voting funds in ada * Add error messages to pin code using tooltip * [VIT-395] Updates cardano-wallet and fixes the smashURL handling issue * Refactor voting registration container to dialog Add new confirmation step Add getWalletKey request for stake_key Add createWalletSignature request for get signature key Update metadata for voting registration transaction * nuke mapping references in a new file * use testnet temporarily * cardano-wallet to latest master * Add wallet-js package from npm * Add request for get transaction detail by id * Parse Stake key using wallet-js method Parse signature response to hex and send transaction Handle JSON.parse errors in request util * Refactor formattedBytesToB16 helper * fix yarn.lock * Create new requestBinary for octet-stream responses Remove unused parsed methods * Refactor applying flow comments * fix darwin build * Fix pin code auto focus and update minimum amount of ADA for voting * Refactor applying flow comments * Updates Daedalus Catalyst icon * temporarily reduce wait time to 60 seconds * Add autofocus to repeat pin code * Revert "use testnet temporarily" This reverts commit 38e3d37. * Add Japanese translations * Add missing translations Update fill color to svg icons Add learn more link to step sign * Improve the id translation for learn more label and URL * Change minimum amount to vote from 8000 to 100 * Remove transform from PIN code to string * Manage Sign metadata errors * Show transaction error message Set to false closeOnOverlayClick in Voting Dialog * Improve focus pin code and manage global value in array * Update svg icons and theme colors * Increase threshold to 7950 ADA and timeout to 3600 seconds * cardano-wallet: udpate to latest stable release * Revert "Increase threshold to 7950 ADA and timeout to 3600 seconds" This reverts commit 3962d3b. * Remove interval for check transaction status Add observable boolean for set if transaction is approved Show error message if transaction status is not in_ledger Hide ITN rewards icon only for Catalyst Hide the delegation center menu for Catalyst * production limits of 7950 ada for voting threshold and 1 hour for tx confirmation * [DDW-541] Updates CHANGELOG * [DDW-541] Code cleanup * [DDW-541] Code cleanup * [DDW-541] Code cleanup * [DDW-541] Code cleanup * [DDW-541] Code cleanup * [DDW-541] Code improvements * [DDW-541] Code improvements * [DDW-541] Code improvements * [DDW-541] Fix bignumber errors * [DDW-541] Rename all components to Voting Registration namespace * [DDW-541] Voting namespace fixing, ordering of theming variables * [DDW-541] Code improvements * [DDW-541] Type improvements * [DDW-541] Code improvements * [DDW-541] Code cleanup * [DDW-541] Code improvements * add payment address to voter registration * fix lint errors * [DDW-541] Code improvements * [DDW-541] Adds HW check, Adds Byron check, Improves styling * [DDW-541] Introduce transaction confirmations * [DDW-541] Introduce Voting registration transaction confirmations check * [DDW-541] Code improvements * [DDW-541] Correctly handle octet-stream error responses * [DDW-541] Refactor steps handling * [DDW-541] Change the Dialog container approach * [DDW-541] Remove unecessary INTL messages * [DDW-541] Remove unecessary INTL component * [DDW-541] Dialog change - Step 2 * [DDW-541] Dialog change - Step 3 * [DDW-541] Dialog change - Step 4 * [DDW-541] Dialog change - Step 5 * [DDW-541] Remove lint errors * [DDW-541] Adjustment * [DDW-541] Expand ProgressBar component for light bg mode * [DDW-541] Storybook stories for all steps * [DDW-541] Voting info * [DDW-541] Flow and Lint issues * [DDW-541] Updates UI * [DDW-541] Adds back button * [DDW-541] Adds loading sceens for Staking/Voting/ITN-redemption * [DDW-541] Text copy update * [DDW-541] UI improvements * [DDW-541] Progress bar animated background * [DDW-541] Updates text copy and adds Japanese translations * [DDW-541] PDF generator * [DDW-541] PDF formatting adjustments * [DDW-541] Translation manager * [DDW-541] Adds Theming support * [DDW-541] Network name - centered and uppercase * [DDW-541] Animation glitches - alternative * [DDW-541] Fix PIN code entry, revert progress bar animation * [DDW-541] Increase poller interval to 5 sec * [DDW-541] Improve confirmation state * [DDW-541] JP translation * [DDW-541] Code improvements * [DDW-541] Updates cardano-wallet * [DDW-541] Adds border to mobile apps QR codes on dark themes * [DDW-541] Fix loading states * [DDW-541] Fixes wallet syncing state on voting dialog step 1 Co-authored-by: Juan Christian Cieri <jcieri@atixlabs.com> Co-authored-by: Michael Bishop <michael.bishop@iohk.io> Co-authored-by: Samuel Leathers <samuel.leathers@iohk.io> Co-authored-by: Tomislav Horaček <tomislav.horacek@thespian.hr> Co-authored-by: Danilo Prates <daniloprates@gmail.com>
1 parent 00525e5 commit ac4c73c

File tree

104 files changed

+5822
-280
lines changed

Some content is hidden

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

104 files changed

+5822
-280
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Changelog
22
=========
33

4-
## vNext
4+
## 3.3.0
55

66
### Features
77

8+
- Implemented Voting Centar ([PR 2315](https://github.com/input-output-hk/daedalus/pull/2315))
89
- Implemented transaction metadata display ([PR 2338](https://github.com/input-output-hk/daedalus/pull/2338))
910
- Displayed fee and deposit info in transaction details and in the delegation wizard ([PR 2339](https://github.com/input-output-hk/daedalus/pull/2339))
1011
- Added SMASH server configuration options ([PR 2259](https://github.com/input-output-hk/daedalus/pull/2259))

nix/sources.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"homepage": null,
3030
"owner": "input-output-hk",
3131
"repo": "cardano-wallet",
32-
"rev": "e82e58a9032627e2ae56e52d39cf303898b50f88",
33-
"sha256": "0xszv7k531p7jsragvhy5248ihni3alajzd5csjalpv28vd4j0sk",
32+
"rev": "2428be4709293733f75fc842d63a5a1944614dd7",
33+
"sha256": "0qyrlsn9aci3di5iw2j3sxcqrjfp284b0hswc2bh53b557g2mzj4",
3434
"type": "tarball",
35-
"url": "https://github.com/input-output-hk/cardano-wallet/archive/e82e58a9032627e2ae56e52d39cf303898b50f88.tar.gz",
35+
"url": "https://github.com/input-output-hk/cardano-wallet/archive/2428be4709293733f75fc842d63a5a1944614dd7.tar.gz",
3636
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
3737
"version": "v2021-01-28"
3838
},

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "daedalus",
33
"productName": "Daedalus",
4-
"version": "3.2.0",
4+
"version": "3.3.0",
55
"description": "Cryptocurrency Wallet",
66
"main": "./dist/main/index.js",
77
"scripts": {
@@ -173,6 +173,7 @@
173173
},
174174
"dependencies": {
175175
"@cardano-foundation/ledgerjs-hw-app-cardano": "2.1.0",
176+
"@iohk-jormungandr/wallet-js": "0.5.0-pre7",
176177
"aes-js": "3.1.2",
177178
"bignumber.js": "9.0.1",
178179
"bip39": "2.3.0",

source/common/ipc/api.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
SaveFileDialogResponseParams,
1212
} from '../types/file-dialog.types';
1313
import type { GenerateAddressPDFParams } from '../types/address-pdf-request.types';
14+
import type { GenerateVotingPDFParams } from '../types/voting-pdf-request.types';
1415
import type { GenerateCsvParams } from '../types/csv-request.types';
1516
import type { GenerateQRCodeParams } from '../types/save-qrCode.types';
1617
import type {
@@ -204,6 +205,13 @@ export const GENERATE_ADDRESS_PDF_CHANNEL = 'GENERATE_ADDRESS_PDF_CHANNEL';
204205
export type GenerateAddressPDFRendererRequest = GenerateAddressPDFParams;
205206
export type GenerateAddressPDFMainResponse = void;
206207

208+
/**
209+
* Channel to generate and save a share voting PDF
210+
*/
211+
export const GENERATE_VOTING_PDF_CHANNEL = 'GENERATE_VOTING_PDF_CHANNEL';
212+
export type GenerateVotingPDFRendererRequest = GenerateVotingPDFParams;
213+
export type GenerateVotingPDFMainResponse = void;
214+
207215
/**
208216
* Channel to generate and save a csv file
209217
*/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @flow
2+
export type GenerateVotingPDFParams = {
3+
title: string,
4+
currentLocale: string,
5+
creationDate: string,
6+
qrCode: string,
7+
walletNameLabel: string,
8+
walletName: string,
9+
isMainnet: boolean,
10+
networkLabel: string,
11+
networkName: string,
12+
filePath: string,
13+
author: string,
14+
};

source/common/utils/logging.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export const filterLogData = (data: Object): Object => {
2929
'recoveryPhrase',
3030
'passphrase',
3131
'password',
32+
'votingKey',
33+
'stakeKey',
34+
'signature',
3235
'accountPublicKey',
3336
'extendedPublicKey',
3437
'publicKeyHex',
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// @flow
2+
import fs from 'fs';
3+
import path from 'path';
4+
import PDFDocument from 'pdfkit';
5+
import qr from 'qr-image';
6+
import { MainIpcChannel } from './lib/MainIpcChannel';
7+
import { GENERATE_VOTING_PDF_CHANNEL } from '../../common/ipc/api';
8+
import type {
9+
GenerateVotingPDFRendererRequest,
10+
GenerateVotingPDFMainResponse,
11+
} from '../../common/ipc/api';
12+
import fontRegularEn from '../../common/assets/pdf/NotoSans-Regular.ttf';
13+
import fontMediumEn from '../../common/assets/pdf/NotoSans-Medium.ttf';
14+
import fontUnicode from '../../common/assets/pdf/arial-unicode.ttf';
15+
16+
export const generateVotingPDFChannel: // IpcChannel<Incoming, Outgoing>
17+
MainIpcChannel<
18+
GenerateVotingPDFRendererRequest,
19+
GenerateVotingPDFMainResponse
20+
> = new MainIpcChannel(GENERATE_VOTING_PDF_CHANNEL);
21+
22+
export const handleVotingPDFRequests = () => {
23+
generateVotingPDFChannel.onReceive(
24+
(request: GenerateVotingPDFRendererRequest) =>
25+
new Promise((resolve, reject) => {
26+
// Prepare params
27+
const {
28+
title,
29+
currentLocale,
30+
creationDate,
31+
qrCode,
32+
walletNameLabel,
33+
walletName,
34+
isMainnet,
35+
networkLabel,
36+
networkName,
37+
filePath,
38+
author,
39+
} = request;
40+
41+
const readAssetSync = (p) => fs.readFileSync(path.join(__dirname, p));
42+
let fontRegular;
43+
let fontMedium;
44+
45+
if (currentLocale === 'ja-JP') {
46+
fontRegular = fontUnicode;
47+
fontMedium = fontUnicode;
48+
} else {
49+
fontRegular = fontRegularEn;
50+
fontMedium = fontMediumEn;
51+
}
52+
53+
// Generate QR image for wallet voting
54+
const qrCodeImage = qr.imageSync(qrCode, {
55+
type: 'png',
56+
size: 10,
57+
ec_level: 'L',
58+
margin: 0,
59+
});
60+
61+
try {
62+
const fontBufferMedium = readAssetSync(fontMedium);
63+
const fontBufferRegular = readAssetSync(fontRegular);
64+
65+
const textColor = '#5e6066';
66+
const textColorRed = '#ea4c5b';
67+
const width = 640;
68+
const height = 450;
69+
const doc = new PDFDocument({
70+
size: [width, height],
71+
margins: {
72+
bottom: 20,
73+
left: 30,
74+
right: 30,
75+
top: 20,
76+
},
77+
info: {
78+
Title: title,
79+
Author: author,
80+
},
81+
}).fillColor(textColor);
82+
83+
// Title
84+
doc.font(fontBufferMedium).fontSize(18).text(title.toUpperCase(), {
85+
align: 'center',
86+
characterSpacing: 2,
87+
});
88+
89+
// Creation date
90+
doc
91+
.font(fontBufferRegular)
92+
.fontSize(12)
93+
.text(creationDate.toUpperCase(), {
94+
align: 'center',
95+
characterSpacing: 0.6,
96+
});
97+
98+
doc.moveDown();
99+
100+
// QR Code
101+
doc.image(qrCodeImage, {
102+
fit: [width - 60, 192],
103+
align: 'center',
104+
});
105+
106+
doc.moveDown();
107+
108+
// Wallet name
109+
doc.font(fontBufferMedium).fontSize(14).text(walletNameLabel, {
110+
align: 'center',
111+
characterSpacing: 0.6,
112+
});
113+
doc.font(fontBufferRegular).text(walletName, {
114+
align: 'center',
115+
characterSpacing: 0.6,
116+
});
117+
118+
doc.moveDown();
119+
120+
// Footer
121+
if (!isMainnet) {
122+
doc
123+
.fontSize(12)
124+
.font(fontBufferMedium)
125+
.fillColor(textColorRed)
126+
.text(`${networkLabel} ${networkName}`, {
127+
align: 'center',
128+
});
129+
}
130+
131+
// Write file to disk
132+
const writeStream = fs.createWriteStream(filePath);
133+
doc.pipe(writeStream);
134+
doc.end();
135+
writeStream.on('close', resolve);
136+
writeStream.on('error', reject);
137+
} catch (error) {
138+
reject(error);
139+
}
140+
})
141+
);
142+
};

source/main/ipc/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { handleBugReportRequests } from './bugReportRequestChannel';
1414
import { handleFileMetaRequests } from './generateFileMetaChannel';
1515
import { handlePaperWalletRequests } from './generatePaperWalletChannel';
1616
import { handleAddressPDFRequests } from './generateAddressPDFChannel';
17+
import { handleVotingPDFRequests } from './generateVotingPDFChannel';
1718
import { saveQRCodeImageRequests } from './saveQRCodeImageChannel';
1819
import { handleRewardsCsvRequests } from './generateCsvChannel';
1920
import { handleFileDialogRequests } from './show-file-dialog-channels';
@@ -33,6 +34,7 @@ export default (window: BrowserWindow) => {
3334
handleFileMetaRequests();
3435
handlePaperWalletRequests();
3536
handleAddressPDFRequests();
37+
handleVotingPDFRequests();
3638
saveQRCodeImageRequests();
3739
handleRewardsCsvRequests();
3840
handleFileDialogRequests(window);

source/main/windows/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const createMainWindow = (locale: string) => {
130130
});
131131

132132
window.webContents.on('did-finish-load', () => {
133-
if (isTest) {
133+
if (isTest || isDev) {
134134
window.showInactive(); // show without focusing the window
135135
} else {
136136
window.show(); // show also focuses the window

source/renderer/app/Routes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import WalletReceivePage from './containers/wallet/WalletReceivePage';
3131
import WalletTransactionsPage from './containers/wallet/WalletTransactionsPage';
3232
import WalletSettingsPage from './containers/wallet/WalletSettingsPage';
3333
import WalletUtxoPage from './containers/wallet/WalletUtxoPage';
34+
import VotingRegistrationPage from './containers/voting/VotingRegistrationPage';
3435

3536
export const Routes = withRouter(() => (
3637
<Route path={ROUTES.ROOT}>
@@ -144,6 +145,10 @@ export const Routes = withRouter(() => (
144145
component={RedeemItnRewardsContainer}
145146
/>
146147
</Route>
148+
<Route
149+
path={ROUTES.VOTING.REGISTRATION}
150+
component={VotingRegistrationPage}
151+
/>
147152
</Switch>
148153
</Root>
149154
</Route>

0 commit comments

Comments
 (0)