Skip to content

Commit 9e12bbf

Browse files
committed
Rework and fix Conway certificates.
1 parent 7007575 commit 9e12bbf

File tree

4 files changed

+69
-58
lines changed

4 files changed

+69
-58
lines changed

lib/cardano/certificate.ak

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,71 @@
11
use cardano/assets.{Lovelace}
2-
use cardano/credential.{Credential,
3-
PoolId, StakeCredential, VerificationKeyHash}
4-
use cardano/governance.{Delegatee}
2+
use cardano/credential.{Credential, StakePoolId, VerificationKeyHash}
53

64
/// An on-chain certificate attesting of some operation. Publishing
75
/// certificates / triggers different kind of rules; most of the time,
86
/// they require signatures from / specific keys.
97
pub type Certificate {
10-
// Register staking credential with an optional deposit amount
11-
RegisterStaking {
12-
delegator: StakeCredential,
13-
deposit_amount: Option<Lovelace>,
8+
// Register a stake credential with an optional deposit amount.
9+
// The deposit is always present when using the new registration certificate
10+
// format available since the Conway era.
11+
RegisterCredential { credential: Credential, deposit: Option<Lovelace> }
12+
// Un-Register a stake credential with an optional refund amount
13+
// The deposit is always present when using the new de-registration certificate
14+
// format available since the Conway era.
15+
UnregisterCredential { credential: Credential, refund: Option<Lovelace> }
16+
// Delegate stake to a [Delegate](#Delegate).
17+
DelegateCredential { credential: Credential, delegate: Delegate }
18+
// Register and delegate staking credential to a Delegatee in one certificate.
19+
RegisterAndDelegateCredential {
20+
credential: Credential,
21+
delegate: Delegate,
22+
deposit: Lovelace,
1423
}
15-
// Un-Register staking credential with an optional refund amount
16-
UnregisterStaking {
17-
delegator: StakeCredential,
18-
refund_amount: Option<Lovelace>,
24+
// Register a delegate representative (a.k.a DRep). The deposit is explicit and
25+
// is refunded when the delegate steps down (unregister).
26+
RegisterDelegateRepresentative {
27+
delegate_representative: Credential,
28+
deposit: Lovelace,
1929
}
20-
// Delegate staking credential to a Delegatee
21-
DelegateStaking { delegator: StakeCredential, delegatee: Delegatee }
22-
// Register and delegate staking credential to a Delegatee in one certificate. Noter that
23-
// deposit is mandatory.
24-
RegisterAndDelegate {
25-
delegator: StakeCredential,
26-
delegatee: Delegatee,
27-
deposit_amount: Lovelace,
30+
// Update a delegate representative (a.k.a DRep). The certificate also contains
31+
// metadata which aren't visible on-chain.
32+
UpdateDelegateRepresentative { delegate_representative: Credential }
33+
// UnRegister a delegate representative, and refund back its past deposit.
34+
UnregisterDelegateRepresentative {
35+
delegate_representative: Credential,
36+
refund: Lovelace,
2837
}
29-
// Register a DRep with a deposit value. The optional anchor is omitted.
30-
RegisterDRep { representative: Credential, deposit_amount: Lovelace }
31-
// Update a DRep. The optional anchor is omitted.
32-
UpdateDRep { representative: Credential }
33-
// UnRegister a DRep with mandatory refund value
34-
UnregisterDRep { representative: Credential, refund_amount: Lovelace }
35-
// A digest of the PoolParams
36-
PoolRegister {
37-
// poolId
38-
pool_id: PoolId,
39-
// pool VFR
40-
pool_vrf: VerificationKeyHash,
38+
// Register a new stake pool
39+
RegisterStakePool {
40+
// The hash digest of the stake pool's cold (public) key
41+
stake_pool: StakePoolId,
42+
// The hash digest of the stake pool's VRF (public) key
43+
vrf: VerificationKeyHash,
4144
}
42-
// The retirement certificate and the Epoch in which the retirement will take place
43-
PoolRetire { pool_id: PoolId, epoch: Int }
45+
// Retire a stake pool. 'at_epoch' indicates in which the retirement will take place
46+
RetireStakePool { stake_pool: StakePoolId, at_epoch: Int }
4447
// Authorize a Hot credential for a specific Committee member's cold credential
45-
AuthorizeHotCommittee { cold_memeber: Credential, hot_member: Credential }
46-
ResignColdCommittee { cold_member: Credential }
48+
AuthorizeConstitutionalCommitteeProxy {
49+
constitutional_committee_member: Credential,
50+
proxy: Credential,
51+
}
52+
// Step down from the constitutional committee as a member.
53+
RetireFromConstitutionalCommittee {
54+
constitutional_committee_member: Credential,
55+
}
56+
}
57+
58+
pub type Delegate {
59+
DelegateBlockProduction { stake_pool: StakePoolId }
60+
DelegateVote { delegate_representative: DelegateRepresentative }
61+
DelegateBoth {
62+
stake_pool: StakePoolId,
63+
delegate_representative: DelegateRepresentative,
64+
}
65+
}
66+
67+
pub type DelegateRepresentative {
68+
Registered(Credential)
69+
AlwaysAbstain
70+
AlwaysNoConfidence
4771
}

lib/cardano/credential.ak

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub type StakeCredential =
101101
pub type PaymentCredential =
102102
Credential
103103

104-
pub type PoolId =
104+
pub type StakePoolId =
105105
Hash<Blake2b_224, VerificationKey>
106106

107107
pub type VerificationKeyHash =
@@ -110,6 +110,5 @@ pub type VerificationKeyHash =
110110
pub type ScriptHash =
111111
Hash<Blake2b_224, Script>
112112

113-
// DatumHash is taken as a Datum type so this may just need to change.
114-
pub type DatumHashDigest =
113+
pub type DatumHash =
115114
Hash<Blake2b_256, Data>

lib/cardano/governance.ak

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,6 @@ pub type GovernanceAction {
7373
NicePoll
7474
}
7575

76-
pub type DRep {
77-
FromCredential(Credential)
78-
AlwaysAbstain
79-
AlwaysNoConfidence
80-
}
81-
82-
pub type Delegatee {
83-
DelegateStake(VerificationKeyHash)
84-
DelegateVote(DRep)
85-
DelegateBoth(VerificationKeyHash, DRep)
86-
}
87-
8876
pub type Vote {
8977
No
9078
Yes
@@ -111,7 +99,7 @@ pub type Mandate =
11199
Int
112100

113101
pub type Voter {
114-
CommitteeVoter(Credential)
115-
DRepVoter(Credential)
116-
StakePoolVoter(VerificationKeyHash)
102+
ConstitutionalCommitteeMember(Credential)
103+
DelegateRepresentative(Credential)
104+
StakePool(VerificationKeyHash)
117105
}

lib/cardano/transaction.ak

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use aiken/option
88
use cardano/assets.{Lovelace, PolicyId, Value}
99
use cardano/certificate.{Certificate}
1010
use cardano/credential.{
11-
Address, DatumHashDigest, Script, ScriptHash, StakeCredential, VerificationKey,
11+
Address, DatumHash, Script, ScriptHash, StakeCredential, VerificationKey,
1212
VerificationKeyHash,
1313
}
1414
use cardano/governance.{GovernanceActionId, ProposalProcedure, Vote, Voter}
@@ -105,7 +105,7 @@ pub type Transaction {
105105
validity_range: ValidityRange,
106106
extra_signatories: List<VerificationKeyHash>,
107107
redeemers: Pairs<ScriptPurpose, Redeemer>,
108-
datums: Dict<DatumHashDigest, Data>,
108+
datums: Dict<DatumHash, Data>,
109109
id: Hash<Blake2b_256, Transaction>,
110110
votes: Dict<Voter, Dict<GovernanceActionId, Vote>>,
111111
proposal_procedures: List<ProposalProcedure>,
@@ -181,7 +181,7 @@ pub type Output {
181181
pub type Datum {
182182
NoDatum
183183
/// A datum referenced by its hash digest.
184-
DatumHash(DatumHashDigest)
184+
DatumHash(DatumHash)
185185
/// A datum completely inlined in the output.
186186
InlineDatum(Data)
187187
}
@@ -221,8 +221,8 @@ pub fn find_input(
221221
/// witnesses.
222222
pub fn find_datum(
223223
outputs: List<Output>,
224-
datums: Dict<DatumHashDigest, Data>,
225-
datum_hash: DatumHashDigest,
224+
datums: Dict<DatumHash, Data>,
225+
datum_hash: DatumHash,
226226
) -> Option<Data> {
227227
datums
228228
|> dict.get(datum_hash)

0 commit comments

Comments
 (0)