@@ -111,6 +111,15 @@ data BakerKeyUpdate = BakerKeyUpdate
111111 }
112112 deriving (Eq , Ord , Show )
113113
114+ -- | Extract the 'BakerKeyUpdate' from a 'BakerKeysWithProofs'.
115+ bakerKeysWithoutProofs :: BakerKeysWithProofs -> BakerKeyUpdate
116+ bakerKeysWithoutProofs BakerKeysWithProofs {.. } =
117+ BakerKeyUpdate
118+ { bkuSignKey = bkwpSignatureVerifyKey,
119+ bkuAggregationKey = bkwpAggregationVerifyKey,
120+ bkuElectionKey = bkwpElectionVerifyKey
121+ }
122+
114123data BakerKeyUpdateResult
115124 = -- | The keys were updated successfully
116125 BKUSuccess ! BakerId
@@ -174,32 +183,83 @@ data BakerAddResult
174183 BAStakeUnderThreshold
175184 deriving (Eq , Ord , Show )
176185
177- -- | Data structure used to add/remove/update baker.
178- data BakerConfigure
179- = -- | Add a baker, all fields are required.
180- BakerConfigureAdd
181- { bcaKeys :: ! BakerKeyUpdate ,
182- bcaCapital :: ! Amount ,
183- bcaRestakeEarnings :: ! Bool ,
184- bcaOpenForDelegation :: ! OpenStatus ,
185- bcaMetadataURL :: ! UrlText ,
186- bcaTransactionFeeCommission :: ! AmountFraction ,
187- bcaBakingRewardCommission :: ! AmountFraction ,
188- bcaFinalizationRewardCommission :: ! AmountFraction
189- }
190- | -- | Update baker with optional fields.
191- BakerConfigureUpdate
192- { -- | The timestamp of the current slot (slot time).
193- bcuSlotTimestamp :: ! Timestamp ,
194- bcuKeys :: ! (Maybe BakerKeyUpdate ),
195- bcuCapital :: ! (Maybe Amount ),
196- bcuRestakeEarnings :: ! (Maybe Bool ),
197- bcuOpenForDelegation :: ! (Maybe OpenStatus ),
198- bcuMetadataURL :: ! (Maybe UrlText ),
199- bcuTransactionFeeCommission :: ! (Maybe AmountFraction ),
200- bcuBakingRewardCommission :: ! (Maybe AmountFraction ),
201- bcuFinalizationRewardCommission :: ! (Maybe AmountFraction )
186+ -- | Result of remove baker.
187+ data BakerRemoveResult
188+ = -- | The baker was removed, effective from the given epoch.
189+ BRRemoved ! BakerId ! Epoch
190+ | -- | This is not a valid baker.
191+ BRInvalidBaker
192+ | -- | A change is already pending on this baker.
193+ BRChangePending ! BakerId
194+ deriving (Eq , Ord , Show )
195+
196+ -- | Parameters for adding a validator.
197+ data ValidatorAdd = ValidatorAdd
198+ { -- | The keys for the validator.
199+ vaKeys :: ! BakerKeyUpdate ,
200+ -- | The initial stake.
201+ vaCapital :: ! Amount ,
202+ -- | Whether to restake earned rewards
203+ vaRestakeEarnings :: ! Bool ,
204+ -- | Whether the validator pool is open for delegation.
205+ vaOpenForDelegation :: ! OpenStatus ,
206+ -- | The metadata URL for the validator.
207+ vaMetadataURL :: ! UrlText ,
208+ -- | The commission rates for the validator.
209+ vaCommissionRates :: ! CommissionRates
210+ }
211+ deriving (Eq , Show )
212+
213+ -- | Parameters for updating an existing validator. Where a field is 'Nothing', the field is not
214+ -- updated.
215+ data ValidatorUpdate = ValidatorUpdate
216+ { -- | The new keys for the validator.
217+ vuKeys :: ! (Maybe BakerKeyUpdate ),
218+ -- | The new capital for the validator. If this is @Just 0@, the validator is removed.
219+ vuCapital :: ! (Maybe Amount ),
220+ -- | Whether to restake earned rewards.
221+ vuRestakeEarnings :: ! (Maybe Bool ),
222+ -- | Whether the validator pool is open for delegation.
223+ vuOpenForDelegation :: ! (Maybe OpenStatus ),
224+ -- | The new metadata URL for the validator.
225+ vuMetadataURL :: ! (Maybe UrlText ),
226+ -- | The new transaction fee commission for the validator.
227+ vuTransactionFeeCommission :: ! (Maybe AmountFraction ),
228+ -- | The new baking reward commission for the validator.
229+ vuBakingRewardCommission :: ! (Maybe AmountFraction ),
230+ -- | The new finalization reward commission for the validator.
231+ vuFinalizationRewardCommission :: ! (Maybe AmountFraction )
232+ }
233+ deriving (Eq , Show )
234+
235+ -- | A 'ValidatorUpdate' that removes the validator.
236+ validatorRemove :: ValidatorUpdate
237+ validatorRemove =
238+ ValidatorUpdate
239+ { vuKeys = Nothing ,
240+ vuCapital = Just 0 ,
241+ vuRestakeEarnings = Nothing ,
242+ vuOpenForDelegation = Nothing ,
243+ vuMetadataURL = Nothing ,
244+ vuTransactionFeeCommission = Nothing ,
245+ vuBakingRewardCommission = Nothing ,
246+ vuFinalizationRewardCommission = Nothing
202247 }
248+
249+ -- | Failure modes when configuring a validator.
250+ data ValidatorConfigureFailure
251+ = -- | The stake is below the required threshold dictated by current chain parameters.
252+ VCFStakeUnderThreshold
253+ | -- | The transaction fee commission is not in the allowed range.
254+ VCFTransactionFeeCommissionNotInRange
255+ | -- | The baking reward commission is not in the allowed range.
256+ VCFBakingRewardCommissionNotInRange
257+ | -- | The finalization reward commission is not in the allowed range.
258+ VCFFinalizationRewardCommissionNotInRange
259+ | -- | The aggregation key is already in use by another validator.
260+ VCFDuplicateAggregationKey ! BakerAggregationVerifyKey
261+ | -- | A change is already pending on this validator.
262+ VCFChangePending
203263 deriving (Eq , Show )
204264
205265-- | A baker update change result from configure baker. Used to indicate whether the configure will cause
@@ -216,55 +276,37 @@ data BakerConfigureUpdateChange
216276 | BakerConfigureFinalizationRewardCommission ! AmountFraction
217277 deriving (Eq , Show )
218278
219- -- | Result of configure baker.
220- data BakerConfigureResult
221- = -- | Configure baker successful.
222- BCSuccess ! [BakerConfigureUpdateChange ] ! BakerId
223- | -- | Account unknown.
224- BCInvalidAccount
225- | -- | The aggregation key already exists.
226- BCDuplicateAggregationKey ! BakerAggregationVerifyKey
227- | -- | The stake is below the required threshold dictated by current chain parameters.
228- BCStakeUnderThreshold
229- | -- | The finalization reward commission is not in the allowed range.
230- BCFinalizationRewardCommissionNotInRange
231- | -- | The baking reward commission is not in the allowed range.
232- BCBakingRewardCommissionNotInRange
233- | -- | The transaction fee commission is not in the allowed range.
234- BCTransactionFeeCommissionNotInRange
235- | -- | A change is already pending on this baker.
236- BCChangePending
237- | -- | This is not a valid baker.
238- BCInvalidBaker
279+ -- | Parameters for adding a delegator.
280+ data DelegatorAdd = DelegatorAdd
281+ { -- | The initial staked capital for the delegator.
282+ daCapital :: ! Amount ,
283+ -- | Whether to restake earnings.
284+ daRestakeEarnings :: ! Bool ,
285+ -- | The delegation target for the delegator.
286+ daDelegationTarget :: ! DelegationTarget
287+ }
239288 deriving (Eq , Show )
240289
241- -- | Result of remove baker.
242- data BakerRemoveResult
243- = -- | The baker was removed, effective from the given epoch.
244- BRRemoved ! BakerId ! Epoch
245- | -- | This is not a valid baker.
246- BRInvalidBaker
247- | -- | A change is already pending on this baker.
248- BRChangePending ! BakerId
249- deriving (Eq , Ord , Show )
290+ -- | Parameters for updating an existing delegator. Where a field is 'Nothing', the field is not
291+ -- updated.
292+ data DelegatorUpdate = DelegatorUpdate
293+ { -- | The new capital for the delegator. If this is @Just 0@, the delegator is removed.
294+ duCapital :: ! (Maybe Amount ),
295+ -- | Whether to restake earnings.
296+ duRestakeEarnings :: ! (Maybe Bool ),
297+ -- | The new delegation target for the delegator.
298+ duDelegationTarget :: ! (Maybe DelegationTarget )
299+ }
300+ deriving (Eq , Show )
250301
251- -- | Data structure used to add/remove/update delegator.
252- data DelegationConfigure
253- = -- | Add a delegator, all fields are required.
254- DelegationConfigureAdd
255- { dcaCapital :: ! Amount ,
256- dcaRestakeEarnings :: ! Bool ,
257- dcaDelegationTarget :: ! DelegationTarget
258- }
259- | -- | Update delegator with optional fields.
260- DelegationConfigureUpdate
261- { -- | The timestamp of the current slot (slot time of the block in which the update occurs).
262- dcuSlotTimestamp :: ! Timestamp ,
263- dcuCapital :: ! (Maybe Amount ),
264- dcuRestakeEarnings :: ! (Maybe Bool ),
265- dcuDelegationTarget :: ! (Maybe DelegationTarget )
302+ -- | A 'DelegatorUpdate' that removes the delegator.
303+ delegatorRemove :: DelegatorUpdate
304+ delegatorRemove =
305+ DelegatorUpdate
306+ { duCapital = Just 0 ,
307+ duRestakeEarnings = Nothing ,
308+ duDelegationTarget = Nothing
266309 }
267- deriving (Eq , Show )
268310
269311-- | A delegation update change result from configure delegation. Used to indicate whether the
270312-- configure will cause any changes to the delegator's stake, restake earnings flag, etc.
@@ -275,24 +317,19 @@ data DelegationConfigureUpdateChange
275317 | DelegationConfigureDelegationTarget ! DelegationTarget
276318 deriving (Eq , Show )
277319
278- -- | Result of configure delegator.
279- data DelegationConfigureResult
280- = -- | Configure delegation successful.
281- DCSuccess ! [DelegationConfigureUpdateChange ] ! DelegatorId
282- | -- | Account unknown.
283- DCInvalidAccount
284- | -- | A change is already pending on this delegator.
285- DCChangePending
286- | -- | This is not a valid delegator.
287- DCInvalidDelegator
288- | -- | Delegation target is not a valid baker.
289- DCInvalidDelegationTarget ! BakerId
320+ -- | Failure modes for configuring a delegator.
321+ data DelegatorConfigureFailure
322+ = -- | The delegation target is not a valid baker.
323+ DCFInvalidDelegationTarget ! BakerId
290324 | -- | The pool is not open for delegators.
291- DCPoolClosed
325+ DCFPoolClosed
292326 | -- | The pool's total capital would become too large.
293- DCPoolStakeOverThreshold
294- | -- | The delegated capital would become too large in comparison with pool owner's equity capital.
295- DCPoolOverDelegated
327+ DCFPoolStakeOverThreshold
328+ | -- | The delegated capital would become too large in comparison with pool owner's equity
329+ -- capital.
330+ DCFPoolOverDelegated
331+ | -- | A change is already pending on this delegator.
332+ DCFChangePending
296333 deriving (Eq , Show )
297334
298335-- | Construct an 'AccountBaker' from a 'GenesisBaker'.
0 commit comments