Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Jun 14, 2024
1 parent 92d8064 commit 35e7807
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
26 changes: 15 additions & 11 deletions lib/api/src/Cardano/Wallet/Api/Http/Shelley/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2916,16 +2916,18 @@ constructTransaction api knownPools poolStatus apiWalletId body = do
foldMap timelockKeyWitCountsForMintBurn
$ maybe [] NE.toList mintBurnDatum

balancedTx <- fmap (toApiSerialisedTransaction (body ^. #encoding)) . liftIO $ W.balanceTx
wrk
pp
timeTranslation
PartialTx
{ tx = Write.fromCardanoApiTx $ Cardano.Tx unbalancedTx []
, extraUTxO = mempty
, redeemers = mempty
, timelockKeyWitnessCounts = mintBurnTimelockKeyWitCounts
}
balancedTx <-
fmap (toApiSerialisedTransaction (body ^. #encoding))
. liftIO $ W.balanceTx
wrk
pp
timeTranslation
PartialTx
{ tx = Write.fromCardanoApiTx $ Cardano.Tx unbalancedTx []
, extraUTxO = mempty
, redeemers = mempty
, timelockKeyWitnessCounts = mintBurnTimelockKeyWitCounts
}

apiDecoded <- decodeTransaction @_ @n api apiWalletId
(toApiDecodeTransactionPostData balancedTx)
Expand Down Expand Up @@ -3352,7 +3354,9 @@ constructSharedTransaction
}

apiDecoded <- decodeSharedTransaction api (ApiT wid)
(ApiDecodeTransactionPostData (ApiT (sealWriteTx balancedTx)) Nothing)
$ ApiDecodeTransactionPostData
(ApiT (sealWriteTx balancedTx))
Nothing
let deposits = case optionalDelegationAction of
Just (JoinRegisteringKey _poolId) ->
[W.getStakeKeyDeposit pp]
Expand Down
26 changes: 8 additions & 18 deletions lib/wallet/src/Cardano/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ module Cardano.Wallet
, buildTransaction
, buildAndSignTransaction
, BuiltTx (..)
, balanceTx
, signTransaction
, constructTransaction
, constructTxMeta
Expand Down Expand Up @@ -232,7 +233,6 @@ module Cardano.Wallet

-- * Internal
, putWalletCheckpoints
, balanceTx
) where

import Prelude hiding
Expand Down Expand Up @@ -2214,11 +2214,6 @@ balanceTx wrk pp timeTranslation partialTx = do
in replaceCosignersWithVerKeys role' template ix

throwBalanceTxErr = throwWrappedErr ExceptionBalanceTx
where
throwOnErr :: (MonadIO m, Exception e) => Either e a -> m a
throwOnErr = either (liftIO . throwIO) pure

throwWrappedErr f e = runExceptT (withExceptT f e) >>= throwOnErr

-- | Build, Sign, Submit transaction.
--
Expand Down Expand Up @@ -2307,11 +2302,6 @@ buildSignSubmitTransaction db@DBLayer{..} netLayer txLayer
& fmap (BuiltTx{..},)
& liftIO
where
throwOnErr :: (MonadIO m, Exception e) => Either e a -> m a
throwOnErr = either (liftIO . throwIO) pure

throwWrappedErr f e = runExceptT (withExceptT f e) >>= throwOnErr

wrapRootKeyError = ExceptionWitnessTx . ErrWitnessTxWithRootKey
wrapNetworkError = ExceptionSubmitTx . ErrSubmitTxNetwork

Expand Down Expand Up @@ -3238,13 +3228,6 @@ transactionFee DBLayer{atomically, walletState} protocolParams
. ExceptT
. pure

throwWrappedErr
:: (Exception e, MonadIO m)
=> (e' -> e)
-> ExceptT e' m a ->
m a
throwWrappedErr f a = either (throwIO . f) pure =<< runExceptT a

-- | Repeatedly (100 times) runs given transaction fee estimation calculation
-- returning 1st and 9nth decile (10nth and 90nth percentile) values of a
-- recoded distribution.
Expand Down Expand Up @@ -3909,6 +3892,13 @@ data PoolRetirementEpochInfo = PoolRetirementEpochInfo
}
deriving (Eq, Generic, Show)

throwOnErr :: (MonadIO m, Exception e) => Either e a -> m a
throwOnErr = either (liftIO . throwIO) pure

throwWrappedErr
:: (MonadIO m, Exception e1) => (e2 -> e1) -> ExceptT e2 m b -> m b
throwWrappedErr f e = runExceptT (withExceptT f e) >>= throwOnErr

{-------------------------------------------------------------------------------
Logging
-------------------------------------------------------------------------------}
Expand Down

0 comments on commit 35e7807

Please sign in to comment.