Skip to content

Commit

Permalink
Merge pull request input-output-hk#3031 from input-output-hk/fix/ddw-…
Browse files Browse the repository at this point in the history
…1134-fix-catalyst-registration-hw

[DDW-1134] Fix Catalyst registration with hardware wallets
  • Loading branch information
danielmain authored Aug 31, 2022
2 parents 0b49b33 + 0f54666 commit 18d103f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ class VotingRegistrationDialogContainer extends Component<Props, State> {
const { calculateTransactionFee } = transactions;
const { getAddressesByWalletId } = addresses;
const { getWalletById } = wallets;
const { selectCoins, initiateTransaction } = hardwareWallets;
const {
selectCoins,
initiateTransaction,
updateTxSignRequest,
} = hardwareWallets;
const { prepareVotingData } = voting;
const amount = formattedAmountToLovelace(
`${VOTING_REGISTRATION_FEE_CALCULATION_AMOUNT}`
Expand All @@ -276,12 +280,15 @@ class VotingRegistrationDialogContainer extends Component<Props, State> {
votingData = await prepareVotingData({
walletId: this.selectedWalletId,
});
({ fee } = await selectCoins({
const coinSelection = await selectCoins({
walletId: this.selectedWalletId,
address: address.id,
amount,
metadata: votingData.metadata,
}));
});

updateTxSignRequest(coinSelection);
fee = coinSelection.fee;
} else {
({ fee } = await calculateTransactionFee({
walletId: this.selectedWalletId,
Expand Down
8 changes: 4 additions & 4 deletions source/renderer/app/i18n/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@
"environment.network.alonzo_purple": "Alonzo Purple",
"environment.network.development": "開発",
"environment.network.mainnet": "メインネット",
"environment.network.preprod": "Pre-Prod",
"environment.network.preview": "Preview",
"environment.network.preprod": "プリプロ",
"environment.network.preview": "プレビュー",
"environment.network.selfnode": "Selfnode",
"environment.network.shelley_qa": "Shelley QA",
"environment.network.staging": "ステージング",
Expand Down Expand Up @@ -682,8 +682,8 @@
"test.environment.daedalusFlightLabel": "Cardano Mainnet - Daedalus Flight",
"test.environment.developmentLabel": "開発",
"test.environment.mainnetLabel": "メインネット",
"test.environment.preprodLabel": "Pre-Prod",
"test.environment.previewLabel": "Preview",
"test.environment.preprodLabel": "プリプロ",
"test.environment.previewLabel": "プレビュー",
"test.environment.selfnodeLabel": "Selfnode",
"test.environment.shelleyQaLabel": "Shelley QA",
"test.environment.stagingLabel": "ステージング",
Expand Down
37 changes: 19 additions & 18 deletions source/renderer/app/stores/VotingStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import { formattedArrayBufferToHexString } from '../utils/formatters';
import walletUtils from '../utils/walletUtils';
import {
VOTING_PHASE_CHECK_INTERVAL,
VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL,
VOTING_REGISTRATION_MIN_TRANSACTION_CONFIRMATIONS,
VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL,
} from '../config/votingConfig';
import { votingPDFGenerator } from '../utils/votingPDFGenerator';
import {
votingPDFGenerator,
VotingPDFGeneratorResult,
} from '../utils/votingPDFGenerator';
import { i18nContext } from '../utils/i18nContext';
import type { PathRoleIdentityType } from '../utils/hardwareWalletUtils';
import type {
Expand Down Expand Up @@ -423,23 +426,21 @@ export default class VotingStore extends Store {
const { network, isMainnet } = this.environment;
const intl = i18nContext(currentLocale);

try {
await votingPDFGenerator({
nextVotingFundNumber,
qrCode,
walletName,
currentLocale,
currentDateFormat,
currentTimeFormat,
desktopDirectoryPath,
network,
isMainnet,
intl,
});
// @ts-ignore ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
const result = await votingPDFGenerator({
nextVotingFundNumber,
qrCode,
walletName,
currentLocale,
currentDateFormat,
currentTimeFormat,
desktopDirectoryPath,
network,
isMainnet,
intl,
});

if (result === VotingPDFGeneratorResult.FileSaved) {
this.actions.voting.saveAsPDFSuccess.trigger();
} catch (error) {
throw new Error(error);
}
};
_checkVotingRegistrationTransaction = async () => {
Expand Down
16 changes: 15 additions & 1 deletion source/renderer/app/utils/votingPDFGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const messages = defineMessages({
description: 'PDF author',
},
});

type Params = {
nextVotingFundNumber: number;
qrCode: string;
Expand All @@ -46,6 +47,12 @@ type Params = {
isMainnet: boolean;
intl: Record<string, any>;
};

export enum VotingPDFGeneratorResult {
FileSaved = 'FileSaved',
CancelledByUser = 'CancelledByUser',
}

export const votingPDFGenerator = async ({
nextVotingFundNumber,
qrCode,
Expand All @@ -57,7 +64,7 @@ export const votingPDFGenerator = async ({
network,
isMainnet,
intl,
}: Params) => {
}: Params): Promise<VotingPDFGeneratorResult> => {
// Consolidate data
const title = intl.formatMessage(messages.title, {
nextVotingFundNumber,
Expand Down Expand Up @@ -93,6 +100,11 @@ export const votingPDFGenerator = async ({
};
const dialogPath = await showSaveDialogChannel.send(params);
const filePath = dialogPath.filePath || '';

if (dialogPath.canceled || !filePath) {
return VotingPDFGeneratorResult.CancelledByUser;
}

await generateVotingPDFChannel.send({
title,
currentLocale,
Expand All @@ -106,4 +118,6 @@ export const votingPDFGenerator = async ({
filePath,
author,
});

return VotingPDFGeneratorResult.FileSaved;
};

0 comments on commit 18d103f

Please sign in to comment.