@@ -22,7 +22,7 @@ import Cardano.Proto.Aux (
22
22
import Control.Lens ((&) , (.~) , (^.) )
23
23
import Control.Monad (guard , when )
24
24
import Coop.Pab.Aux (Trx (Trx ), currencyValue , datumFromTxOut , datumFromTxOutOrFail , deplAuthCs , deplAuthMp , deplCertCs , deplCertVAddress , deplFsCs , deplFsVAddress , deplFsVHash , findOutsAt , findOutsAt' , findOutsAtHolding' , findOutsAtHoldingCurrency , findOutsAtHoldingCurrency' , hasCurrency , hashTxInputs , interval' , minUtxoAdaValue , mkMintOneShotTrx , submitTrx , submitTrx' , toDatum , toRedeemer )
25
- import Coop.Types (AuthBatchId , AuthDeployment (AuthDeployment , ad'authMp , ad'authorityAc , ad'certMp , ad'certV ), AuthMpParams (AuthMpParams ), AuthMpRedeemer (AuthMpBurn , AuthMpMint ), AuthParams (AuthParams , ap'authTokenCs , ap'certTokenCs ), CertDatum (CertDatum , cert'id , cert'validity ), CertMpParams (CertMpParams ), CertMpRedeemer (CertMpBurn , CertMpMint ), CoopDeployment (CoopDeployment , cd'auth , cd'fsMp , cd'fsV ), CoopPlutus (cp'fsV , cp'mkAuthMp , cp'mkCertMp , cp'mkFsMp , cp'mkOneShotMp ), CoopState (CoopState ), FactStatementId , FsDatum (FsDatum , fd'fsId , fs'gcAfter , fs'submitter ), FsMpParams (FsMpParams ), FsMpRedeemer (FsMpBurn , FsMpMint ), cp'certV )
25
+ import Coop.Types (AuthBatchId , AuthDeployment (AuthDeployment , ad'authPolicy , ad'authorityAsset , ad'certPolicy , ad'certValidator ), AuthMpParams (AuthMpParams ), AuthMpRedeemer (AuthMpBurn , AuthMpMint ), AuthParams (AuthParams , ap'authTokenCs , ap'certTokenCs ), CertDatum (CertDatum , cert'id , cert'validity ), CertMpParams (CertMpParams ), CertMpRedeemer (CertMpBurn , CertMpMint ), CoopDeployment (CoopDeployment , cd'auth , cd'fsPolicy , cd'fsValidator ), CoopPlutus (cp'fsV , cp'mkAuthMp , cp'mkCertMp , cp'mkFsMp , cp'mkOneShotMp ), CoopState (CoopState ), FactStatementId , FsDatum (FsDatum , fd'fsId , fs'gcAfter , fs'submitter ), FsMpParams (FsMpParams ), FsMpRedeemer (FsMpBurn , FsMpMint ), cp'certV )
26
26
import Data.Bool (bool )
27
27
import Data.Foldable (toList )
28
28
import Data.List (nub , partition )
@@ -103,32 +103,37 @@ deployCoop coopPlutus aaWallet atLeastAaQ aaQToMint = do
103
103
mkAuthDeployment :: CoopPlutus -> AssetClass -> Integer -> AuthDeployment
104
104
mkAuthDeployment coopPlutus aaAc atLeastAaQ =
105
105
let authMpParams = AuthMpParams aaAc atLeastAaQ
106
- certMpParams = CertMpParams aaAc atLeastAaQ (mkValidatorAddress certV)
106
+ certMpParams = CertMpParams aaAc atLeastAaQ certAddr
107
107
certV = Validator $ cp'certV coopPlutus
108
+ certAddr = mkValidatorAddress certV
108
109
certMp = MintingPolicy $ applyArguments (cp'mkCertMp coopPlutus) [toData certMpParams]
110
+ certSym = scriptCurrencySymbol certMp
109
111
authMp = MintingPolicy $ applyArguments (cp'mkAuthMp coopPlutus) [toData authMpParams]
110
- in AuthDeployment aaAc certV certMp authMp
112
+ authSym = scriptCurrencySymbol authMp
113
+ in AuthDeployment aaAc certV certAddr certMp certSym authMp authSym
111
114
112
115
mkCoopDeployment :: CoopPlutus -> AssetClass -> AuthDeployment -> CoopDeployment
113
116
mkCoopDeployment coopPlutus coopAc authDeployment =
114
117
let fsV = Validator (cp'fsV coopPlutus)
118
+ fsAddr = mkValidatorAddress fsV
115
119
fsMp =
116
120
MintingPolicy $
117
121
applyArguments
118
122
(cp'mkFsMp coopPlutus)
119
123
[ toData
120
124
( FsMpParams
121
125
coopAc
122
- (mkValidatorAddress fsV)
126
+ fsAddr
123
127
(authParamsFromDeployment authDeployment)
124
128
)
125
129
]
126
- in CoopDeployment coopAc fsMp fsV authDeployment
130
+ fsSym = scriptCurrencySymbol fsMp
131
+ in CoopDeployment coopAc fsMp fsSym fsV fsAddr authDeployment
127
132
where
128
133
authParamsFromDeployment ad =
129
134
AuthParams
130
- { ap'authTokenCs = scriptCurrencySymbol (ad'authMp ad)
131
- , ap'certTokenCs = scriptCurrencySymbol (ad'certMp ad)
135
+ { ap'authTokenCs = scriptCurrencySymbol (ad'authPolicy ad)
136
+ , ap'certTokenCs = scriptCurrencySymbol (ad'certPolicy ad)
132
137
}
133
138
134
139
mintCertRedeemers :: CoopPlutus -> Integer -> Contract w s Text AssetClass
@@ -152,8 +157,8 @@ mintCertRedeemers coopPlutus q = do
152
157
153
158
mkMintCertTrx :: CoopDeployment -> PaymentPubKeyHash -> AssetClass -> POSIXTimeRange -> Map TxOutRef ChainIndexTxOut -> (Trx i o a , AssetClass )
154
159
mkMintCertTrx coopDeployment self redeemerAc validityInterval aaOuts =
155
- let certMp = (ad'certMp . cd'auth) coopDeployment
156
- certV = (ad'certV . cd'auth) coopDeployment
160
+ let certMp = (ad'certPolicy . cd'auth) coopDeployment
161
+ certV = (ad'certValidator . cd'auth) coopDeployment
157
162
certVAddr = validatorHash certV
158
163
aaOrefs = Map. keys aaOuts
159
164
certId = hashTxInputs aaOuts
@@ -204,8 +209,8 @@ burnCerts coopDeployment certRdmrAc = do
204
209
when (null obsoleteCertOuts) (throwError " burnCerts: There should be some obsolete $CERT inputs" )
205
210
206
211
(now, _) <- currentNodeClientTimeRange
207
- let certMp = (ad'certMp . cd'auth) coopDeployment
208
- certV = (ad'certV . cd'auth) coopDeployment
212
+ let certMp = (ad'certPolicy . cd'auth) coopDeployment
213
+ certV = (ad'certValidator . cd'auth) coopDeployment
209
214
certRdmdrOrefs = Map. keys certRdmrOuts
210
215
certOrefs = Map. keys obsoleteCertOuts
211
216
certVal = foldMap (\ out -> inv $ currencyValue (out ^. ciTxOutValue) certCs) (toList obsoleteCertOuts)
@@ -311,7 +316,7 @@ mintAuthAndCert coopDeployment authWallets nAuthTokensPerWallet certRdmrAc from
311
316
312
317
mkBurnAuthsTrx :: CoopDeployment -> PaymentPubKeyHash -> Map TxOutRef ChainIndexTxOut -> Trx i o a
313
318
mkBurnAuthsTrx coopDeployment self authOuts = do
314
- let authMp = (ad'authMp . cd'auth) coopDeployment
319
+ let authMp = (ad'authPolicy . cd'auth) coopDeployment
315
320
authCs = scriptCurrencySymbol authMp
316
321
authOrefs = Map. keys authOuts
317
322
authVal = foldMap (\ out -> inv $ currencyValue (out ^. ciTxOutValue) authCs) (toList authOuts)
@@ -339,10 +344,10 @@ getState coopDeployment = do
339
344
let logI m = logInfo @ String (" getState: " <> m)
340
345
logI " Starting"
341
346
342
- let certVAddr = mkValidatorAddress . ad'certV . cd'auth $ coopDeployment
343
- certCs = scriptCurrencySymbol . ad'certMp . cd'auth $ coopDeployment
344
- fsVAddr = mkValidatorAddress . cd'fsV $ coopDeployment
345
- fsCs = scriptCurrencySymbol . cd'fsMp $ coopDeployment
347
+ let certVAddr = mkValidatorAddress . ad'certValidator . cd'auth $ coopDeployment
348
+ certCs = scriptCurrencySymbol . ad'certPolicy . cd'auth $ coopDeployment
349
+ fsVAddr = mkValidatorAddress . cd'fsValidator $ coopDeployment
350
+ fsCs = scriptCurrencySymbol . cd'fsPolicy $ coopDeployment
346
351
347
352
certOuts <- findOutsAtHoldingCurrency certVAddr certCs
348
353
fsOuts <- findOutsAtHoldingCurrency fsVAddr fsCs
@@ -372,19 +377,19 @@ findOutsAtCertV coopDeployment p = do
372
377
373
378
logI " Starting"
374
379
375
- let certVAddr = (mkValidatorAddress . ad'certV . cd'auth) coopDeployment
380
+ let certVAddr = (mkValidatorAddress . ad'certValidator . cd'auth) coopDeployment
376
381
findOutsAt @ CertDatum
377
382
certVAddr
378
383
(maybe False . p)
379
384
380
385
findOutsAtCertVWithCERT :: CoopDeployment -> Contract w s Text (Map TxOutRef ChainIndexTxOut )
381
- findOutsAtCertVWithCERT coopDeployment = findOutsAtCertV coopDeployment (\ v _ -> hasCurrency v ((scriptCurrencySymbol . ad'certMp . cd'auth) coopDeployment))
386
+ findOutsAtCertVWithCERT coopDeployment = findOutsAtCertV coopDeployment (\ v _ -> hasCurrency v ((scriptCurrencySymbol . ad'certPolicy . cd'auth) coopDeployment))
382
387
383
388
findOutsAtHoldingAa :: PaymentPubKeyHash -> CoopDeployment -> Contract w s Text (Map TxOutRef ChainIndexTxOut )
384
389
findOutsAtHoldingAa wallet coopDeployment = do
385
390
let logI m = logInfo @ String (" findOutsAtHoldingAa: " <> m)
386
391
logI " Starting"
387
- let aaAc = (ad'authorityAc . cd'auth) coopDeployment
392
+ let aaAc = (ad'authorityAsset . cd'auth) coopDeployment
388
393
found <- findOutsAtHolding' wallet aaAc
389
394
logI " Finished"
390
395
return found
@@ -567,8 +572,8 @@ mkMintFsTrx ::
567
572
(Value , PaymentPubKeyHash ) ->
568
573
Trx i o a
569
574
mkMintFsTrx coopDeployment now minutes publishingSpec (feeVal, feeCollectorPpkh) = do
570
- let fsMp = cd'fsMp coopDeployment
571
- fsV = cd'fsV coopDeployment
575
+ let fsMp = cd'fsPolicy coopDeployment
576
+ fsV = cd'fsValidator coopDeployment
572
577
fsVHash = deplFsVHash coopDeployment
573
578
fsCs = deplFsCs coopDeployment
574
579
authCs = deplAuthCs coopDeployment
@@ -702,8 +707,8 @@ runGcFsTx coopDeployment submit req = do
702
707
703
708
mkGcFsTrx :: CoopDeployment -> PaymentPubKeyHash -> [((TxOutRef , ChainIndexTxOut ), FsDatum )] -> POSIXTime -> Trx i o a
704
709
mkGcFsTrx coopDeployment submitterPkh fsOutsWithDatum now = do
705
- let fsMp = cd'fsMp coopDeployment
706
- fsV = cd'fsV coopDeployment
710
+ let fsMp = cd'fsPolicy coopDeployment
711
+ fsV = cd'fsValidator coopDeployment
707
712
fsCs = deplFsCs coopDeployment
708
713
709
714
totalFsValToBurn =
0 commit comments