diff --git a/source/renderer/app/containers/voting/dialogs/VotingRegistrationDialogContainer.tsx b/source/renderer/app/containers/voting/dialogs/VotingRegistrationDialogContainer.tsx index bd60df2779..d9a2340417 100644 --- a/source/renderer/app/containers/voting/dialogs/VotingRegistrationDialogContainer.tsx +++ b/source/renderer/app/containers/voting/dialogs/VotingRegistrationDialogContainer.tsx @@ -255,7 +255,11 @@ class VotingRegistrationDialogContainer extends Component { 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}` @@ -276,12 +280,15 @@ class VotingRegistrationDialogContainer extends Component { 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, diff --git a/source/renderer/app/i18n/locales/ja-JP.json b/source/renderer/app/i18n/locales/ja-JP.json index 89cfce7aaa..773c7ed226 100755 --- a/source/renderer/app/i18n/locales/ja-JP.json +++ b/source/renderer/app/i18n/locales/ja-JP.json @@ -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": "ステージング", @@ -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": "ステージング", diff --git a/source/renderer/app/stores/VotingStore.ts b/source/renderer/app/stores/VotingStore.ts index 5ab01a9511..fcbb497998 100644 --- a/source/renderer/app/stores/VotingStore.ts +++ b/source/renderer/app/stores/VotingStore.ts @@ -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 { @@ -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 () => { diff --git a/source/renderer/app/utils/votingPDFGenerator.ts b/source/renderer/app/utils/votingPDFGenerator.ts index 0b710ba6f4..3f3c60567b 100644 --- a/source/renderer/app/utils/votingPDFGenerator.ts +++ b/source/renderer/app/utils/votingPDFGenerator.ts @@ -34,6 +34,7 @@ const messages = defineMessages({ description: 'PDF author', }, }); + type Params = { nextVotingFundNumber: number; qrCode: string; @@ -46,6 +47,12 @@ type Params = { isMainnet: boolean; intl: Record; }; + +export enum VotingPDFGeneratorResult { + FileSaved = 'FileSaved', + CancelledByUser = 'CancelledByUser', +} + export const votingPDFGenerator = async ({ nextVotingFundNumber, qrCode, @@ -57,7 +64,7 @@ export const votingPDFGenerator = async ({ network, isMainnet, intl, -}: Params) => { +}: Params): Promise => { // Consolidate data const title = intl.formatMessage(messages.title, { nextVotingFundNumber, @@ -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, @@ -106,4 +118,6 @@ export const votingPDFGenerator = async ({ filePath, author, }); + + return VotingPDFGeneratorResult.FileSaved; };