Skip to content

Commit

Permalink
Don't adjust the fee within the Shelley transaction layer.
Browse files Browse the repository at this point in the history
At this point, the fee should already be correct, and deposits should
already have been accounted for.
  • Loading branch information
jonathanknowles committed Sep 23, 2021
1 parent f2ef5ca commit a32ff83
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Expand Up @@ -346,8 +346,8 @@ newTransactionLayer networkId = TransactionLayer
Nothing -> do
withShelleyBasedEra era $ do
let payload = TxPayload (view #txMetadata ctx) mempty mempty
let fees = delta
mkTx networkId payload ttl stakeCreds keystore wdrl selection fees
mkTx networkId payload ttl stakeCreds keystore wdrl
selection delta

Just action -> do
withShelleyBasedEra era $ do
Expand All @@ -357,12 +357,8 @@ newTransactionLayer networkId = TransactionLayer
[ mkShelleyWitness unsigned stakeCreds
]
let payload = TxPayload (view #txMetadata ctx) certs mkWits
let fees = case action of
RegisterKeyAndJoin{} ->
unsafeSubtractCoin selection delta (stakeKeyDeposit pp)
_ ->
delta
mkTx networkId payload ttl stakeCreds keystore wdrl selection fees
mkTx networkId payload ttl stakeCreds keystore wdrl
selection delta

, mkUnsignedTransaction = \era stakeXPub pp ctx selection -> do
let ttl = txTimeToLive ctx
Expand All @@ -373,19 +369,15 @@ newTransactionLayer networkId = TransactionLayer
Nothing -> do
withShelleyBasedEra era $ do
let md = view #txMetadata ctx
let fees = delta
constructUnsignedTx networkId (md, []) ttl rewardAcct wdrl selection fees
constructUnsignedTx networkId (md, []) ttl rewardAcct wdrl
selection delta

Just action -> do
withShelleyBasedEra era $ do
let certs = mkDelegationCertificates action stakeXPub
let payload = (view #txMetadata ctx, certs)
let fees = case action of
RegisterKeyAndJoin{} ->
unsafeSubtractCoin selection delta (stakeKeyDeposit pp)
_ ->
delta
constructUnsignedTx networkId payload ttl rewardAcct wdrl selection fees
constructUnsignedTx networkId payload ttl rewardAcct wdrl
selection delta

, calcMinimumCost = \pp ctx skeleton ->
estimateTxCost pp $
Expand All @@ -409,18 +401,6 @@ newTransactionLayer networkId = TransactionLayer
, updateTx = \_sealedTx _inpsOuts ->
error "updateTx not implemented"
}
where
unsafeSubtractCoin
:: (HasCallStack, Buildable ctx) => ctx -> Coin -> Coin -> Coin
unsafeSubtractCoin ctx a b = case a `subtractCoin` b of
Nothing -> error $ unlines
[ "unsafeSubtractCoin: got a negative value. Tried to subtract "
<> show b <> " from " <> show a <> "."
, "In the context of: "
, pretty ctx
]
Just c ->
c

_decodeSealedTx :: SealedTx -> Tx
_decodeSealedTx (cardanoTx -> InAnyCardanoEra _era tx) = fromCardanoTx tx
Expand Down

0 comments on commit a32ff83

Please sign in to comment.