Skip to content

Commit

Permalink
Add more sortable fields for /delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed Jun 25, 2024
1 parent e5bafe3 commit 58ca233
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Tzkt.Api/Controllers/DelegatesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public DelegatesController(AccountRepository accounts)
[Range(0, 10000)] int limit = 100)
{
#region validate
if (sort != null && !sort.Validate("id", "stakingBalance", "balance", "numDelegators", "activationLevel", "deactivationLevel"))
if (sort != null && !sort.Validate("id", "stakedBalance", "externalStakedBalance", "delegatedBalance",
"stakingBalance", "balance", "numDelegators", "stakersCount", "activationLevel", "deactivationLevel"))
return new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed.");
#endregion

Expand Down
12 changes: 12 additions & 0 deletions Tzkt.Api/Repositories/AccountRepository.Bakers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,13 @@ public async Task<int> GetDelegatesCount(BoolParameter active)
{
"activationLevel" => ("ActivationLevel", "ActivationLevel"),
"deactivationLevel" => ("DeactivationLevel", "DeactivationLevel"),
"stakedBalance" => ("OwnStakedBalance", "OwnStakedBalance"),
"externalStakedBalance" => ("ExternalStakedBalance", "ExternalStakedBalance"),
"delegatedBalance" => ("DelegatedBalance", "DelegatedBalance"),
"stakingBalance" => ("StakingBalance", "StakingBalance"),
"balance" => ("Balance", "Balance"),
"numDelegators" => ("DelegatorsCount", "DelegatorsCount"),
"stakersCount" => ("StakersCount", "StakersCount"),
_ => ("Id", "Id")
});

Expand Down Expand Up @@ -355,9 +359,13 @@ public async Task<object[][]> GetDelegates(
{
"activationLevel" => ("ActivationLevel", "ActivationLevel"),
"deactivationLevel" => ("DeactivationLevel", "DeactivationLevel"),
"stakedBalance" => ("OwnStakedBalance", "OwnStakedBalance"),
"externalStakedBalance" => ("ExternalStakedBalance", "ExternalStakedBalance"),
"delegatedBalance" => ("DelegatedBalance", "DelegatedBalance"),
"stakingBalance" => ("StakingBalance", "StakingBalance"),
"balance" => ("Balance", "Balance"),
"numDelegators" => ("DelegatorsCount", "DelegatorsCount"),
"stakersCount" => ("StakersCount", "StakersCount"),
_ => ("Id", "Id")
});

Expand Down Expand Up @@ -857,9 +865,13 @@ public async Task<object[]> GetDelegates(
{
"activationLevel" => ("ActivationLevel", "ActivationLevel"),
"deactivationLevel" => ("DeactivationLevel", "DeactivationLevel"),
"stakedBalance" => ("OwnStakedBalance", "OwnStakedBalance"),
"externalStakedBalance" => ("ExternalStakedBalance", "ExternalStakedBalance"),
"delegatedBalance" => ("DelegatedBalance", "DelegatedBalance"),
"stakingBalance" => ("StakingBalance", "StakingBalance"),
"balance" => ("Balance", "Balance"),
"numDelegators" => ("DelegatorsCount", "DelegatorsCount"),
"stakersCount" => ("StakersCount", "StakersCount"),
_ => ("Id", "Id")
});

Expand Down
4 changes: 2 additions & 2 deletions Tzkt.Api/Swagger/Description.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ It's available for the following Tezos networks with the following base URLs:
- Ghostnet: `https://api.ghostnet.tzkt.io/` ([view docs](https://api.ghostnet.tzkt.io))
- Parisnet: `https://api.parisnet.tzkt.io/` ([view docs](https://api.parisnet.tzkt.io))

### Sending requests
### Sending Requests

To send a request to Free TzKT API you need literally nothing. Just take the base URL of the particular network
(for example, Tezos mainnet: `https://api.tzkt.io`) and append the path of the particular endpoint
Expand Down Expand Up @@ -84,7 +84,7 @@ If your key was compromised, just let us know and we will issue a new one.
Also note that passing the API key via HTTP headers is more secure, because in HTTPS headers are encrypted,
but query string is not, so the key can be unintentionally exposed to third parties.

### Sending requests
### Sending Requests

Sending a request with the API key passed as a query string parameter:

Expand Down

0 comments on commit 58ca233

Please sign in to comment.