Skip to content

Commit

Permalink
fixup! feat: add i18n to confirmation dialog and handle API error cases
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Guzei <[email protected]>
  • Loading branch information
DominikGuzei authored and szymonmaslowski committed Nov 22, 2024
1 parent 77d6afb commit 25cf89e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,9 @@ export const messages = defineMessages({
defaultMessage: '!!!Chosen same value as previously',
description: 'Chosen same value as previously',
},
initializeNotEnoughMoney: {
id: 'voting.governance.initializeTxError.notEnoughMoney',
defaultMessage: '!!!Not enough funds',
description: 'Governance voting error when wallet has not enough funds',
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ const mapOfTxErrorCodeToIntl: Record<
> = {
generic: messages.initializeTxErrorGeneric,
same_vote: messages.initializeTxErrorSameVote,
no_utxos_available: messages.initializeNotEnoughMoney,
not_enough_money: messages.initializeNotEnoughMoney,
};

function VotingPowerDelegation({
Expand Down
5 changes: 5 additions & 0 deletions source/renderer/app/i18n/locales/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4470,6 +4470,11 @@
"defaultMessage": "!!!Chosen same value as previously",
"description": "Chosen same value as previously",
"id": "voting.governance.initializeTxError.sameVote"
},
{
"defaultMessage": "!!!Not enough funds",
"description": "Governance voting error when wallet has not enough funds",
"id": "voting.governance.initializeTxError.notEnoughMoney"
}
],
"path": "source/renderer/app/components/voting/voting-governance/VotingPowerDelegation.messages.ts"
Expand Down
1 change: 1 addition & 0 deletions source/renderer/app/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
"voting.governance.drepInputPlaceholder": "Paste DRep ID here …",
"voting.governance.heading": "CARDANO VOTING POWER DELEGATION",
"voting.governance.initializeTxError.generic": "Something went wrong during transaction initialization. Please try again in a few minutes. ",
"voting.governance.initializeTxError.notEnoughMoney": "This wallet does not contain the minimum required amount of 1 ADA. The wallet might still be syncing. Please choose another wallet to vote.",
"voting.governance.initializeTxError.sameVote": "This voting power delegation choice has already been successfully recorded in a previous transaction. Please change the registration type or DRep ID in order to proceed.",
"voting.governance.learnMoreLinkLabel": "Cardano Governance.",
"voting.governance.noConfidence": "No Confidence",
Expand Down
1 change: 1 addition & 0 deletions source/renderer/app/i18n/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
"voting.governance.drepInputPlaceholder": "!!!Paste DRep ID here …",
"voting.governance.heading": "!!!CARDANO VOTING POWER DELEGATION",
"voting.governance.initializeTxError.generic": "!!!Could not initialize transaction. Please try again!",
"voting.governance.initializeTxError.notEnoughMoney": "!!!Not enough funds",
"voting.governance.initializeTxError.sameVote": "!!!Chosen same value as previously",
"voting.governance.learnMoreLinkLabel": "!!!Governance link label",
"voting.governance.noConfidence": "!!!No Confidence",
Expand Down
6 changes: 5 additions & 1 deletion source/renderer/app/stores/VotingStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ type GenericErrorCode = 'generic';
export type InitializeVPDelegationTxError =
| GenericErrorCode
| typeof expectedInitializeVPDelegationTxErrors[number];
export const expectedInitializeVPDelegationTxErrors = ['same_vote'] as const;
export const expectedInitializeVPDelegationTxErrors = [
'same_vote',
'no_utxos_available',
'not_enough_money',
] as const;

export type DelegateVotesError =
| GenericErrorCode
Expand Down
5 changes: 5 additions & 0 deletions translations/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4470,6 +4470,11 @@
"defaultMessage": "!!!Chosen same value as previously",
"description": "Chosen same value as previously",
"id": "voting.governance.initializeTxError.sameVote"
},
{
"defaultMessage": "!!!Not enough funds",
"description": "Governance voting error when wallet has not enough funds",
"id": "voting.governance.initializeTxError.notEnoughMoney"
}
],
"path": "source/renderer/app/components/voting/voting-governance/VotingPowerDelegation.messages.ts"
Expand Down

0 comments on commit 25cf89e

Please sign in to comment.