Bump LPE and update use sites.
This commit is contained in:
parent
16f3a610bb
commit
5ebdc04498
19 changed files with 104 additions and 149 deletions
|
|
@ -48,9 +48,6 @@ deriving via
|
|||
instance
|
||||
Aeson.ToJSON Plutus.TxId
|
||||
|
||||
deriving anyclass instance Aeson.FromJSON Plutus.TxOutRef
|
||||
deriving anyclass instance Aeson.ToJSON Plutus.TxOutRef
|
||||
|
||||
instance (Coercible a Plutus.LedgerBytes) => Aeson.ToJSON (AsBase16Bytes a) where
|
||||
toJSON =
|
||||
Aeson.String
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ import Plutarch.Api.V2 (
|
|||
PTxOut (PTxOut),
|
||||
)
|
||||
import Plutarch.Extra.AssetClass (passetClass, passetClassValueOf)
|
||||
import Plutarch.Extra.List (plookup)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.List (plookupAssoc)
|
||||
import Plutarch.Extra.ScriptContext (pisTokenSpent)
|
||||
import Plutarch.Extra.Sum (PSum (PSum))
|
||||
import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC)
|
||||
import Plutarch.Extra.Traversable (pfoldMap)
|
||||
import Plutarch.Extra.Value (psymbolValueOf)
|
||||
import PlutusLedgerApi.V1.Value (AssetClass (AssetClass))
|
||||
|
|
@ -83,7 +83,7 @@ authorityTokensValidIn = phoistAcyclic $
|
|||
PValue value' <- pmatchC txOut.value
|
||||
PMap value <- pmatchC value'
|
||||
pure $
|
||||
pmatch (plookup # pdata authorityTokenSym # value) $ \case
|
||||
pmatch (plookupAssoc # pfstBuiltin # psndBuiltin # pdata authorityTokenSym # value) $ \case
|
||||
PJust (pfromData -> _tokenMap') ->
|
||||
pmatch (pfield @"credential" # address) $ \case
|
||||
PPubKeyCredential _ ->
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import GHC.Records (HasField)
|
|||
import Plutarch.Api.V1 (PCredential (PPubKeyCredential, PScriptCredential), PPubKeyHash)
|
||||
import Plutarch.Api.V2 (PTxInInfo)
|
||||
import Plutarch.Extra.ScriptContext (ptxSignedBy)
|
||||
import Plutarch.Extra.TermCont (pmatchC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pmatchC)
|
||||
|
||||
{- | Context required in order to check 'AuthorizationCredential'.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import Plutarch.Api.V2 (
|
|||
PTxOutRef,
|
||||
PValidator,
|
||||
)
|
||||
import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC, ptryFromC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC, ptryFromC)
|
||||
import Plutarch.TryFrom ()
|
||||
import PlutusLedgerApi.V1.Value (CurrencySymbol)
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import Plutarch.Extra.Maybe (
|
|||
passertPJust,
|
||||
)
|
||||
import Plutarch.Extra.ScriptContext (pfromOutputDatum, pisScriptAddress)
|
||||
import Plutarch.Extra.TermCont (pguardC, pletFieldsC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletFieldsC)
|
||||
import Plutarch.Extra.Value (pvalueOf)
|
||||
import Plutarch.Lift (PConstantDecl, PLifted, PUnsafeLiftDecl)
|
||||
import PlutusLedgerApi.V1 (TxOutRef)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import Plutarch.DataRepr (
|
|||
PDataFields,
|
||||
)
|
||||
import Plutarch.Extra.ScriptContext (pfindTxInByTxOutRef, pisPubKey)
|
||||
import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC)
|
||||
import Plutarch.Lift (PConstantDecl, PUnsafeLiftDecl (PLifted))
|
||||
import PlutusLedgerApi.V1.Credential (Credential)
|
||||
import PlutusLedgerApi.V1.Value (CurrencySymbol, Value)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import Plutarch.Extra.IsData (
|
|||
EnumIsData (EnumIsData),
|
||||
PlutusTypeEnumData,
|
||||
)
|
||||
import Plutarch.Extra.TermCont (pletFieldsC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pletFieldsC)
|
||||
import Plutarch.Lift (PConstantDecl, PUnsafeLiftDecl (PLifted))
|
||||
import PlutusLedgerApi.V1 (TxOutRef)
|
||||
import PlutusLedgerApi.V1.Value (AssetClass)
|
||||
|
|
|
|||
|
|
@ -64,9 +64,10 @@ import Plutarch.Api.V2 (
|
|||
)
|
||||
import Plutarch.Extra.AssetClass (passetClass, passetClassValueOf)
|
||||
import Plutarch.Extra.Field (pletAll, pletAllC)
|
||||
import Plutarch.Extra.List (pfirstJust, pmapMaybe, pmsort)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.List (pfindJust, pmapMaybe)
|
||||
import Plutarch.Extra.Map (pkeys, ptryLookup)
|
||||
import Plutarch.Extra.Maybe (passertPJust, pjust, pmaybe, pmaybeData, pnothing)
|
||||
import Plutarch.Extra.Ord (psort)
|
||||
import Plutarch.Extra.Record (mkRecordConstr, (.&), (.=))
|
||||
import Plutarch.Extra.ScriptContext (
|
||||
pfindTxInByTxOutRef,
|
||||
|
|
@ -76,7 +77,7 @@ import Plutarch.Extra.ScriptContext (
|
|||
pscriptHashFromAddress,
|
||||
pvalueSpent,
|
||||
)
|
||||
import Plutarch.Extra.TermCont (
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (
|
||||
pguardC,
|
||||
pletC,
|
||||
pletFieldsC,
|
||||
|
|
@ -145,7 +146,7 @@ governorPolicy initialSpend =
|
|||
|
||||
let governorOutputDatum =
|
||||
passertPJust # "Governor output should present"
|
||||
#$ pfirstJust
|
||||
#$ pfindJust
|
||||
# plam
|
||||
( flip (pletFields @'["value", "datum"]) $ \txOutF ->
|
||||
let isGovernorUTxO =
|
||||
|
|
@ -298,7 +299,7 @@ governorValidator as =
|
|||
pletC $
|
||||
passertPJust
|
||||
# "Own output should present"
|
||||
#$ pfirstJust
|
||||
#$ pfindJust
|
||||
# plam
|
||||
( flip pletAll $ \outputF ->
|
||||
let gstSymbol = pconstant $ governorSTSymbol as
|
||||
|
|
@ -412,7 +413,7 @@ governorValidator as =
|
|||
|
||||
let stakeInputDatum =
|
||||
passertPJust # "Stake input should present"
|
||||
#$ pfirstJust
|
||||
#$ pfindJust
|
||||
# plam ((getStakeDatum #) . (pfield @"resolved" #))
|
||||
# pfromData txInfoF.inputs
|
||||
|
||||
|
|
@ -435,7 +436,7 @@ governorValidator as =
|
|||
|
||||
let proposalOutputDatum =
|
||||
passertPJust # "Proposal output should present"
|
||||
#$ pfirstJust
|
||||
#$ pfindJust
|
||||
# getProposalDatum
|
||||
# pfromData txInfoF.outputs
|
||||
|
||||
|
|
@ -472,7 +473,7 @@ governorValidator as =
|
|||
|
||||
let stakeOutputDatum =
|
||||
passertPJust # "Output stake should be presented"
|
||||
#$ pfirstJust
|
||||
#$ pfindJust
|
||||
# getStakeDatum
|
||||
# pfromData txInfoF.outputs
|
||||
|
||||
|
|
@ -507,7 +508,7 @@ governorValidator as =
|
|||
|
||||
let proposalInputDatum =
|
||||
passertPJust # "Proposal input not found"
|
||||
#$ pfirstJust
|
||||
#$ pfindJust
|
||||
# plam ((getProposalDatum #) . (pfield @"resolved" #))
|
||||
# pfromData txInfoF.inputs
|
||||
|
||||
|
|
@ -584,7 +585,7 @@ governorValidator as =
|
|||
|
||||
-- The sorted hashes of all the GAT receivers.
|
||||
actualReceivers =
|
||||
pmsort
|
||||
psort
|
||||
#$ pmapMaybe
|
||||
# getReceiverScriptHash
|
||||
# pfromData txInfoF.outputs
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ import Plutarch.Extra.IsData (
|
|||
PlutusTypeEnumData,
|
||||
ProductIsData (ProductIsData),
|
||||
)
|
||||
import Plutarch.Extra.List (pfirstJust)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.List (pfindJust)
|
||||
import Plutarch.Extra.Map qualified as PM
|
||||
import Plutarch.Extra.Maybe (pfromJust)
|
||||
import Plutarch.Extra.TermCont (pguardC, pletC, pmatchC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletC, pmatchC)
|
||||
import Plutarch.Lift (
|
||||
DerivePConstantViaNewtype (DerivePConstantViaNewtype),
|
||||
PConstantDecl,
|
||||
|
|
@ -941,7 +941,7 @@ pneutralOption = phoistAcyclic $
|
|||
(PAssocMap.pnull # el)
|
||||
(pcon $ PJust rt)
|
||||
(pcon PNothing)
|
||||
in pfromJust #$ pfirstJust # f # l
|
||||
in pfromJust #$ pfindJust # f # l
|
||||
|
||||
{- | Return true if the thresholds are valid.
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import Agora.Stake (
|
|||
)
|
||||
import Agora.Utils (
|
||||
plistEqualsBy,
|
||||
pltAsData,
|
||||
)
|
||||
import Plutarch.Api.V1 (PCredential)
|
||||
import Plutarch.Api.V1.AssocMap (plookup)
|
||||
|
|
@ -57,7 +56,7 @@ import Plutarch.Extra.AssetClass (passetClass, passetClassValueOf)
|
|||
import Plutarch.Extra.Category (PCategory (pidentity), PSemigroupoid ((#>>>)))
|
||||
import Plutarch.Extra.Comonad (pextract)
|
||||
import Plutarch.Extra.Field (pletAll, pletAllC)
|
||||
import Plutarch.Extra.List (pfirstJust, pisUniq', pmergeBy, pmsort)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.List (pfindJust)
|
||||
import Plutarch.Extra.Map (pupdate)
|
||||
import Plutarch.Extra.Maybe (
|
||||
passertPJust,
|
||||
|
|
@ -66,6 +65,7 @@ import Plutarch.Extra.Maybe (
|
|||
pmaybe,
|
||||
pnothing,
|
||||
)
|
||||
import Plutarch.Extra.Ord (pallUnique, pfromOrdBy, psort, ptryMergeBy)
|
||||
import Plutarch.Extra.Record (mkRecordConstr, (.&), (.=))
|
||||
import Plutarch.Extra.ScriptContext (
|
||||
pfindTxInByTxOutRef,
|
||||
|
|
@ -73,7 +73,7 @@ import Plutarch.Extra.ScriptContext (
|
|||
pisTokenSpent,
|
||||
ptryFromOutputDatum,
|
||||
)
|
||||
import Plutarch.Extra.TermCont (
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (
|
||||
pguardC,
|
||||
pletC,
|
||||
pletFieldsC,
|
||||
|
|
@ -262,7 +262,7 @@ proposalValidator as maximumCosigners =
|
|||
pletC $
|
||||
passertPJust
|
||||
# "Own output should be present"
|
||||
#$ pfirstJust
|
||||
#$ pfindJust
|
||||
# plam
|
||||
( flip pletAll $ \outputF ->
|
||||
let pstSymbol = pconstant $ proposalSTSymbol as
|
||||
|
|
@ -366,7 +366,7 @@ proposalValidator as maximumCosigners =
|
|||
\ctxF ->
|
||||
pcon $
|
||||
ctxF
|
||||
{ orderedOwners = pmsort # ctxF.orderedOwners
|
||||
{ orderedOwners = psort # ctxF.orderedOwners
|
||||
}
|
||||
|
||||
initialCtx = pcon $ PWitnessMultipleStakeContext 0 pnil
|
||||
|
|
@ -396,13 +396,13 @@ proposalValidator as maximumCosigners =
|
|||
((PSpendSingleStakeContext :--> PUnit) :--> PUnit) <-
|
||||
pletC $
|
||||
let stakeInput =
|
||||
passertPJust # "Stake input should present" #$ pfirstJust
|
||||
passertPJust # "Stake input should present" #$ pfindJust
|
||||
# ((pfield @"resolved" @_ @PTxInInfo) #>>> getStakeDatum)
|
||||
# txInfoF.inputs
|
||||
|
||||
stakeOutput =
|
||||
passertPJust # "Stake output should present"
|
||||
#$ pfirstJust # getStakeDatum # txInfoF.outputs
|
||||
#$ pfindJust # getStakeDatum # txInfoF.outputs
|
||||
|
||||
ctx = pcon $ PSpendSingleStakeContext stakeInput stakeOutput
|
||||
in plam (# ctx)
|
||||
|
|
@ -437,15 +437,16 @@ proposalValidator as maximumCosigners =
|
|||
-- signatures will be ordered.
|
||||
updatedSigs <-
|
||||
pletC $
|
||||
pmergeBy # pltAsData
|
||||
ptryMergeBy # (pfromOrdBy # plam pfromData)
|
||||
# newSigs
|
||||
# proposalInputDatumF.cosigners
|
||||
|
||||
pguardC "Less cosigners than maximum limit" $
|
||||
plength # updatedSigs #< pconstant maximumCosigners
|
||||
|
||||
pguardC "Cosigners are unique" $
|
||||
pisUniq' # updatedSigs
|
||||
-- assuming sigs are sorted
|
||||
PJust cosUnique <- pmatchC $ pallUnique #$ pmap # plam pfromData # updatedSigs
|
||||
pguardC "Cosigners are unique" cosUnique
|
||||
|
||||
pguardC "All new cosigners are witnessed by their Stake datums" $
|
||||
-- Also, this ensures that the cosigners field in the output
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import Plutarch.DataRepr (
|
|||
import Plutarch.Extra.Applicative (PApply (pliftA2))
|
||||
import Plutarch.Extra.Field (pletAll, pletAllC)
|
||||
import Plutarch.Extra.Maybe (pjust, pmaybe, pnothing)
|
||||
import Plutarch.Extra.TermCont (pmatchC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pmatchC)
|
||||
import Plutarch.Extra.Time (
|
||||
PCurrentTime (PCurrentTime),
|
||||
pisCurrentTimeWithin,
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ import Plutarch.Extra.IsData (
|
|||
PlutusTypeDataList,
|
||||
ProductIsData (ProductIsData),
|
||||
)
|
||||
import Plutarch.Extra.List (pnotNull)
|
||||
import Plutarch.Extra.Sum (PSum (PSum))
|
||||
import Plutarch.Extra.Traversable (pfoldMap)
|
||||
import Plutarch.Lift (PConstantDecl, PUnsafeLiftDecl (PLifted))
|
||||
|
|
@ -376,7 +375,7 @@ deriving via
|
|||
pstakeLocked :: forall (s :: S). Term s (PStakeDatum :--> PBool)
|
||||
pstakeLocked = phoistAcyclic $
|
||||
plam $ \stakeDatum ->
|
||||
pnotNull #$ pfield @"lockedBy" @(PBuiltinList _) # pto stakeDatum
|
||||
pnot #$ pnull #$ pfield @"lockedBy" @(PBuiltinList _) # pto stakeDatum
|
||||
|
||||
{- | Get the number of *alive* proposals that were created by the given stake.
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import Plutarch.Api.V2 (PMaybeData)
|
|||
import Plutarch.Extra.Field (pletAllC)
|
||||
import Plutarch.Extra.Maybe (pdjust, pdnothing, pmaybeData)
|
||||
import Plutarch.Extra.Record (mkRecordConstr, (.&), (.=))
|
||||
import Plutarch.Extra.TermCont (pguardC, pletC, pmatchC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletC, pmatchC)
|
||||
import Plutarch.Extra.Value (pgeqByClass, pgeqByClass')
|
||||
import Plutarch.Numeric.Additive (AdditiveMonoid (zero), AdditiveSemigroup ((+)))
|
||||
import Plutarch.SafeMoney (pdiscreteValue)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ import Plutarch.Extra.AssetClass (
|
|||
)
|
||||
import Plutarch.Extra.Bind (PBind ((#>>=)))
|
||||
import Plutarch.Extra.Field (pletAllC)
|
||||
import Plutarch.Extra.List (pfirstJust)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.List (pfindJust)
|
||||
import Plutarch.Extra.Maybe (
|
||||
passertPJust,
|
||||
pjust,
|
||||
|
|
@ -89,7 +89,7 @@ import Plutarch.Extra.ScriptContext (
|
|||
pfromOutputDatum,
|
||||
pvalueSpent,
|
||||
)
|
||||
import Plutarch.Extra.TermCont (
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (
|
||||
pguardC,
|
||||
pletC,
|
||||
pletFieldsC,
|
||||
|
|
@ -324,7 +324,7 @@ mkStakeValidator
|
|||
|
||||
let -- Look for the output stake.
|
||||
stakeOutput =
|
||||
pfirstJust
|
||||
pfindJust
|
||||
# plam
|
||||
( \output -> unTermCont $ do
|
||||
outputF <-
|
||||
|
|
@ -409,7 +409,7 @@ mkStakeValidator
|
|||
(pjust # ref)
|
||||
pnothing
|
||||
|
||||
proposalRef = pfirstJust # f # txInfoF.inputs
|
||||
proposalRef = pfindJust # f # txInfoF.inputs
|
||||
in pif pstMinted (pcon PNewProposal) $
|
||||
pmaybe
|
||||
# pcon PNoProposal
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module Agora.Treasury (
|
|||
import Agora.AuthorityToken (singleAuthorityTokenBurned)
|
||||
import Plutarch.Api.V1.Value (PValue)
|
||||
import Plutarch.Api.V2 (PScriptPurpose (PSpending), PValidator)
|
||||
import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC)
|
||||
import Plutarch.TryFrom ()
|
||||
import PlutusLedgerApi.V1.Value (CurrencySymbol)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ module Agora.Utils (
|
|||
|
||||
import Plutarch.Api.V1 (PPOSIXTime, PTokenName, PValidatorHash)
|
||||
import Plutarch.Api.V2 (PScriptHash)
|
||||
import Plutarch.Extra.TermCont (pmatchC)
|
||||
import "liqwid-plutarch-extra" Plutarch.Extra.TermCont (pmatchC)
|
||||
import Plutarch.Extra.Time (PCurrentTime (PCurrentTime))
|
||||
import Plutarch.List (puncons)
|
||||
import Plutarch.Unsafe (punsafeCoerce)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue