diff --git a/src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistory.cs b/src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistory.cs index fc1c288..d35de3f 100644 --- a/src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistory.cs +++ b/src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistory.cs @@ -3,6 +3,7 @@ using Mx.NET.SDK.Core.Domain.Values; using Mx.NET.SDK.Provider.Dtos.API.Accounts; using Mx.NET.SDK.Domain.Helper; +using System.Linq; namespace Mx.NET.SDK.Domain.Data.Accounts { @@ -40,5 +41,15 @@ public static AccountHistory From(AccountHistoryDto accountHistory) IsSender = accountHistory.IsSender, }; } + public static AccountHistory[] From(AccountHistoryDto[] accountHistories) + { + return accountHistories.Select(accountHistory => new AccountHistory() + { + Address = Address.FromBech32(accountHistory.Address), + Balance = ESDTAmount.From(accountHistory.Balance), + HistoryTime = accountHistory.Timestamp.ToDateTime(), + IsSender = accountHistory.IsSender, + }).ToArray(); + } } } diff --git a/src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistoryToken.cs b/src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistoryToken.cs index ade08fd..6d45a6c 100644 --- a/src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistoryToken.cs +++ b/src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistoryToken.cs @@ -3,6 +3,7 @@ using Mx.NET.SDK.Core.Domain.Values; using Mx.NET.SDK.Provider.Dtos.API.Accounts; using Mx.NET.SDK.Domain.Helper; +using System.Linq; namespace Mx.NET.SDK.Domain.Data.Accounts { @@ -16,7 +17,7 @@ public class AccountHistoryToken /// /// Account EGLD Balance /// - public ESDTAmount Balance { get; set; } + public string Balance { get; set; } /// /// History moment @@ -40,11 +41,23 @@ public static AccountHistoryToken From(AccountHistoryTokenDto accountHistoryToke return new AccountHistoryToken() { Address = Address.FromBech32(accountHistoryToken.Address), - Balance = ESDTAmount.From(accountHistoryToken.Balance), + Balance = accountHistoryToken.Balance, HistoryTime = accountHistoryToken.Timestamp.ToDateTime(), IsSender = accountHistoryToken.IsSender, Token = accountHistoryToken.Token }; } + + public static AccountHistoryToken[] From(AccountHistoryTokenDto[] accountHistoriesToken) + { + return accountHistoriesToken.Select(accountHistoryToken => new AccountHistoryToken() + { + Address = Address.FromBech32(accountHistoryToken.Address), + Balance = accountHistoryToken.Balance, + HistoryTime = accountHistoryToken.Timestamp.ToDateTime(), + IsSender = accountHistoryToken.IsSender, + Token = accountHistoryToken.Token + }).ToArray(); + } } } diff --git a/src/Mx.NET.SDK/Mx.NET.SDK.csproj b/src/Mx.NET.SDK/Mx.NET.SDK.csproj index 372d84a..8c6f9c4 100644 --- a/src/Mx.NET.SDK/Mx.NET.SDK.csproj +++ b/src/Mx.NET.SDK/Mx.NET.SDK.csproj @@ -11,7 +11,7 @@ https://github.com/RemarkableTools/Mx.NET.SDK GitHub Remarkable Tools - 2.0.16 + 2.0.17 true RemarkableTools.Mx README.md diff --git a/src/Mx.NET.SDK/Provider/API/IAccountsProvider.cs b/src/Mx.NET.SDK/Provider/API/IAccountsProvider.cs index b06ddaa..fdf0f0d 100644 --- a/src/Mx.NET.SDK/Provider/API/IAccountsProvider.cs +++ b/src/Mx.NET.SDK/Provider/API/IAccountsProvider.cs @@ -229,7 +229,7 @@ public interface IAccountsProvider /// Number of items to retrieve (max 10000) /// Number of items to skip for the result set /// - Task GetAccountHistory(string address, int size = 100, int from = 0); + Task GetAccountHistory(string address, int size = 100, int from = 0, Dictionary parameters = null); /// /// Returns account Token balance history @@ -239,6 +239,6 @@ public interface IAccountsProvider /// Number of items to retrieve (max 10000) /// Number of items to skip for the result set /// - Task GetAccountHistoryToken(string address, string tokenIdentifier, int size = 100, int from = 0); + Task GetAccountHistoryToken(string address, string tokenIdentifier, int size = 100, int from = 0, Dictionary parameters = null); } } diff --git a/src/Mx.NET.SDK/Provider/ApiProvider.cs b/src/Mx.NET.SDK/Provider/ApiProvider.cs index 70ef841..e5345b7 100644 --- a/src/Mx.NET.SDK/Provider/ApiProvider.cs +++ b/src/Mx.NET.SDK/Provider/ApiProvider.cs @@ -240,16 +240,22 @@ public async Task GetAccountContractsCount(string address) return await Get($"accounts/{address}/contracts/count"); } - public async Task GetAccountHistory(string address, int size = 100, int from = 0) + public async Task GetAccountHistory(string address, int size = 100, int from = 0, Dictionary parameters = null) { size = size > 10000 ? 10000 : size; - return await Get($"accounts/{address}/history?from={from}&size={size}"); + string args = ""; + if (parameters != null) + args = $"&{string.Join("&", parameters.Select(e => $"{e.Key}={e.Value}"))}"; + return await Get($"accounts/{address}/history?from={from}&size={size}{args}"); } - public async Task GetAccountHistoryToken(string address, string tokenIdentifier, int size = 100, int from = 0) + public async Task GetAccountHistoryToken(string address, string tokenIdentifier, int size = 100, int from = 0, Dictionary parameters = null) { size = size > 10000 ? 10000 : size; - return await Get($"accounts/{address}/history/{tokenIdentifier}?from={from}&size={size}"); + string args = ""; + if (parameters != null) + args = $"&{string.Join("&", parameters.Select(e => $"{e.Key}={e.Value}"))}"; + return await Get($"accounts/{address}/history/{tokenIdentifier}?from={from}&size={size}{args}"); } #endregion