Skip to content

Commit 2a61017

Browse files
committed
Docstring fields
1 parent 4a0a83e commit 2a61017

2 files changed

Lines changed: 113 additions & 4 deletions

File tree

pycardano/certificate.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class Anchor(ArrayCBORSerializable):
5151
"""
5252

5353
url: str
54+
"""The URL pointing to the anchor's resource location"""
55+
5456
data_hash: AnchorDataHash
57+
"""The hash of the data associated with this anchor"""
5558

5659

5760
@dataclass(repr=False)
@@ -65,6 +68,7 @@ class StakeCredential(ArrayCBORSerializable):
6568
_CODE: Optional[int] = field(init=False, default=None)
6669

6770
credential: Union[VerificationKeyHash, ScriptHash]
71+
"""The actual credential, either a verification key hash or script hash"""
6872

6973
def __post_init__(self):
7074
if isinstance(self.credential, VerificationKeyHash):
@@ -121,9 +125,12 @@ class DRep(ArrayCBORSerializable):
121125
"""
122126

123127
kind: DRepKind
128+
"""The type of DRep (verification key, script hash, always abstain, or always no confidence)"""
129+
124130
credential: Optional[Union[VerificationKeyHash, ScriptHash]] = field(
125131
default=None, metadata={"optional": True}
126132
)
133+
"""The credential associated with this DRep, if applicable"""
127134

128135
@classmethod
129136
@limit_primitive_type(list)
@@ -156,6 +163,7 @@ class StakeRegistration(CodedSerializable):
156163

157164
_CODE: int = field(init=False, default=0)
158165
stake_credential: StakeCredential
166+
"""The stake credential being registered"""
159167

160168

161169
@dataclass(repr=False)
@@ -164,6 +172,7 @@ class StakeDeregistration(CodedSerializable):
164172

165173
_CODE: int = field(init=False, default=1)
166174
stake_credential: StakeCredential
175+
"""The stake credential being deregistered"""
167176

168177

169178
@dataclass(repr=False)
@@ -172,7 +181,10 @@ class StakeDelegation(CodedSerializable):
172181

173182
_CODE: int = field(init=False, default=2)
174183
stake_credential: StakeCredential
184+
"""The stake credential being delegated"""
185+
175186
pool_keyhash: PoolKeyHash
187+
"""The hash of the pool's key to delegate to"""
176188

177189

178190
@dataclass(repr=False)
@@ -181,6 +193,7 @@ class PoolRegistration(CodedSerializable):
181193

182194
_CODE: int = field(init=False, default=3)
183195
pool_params: PoolParams
196+
"""The parameters defining the stake pool's configuration"""
184197

185198
def to_primitive(self):
186199
pool_params = self.pool_params.to_primitive()
@@ -212,7 +225,10 @@ class PoolRetirement(CodedSerializable):
212225

213226
_CODE: int = field(init=False, default=4)
214227
pool_keyhash: PoolKeyHash
228+
"""The hash of the pool's key that is being retired"""
229+
215230
epoch: int
231+
"""The epoch number when the pool will retire"""
216232

217233

218234
@dataclass(repr=False)
@@ -221,7 +237,10 @@ class StakeRegistrationConway(CodedSerializable):
221237

222238
_CODE: int = field(init=False, default=7)
223239
stake_credential: StakeCredential
240+
"""The stake credential being registered"""
241+
224242
coin: int
243+
"""The amount of coins associated with this registration"""
225244

226245

227246
@dataclass(repr=False)
@@ -230,7 +249,10 @@ class StakeDeregistrationConway(CodedSerializable):
230249

231250
_CODE: int = field(init=False, default=8)
232251
stake_credential: StakeCredential
252+
"""The stake credential being deregistered"""
253+
233254
coin: int
255+
"""The amount of coins associated with this deregistration"""
234256

235257

236258
@dataclass(repr=False)
@@ -239,7 +261,10 @@ class VoteDelegation(CodedSerializable):
239261

240262
_CODE: int = field(init=False, default=9)
241263
stake_credential: StakeCredential
264+
"""The stake credential delegating its voting power"""
265+
242266
drep: DRep
267+
"""The DRep receiving the voting power delegation"""
243268

244269

245270
@dataclass(repr=False)
@@ -248,8 +273,13 @@ class StakeAndVoteDelegation(CodedSerializable):
248273

249274
_CODE: int = field(init=False, default=10)
250275
stake_credential: StakeCredential
276+
"""The stake credential being delegated"""
277+
251278
pool_keyhash: PoolKeyHash
279+
"""The hash of the pool's key receiving the stake delegation"""
280+
252281
drep: DRep
282+
"""The DRep receiving the voting power delegation"""
253283

254284

255285
@dataclass(repr=False)
@@ -258,8 +288,13 @@ class StakeRegistrationAndDelegation(CodedSerializable):
258288

259289
_CODE: int = field(init=False, default=11)
260290
stake_credential: StakeCredential
291+
"""The stake credential being registered and delegated"""
292+
261293
pool_keyhash: PoolKeyHash
294+
"""The hash of the pool's key receiving the delegation"""
295+
262296
coin: int
297+
"""The amount of coins associated with this registration"""
263298

264299

265300
@dataclass(repr=False)
@@ -268,8 +303,13 @@ class StakeRegistrationAndVoteDelegation(CodedSerializable):
268303

269304
_CODE: int = field(init=False, default=12)
270305
stake_credential: StakeCredential
306+
"""The stake credential being registered"""
307+
271308
drep: DRep
309+
"""The DRep receiving the voting power delegation"""
310+
272311
coin: int
312+
"""The amount of coins associated with this registration"""
273313

274314

275315
@dataclass(repr=False)
@@ -278,9 +318,16 @@ class StakeRegistrationAndDelegationAndVoteDelegation(CodedSerializable):
278318

279319
_CODE: int = field(init=False, default=13)
280320
stake_credential: StakeCredential
321+
"""The stake credential being registered and delegated"""
322+
281323
pool_keyhash: PoolKeyHash
324+
"""The hash of the pool's key receiving the stake delegation"""
325+
282326
drep: DRep
327+
"""The DRep receiving the voting power delegation"""
328+
283329
coin: int
330+
"""The amount of coins associated with this registration"""
284331

285332

286333
@dataclass(repr=False)
@@ -289,7 +336,10 @@ class AuthCommitteeHotCertificate(CodedSerializable):
289336

290337
_CODE: int = field(init=False, default=14)
291338
committee_cold_credential: StakeCredential
339+
"""The cold credential of the committee member"""
340+
292341
committee_hot_credential: StakeCredential
342+
"""The hot credential being authorized"""
293343

294344

295345
@dataclass(repr=False)
@@ -298,7 +348,10 @@ class ResignCommitteeColdCertificate(CodedSerializable):
298348

299349
_CODE: int = field(init=False, default=15)
300350
committee_cold_credential: StakeCredential
351+
"""The cold credential of the resigning committee member"""
352+
301353
anchor: Optional[Anchor]
354+
"""Optional anchor containing additional metadata about the resignation"""
302355

303356

304357
@dataclass(repr=False)
@@ -307,8 +360,13 @@ class RegDRepCert(CodedSerializable):
307360

308361
_CODE: int = field(init=False, default=16)
309362
drep_credential: DRepCredential
363+
"""The credential of the DRep being registered"""
364+
310365
coin: int
366+
"""The amount of coins associated with this registration"""
367+
311368
anchor: Optional[Anchor] = field(default=None)
369+
"""Optional anchor containing additional metadata about the DRep"""
312370

313371

314372
@dataclass(repr=False)
@@ -317,7 +375,10 @@ class UnregDRepCertificate(CodedSerializable):
317375

318376
_CODE: int = field(init=False, default=17)
319377
drep_credential: DRepCredential
378+
"""The credential of the DRep being unregistered"""
379+
320380
coin: int
381+
"""The amount of coins associated with this unregistration"""
321382

322383

323384
@dataclass(repr=False)
@@ -326,7 +387,10 @@ class UpdateDRepCertificate(CodedSerializable):
326387

327388
_CODE: int = field(init=False, default=18)
328389
drep_credential: DRepCredential
390+
"""The credential of the DRep being updated"""
391+
329392
anchor: Optional[Anchor]
393+
"""Optional anchor containing the updated metadata"""
330394

331395

332396
Certificate = Union[

pycardano/governance.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ class GovActionId(ArrayCBORSerializable):
4747
"""
4848

4949
transaction_id: TransactionId
50-
gov_action_index: int # uint .size 2
50+
"""The transaction ID where this governance action was submitted"""
51+
52+
gov_action_index: int
53+
"""The index of this governance action within the transaction (0-65535)"""
5154

5255
def __post_init__(self):
5356
if not 0 <= self.gov_action_index <= 65535: # uint .size 2
@@ -63,17 +66,29 @@ def from_primitive(
6366

6467
@dataclass(repr=False)
6568
class ParameterChangeAction(CodedSerializable):
69+
"""Represents a governance action to change protocol parameters."""
70+
6671
_CODE: int = field(init=False, default=0)
6772
gov_action_id: Optional[GovActionId]
68-
protocol_param_update: Dict # TODO: Define ProtocolParamUpdate type
73+
"""Optional reference to a previous governance action"""
74+
75+
protocol_param_update: Dict
76+
"""Dictionary containing the protocol parameters to be updated"""
77+
6978
policy_hash: Optional[PolicyHash]
79+
"""Optional policy hash associated with this parameter change"""
7080

7181

7282
@dataclass(repr=False)
7383
class HardForkInitiationAction(CodedSerializable):
84+
"""Represents a governance action to initiate a hard fork."""
85+
7486
_CODE: int = field(init=False, default=1)
7587
gov_action_id: Optional[GovActionId]
76-
protocol_version: Tuple[int, int] # major, minor version
88+
"""Optional reference to a previous governance action"""
89+
90+
protocol_version: Tuple[int, int]
91+
"""The target protocol version as (major, minor) version numbers"""
7792

7893
def __post_init__(self):
7994
major, minor = self.protocol_version
@@ -83,37 +98,61 @@ def __post_init__(self):
8398

8499
@dataclass(repr=False)
85100
class TreasuryWithdrawalsAction(CodedSerializable):
101+
"""Represents a governance action to withdraw funds from the treasury."""
102+
86103
_CODE: int = field(init=False, default=2)
87104
withdrawals: Withdrawals
105+
"""The withdrawal amounts and their destinations"""
106+
88107
policy_hash: Optional[PolicyHash]
108+
"""Optional policy hash associated with these withdrawals"""
89109

90110

91111
@dataclass(repr=False)
92112
class NoConfidence(CodedSerializable):
113+
"""Represents a governance action expressing no confidence."""
114+
93115
_CODE: int = field(init=False, default=3)
94116
gov_action_id: Optional[GovActionId]
117+
"""Optional reference to a previous governance action"""
95118

96119

97120
@dataclass(repr=False)
98121
class UpdateCommittee(CodedSerializable):
122+
"""Represents a governance action to update the constitutional committee."""
123+
99124
_CODE: int = field(init=False, default=4)
100125
gov_action_id: Optional[GovActionId]
126+
"""Optional reference to a previous governance action"""
127+
101128
committee_cold_credentials: Set[
102129
StakeCredential
103130
] # TODO: Define CommitteeColdCredential
131+
"""Set of cold credentials for committee members"""
132+
104133
committee_expiration: Dict[StakeCredential, int] # credential -> epoch_no
134+
"""Mapping of committee members to their expiration epochs"""
135+
105136
quorum: Tuple[int, int] # unit_interval
137+
"""The quorum threshold as a unit interval (numerator, denominator)"""
106138

107139

108140
@dataclass(repr=False)
109141
class NewConstitution(CodedSerializable):
142+
"""Represents a governance action to establish a new constitution."""
143+
110144
_CODE: int = field(init=False, default=5)
111145
gov_action_id: Optional[GovActionId]
146+
"""Optional reference to a previous governance action"""
147+
112148
constitution: Tuple[Anchor, Optional[ScriptHash]]
149+
"""The constitution data as (anchor, optional script hash)"""
113150

114151

115152
@dataclass(repr=False)
116153
class InfoAction(CodedSerializable):
154+
"""Represents an informational governance action with no direct effect."""
155+
117156
_CODE: int = field(init=False, default=6)
118157

119158

@@ -125,7 +164,10 @@ class VotingProcedure(ArrayCBORSerializable):
125164
"""
126165

127166
vote: Vote
167+
"""The vote cast (YES, NO, or ABSTAIN)"""
168+
128169
anchor: Optional[Anchor]
170+
"""Optional metadata associated with this vote"""
129171

130172
@classmethod
131173
@limit_primitive_type(list)
@@ -148,7 +190,10 @@ class Voter(ArrayCBORSerializable):
148190
_CODE: Optional[int] = field(init=False, default=None)
149191

150192
credential: Union[VerificationKeyHash, ScriptHash]
151-
voter_type: str # One of: "committee_hot", "drep", "staking_pool"
193+
"""The credential identifying the voter"""
194+
195+
voter_type: str
196+
"""The type of voter ('committee_hot', 'drep', or 'staking_pool')"""
152197

153198
def __post_init__(self):
154199
if self.voter_type == "committee_hot":

0 commit comments

Comments
 (0)