-
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.
Merge pull request #25 from RemarkableTools/dev
Dev
- Loading branch information
Showing
11 changed files
with
530 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
using Mx.NET.SDK.Domain.Data.Common; | ||
using Mx.NET.SDK.Domain.Helper; | ||
using Mx.NET.SDK.Provider.Dtos.API.Block; | ||
using System; | ||
|
||
namespace Mx.NET.SDK.Domain.Data.Block | ||
{ | ||
public class Block | ||
{ | ||
/// <summary> | ||
/// Block hash | ||
/// </summary> | ||
public string Hash { get; private set; } | ||
|
||
/// <summary> | ||
/// Block epoch | ||
/// </summary> | ||
public int Epoch { get; private set; } | ||
|
||
/// <summary> | ||
/// Block nonce | ||
/// </summary> | ||
public ulong Nonce { get; private set; } | ||
|
||
/// <summary> | ||
/// Block previous hash | ||
/// </summary> | ||
public string PrevHash { get; private set; } | ||
|
||
/// <summary> | ||
/// Block proposer | ||
/// </summary> | ||
public string Proposer { get; private set; } | ||
|
||
/// <summary> | ||
/// Block proposer identity | ||
/// </summary> | ||
public ProposerIdentity ProposerIdentity { get; private set; } | ||
|
||
/// <summary> | ||
/// Block public key bitmap | ||
/// </summary> | ||
public string PubKeyBitmap { get; private set; } | ||
|
||
/// <summary> | ||
/// Block round | ||
/// </summary> | ||
public ulong Round { get; private set; } | ||
|
||
/// <summary> | ||
/// Block shard | ||
/// </summary> | ||
public int Shard { get; private set; } | ||
|
||
/// <summary> | ||
/// Block size | ||
/// </summary> | ||
public int Size { get; private set; } | ||
|
||
/// <summary> | ||
/// Block size txs | ||
/// </summary> | ||
public int SizeTxs { get; private set; } | ||
|
||
/// <summary> | ||
/// Block state root hash | ||
/// </summary> | ||
public string StateRootHash { get; private set; } | ||
|
||
/// <summary> | ||
/// Block creation date | ||
/// </summary> | ||
public DateTime CreationDate { get; private set; } | ||
|
||
/// <summary> | ||
/// Block transactions count | ||
/// </summary> | ||
public long TxCount { get; private set; } | ||
|
||
/// <summary> | ||
/// Block gas consumed | ||
/// </summary> | ||
public ulong GasConsumed { get; private set; } | ||
|
||
/// <summary> | ||
/// Block gas refunded | ||
/// </summary> | ||
public ulong GasRefunded { get; private set; } | ||
|
||
/// <summary> | ||
/// Block gas penalized | ||
/// </summary> | ||
public ulong GasPenalized { get; private set; } | ||
|
||
/// <summary> | ||
/// Block max gas limit | ||
/// </summary> | ||
public ulong MaxGasLimit { get; private set; } | ||
|
||
/// <summary> | ||
/// Mini blocks hashes | ||
/// </summary> | ||
public string[] MiniBlocksHashes { get; private set; } | ||
|
||
/// <summary> | ||
/// Notarized blocks hashes | ||
/// </summary> | ||
public string[] NotarizedBlocksHashes { get; private set; } | ||
|
||
/// <summary> | ||
/// Block validators | ||
/// </summary> | ||
public string[] Validators { get; private set; } | ||
|
||
private Block() { } | ||
|
||
/// <summary> | ||
/// Creates a new Block from data | ||
/// </summary> | ||
/// <param name="block">Block Data Object from API</param> | ||
/// <returns></returns> | ||
public static Block From(BlockDto block) | ||
{ | ||
return new Block() | ||
{ | ||
Hash = block.Hash, | ||
Epoch = block.Epoch ?? 0, | ||
Nonce = block.Nonce ?? 0, | ||
PrevHash = block.PrevHash, | ||
Proposer = block.Proposer, | ||
ProposerIdentity = ProposerIdentity.From(block.ProposerIdentity), | ||
PubKeyBitmap = block.PubKeyBitmap, | ||
Round = block.Round ?? 0, | ||
Shard = block.Shard ?? 0, | ||
Size = block.Size ?? 0, | ||
SizeTxs = block.SizeTxs ?? 0, | ||
StateRootHash = block.StateRootHash, | ||
CreationDate = (block.Timestamp ?? 0).ToDateTime(), | ||
TxCount = block.TxCount ?? 0, | ||
GasConsumed = block.GasConsumed ?? 0, | ||
GasRefunded = block.GasRefunded ?? 0, | ||
GasPenalized = block.GasPenalized ?? 0, | ||
MaxGasLimit = block.MaxGasLimit ?? 0, | ||
MiniBlocksHashes = block.MiniBlocksHashes, | ||
NotarizedBlocksHashes = block.NotarizedBlocksHashes, | ||
Validators = block.Validators | ||
}; | ||
} | ||
} | ||
} |
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,133 @@ | ||
using Mx.NET.SDK.Domain.Data.Common; | ||
using Mx.NET.SDK.Domain.Helper; | ||
using Mx.NET.SDK.Provider.Dtos.API.Block; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Mx.NET.SDK.Domain.Data.Block | ||
{ | ||
public class Blocks | ||
{ | ||
/// <summary> | ||
/// Block hash | ||
/// </summary> | ||
public string Hash { get; private set; } | ||
|
||
/// <summary> | ||
/// Block epoch | ||
/// </summary> | ||
public int Epoch { get; private set; } | ||
|
||
/// <summary> | ||
/// Block nonce | ||
/// </summary> | ||
public ulong Nonce { get; private set; } | ||
|
||
/// <summary> | ||
/// Block previous hash | ||
/// </summary> | ||
public string PrevHash { get; private set; } | ||
|
||
/// <summary> | ||
/// Block proposer | ||
/// </summary> | ||
public string Proposer { get; private set; } | ||
|
||
/// <summary> | ||
/// Block proposer identity | ||
/// </summary> | ||
public ProposerIdentity ProposerIdentity { get; private set; } | ||
|
||
/// <summary> | ||
/// Block public key bitmap | ||
/// </summary> | ||
public string PubKeyBitmap { get; private set; } | ||
|
||
/// <summary> | ||
/// Block round | ||
/// </summary> | ||
public ulong Round { get; private set; } | ||
|
||
/// <summary> | ||
/// Block shard | ||
/// </summary> | ||
public int Shard { get; private set; } | ||
|
||
/// <summary> | ||
/// Block size | ||
/// </summary> | ||
public int Size { get; private set; } | ||
|
||
/// <summary> | ||
/// Block size txs | ||
/// </summary> | ||
public int SizeTxs { get; private set; } | ||
|
||
/// <summary> | ||
/// Block state root hash | ||
/// </summary> | ||
public string StateRootHash { get; private set; } | ||
|
||
/// <summary> | ||
/// Block creation date | ||
/// </summary> | ||
public DateTime CreationDate { get; private set; } | ||
|
||
/// <summary> | ||
/// Block transactions count | ||
/// </summary> | ||
public long TxCount { get; private set; } | ||
|
||
/// <summary> | ||
/// Block gas consumed | ||
/// </summary> | ||
public ulong GasConsumed { get; private set; } | ||
|
||
/// <summary> | ||
/// Block gas refunded | ||
/// </summary> | ||
public ulong GasRefunded { get; private set; } | ||
|
||
/// <summary> | ||
/// Block gas penalized | ||
/// </summary> | ||
public ulong GasPenalized { get; private set; } | ||
|
||
/// <summary> | ||
/// Block max gas limit | ||
/// </summary> | ||
public ulong MaxGasLimit { get; private set; } | ||
|
||
private Blocks() { } | ||
|
||
/// <summary> | ||
/// Creates a new array of Blocks from data | ||
/// </summary> | ||
/// <param name="blocks">Array of Blocks Data Object from API</param> | ||
/// <returns>Array of Blocks objects</returns> | ||
public static Blocks[] From(BlocksDto[] blocks) | ||
{ | ||
return blocks.Select(block => new Blocks() | ||
{ | ||
Hash = block.Hash, | ||
Epoch = block.Epoch ?? 0, | ||
Nonce = block.Nonce ?? 0, | ||
PrevHash = block.PrevHash, | ||
Proposer = block.Proposer, | ||
ProposerIdentity = ProposerIdentity.From(block.ProposerIdentity), | ||
PubKeyBitmap = block.PubKeyBitmap, | ||
Round = block.Round ?? 0, | ||
Shard = block.Shard ?? 0, | ||
Size = block.Size ?? 0, | ||
SizeTxs = block.SizeTxs ?? 0, | ||
StateRootHash = block.StateRootHash, | ||
CreationDate = (block.Timestamp ?? 0).ToDateTime(), | ||
TxCount = block.TxCount ?? 0, | ||
GasConsumed = block.GasConsumed ?? 0, | ||
GasRefunded = block.GasRefunded ?? 0, | ||
GasPenalized = block.GasPenalized ?? 0, | ||
MaxGasLimit = block.MaxGasLimit ?? 0, | ||
}).ToArray(); | ||
} | ||
} | ||
} |
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,56 @@ | ||
using Mx.NET.SDK.Provider.Dtos.API.Block; | ||
|
||
namespace Mx.NET.SDK.Domain.Data.Common | ||
{ | ||
/// <summary> | ||
/// Proposer Identity for Block | ||
/// </summary> | ||
public class ProposerIdentity | ||
{ | ||
public string Identity { get; private set; } | ||
public string Name { get; private set; } | ||
public string Description { get; private set; } | ||
public string Avatar { get; private set; } | ||
public string Website { get; private set; } | ||
public string Twitter { get; private set; } | ||
public string Location { get; private set; } | ||
public double Score { get; private set; } | ||
public int Validators { get; private set; } | ||
public string Stake { get; private set; } | ||
public string TopUp { get; private set; } | ||
public string Locked { get; private set; } | ||
public dynamic Distribution { get; private set; } | ||
public string[] Providers { get; private set; } | ||
public double StakePercent { get; private set; } | ||
public double Apr { get; private set; } | ||
public int Rank { get; private set; } | ||
|
||
private ProposerIdentity() { } | ||
|
||
public static ProposerIdentity From(ProposerIdentityDto proposerIdentity) | ||
{ | ||
if (proposerIdentity == null) return null; | ||
|
||
return new ProposerIdentity() | ||
{ | ||
Identity = proposerIdentity.Identity, | ||
Name = proposerIdentity.Name, | ||
Description = proposerIdentity.Description, | ||
Avatar = proposerIdentity.Avatar, | ||
Website = proposerIdentity.Website, | ||
Twitter = proposerIdentity.Twitter, | ||
Location = proposerIdentity.Location, | ||
Score = proposerIdentity.Score ?? 0, | ||
Validators = proposerIdentity.Validators ?? 0, | ||
Stake = proposerIdentity.Stake, | ||
TopUp = proposerIdentity.TopUp, | ||
Locked = proposerIdentity.Locked, | ||
Distribution = proposerIdentity.Distribution, | ||
Providers = proposerIdentity.Providers, | ||
StakePercent = proposerIdentity.StakePercent ?? 0, | ||
Apr = proposerIdentity.Apr ?? 0, | ||
Rank = proposerIdentity.Rank ?? 0 | ||
}; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.