Skip to content

Commit

Permalink
Merge branch 'feature/#37' into Manual-Test
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisPitallano committed Feb 21, 2022
2 parents 6fbe2bb + 3e7e1fe commit d6f9570
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/BscScan.NetCore/Constants/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ internal static class BlocksModuleAction
public const string GET_BLOCK_NUMBER_BY_TIMESTAMP= "getblocknobytime";
public const string GET_DAILY_AVG_BLOCK_SIZE = "dailyavgblocksize";
public const string GET_DAILY_BLOCK_COUNT = "dailyblkcount";
public const string GET_DAILY_BLOCK_REWARDS = "dailyblockrewards";
}


Expand Down
7 changes: 7 additions & 0 deletions src/BscScan.NetCore/Contracts/IBscScanBlocksService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@ public interface IBscScanBlocksService
/// <param name="request">DailyBlockCountAndRewardRequest Model</param>
/// <returns>Returns the number of blocks validated daily and the amount of block rewards.</returns>
Task<DailyBlockCountAndRewards?> GetDailyBlockCountsAndRewards(DailyBlockCountAndRewardRequest request);

/// <summary>
/// Get Daily Block Rewards 🅰🅿🅸 🅿🆁🅾
/// </summary>
/// <param name="request">DailyBlockRequest Model</param>
/// <returns>Returns the amount of block rewards distributed to validators daily.</returns>
Task<DailyBlockRewards?> GetDailyBlockRewards(DailyBlockRequest request);
}
}
40 changes: 40 additions & 0 deletions src/BscScan.NetCore/Models/Response/Blocks/DailyBlockRewards.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Text.Json.Serialization;

namespace BscScan.NetCore.Models.Response.Blocks
{
/// <summary>
/// DailyBlockCountAndRewards
/// </summary>
public class DailyBlockRewards : BaseResponse
{
/// <summary>
/// List of DailyBlockCountAndRewardsData
/// </summary>
[JsonPropertyName("result")]
public IEnumerable<DailyBlockRewardsData>? Result { get; set; }
}

/// <summary>
/// DailyBlockCountAndRewardsData
/// </summary>
public class DailyBlockRewardsData
{
/// <summary>
/// UTCDate
/// </summary>
[JsonPropertyName("UTCDate")]
public string? UtcDate { get; set; }

/// <summary>
/// UnixTimeStamp
/// </summary>
[JsonPropertyName("unixTimeStamp")]
public string? UnixTimeStamp { get; set; }

/// <summary>
/// BlockRewardsEth
/// </summary>
[JsonPropertyName("blockRewards_Eth")]
public string? BlockRewardsEth { get; set; }
}
}
13 changes: 13 additions & 0 deletions src/BscScan.NetCore/Services/BscScanBlocksService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,18 @@ public BscScanBlocksService(HttpClient bscScanHttpClient, BscScanConfiguration b
var result = await JsonSerializer.DeserializeAsync<DailyBlockCountAndRewards>(responseStream);
return result;
}

/// <inheritdoc />
public async Task<DailyBlockRewards?> GetDailyBlockRewards(DailyBlockRequest request)
{
var queryParameters = $"{_bscScanModuleStat}{request.ToRequestParameters(BlocksModuleAction.GET_DAILY_BLOCK_REWARDS)}";
using var response = await BscScanHttpClient.GetAsync($"{queryParameters}")
.ConfigureAwait(false);

response.EnsureSuccessStatusCode();
await using var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
var result = await JsonSerializer.DeserializeAsync<DailyBlockRewards>(responseStream);
return result;
}
}
}

0 comments on commit d6f9570

Please sign in to comment.