add changelog entry for Credential change
This commit is contained in:
parent
968cf337cc
commit
b32ae8ca57
4 changed files with 28 additions and 26 deletions
11
CHANGELOG.md
11
CHANGELOG.md
|
|
@ -6,6 +6,17 @@ This format is based on [Keep A Changelog](https://keepachangelog.com/en/1.0.0).
|
||||||
|
|
||||||
### Modified
|
### Modified
|
||||||
|
|
||||||
|
- Use `Credential` instead of `PubKeyHash`
|
||||||
|
|
||||||
|
Included by [#158](https://github.com/Liqwid-Labs/agora/pull/158).
|
||||||
|
|
||||||
|
NOTE: This changes the representation of the following types:
|
||||||
|
|
||||||
|
- `PStakeDatum`
|
||||||
|
- `PStakeRedeemer`
|
||||||
|
- `PProposalDatum`
|
||||||
|
- `PProposalRedeemer`
|
||||||
|
|
||||||
- Use plutus v2 types.
|
- Use plutus v2 types.
|
||||||
|
|
||||||
Included by [#156](https://github.com/Liqwid-Labs/agora/pull/156).
|
Included by [#156](https://github.com/Liqwid-Labs/agora/pull/156).
|
||||||
|
|
|
||||||
|
|
@ -5,30 +5,21 @@ Description: Functions for dealing with generalized credentials.
|
||||||
|
|
||||||
Functions for dealing with generalized credentials.
|
Functions for dealing with generalized credentials.
|
||||||
-}
|
-}
|
||||||
module Agora.Credential (PAuthorizationCredential, AuthorizationCredential, pauthorizedBy, authorizationContext) where
|
module Agora.Credential (
|
||||||
|
pauthorizedBy,
|
||||||
|
authorizationContext,
|
||||||
|
) where
|
||||||
|
|
||||||
import GHC.Records (HasField)
|
import GHC.Records (HasField)
|
||||||
import Plutarch.Api.V1 (PCredential (..), PPubKeyHash)
|
import Plutarch.Api.V1 (PCredential (PPubKeyCredential, PScriptCredential), PPubKeyHash)
|
||||||
import Plutarch.Api.V2 (PTxInInfo (..))
|
import Plutarch.Api.V2 (PTxInInfo)
|
||||||
import Plutarch.Extra.ScriptContext (ptxSignedBy)
|
import Plutarch.Extra.ScriptContext (ptxSignedBy)
|
||||||
import Plutarch.Extra.TermCont (pmatchC)
|
import Plutarch.Extra.TermCont (pmatchC)
|
||||||
import PlutusLedgerApi.V2 (Credential)
|
|
||||||
|
|
||||||
{- | This type represents a general purpose authority which can be used
|
|
||||||
to check for approval.
|
|
||||||
|
|
||||||
The most basic case is simply a PubKeyCredential.
|
|
||||||
|
|
||||||
@since 1.0.0
|
|
||||||
-}
|
|
||||||
type AuthorizationCredential =
|
|
||||||
Credential
|
|
||||||
|
|
||||||
type PAuthorizationCredential =
|
|
||||||
PCredential
|
|
||||||
|
|
||||||
{- | Context required in order to check 'AuthorizationCredential'.
|
{- | Context required in order to check 'AuthorizationCredential'.
|
||||||
|
|
||||||
|
Construct using 'authorizationContext'.
|
||||||
|
|
||||||
@since 1.0.0
|
@since 1.0.0
|
||||||
-}
|
-}
|
||||||
data PAuthorizationContext (s :: S) = PAuthorizationContext
|
data PAuthorizationContext (s :: S) = PAuthorizationContext
|
||||||
|
|
@ -55,7 +46,7 @@ instance DerivePlutusType PAuthorizationContext where
|
||||||
@since 1.0.0
|
@since 1.0.0
|
||||||
-}
|
-}
|
||||||
authorizationContext ::
|
authorizationContext ::
|
||||||
forall {r} {s :: S}.
|
forall (s :: S) r.
|
||||||
( HasField "inputs" r (Term s (PBuiltinList PTxInInfo))
|
( HasField "inputs" r (Term s (PBuiltinList PTxInInfo))
|
||||||
, HasField "signatories" r (Term s (PBuiltinList (PAsData PPubKeyHash)))
|
, HasField "signatories" r (Term s (PBuiltinList (PAsData PPubKeyHash)))
|
||||||
) =>
|
) =>
|
||||||
|
|
@ -68,7 +59,7 @@ authorizationContext f =
|
||||||
|
|
||||||
@since 1.0.0
|
@since 1.0.0
|
||||||
-}
|
-}
|
||||||
pauthorizedBy :: forall (s :: S). Term s (PAuthorizationContext :--> PAuthorizationCredential :--> PBool)
|
pauthorizedBy :: forall (s :: S). Term s (PAuthorizationContext :--> PCredential :--> PBool)
|
||||||
pauthorizedBy = phoistAcyclic $
|
pauthorizedBy = phoistAcyclic $
|
||||||
plam $ \ctx credential -> unTermCont $ do
|
plam $ \ctx credential -> unTermCont $ do
|
||||||
ctxF <- pmatchC ctx
|
ctxF <- pmatchC ctx
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ module Agora.Proposal (
|
||||||
pisProposalThresholdsValid,
|
pisProposalThresholdsValid,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Agora.Credential (AuthorizationCredential, PAuthorizationCredential)
|
|
||||||
import Agora.Plutarch.Orphans ()
|
import Agora.Plutarch.Orphans ()
|
||||||
import Agora.Proposal.Time (
|
import Agora.Proposal.Time (
|
||||||
PProposalStartingTime,
|
PProposalStartingTime,
|
||||||
|
|
@ -53,7 +52,7 @@ import Agora.Proposal.Time (
|
||||||
import Agora.SafeMoney (GTTag)
|
import Agora.SafeMoney (GTTag)
|
||||||
import Data.Tagged (Tagged)
|
import Data.Tagged (Tagged)
|
||||||
import Generics.SOP qualified as SOP
|
import Generics.SOP qualified as SOP
|
||||||
import Plutarch.Api.V1 (PMap, PValidatorHash)
|
import Plutarch.Api.V1 (PCredential, PMap, PValidatorHash)
|
||||||
import Plutarch.Api.V1.AssocMap qualified as PAssocMap
|
import Plutarch.Api.V1.AssocMap qualified as PAssocMap
|
||||||
import Plutarch.Api.V2 (
|
import Plutarch.Api.V2 (
|
||||||
KeyGuarantees (Unsorted),
|
KeyGuarantees (Unsorted),
|
||||||
|
|
@ -347,7 +346,7 @@ data ProposalRedeemer
|
||||||
-- provided enough GT is shared among them.
|
-- provided enough GT is shared among them.
|
||||||
--
|
--
|
||||||
-- This list should be sorted in ascending order.
|
-- This list should be sorted in ascending order.
|
||||||
Cosign [AuthorizationCredential]
|
Cosign [Credential]
|
||||||
| -- | Allow unlocking one or more stakes with votes towards particular 'ResultTag'.
|
| -- | Allow unlocking one or more stakes with votes towards particular 'ResultTag'.
|
||||||
Unlock
|
Unlock
|
||||||
| -- | Advance the proposal, performing the required checks for whether that is legal.
|
| -- | Advance the proposal, performing the required checks for whether that is legal.
|
||||||
|
|
@ -617,7 +616,7 @@ newtype PProposalDatum (s :: S) = PProposalDatum
|
||||||
'[ "proposalId" ':= PProposalId
|
'[ "proposalId" ':= PProposalId
|
||||||
, "effects" ':= PMap 'Unsorted PResultTag PProposalEffectGroup
|
, "effects" ':= PMap 'Unsorted PResultTag PProposalEffectGroup
|
||||||
, "status" ':= PProposalStatus
|
, "status" ':= PProposalStatus
|
||||||
, "cosigners" ':= PBuiltinList (PAsData PAuthorizationCredential)
|
, "cosigners" ':= PBuiltinList (PAsData PCredential)
|
||||||
, "thresholds" ':= PProposalThresholds
|
, "thresholds" ':= PProposalThresholds
|
||||||
, "votes" ':= PProposalVotes
|
, "votes" ':= PProposalVotes
|
||||||
, "timingConfig" ':= PProposalTimingConfig
|
, "timingConfig" ':= PProposalTimingConfig
|
||||||
|
|
@ -656,7 +655,7 @@ deriving via (DerivePConstantViaDataList ProposalDatum PProposalDatum) instance
|
||||||
-}
|
-}
|
||||||
data PProposalRedeemer (s :: S)
|
data PProposalRedeemer (s :: S)
|
||||||
= PVote (Term s (PDataRecord '["resultTag" ':= PResultTag]))
|
= PVote (Term s (PDataRecord '["resultTag" ':= PResultTag]))
|
||||||
| PCosign (Term s (PDataRecord '["newCosigners" ':= PBuiltinList (PAsData PAuthorizationCredential)]))
|
| PCosign (Term s (PDataRecord '["newCosigners" ':= PBuiltinList (PAsData PCredential)]))
|
||||||
| PUnlock (Term s (PDataRecord '[]))
|
| PUnlock (Term s (PDataRecord '[]))
|
||||||
| PAdvanceProposal (Term s (PDataRecord '[]))
|
| PAdvanceProposal (Term s (PDataRecord '[]))
|
||||||
deriving stock
|
deriving stock
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ module Agora.Proposal.Scripts (
|
||||||
proposalPolicy,
|
proposalPolicy,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Agora.Credential (PAuthorizationCredential, authorizationContext, pauthorizedBy)
|
import Agora.Credential (authorizationContext, pauthorizedBy)
|
||||||
import Agora.Proposal (
|
import Agora.Proposal (
|
||||||
PProposalDatum (PProposalDatum),
|
PProposalDatum (PProposalDatum),
|
||||||
PProposalRedeemer (..),
|
PProposalRedeemer (..),
|
||||||
|
|
@ -40,6 +40,7 @@ import Agora.Stake (
|
||||||
import Agora.Utils (
|
import Agora.Utils (
|
||||||
pltAsData,
|
pltAsData,
|
||||||
)
|
)
|
||||||
|
import Plutarch.Api.V1 (PCredential)
|
||||||
import Plutarch.Api.V2 (
|
import Plutarch.Api.V2 (
|
||||||
PDatumHash,
|
PDatumHash,
|
||||||
PMintingPolicy,
|
PMintingPolicy,
|
||||||
|
|
@ -299,7 +300,7 @@ proposalValidator as maximumCosigners =
|
||||||
Term
|
Term
|
||||||
_
|
_
|
||||||
( ( PInteger
|
( ( PInteger
|
||||||
:--> PBuiltinList (PAsData PAuthorizationCredential)
|
:--> PBuiltinList (PAsData PCredential)
|
||||||
:--> PUnit
|
:--> PUnit
|
||||||
)
|
)
|
||||||
:--> PUnit
|
:--> PUnit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue