Skip to content

Commit

Permalink
Add carbolymer patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Nov 21, 2024
1 parent 43a51c3 commit 0c17db1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import Data.Function ((&))
import qualified Data.List as List
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (catMaybes, fromMaybe, mapMaybe)
import Data.Maybe (catMaybes, fromMaybe, mapMaybe, maybeToList)
import Data.Set (Set)
import qualified Data.Set as Set
import qualified Data.Text as Text
Expand Down Expand Up @@ -1403,19 +1403,26 @@ createTxMintValue era (val, scriptWitnesses) =
caseShelleyToAllegraOrMaryEraOnwards
(const (txFeatureMismatchPure (toCardanoEra era) TxFeatureMintValue))
( \w -> do
-- The set of policy ids for which we need witnesses:
let witnessesNeededSet :: Set PolicyId
witnessesNeededSet =
fromList [pid | (AssetId pid _, _) <- toList val]
let policiesWithAssets :: [(PolicyId, AssetName, Quantity)]
policiesWithAssets = [(pid, assetName, quantity) | (AssetId pid assetName, quantity) <- toList val]
-- The set of policy ids for which we need witnesses:
witnessesNeededSet :: Set PolicyId
witnessesNeededSet = fromList [pid | (pid, _, _) <- policiesWithAssets]

let witnessesProvidedMap :: Map PolicyId (ScriptWitness WitCtxMint era)
witnessesProvidedMap = fromList $ [(polid, sWit) | MintScriptWitnessWithPolicyId polid sWit <- scriptWitnesses]
witnessesProvidedSet = Map.keysSet witnessesProvidedMap

policiesWithWitnesses =
Map.fromListWith
(<>)
[ (pid, [(assetName, quantity, BuildTxWith witness)])
| (pid, assetName, quantity) <- policiesWithAssets
, witness <- maybeToList $ Map.lookup pid witnessesProvidedMap
]
-- Check not too many, nor too few:
validateAllWitnessesProvided witnessesNeededSet witnessesProvidedSet
validateNoUnnecessaryWitnesses witnessesNeededSet witnessesProvidedSet
return (TxMintValue w val (BuildTxWith witnessesProvidedMap))
pure $ TxMintValue w policiesWithWitnesses
)
era
where
Expand Down

0 comments on commit 0c17db1

Please sign in to comment.