Skip to content

Commit

Permalink
impl of _calcScriptExecutionCost - part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
paweljakubas committed Sep 13, 2021
1 parent 7d61c4a commit c54ec79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/shelley/src/Cardano/Wallet/Shelley/Compatibility.hs
Expand Up @@ -75,6 +75,7 @@ module Cardano.Wallet.Shelley.Compatibility
, internalError
, isInternalError
, ToCardanoGenTx (..)
, fromLedgerExUnits

-- ** Assessing sizes of token bundles
, tokenBundleSizeAssessor
Expand Down Expand Up @@ -674,6 +675,15 @@ executionUnitPricesFromPParams pp =
, W.priceExecutionMemory = Ledger.unboundRational prMem
}

fromLedgerExUnits
:: Alonzo.ExUnits
-> W.ExecutionUnits
fromLedgerExUnits (Alonzo.ExUnits mem steps) =
W.ExecutionUnits
{ executionSteps = steps
, executionMemory = mem
}

txParametersFromPParams
:: HasField "_minfeeA" pparams Natural
=> HasField "_minfeeB" pparams Natural
Expand Down
5 changes: 4 additions & 1 deletion lib/shelley/src/Cardano/Wallet/Shelley/Transaction.hs
Expand Up @@ -109,6 +109,7 @@ import Cardano.Wallet.Primitive.Types.Tx
import Cardano.Wallet.Shelley.Compatibility
( fromAllegraTx
, fromAlonzoTx
, fromLedgerExUnits
, fromMaryTx
, fromShelleyTx
, sealShelleyTx
Expand Down Expand Up @@ -173,6 +174,7 @@ import qualified Cardano.Crypto as CC
import qualified Cardano.Crypto.DSIGN as DSIGN
import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Crypto.Wallet as Crypto.HD
import qualified Cardano.Ledger.Alonzo.TxWitness as SL
import qualified Cardano.Ledger.Core as SL
import qualified Cardano.Wallet.Primitive.Types.Coin as Coin
import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TokenBundle
Expand Down Expand Up @@ -499,7 +501,8 @@ _calcScriptExecutionCost pp sealedTx = undefined
getScriptData _ = error "we should not expect Cardano.ByronTxBody here"
getRedeemers Cardano.TxBodyNoScriptData = Nothing
getRedeemers (Cardano.TxBodyScriptData _ _ redeemers) = Just redeemers
in getRedeemers $ getScriptData $ Cardano.getTxBody txValid
getExtUnit (SL.Redeemers rmds) = map (fromLedgerExUnits . snd . snd) $ Map.toList rmds
in getExtUnit <$> (getRedeemers $ getScriptData $ Cardano.getTxBody txValid)
Left _ -> Nothing

_decodeSignedTx
Expand Down

0 comments on commit c54ec79

Please sign in to comment.