Skip to content

Commit

Permalink
Merge pull request #3237 from input-output-hk/LW-11518-catch-errors-a…
Browse files Browse the repository at this point in the history
…nd-inform-user-of-the-need-to-register-voting-rights

fix: catch errors and inform user of the need to register voting rights [LW-11518]
  • Loading branch information
szymonmaslowski authored Nov 27, 2024
2 parents 2867056 + 58bcd21 commit 235216a
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

- Update `cardano-node` to 10.1.1 via `cardano-wallet` [`ba7d3340968`](https://github.com/cardano-foundation/cardano-wallet/commit/ba7d33409680f4e75ef260add8744dcf71f40a77) ([PR 3229](https://github.com/input-output-hk/daedalus/pull/3229))

### Fixes

- 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)

## 6.0.2

### Fixes
Expand Down
3 changes: 3 additions & 0 deletions source/renderer/app/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,9 @@ export default class AdaApi {
.set('wrongEncryptionPassphrase')
.where('code', 'bad_request')
.inc('message', 'passphrase is too short')
.set('conwayWalletNotDelegatedToDRep')
.where('code', 'created_invalid_transaction')
.inc('message', 'ConwayWdrlNotDelegatedToDRep')
.set('transactionIsTooBig', true, {
linkLabel: 'tooBigTransactionErrorLinkLabel',
linkURL: 'tooBigTransactionErrorLinkURL',
Expand Down
6 changes: 6 additions & 0 deletions source/renderer/app/api/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ export const messages = defineMessages({
description:
'"Balance after transaction would not leave enough ada in the wallet to support tokens remaining in wallet',
},
conwayWalletNotDelegatedToDRep: {
id: 'api.errors.conwayWalletNotDelegatedToDRep',
defaultMessage: '!!!conwayWalletNotDelegatedToDRep',
description:
'Error message shown when conway era wallet has staking rewards but has not participated in governance yet.',
},
});

type Balances = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ function View({
!isPasswordValid({
isHardwareWallet,
isValid: passphraseField.isValid,
}),
}) ||
!!error,
},
];

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 @@ -95,6 +95,11 @@
"defaultMessage": "!!!Insufficient funds to support tokens. You need at least an additional {adaAmount} ADA in your wallet to process this transaction.",
"description": "\"Balance after transaction would not leave enough ada in the wallet to support tokens remaining in wallet",
"id": "api.errors.NotEnoughFundsForTransactionFeesErrorWithTokens"
},
{
"defaultMessage": "!!!conwayWalletNotDelegatedToDRep",
"description": "Error message shown when conway era wallet has staking rewards but has not participated in governance yet.",
"id": "api.errors.conwayWalletNotDelegatedToDRep"
}
],
"path": "source/renderer/app/api/errors.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 @@ -34,6 +34,7 @@
"api.errors.WalletAlreadyImportedError": "Wallet you are trying to import already exists.",
"api.errors.WalletAlreadyRestoredError": "Wallet you are trying to restore already exists.",
"api.errors.WalletFileImportError": "Wallet could not be imported, please make sure you are providing a correct file.",
"api.errors.conwayWalletNotDelegatedToDRep": "Daedalus cannot process this transaction because of blocked staking rewards. To unblock your rewards go to the <a href=\"/#/voting/governance\">Cardano voting power delegation tab</a> and delegate your voting power",
"api.errors.inputsDepleted": "Your wallet contains only reward funds.<br />Please send at least 1 ADA to your wallet so that you can spend the funds.",
"api.errors.invalidAddress": "Please enter a valid address.",
"api.errors.invalidSmashServer": "This URL is not a valid SMASH server",
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 @@ -34,6 +34,7 @@
"api.errors.WalletAlreadyImportedError": "インポートしようとしているウォレットは既に存在します。",
"api.errors.WalletAlreadyRestoredError": "復元しようとしているウォレットは既に存在します。",
"api.errors.WalletFileImportError": "ウォレットをインポートできませんでした。有効なファイルを指定していることを確認してください。",
"api.errors.conwayWalletNotDelegatedToDRep": "ステーキング報酬がブロックされているため、このトランザクションを処理できません。報酬のブロックを解除するには、<a href=\"/#/voting/governance\">Cardano投票権の委任タブ</a>に移動し、投票権を委任してください。",
"api.errors.inputsDepleted": "このウォレットには報酬として得られた資金しか入っていません。<br />資金を使用するには1ADA以上をウォレットに入金してください。",
"api.errors.invalidAddress": "有効なアドレスを入力してください。",
"api.errors.invalidSmashServer": "このURLは有効なSMASHサーバーではありません",
Expand Down
8 changes: 7 additions & 1 deletion source/renderer/app/stores/WalletsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,12 @@ export default class WalletsStore extends Store {
: null;
const wallet = this.active;
if (!wallet) throw new Error('Active wallet required before sending.');
// @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message

/**
* Do not try to catch the request error here, its intended to throw
* a localized error created in app/api/api.ts
*/
// @ts-ignore
await this.sendMoneyRequest.execute({
address: receiver,
amount: parseInt(amount, 10),
Expand All @@ -847,6 +852,7 @@ export default class WalletsStore extends Store {
assets: formattedAssets,
hasAssetsRemainingAfterTransaction,
});
// The following code will not be executed if the request above fails
this.analytics.sendEvent(
EventCategories.WALLETS,
'Transaction made',
Expand Down
8 changes: 7 additions & 1 deletion storybook/stories/wallets/send/WalletSend.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import { NUMBER_OPTIONS } from '../../../../source/renderer/app/config/profileCo
import Wallet, {
HwDeviceStatuses,
} from '../../../../source/renderer/app/domains/Wallet';
import { messages } from '../../../../source/renderer/app/api/errors';
// Screens
import WalletSendForm from '../../../../source/renderer/app/components/wallet/WalletSendForm';
import type { WalletTokens } from '../../../../source/renderer/app/api/assets/types';
import { WalletSendConfirmationDialogView } from '../../../../source/renderer/app/containers/wallet/dialogs/send-confirmation/SendConfirmation.view';
import { noopAnalyticsTracker as analyticsTracker } from '../../../../source/renderer/app/analytics';
import LocalizableError from '../../../../source/renderer/app/i18n/LocalizableError';

const allAssets = [
generateAssetToken(
Expand Down Expand Up @@ -470,7 +472,11 @@ storiesOf('Wallets / Send', module)
isSubmitting={boolean('isSubmitting', false)}
isHardwareWallet={boolean('isHardwareWallet', false)}
formattedTotalAmount="21.000000"
error={null}
error={
new LocalizableError({
...messages.conwayWalletNotDelegatedToDRep,
})
}
onCancel={action('onCancel')}
onSubmitCb={action('onSubmitCb')}
onTermsCheckboxClick={action('onTermsCheckboxClick')}
Expand Down
5 changes: 5 additions & 0 deletions translations/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
"defaultMessage": "!!!Insufficient funds to support tokens. You need at least an additional {adaAmount} ADA in your wallet to process this transaction.",
"description": "\"Balance after transaction would not leave enough ada in the wallet to support tokens remaining in wallet",
"id": "api.errors.NotEnoughFundsForTransactionFeesErrorWithTokens"
},
{
"defaultMessage": "!!!conwayWalletNotDelegatedToDRep",
"description": "Error message shown when conway era wallet has staking rewards but has not participated in governance yet.",
"id": "api.errors.conwayWalletNotDelegatedToDRep"
}
],
"path": "source/renderer/app/api/errors.ts"
Expand Down

0 comments on commit 235216a

Please sign in to comment.