| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Certificate
Description
Assemble standalone staking and governance certificates from validated credentials, delegation targets, pool parameters and optional anchors. Deposits and refunds are explicit lovelace; protocol and era checks belong to the transaction workflow. Fresh encoding may change imported transaction bytes.
import qualified Cometa.Certificate as Certificate import qualified Cometa.Credential as Credential import qualified Cometa.Governance.DRep as DRep abstain :: Credential.Credential Credential.Stake -> Certificate.Certificate abstain stake = Certificate.VoteDelegation stake DRep.AlwaysAbstain
Synopsis
- data Certificate
- = StakeRegistration !(Credential Stake)
- | StakeDeregistration !(Credential Stake)
- | StakeDelegation !(Credential Stake) !(KeyHash StakePool)
- | PoolRegistration !PoolParameters
- | PoolRetirement !(KeyHash StakePool) !Word64
- | GenesisKeyDelegation !(KeyHash Genesis) !(KeyHash GenesisDelegate) !VrfKeyHash
- | MoveInstantaneousRewards !Mir
- | Registration !(Credential Stake) !Word64
- | Unregistration !(Credential Stake) !Word64
- | VoteDelegation !(Credential Stake) !DRep
- | StakeVoteDelegation !(Credential Stake) !(KeyHash StakePool) !DRep
- | StakeRegistrationDelegation !(Credential Stake) !(KeyHash StakePool) !Word64
- | VoteRegistrationDelegation !(Credential Stake) !DRep !Word64
- | StakeVoteRegistrationDelegation !(Credential Stake) !(KeyHash StakePool) !DRep !Word64
- | AuthorizeCommitteeHot !(Credential CommitteeCold) !(Credential CommitteeHot)
- | ResignCommitteeCold !(Credential CommitteeCold) !(Maybe Anchor)
- | RegisterDRep !(Credential DRep) !Word64 !(Maybe Anchor)
- | UnregisterDRep !(Credential DRep) !Word64
- | UpdateDRep !(Credential DRep) !(Maybe Anchor)
- data Mir
- = ToOtherPot !Pot !Word64
- | ToStakeCredentials !Pot !(Map (Credential Stake) Word64)
- data Pot
- encodeCbor :: Certificate -> ByteString
- data EncodedCertificate
- decodeCbor :: ByteString -> Either Error EncodedCertificate
- fromCertificate :: Certificate -> EncodedCertificate
- toCertificate :: EncodedCertificate -> Certificate
- toCbor :: EncodedCertificate -> ByteString
Documentation
data Certificate Source #
Certificate semantic data. Deposits, refunds and reward amounts are unsigned
64-bit lovelace. Constructors do not check protocol parameters, era eligibility,
registration state, witnesses, or ledger acceptance. Equality and ordering
compare constructor then fields; Show is diagnostic.
Constructors
| StakeRegistration !(Credential Stake) | Register a stake credential without an explicit deposit (legacy form). |
| StakeDeregistration !(Credential Stake) | Deregister a stake credential without an explicit refund (legacy form). |
| StakeDelegation !(Credential Stake) !(KeyHash StakePool) | Delegate stake to the pool identified by its operator key hash. |
| PoolRegistration !PoolParameters | Register or update all pool parameters. |
| PoolRetirement !(KeyHash StakePool) !Word64 | Retire a pool at the given epoch (unsigned 64-bit epoch number). |
| GenesisKeyDelegation !(KeyHash Genesis) !(KeyHash GenesisDelegate) !VrfKeyHash | Delegate a genesis key to a delegate key and VRF key hash (legacy form). |
| MoveInstantaneousRewards !Mir | Transfer instantaneous rewards (legacy form). |
| Registration !(Credential Stake) !Word64 | Register a stake credential with its explicit deposit in lovelace. |
| Unregistration !(Credential Stake) !Word64 | Deregister a stake credential with its explicit refund in lovelace. |
| VoteDelegation !(Credential Stake) !DRep | Delegate voting power to a DRep or a predefined target. |
| StakeVoteDelegation !(Credential Stake) !(KeyHash StakePool) !DRep | Delegate stake and voting power together. |
| StakeRegistrationDelegation !(Credential Stake) !(KeyHash StakePool) !Word64 | Register and delegate stake; the last argument is the deposit in lovelace. |
| VoteRegistrationDelegation !(Credential Stake) !DRep !Word64 | Register and delegate voting power; the last argument is the deposit in lovelace. |
| StakeVoteRegistrationDelegation !(Credential Stake) !(KeyHash StakePool) !DRep !Word64 | Register and delegate both powers; the last argument is the deposit in lovelace. |
| AuthorizeCommitteeHot !(Credential CommitteeCold) !(Credential CommitteeHot) | Authorize a committee hot credential using its cold credential. |
| ResignCommitteeCold !(Credential CommitteeCold) !(Maybe Anchor) | Resign a committee cold credential with an optional explanation. |
| RegisterDRep !(Credential DRep) !Word64 !(Maybe Anchor) | Register a DRep with its deposit in lovelace and optional metadata. |
| UnregisterDRep !(Credential DRep) !Word64 | Unregister a DRep with its refund in lovelace. |
| UpdateDRep !(Credential DRep) !(Maybe Anchor) | Update or remove a DRep metadata anchor. |
Instances
| Show Certificate Source # | |
Defined in Cometa.Internal.Certificate Methods showsPrec :: Int -> Certificate -> ShowS # show :: Certificate -> String # showList :: [Certificate] -> ShowS # | |
| Eq Certificate Source # | |
Defined in Cometa.Internal.Certificate | |
| Ord Certificate Source # | |
Defined in Cometa.Internal.Certificate Methods compare :: Certificate -> Certificate -> Ordering # (<) :: Certificate -> Certificate -> Bool # (<=) :: Certificate -> Certificate -> Bool # (>) :: Certificate -> Certificate -> Bool # (>=) :: Certificate -> Certificate -> Bool # max :: Certificate -> Certificate -> Certificate # min :: Certificate -> Certificate -> Certificate # | |
Instantaneous reward transfers. All quantities are lovelace from 0 through 2^64-1; signed reward adjustments are rejected.
Constructors
| ToOtherPot !Pot !Word64 | Transfer from the source pot to the other accounting pot. |
| ToStakeCredentials !Pot !(Map (Credential Stake) Word64) | Assign rewards from the source pot to unique stake credentials. |
Source accounting pot for instantaneous rewards. Ordering follows CBOR codes.
encodeCbor :: Certificate -> ByteString Source #
Encode semantic data as fresh definite CBOR with minimal unsigned integers. Reward credentials are sorted by kind and hash. No ledger validation occurs.
data EncodedCertificate Source #
Certificate with its exact original CBOR. Equality and ordering include bytes.
Instances
| Show EncodedCertificate Source # | |
Defined in Cometa.Internal.Certificate Methods showsPrec :: Int -> EncodedCertificate -> ShowS # show :: EncodedCertificate -> String # showList :: [EncodedCertificate] -> ShowS # | |
| Eq EncodedCertificate Source # | |
Defined in Cometa.Internal.Certificate Methods (==) :: EncodedCertificate -> EncodedCertificate -> Bool # (/=) :: EncodedCertificate -> EncodedCertificate -> Bool # | |
| Ord EncodedCertificate Source # | |
Defined in Cometa.Internal.Certificate Methods compare :: EncodedCertificate -> EncodedCertificate -> Ordering # (<) :: EncodedCertificate -> EncodedCertificate -> Bool # (<=) :: EncodedCertificate -> EncodedCertificate -> Bool # (>) :: EncodedCertificate -> EncodedCertificate -> Bool # (>=) :: EncodedCertificate -> EncodedCertificate -> Bool # max :: EncodedCertificate -> EncodedCertificate -> EncodedCertificate # min :: EncodedCertificate -> EncodedCertificate -> EncodedCertificate # | |
decodeCbor :: ByteString -> Either Error EncodedCertificate Source #
Validate one complete certificate and retain its exact CBOR. Accepts definite
and indefinite arrays, nonminimal integers, and all certificate kinds 0–18.
Credential/hash lengths, arity and unsigned 64-bit bounds are checked. MIR
signed amounts and duplicate reward credentials are rejected. Malformed input
or trailing bytes returns InvalidCertificateCbor.
fromCertificate :: Certificate -> EncodedCertificate Source #
Create an exact envelope using fresh certificate encoding.
toCertificate :: EncodedCertificate -> Certificate Source #
Inspect semantic certificate fields without changing the exact envelope.
toCbor :: EncodedCertificate -> ByteString Source #
Exact imported bytes, or fresh bytes for values built with fromCertificate.
Use this when imported certificate encoding must remain unchanged.