Skip to content

Commit

Permalink
introduce ForeignTransaction error
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Jan 18, 2022
1 parent 943f109 commit 201111f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/core/src/Cardano/Wallet.hs
Expand Up @@ -3066,8 +3066,9 @@ data BalanceTxNotSupportedReason
deriving (Show, Eq)

-- | Errors that can occur when submitting a transaction.
newtype ErrSubmitTransaction
data ErrSubmitTransaction
= ErrSubmitTransactionNoSuchWallet ErrNoSuchWallet
| ErrSubmitTransactionForeignWallet
deriving (Show, Eq)

-- | Errors that can occur when constructing an unsigned transaction.
Expand Down
6 changes: 6 additions & 0 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -3917,6 +3917,12 @@ instance IsServerError ErrSubmitTransaction where
{ errHTTPCode = 404
, errReasonPhrase = errReasonPhrase err404
}
ErrSubmitTransactionForeignWallet ->
apiError err403 ForeignTransaction $ mconcat
[ "The transaction to be submitted is foreign to the current wallet "
, "and cannot be sent. Submit a transaction that has either input, output "
, "or withdrawal belonging to the wallet."
]

instance IsServerError ErrSubmitTx where
toServerError = \case
Expand Down
1 change: 1 addition & 0 deletions lib/core/src/Cardano/Wallet/Api/Types.hs
Expand Up @@ -1662,6 +1662,7 @@ data ApiErrorCode
| UnresolvedInputs
| RedeemerInvalidData
| ExistingKeyWitnesses
| ForeignTransaction
deriving (Eq, Generic, Show, Data, Typeable)
deriving anyclass NFData

Expand Down
18 changes: 18 additions & 0 deletions specifications/api/swagger.yaml
Expand Up @@ -4218,6 +4218,17 @@ x-errCreatedInvalidTransaction: &errCreatedInvalidTransaction
type: string
enum: ['created_invalid_transaction']

x-errForeignTransaction: &errForeignTransaction
<<: *responsesErr
title: foreign_transaction
properties:
message:
type: string
description: Occurs when a transaction to be submitted does have neither input, output nor withdrawal belonging to a given wallet.
code:
type: string
enum: ['foreign_transaction']

x-errRejectedByCoreNode: &errRejectedByCoreNode
<<: *responsesErr
title: rejected_by_core_node
Expand Down Expand Up @@ -5116,6 +5127,13 @@ x-responsesSubmitTransaction: &responsesSubmitTransaction
content:
application/json:
schema: *ApiTxId
403:
description: Forbidden
content:
application/json:
schema:
oneOf:
- <<: *errForeignTransaction

x-responsesPostExternalTransaction: &responsesPostExternalTransaction
<<: *responsesErr400
Expand Down

0 comments on commit 201111f

Please sign in to comment.