cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

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

Instances details
Show Certificate Source # 
Instance details

Defined in Cometa.Internal.Certificate

Eq Certificate Source # 
Instance details

Defined in Cometa.Internal.Certificate

Ord Certificate Source # 
Instance details

Defined in Cometa.Internal.Certificate

data Mir Source #

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.

Instances

Instances details
Show Mir Source # 
Instance details

Defined in Cometa.Internal.Certificate

Methods

showsPrec :: Int -> Mir -> ShowS #

show :: Mir -> String #

showList :: [Mir] -> ShowS #

Eq Mir Source # 
Instance details

Defined in Cometa.Internal.Certificate

Methods

(==) :: Mir -> Mir -> Bool #

(/=) :: Mir -> Mir -> Bool #

Ord Mir Source # 
Instance details

Defined in Cometa.Internal.Certificate

Methods

compare :: Mir -> Mir -> Ordering #

(<) :: Mir -> Mir -> Bool #

(<=) :: Mir -> Mir -> Bool #

(>) :: Mir -> Mir -> Bool #

(>=) :: Mir -> Mir -> Bool #

max :: Mir -> Mir -> Mir #

min :: Mir -> Mir -> Mir #

data Pot Source #

Source accounting pot for instantaneous rewards. Ordering follows CBOR codes.

Constructors

Reserves

The reserve accounting pot.

Treasury

The treasury accounting pot.

Instances

Instances details
Bounded Pot Source # 
Instance details

Defined in Cometa.Internal.Certificate

Methods

minBound :: Pot #

maxBound :: Pot #

Enum Pot Source # 
Instance details

Defined in Cometa.Internal.Certificate

Methods

succ :: Pot -> Pot #

pred :: Pot -> Pot #

toEnum :: Int -> Pot #

fromEnum :: Pot -> Int #

enumFrom :: Pot -> [Pot] #

enumFromThen :: Pot -> Pot -> [Pot] #

enumFromTo :: Pot -> Pot -> [Pot] #

enumFromThenTo :: Pot -> Pot -> Pot -> [Pot] #

Show Pot Source # 
Instance details

Defined in Cometa.Internal.Certificate

Methods

showsPrec :: Int -> Pot -> ShowS #

show :: Pot -> String #

showList :: [Pot] -> ShowS #

Eq Pot Source # 
Instance details

Defined in Cometa.Internal.Certificate

Methods

(==) :: Pot -> Pot -> Bool #

(/=) :: Pot -> Pot -> Bool #

Ord Pot Source # 
Instance details

Defined in Cometa.Internal.Certificate

Methods

compare :: Pot -> Pot -> Ordering #

(<) :: Pot -> Pot -> Bool #

(<=) :: Pot -> Pot -> Bool #

(>) :: Pot -> Pot -> Bool #

(>=) :: Pot -> Pot -> Bool #

max :: Pot -> Pot -> Pot #

min :: Pot -> Pot -> Pot #

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.

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.