-
Notifications
You must be signed in to change notification settings - Fork 2
fix(stellar-wallet-snap): display transaction error message + skip security scanning when failed during the background validation in confirmation dialog #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e32b67b
fix: ongoing txn validation
stanleyyconsensys 9e5da31
chore: update change log
stanleyyconsensys 69ad6a5
Update refreshConfirmationContext.md
stanleyyconsensys e6a1a8d
chore: update test and code
stanleyyconsensys 5accae1
Update handler.ts
stanleyyconsensys 33d08db
fix: lint
stanleyyconsensys a94fe75
chore: update change log and readme
stanleyyconsensys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,21 @@ import { Networks } from '@stellar/stellar-sdk'; | |
| import { KnownCaip2ChainId } from '../../../api'; | ||
| import type { AssetMetadataService } from '../../../services/asset-metadata'; | ||
| import type { TransactionService } from '../../../services/transaction'; | ||
| import { | ||
| InsufficientBalanceException, | ||
| InsufficientBalanceToCoverBaseReserveException, | ||
| InsufficientBalanceToCoverFeeException, | ||
| InvalidAmountForCreateAccountException, | ||
| InvalidAssetForCreateAccountException, | ||
| RemoveTrustlineWithNonZeroBalanceException, | ||
| RequiresMemoException, | ||
| TransactionExpireException, | ||
| TransactionValidationException, | ||
| TrustlineExceedLimitException, | ||
| TrustlineNotAuthorizedException, | ||
| TrustlineNotFoundException, | ||
| UpdateTrustlineException, | ||
| } from '../../../services/transaction'; | ||
| import type { MockClassicOperation } from '../../../services/transaction/__mocks__/transaction.fixtures'; | ||
| import { buildMockClassicTransaction } from '../../../services/transaction/__mocks__/transaction.fixtures'; | ||
| import { FetchStatus } from '../../../ui/confirmation/api'; | ||
|
|
@@ -160,23 +175,93 @@ describe('ConfirmationTransactionRefresher', () => { | |
| transaction: transactionXdr, | ||
| }, | ||
| }, | ||
| reschedule: false, | ||
| reschedule: true, | ||
| }); | ||
| }); | ||
|
|
||
| it('marks the transaction invalid when re-validation throws', async () => { | ||
| const { refresher, transactionService } = setup(); | ||
| transactionService.createValidatedSendTransaction.mockRejectedValueOnce( | ||
| new Error('insufficient balance'), | ||
| ); | ||
| it.each([ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add all coverage to the test |
||
| { | ||
| error: new InsufficientBalanceException('1', '2'), | ||
| errorMessage: 'confirmation.txnError.insufficientBalance', | ||
| }, | ||
| { | ||
| error: new InsufficientBalanceToCoverFeeException('1', '2'), | ||
| errorMessage: 'confirmation.txnError.insufficientBalanceToCoverFee', | ||
| }, | ||
| { | ||
| error: new InsufficientBalanceToCoverBaseReserveException('1', '2'), | ||
| errorMessage: | ||
| 'confirmation.txnError.insufficientBalanceToCoverBaseReserve', | ||
| }, | ||
| { | ||
| error: new RequiresMemoException(toAddress), | ||
| errorMessage: 'confirmation.txnError.requiresMemo', | ||
| }, | ||
| { | ||
| error: new InvalidAmountForCreateAccountException('0.5'), | ||
| errorMessage: 'confirmation.txnError.invalidCreateAccountAmount', | ||
| }, | ||
| { | ||
| error: new InvalidAssetForCreateAccountException(classicAssetId), | ||
| errorMessage: 'confirmation.txnError.invalidCreateAccountAsset', | ||
| }, | ||
| { | ||
| error: new TrustlineNotAuthorizedException(classicAssetId, accountId), | ||
| errorMessage: 'confirmation.txnError.trustlineNotAuthorized', | ||
| }, | ||
| { | ||
| error: new TrustlineNotFoundException(classicAssetId, accountId), | ||
| errorMessage: 'confirmation.txnError.trustlineNotFoundOnAccount', | ||
| }, | ||
| { | ||
| error: new TrustlineNotFoundException(classicAssetId, toAddress), | ||
| errorMessage: 'confirmation.txnError.trustlineNotFound', | ||
| }, | ||
| { | ||
| error: new TrustlineExceedLimitException(classicAssetId), | ||
| errorMessage: 'confirmation.txnError.trustlineExceedLimit', | ||
| }, | ||
| { | ||
| error: new RemoveTrustlineWithNonZeroBalanceException('nonzero'), | ||
| errorMessage: 'confirmation.txnError.trustlineNonZeroBalance', | ||
| }, | ||
| { | ||
| error: new UpdateTrustlineException('limit'), | ||
| errorMessage: 'confirmation.txnError.updateTrustlineLimit', | ||
| }, | ||
| { | ||
| error: new TransactionExpireException(1), | ||
| errorMessage: 'confirmation.txnError.expired', | ||
| }, | ||
| { | ||
| error: new TransactionValidationException('unknown'), | ||
| errorMessage: 'confirmation.txnError.generic', | ||
| }, | ||
| { | ||
| error: new Error('unknown'), | ||
| errorMessage: 'confirmation.txnError.generic', | ||
| }, | ||
| ])( | ||
| 'marks the transaction invalid when re-validation throws ($errorMessage)', | ||
| async ({ error, errorMessage }) => { | ||
| const { refresher, transactionService } = setup(); | ||
| transactionService.createValidatedSendTransaction.mockRejectedValueOnce( | ||
| error, | ||
| ); | ||
|
|
||
| const result = await refresher.refresh(createTransactionContext()); | ||
| const result = await refresher.refresh(createTransactionContext()); | ||
|
|
||
| expect(result).toStrictEqual({ | ||
| result: { transactionsFetchStatus: FetchStatus.Error }, | ||
| reschedule: false, | ||
| }); | ||
| }); | ||
| expect(result).toStrictEqual({ | ||
| result: { | ||
| transactionsFetchStatus: FetchStatus.Error, | ||
| errorMessage, | ||
| scanFetchStatus: FetchStatus.Error, | ||
| }, | ||
| reschedule: false, | ||
| halt: true, | ||
| }); | ||
| }, | ||
| ); | ||
|
|
||
| it('re-validates a change-trust opt-in transaction', async () => { | ||
| const { refresher, transactionService } = setup(); | ||
|
|
@@ -205,7 +290,7 @@ describe('ConfirmationTransactionRefresher', () => { | |
| transaction: transactionXdr, | ||
| }, | ||
| }, | ||
| reschedule: false, | ||
| reschedule: true, | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -246,7 +331,7 @@ describe('ConfirmationTransactionRefresher', () => { | |
| transaction: transactionXdr, | ||
| }, | ||
| }, | ||
| reschedule: false, | ||
| reschedule: true, | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -273,7 +358,7 @@ describe('ConfirmationTransactionRefresher', () => { | |
| transaction: transactionXdr, | ||
| }, | ||
| }, | ||
| reschedule: false, | ||
| reschedule: true, | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -313,7 +398,7 @@ describe('ConfirmationTransactionRefresher', () => { | |
| transaction: transactionXdr, | ||
| }, | ||
| }, | ||
| reschedule: false, | ||
| reschedule: true, | ||
| }); | ||
| } finally { | ||
| jest.useRealTimers(); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to unknown to accept any error