Skip to content

Commit

Permalink
make foreign wallet definition laxer
Browse files Browse the repository at this point in the history
hlint
  • Loading branch information
paweljakubas committed Jan 18, 2022
1 parent ae4e0f1 commit daf14bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Expand Up @@ -642,7 +642,7 @@ errMsg400ScriptNotUniformRoles =
errMsg403ForeignTransaction :: String
errMsg403ForeignTransaction = mconcat
[ "The transaction to be submitted is foreign to the current wallet "
, "and cannot be sent. Submit a transaction that has either input, output "
, "and cannot be sent. Submit a transaction that has either input "
, "or withdrawal belonging to the wallet."
]

Expand Down
Expand Up @@ -2158,8 +2158,7 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do
]
forM_ scenarios $ \(title, foreignWallet) -> it title $ \ctx -> runResourceT $ do
wa <- fixtureWallet ctx
wb <- fixtureWallet ctx
wF <- foreignWallet ctx
wb <- foreignWallet ctx

-- Construct tx
payload <- mkTxPayload ctx wb $ minUTxOValue (_mainEra ctx)
Expand All @@ -2176,8 +2175,8 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do
signedTx <- getFromResponse Prelude.id <$>
request @ApiSerialisedTransaction ctx signEndpoint Default toSign

-- Submit tx (from wF)
submittedTx <- submitTxWithWid ctx wF signedTx
-- Submit tx (from wb)
submittedTx <- submitTxWithWid ctx wb signedTx
verify submittedTx
[ expectResponseCode HTTP.status403
, expectErrorMessage errMsg403ForeignTransaction
Expand Down
8 changes: 2 additions & 6 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -2410,15 +2410,11 @@ submitTransaction ctx apiw@(ApiT wid) apitx@(ApiSerialisedTransaction (ApiT seal
isForeign apiDecodedTx =
let generalInps = apiDecodedTx ^. #inputs
generalWdrls = apiDecodedTx ^. #withdrawals
generalOuts = apiDecodedTx ^. #outputs
isInpForeign (WalletInput _) = False
isInpForeign _ = True
isOutForeign (WalletOutput _) = False
isOutForeign _ = True
isWdrlForeign (ApiWithdrawalGeneral _ _ context) = context == External
in
all isInpForeign generalInps &&
all isOutForeign generalOuts &&
all isWdrlForeign generalWdrls

joinStakePool
Expand Down Expand Up @@ -3942,11 +3938,11 @@ instance IsServerError ErrSubmitTransaction where
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 "
, "and cannot be sent. Submit a transaction that has either input "
, "or withdrawal belonging to the wallet."
]
ErrSubmitTransactionPartiallySignedOrNoSignedTx expectedWitsNo foundWitsNo ->
apiError err403 MissingWitnessesInTransaction $ mconcat $
apiError err403 MissingWitnessesInTransaction $ mconcat
[ "The transaction has ", toText expectedWitsNo
, " inputs and ", toText foundWitsNo, " witnesses included."
, " Submit fully-signed transaction."
Expand Down

0 comments on commit daf14bb

Please sign in to comment.