Skip to content

Commit

Permalink
changes NotEnoughFundsError messages (iron-fish#2974)
Browse files Browse the repository at this point in the history
* changes NotEnoughFundsError messages

removes message indicating that 'balance changed' since we no longer store
pending balances.

NotEnoughFundsError when sending a transaction is now likely to occur if not
enough notes are available to spend because of pending or unconfirmed
transactions.

* fixes test that relies on error message
  • Loading branch information
hughy authored Jan 18, 2023
1 parent 09df5ca commit f9d71f9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion ironfish/src/rpc/routes/wallet/sendTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ describe('Transactions sendTransaction', () => {

await expect(routeTest.client.sendTransaction(TEST_PARAMS)).rejects.toThrow(
expect.objectContaining({
message: expect.stringContaining('Your balance changed while creating a transaction.'),
status: 400,
code: ERROR_CODES.INSUFFICIENT_BALANCE,
}),
Expand Down
2 changes: 1 addition & 1 deletion ironfish/src/rpc/routes/wallet/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ router.register<typeof SendTransactionRequestSchema, SendTransactionResponse>(
} catch (e) {
if (e instanceof NotEnoughFundsError) {
throw new ValidationError(
`Your balance changed while creating a transaction.`,
`Not enough unspent notes available to fund the transaction. Please wait for any pending transactions to be confirmed.`,
400,
ERROR_CODES.INSUFFICIENT_BALANCE,
)
Expand Down
4 changes: 3 additions & 1 deletion ironfish/src/wallet/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class NotEnoughFundsError extends Error {
amountNeeded,
true,
assetId.toString('hex'),
)} but have '${CurrencyUtils.renderIron(amount)}'`
)} but have '${CurrencyUtils.renderIron(
amount,
)} available to spend. Please fund your account and/or wait for any pending transactions to be confirmed.'`
}
}

0 comments on commit f9d71f9

Please sign in to comment.