Skip to content

Commit

Permalink
Revise API validity interval descriptions and error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Apr 29, 2022
1 parent baece1b commit 2f13c08
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
17 changes: 9 additions & 8 deletions lib/core-integration/src/Test/Integration/Framework/TestData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -703,17 +703,18 @@ errMsg403MintOrBurnAssetQuantityOutOfBounds = mconcat
]

errMsg403InvalidValidityBounds :: String
errMsg403InvalidValidityBounds = mconcat
[ "It looks like I've created a transaction "
, "with wrong validity bounds. Please make sure before validity bound "
, "is preceding hereafter validity bound, and nonnegative times are used."
errMsg403InvalidValidityBounds = unwords
[ "Attempted to create a transaction with invalid validity bounds."
, "Please make sure that the 'invalid_before' bound precedes the"
, "'invalid_hereafter' bound, and that you have not used negative"
, "time values."
]

errMsg403ValidityIntervalNotInsideScriptTimelock :: String
errMsg403ValidityIntervalNotInsideScriptTimelock = mconcat
[ "It looks like I've created a transaction "
, "with validity interval that is not inside script's timelock interval."
, "Please make sure validity interval is subset of script's timelock interval."
errMsg403ValidityIntervalNotInsideScriptTimelock = unwords
[ "Attempted to create a transaction with a validity interval"
, "that is not a subinterval of an associated script's timelock"
, "interval."
]

--------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do
]

it "TRANS_NEW_VALIDITY_INTERVAL_02 - \
\Validity bound should precede" $
\Validity bounds should be ordered correctly" $
\ctx -> runResourceT $ do

wa <- fixtureWallet ctx
Expand All @@ -1220,7 +1220,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do
]

it "TRANS_NEW_VALIDITY_INTERVAL_02 - \
\Missing lower validity interval is acceptable" $
\Missing lower validity bound is acceptable" $
\ctx -> runResourceT $ do

wa <- fixtureWallet ctx
Expand All @@ -1242,7 +1242,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do
]

it "TRANS_NEW_VALIDITY_INTERVAL_02 - \
\Missing upper validity interval is acceptable" $
\Missing upper validity bound is acceptable" $
\ctx -> runResourceT $ do

wa <- fixtureWallet ctx
Expand Down
17 changes: 9 additions & 8 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4410,16 +4410,17 @@ instance IsServerError ErrConstructTx where
, "not exceed 9223372036854775807 (2^63 - 1)."
]
ErrConstructTxWrongValidityBounds ->
apiError err403 InvalidValidityBounds $ mconcat
[ "It looks like I've created a transaction "
, "with wrong validity bounds. Please make sure before validity bound "
, "is preceding hereafter validity bound, and nonnegative times are used."
apiError err403 InvalidValidityBounds $ T.unwords
[ "Attempted to create a transaction with invalid validity bounds."
, "Please make sure that the 'invalid_before' bound precedes the"
, "'invalid_hereafter' bound, and that you have not used negative"
, "time values."
]
ErrConstructTxValidityIntervalNotWithinScriptTimelock ->
apiError err403 ValidityIntervalNotInsideScriptTimelock $ mconcat
[ "It looks like I've created a transaction "
, "with validity interval that is not inside script's timelock interval."
, "Please make sure validity interval is subset of script's timelock interval."
apiError err403 ValidityIntervalNotInsideScriptTimelock $ T.unwords
[ "Attempted to create a transaction with a validity interval"
, "that is not a subinterval of an associated script's timelock"
, "interval."
]
ErrConstructTxNotImplemented _ ->
apiError err501 NotImplemented
Expand Down
9 changes: 5 additions & 4 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4146,8 +4146,9 @@ x-errInvalidValidityBounds: &errInvalidValidityBounds
message:
type: string
description:
Occurs when upon transaction construction before validity bound does
not precede hereafter valdity bound or negative time is used.
Occurs when attempting to create a transaction with invalid validity
bounds. The 'invalid_before' bound must precede the 'invalid_hereafter'
bound, and the given time values must not be negative.
code:
type: string
enum: ['invalid_validity_bounds']
Expand All @@ -4159,8 +4160,8 @@ x-errValidityIntervalNotInsideScriptTimelock: &errValidityIntervalNotInsideScrip
message:
type: string
description:
Occurs when upon transaction construction the transaction's validity
interval is not inside the native script's timelock interval.
Occurs when attempting to create a transaction with a validity interval
that is not a subinterval of an associated script's timelock interval.
code:
type: string
enum: ['validity_interval_not_inside_script_timelock']
Expand Down

0 comments on commit 2f13c08

Please sign in to comment.