Skip to content

Commit

Permalink
Merge #2683
Browse files Browse the repository at this point in the history
2683: Correct error method when hardened index wrong r=piotr-iohk a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue that this PR relates to and which requirements it tackles. Jira issues of the form ADP- will be auto-linked. -->
ADP-927

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] Correcting hardened index error


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!--
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
 ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages.
-->


Co-authored-by: Pawel Jakubas <pawel.jakubas@iohk.io>
  • Loading branch information
iohk-bors[bot] and paweljakubas authored May 31, 2021
2 parents 0b8cadb + 7357034 commit ecbf6b5
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -469,7 +469,7 @@ errMsg503PastHorizon = "Tried to convert something that is past the horizon"
errMsg403WrongIndex :: String
errMsg403WrongIndex = "It looks like you've provided a derivation index that is out of bound.\
\ The index is well-formed, but I require indexes valid for hardened derivation only. That\
\ is, indexes between 2147483648 and 4294967295 with a suffix 'H'."
\ is, indexes between 0H and 2147483647H."

errMsg403OutputTokenBundleSizeExceedsLimit
:: Address
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
@@ -3572,12 +3572,12 @@ instance IsServerError ErrSelectAssets where

instance IsServerError (ErrInvalidDerivationIndex 'Hardened level) where
toServerError = \case
ErrIndexOutOfBound minIx maxIx _ix ->
ErrIndexOutOfBound (Index minIx) (Index maxIx) _ix ->
apiError err403 HardenedDerivationRequired $ mconcat
[ "It looks like you've provided a derivation index that is "
, "out of bound. The index is well-formed, but I require "
, "indexes valid for hardened derivation only. That is, indexes "
, "between ", pretty minIx, " and ", pretty maxIx, " with a suffix 'H'."
, "between 0H and ", pretty (Index $ maxIx - minIx), "H."
]

instance IsServerError (Request, ServerError) where
4 changes: 3 additions & 1 deletion specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
@@ -2960,7 +2960,9 @@ x-errHardenedDerivationRequired: &errHardenedDerivationRequired
properties:
message:
type: string
description: A descriptive error message.
description:
Occurs when hardened derivation is required and soft index is used
(without suffix 'H').
code:
type: string
enum: ['hardened_derivation_required']

0 comments on commit ecbf6b5

Please sign in to comment.