-
Notifications
You must be signed in to change notification settings - Fork 35
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
Showing
17 changed files
with
755 additions
and
5 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
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
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,116 @@ | ||
namespace Tzkt.Api.Models | ||
{ | ||
public class StakingOperation : Operation | ||
{ | ||
/// <summary> | ||
/// Type of the operation, `staking` | ||
/// </summary> | ||
public override string Type => OpTypes.Staking; | ||
|
||
/// <summary> | ||
/// Internal TzKT ID. | ||
/// **[sortable]** | ||
/// </summary> | ||
public override long Id { get; set; } | ||
|
||
/// <summary> | ||
/// Height of the block from the genesis | ||
/// </summary> | ||
public int Level { get; set; } | ||
|
||
/// <summary> | ||
/// Datetime at which the block is claimed to have been created (ISO 8601, e.g. `2020-02-20T02:40:57Z`) | ||
/// </summary> | ||
public DateTime Timestamp { get; set; } | ||
|
||
/// <summary> | ||
/// Hash of the operation | ||
/// </summary> | ||
public string Hash { get; set; } | ||
|
||
/// <summary> | ||
/// Information about the account who has sent the operation | ||
/// </summary> | ||
public Alias Sender { get; set; } | ||
|
||
/// <summary> | ||
/// An account nonce which is used to prevent operation replay | ||
/// </summary> | ||
public int Counter { get; set; } | ||
|
||
/// <summary> | ||
/// A cap on the amount of gas a given operation can consume | ||
/// </summary> | ||
public int GasLimit { get; set; } | ||
|
||
/// <summary> | ||
/// Amount of gas, consumed by the operation | ||
/// </summary> | ||
public int GasUsed { get; set; } | ||
|
||
/// <summary> | ||
/// A cap on the amount of storage a given operation can consume | ||
/// </summary> | ||
public int StorageLimit { get; set; } | ||
|
||
/// <summary> | ||
/// Fee to the baker, produced block, in which the operation was included (micro tez) | ||
/// </summary> | ||
public long BakerFee { get; set; } | ||
|
||
/// <summary> | ||
/// Staking operation kind (`stake`, `unstake`, `finalize`, `set_parameters`) | ||
/// </summary> | ||
public string Kind { get; set; } | ||
|
||
/// <summary> | ||
/// Information about the baker | ||
/// </summary> | ||
public Alias Baker { get; set; } | ||
|
||
/// <summary> | ||
/// Amount (micro tez) | ||
/// </summary> | ||
public long? Amount { get; set; } | ||
|
||
/// <summary> | ||
/// Pseudotokens | ||
/// </summary> | ||
public long? Pseudotokens { get; set; } | ||
|
||
/// <summary> | ||
/// This parameter determines the maximum portion (millionth) of external stake by stakers over the baker's own staked funds. | ||
/// </summary> | ||
public long? LimitOfStakingOverBaking { get; set; } | ||
|
||
/// <summary> | ||
/// This parameter determines the fraction (billionth) of the rewards that accrue to the baker's liquid spendable balance — the remainder accrues to frozen stakes. | ||
/// </summary> | ||
public long? EdgeOfBakingOverStaking { get; set; } | ||
|
||
/// <summary> | ||
/// Cycle from which the specified staking parameters are activated | ||
/// </summary> | ||
public int? ActivationCycle { get; set; } | ||
|
||
/// <summary> | ||
/// Operation status (`applied` - an operation applied by the node and successfully added to the blockchain, | ||
/// `failed` - an operation which failed with some particular error (not enough balance, gas limit, etc), | ||
/// `backtracked` - an operation which was successful but reverted due to one of the following operations in the same operation group was failed, | ||
/// `skipped` - all operations after the failed one in an operation group) | ||
/// </summary> | ||
public string Status { get; set; } | ||
|
||
/// <summary> | ||
/// List of errors provided by the node, injected the operation to the blockchain. `null` if there is no errors | ||
/// </summary> | ||
public List<OperationError> Errors { get; set; } | ||
|
||
#region injecting | ||
/// <summary> | ||
/// Injected historical quote at the time of operation | ||
/// </summary> | ||
public QuoteShort Quote { get; set; } | ||
#endregion | ||
} | ||
} |
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,44 @@ | ||
using Microsoft.AspNetCore.Mvc.ModelBinding; | ||
|
||
namespace Tzkt.Api | ||
{ | ||
public class StakingOperationKindBinder : IModelBinder | ||
{ | ||
public Task BindModelAsync(ModelBindingContext bindingContext) | ||
{ | ||
var model = bindingContext.ModelName; | ||
var hasValue = false; | ||
|
||
if (!bindingContext.TryGetStakingOperationKind($"{model}", ref hasValue, out var value)) | ||
return Task.CompletedTask; | ||
|
||
if (!bindingContext.TryGetStakingOperationKind($"{model}.eq", ref hasValue, out var eq)) | ||
return Task.CompletedTask; | ||
|
||
if (!bindingContext.TryGetStakingOperationKind($"{model}.ne", ref hasValue, out var ne)) | ||
return Task.CompletedTask; | ||
|
||
if (!bindingContext.TryGetStakingOperationKindsList($"{model}.in", ref hasValue, out var @in)) | ||
return Task.CompletedTask; | ||
|
||
if (!bindingContext.TryGetStakingOperationKindsList($"{model}.ni", ref hasValue, out var ni)) | ||
return Task.CompletedTask; | ||
|
||
if (!hasValue) | ||
{ | ||
bindingContext.Result = ModelBindingResult.Success(null); | ||
return Task.CompletedTask; | ||
} | ||
|
||
bindingContext.Result = ModelBindingResult.Success(new StakingOperationKindParameter | ||
{ | ||
Eq = value ?? eq, | ||
Ne = ne, | ||
In = @in, | ||
Ni = ni | ||
}); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
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,41 @@ | ||
using Tzkt.Api.Services; | ||
|
||
namespace Tzkt.Api | ||
{ | ||
public class StakingOperationFilter : ManagerOperationFilter | ||
{ | ||
/// <summary> | ||
/// Filter by any of the specified fields (`sender`, or `baker`). | ||
/// Example: `anyof.sender.baker=tz1...` will return operations where `sender` OR `baker` is equal to the specified value. | ||
/// This parameter is useful when you need to get all operations somehow related to the account in a single request. | ||
/// Click on the parameter to expand more details. | ||
/// </summary> | ||
public AnyOfParameter anyof { get; set; } | ||
|
||
/// <summary> | ||
/// Filter by baker address. | ||
/// Click on the parameter to expand more details. | ||
/// </summary> | ||
public AccountParameter baker { get; set; } | ||
|
||
/// <summary> | ||
/// Filter by operation kind (`stake`, `unstake`, `finalize`, or `set_parameters`). | ||
/// Click on the parameter to expand more details. | ||
/// </summary> | ||
public StakingOperationKindParameter kind { get; set; } | ||
|
||
public override bool Empty => | ||
base.Empty && | ||
anyof == null && | ||
baker == null && | ||
kind == null; | ||
|
||
public override string Normalize(string name) | ||
{ | ||
return ResponseCacheService.BuildKey("", | ||
("id", id), ("hash", hash), ("counter", counter), ("level", level), | ||
("timestamp", timestamp), ("status", status), ("sender", sender), | ||
("anyof", anyof), ("baker", baker), ("kind", kind)); | ||
} | ||
} | ||
} |
Oops, something went wrong.