-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
schwartz-concordium
committed
Aug 1, 2023
1 parent
35b3bef
commit 1189143
Showing
3 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Concordium.Grpc.V2; | ||
using Concordium.Sdk.Exceptions; | ||
using Concordium.Sdk.Helpers; | ||
|
||
namespace Concordium.Sdk.Types; | ||
|
||
/// <summary> | ||
/// Pending change in the baker's stake. | ||
/// </summary> | ||
public abstract record BakerPoolPendingChange | ||
{ | ||
internal static BakerPoolPendingChange? From(PoolPendingChange? pendingChange) | ||
{ | ||
if (pendingChange is null) | ||
{ | ||
return null; | ||
} | ||
|
||
return pendingChange.ChangeCase switch | ||
{ | ||
PoolPendingChange.ChangeOneofCase.Reduce => | ||
new BakerPoolReduceStakePending(CcdAmount.From(pendingChange.Reduce.ReducedEquityCapital), pendingChange.Reduce.EffectiveTime.ToDateTimeOffset()), | ||
PoolPendingChange.ChangeOneofCase.Remove => | ||
new BakerPoolRemovePending(pendingChange.Remove.EffectiveTime.ToDateTimeOffset()) | ||
, | ||
PoolPendingChange.ChangeOneofCase.None => null, | ||
_ => throw new MissingEnumException<PoolPendingChange.ChangeOneofCase>(pendingChange.ChangeCase) | ||
}; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The baker will be removed at the given time. | ||
/// </summary> | ||
/// <param name="EffectiveTime">Time when the baker will be removed.</param> | ||
public sealed record BakerPoolRemovePending(DateTimeOffset EffectiveTime) : BakerPoolPendingChange; | ||
/// <summary> | ||
/// The stake is being reduced. The new stake will take affect at the given time. | ||
/// </summary> | ||
/// <param name="NewStake">New stake which will take effect.</param> | ||
/// <param name="EffectiveTime">Time when the baker will be removed.</param> | ||
public sealed record BakerPoolReduceStakePending(CcdAmount NewStake, DateTimeOffset EffectiveTime) : BakerPoolPendingChange; | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters