Skip to content

Commit aa82aa9

Browse files
committed
Extract scripts for redeemers
1 parent 329563d commit aa82aa9

File tree

1 file changed

+17
-11
lines changed
  • cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx

1 file changed

+17
-11
lines changed

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Alonzo.hs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import qualified Data.ByteString.Lazy.Char8 as LBS
6666

6767
import qualified Data.ByteString.Short as SBS
6868

69+
import Cardano.Ledger.Conway.Governance
6970
import Cardano.Ledger.Conway.Scripts (ConwayPlutusPurpose (..))
7071
import qualified Cardano.Ledger.TxIn as Ledger
7172
import qualified Data.Map.Strict as Map
@@ -250,8 +251,8 @@ resolveRedeemers ioExtraPlutus mprices tx toCert =
250251
Just (Right (ConwaySpending txIn)) -> handleTxInPtr rdmrIx (Alonzo.unAsItem txIn) rdmrMps
251252
Just (Right (ConwayRewarding rwdAcnt)) -> handleRewardPtr rdmrIx (Alonzo.unAsItem rwdAcnt) rdmrMps
252253
Just (Right (ConwayCertifying dcert)) -> handleCertPtr rdmrIx (toCert $ Alonzo.unAsItem dcert) rdmrMps
253-
Just (Right (ConwayVoting _)) -> (rdmrMps, Nothing)
254-
Just (Right (ConwayProposing _)) -> (rdmrMps, Nothing)
254+
Just (Right (ConwayVoting voter)) -> (rdmrMps, Right <$> getConwayVotingScriptHash (Alonzo.unAsItem voter))
255+
Just (Right (ConwayProposing proposal)) -> (rdmrMps, Right <$> getConwayProposalScriptHash (Alonzo.unAsItem proposal))
255256
Nothing -> (rdmrMps, Nothing)
256257

257258
(tag, idx) = getPurpose ptr
@@ -384,15 +385,20 @@ scriptHashCert cert = case cert of
384385
Left scert -> scriptHashCertShelley scert
385386
Right ccert -> scriptHashCertConway ccert
386387

387-
-- TODO: Conway
388388
scriptHashCertConway :: ConwayCert -> Maybe ByteString
389-
scriptHashCertConway _cert = Nothing
389+
scriptHashCertConway cert = unScriptHash <$> getScriptWitnessTxCert cert
390390

391391
scriptHashCertShelley :: ShelleyCert -> Maybe ByteString
392-
scriptHashCertShelley cert =
393-
case cert of
394-
Shelley.ShelleyTxCertDelegCert (Shelley.ShelleyUnRegCert cred) ->
395-
getCredentialScriptHash cred
396-
Shelley.ShelleyTxCertDelegCert (Shelley.ShelleyDelegCert cred _) ->
397-
getCredentialScriptHash cred
398-
_ -> Nothing
392+
scriptHashCertShelley cert = unScriptHash <$> getScriptWitnessTxCert cert
393+
394+
getConwayVotingScriptHash :: Voter StandardCrypto -> Maybe ByteString
395+
getConwayVotingScriptHash = \case
396+
CommitteeVoter cred -> getCredentialScriptHash cred
397+
DRepVoter cred -> getCredentialScriptHash cred
398+
StakePoolVoter _ -> Nothing
399+
400+
getConwayProposalScriptHash :: EraCrypto era ~ StandardCrypto => ProposalProcedure era -> Maybe ByteString
401+
getConwayProposalScriptHash pp = case pProcGovAction pp of
402+
ParameterChange _ _ p -> unScriptHash <$> strictMaybeToMaybe p
403+
TreasuryWithdrawals _ p -> unScriptHash <$> strictMaybeToMaybe p
404+
_ -> Nothing

0 commit comments

Comments
 (0)