-
Notifications
You must be signed in to change notification settings - Fork 15
fix: error message for over available tokens to mint or melt #791
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
Conversation
@@ -1981,7 +1981,8 @@ describe('mintTokens', () => { | |||
const { hash: tokenUid } = await createTokenHelper(hWallet, 'Token to Mint', 'TMINT', 100); | |||
|
|||
// Should not mint more tokens than the HTR funds allow | |||
await expect(hWallet.mintTokens(tokenUid, 9000)).rejects.toThrow('HTR tokens'); | |||
await expect(hWallet.mintTokens(tokenUid, 9000)) | |||
.rejects.toThrow(/^Not enough HTR tokens for deposit: 90 required, \d+ available$/); |
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.
The available tokens can change for each test, therefore we match for any digit with \d+
.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #791 +/- ##
=======================================
Coverage 80.52% 80.53%
=======================================
Files 81 81
Lines 6460 6462 +2
Branches 1400 1393 -7
=======================================
+ Hits 5202 5204 +2
Misses 1245 1245
Partials 13 13 ☔ View full report in Codecov by Sentry. |
throw new InsufficientFundsError( | ||
`Not enough HTR tokens for deposit: ${depositAmount} required, ${foundAmount} available` | ||
`Not enough HTR tokens for deposit: ${depositAmount} required, ${availableAmount} available` |
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.
The error message is used as an error feedback message for users on Wallet Desktop. We could have removed the "available" part from the message as an easier solution, however as it is used in the frontend Carneiro and I discussed it would be better to change the "internals" rather then the message.
@@ -49,7 +49,7 @@ export async function fastUtxoSelection( | |||
storage: IStorage, | |||
token: string, | |||
amount: OutputValueType | |||
): Promise<{ utxos: IUtxo[]; amount: OutputValueType }> { | |||
): Promise<{ utxos: IUtxo[]; amount: OutputValueType; available?: OutputValueType }> { |
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.
Missing this new return key in the docstring
90a7018
to
ac64e40
Compare
Motivation
When we try to mint or melt tokens with more than the available amount, it throws an error. The error message informs the requested amount to mint or melt and the available token amount. The bug here is that the available amount is always zero.
Acceptance Criteria
It closes https://github.com/HathorNetwork/internal-issues/issues/398
Security Checklist