Skip to content

Commit

Permalink
Merge pull request #62 from RemarkableTools/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
axenteoctavian authored Feb 8, 2024
2 parents 262aa13 + 7d5adf2 commit 39a1383
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
11 changes: 11 additions & 0 deletions src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
}
}
}
17 changes: 15 additions & 2 deletions src/Mx.NET.SDK/Domain/Data/Accounts/AccountHistoryToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -16,7 +17,7 @@ public class AccountHistoryToken
/// <summary>
/// Account EGLD Balance
/// </summary>
public ESDTAmount Balance { get; set; }
public string Balance { get; set; }

/// <summary>
/// History moment
Expand All @@ -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();
}
}
}
2 changes: 1 addition & 1 deletion src/Mx.NET.SDK/Mx.NET.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<RepositoryUrl>https://github.com/RemarkableTools/Mx.NET.SDK</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<Company>Remarkable Tools</Company>
<Version>2.0.16</Version>
<Version>2.0.17</Version>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Title>RemarkableTools.Mx</Title>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
4 changes: 2 additions & 2 deletions src/Mx.NET.SDK/Provider/API/IAccountsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public interface IAccountsProvider
/// <param name="size">Number of items to retrieve (max 10000)</param>
/// <param name="from">Number of items to skip for the result set</param>
/// <returns><see cref="AccountHistoryDto"/></returns>
Task<AccountHistoryDto[]> GetAccountHistory(string address, int size = 100, int from = 0);
Task<AccountHistoryDto[]> GetAccountHistory(string address, int size = 100, int from = 0, Dictionary<string, string> parameters = null);

/// <summary>
/// Returns account Token balance history
Expand All @@ -239,6 +239,6 @@ public interface IAccountsProvider
/// <param name="size">Number of items to retrieve (max 10000)</param>
/// <param name="from">Number of items to skip for the result set</param>
/// <returns><see cref="AccountHistoryTokenDto"/></returns>
Task<AccountHistoryTokenDto[]> GetAccountHistoryToken(string address, string tokenIdentifier, int size = 100, int from = 0);
Task<AccountHistoryTokenDto[]> GetAccountHistoryToken(string address, string tokenIdentifier, int size = 100, int from = 0, Dictionary<string, string> parameters = null);
}
}
14 changes: 10 additions & 4 deletions src/Mx.NET.SDK/Provider/ApiProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,22 @@ public async Task<string> GetAccountContractsCount(string address)
return await Get<string>($"accounts/{address}/contracts/count");
}

public async Task<AccountHistoryDto[]> GetAccountHistory(string address, int size = 100, int from = 0)
public async Task<AccountHistoryDto[]> GetAccountHistory(string address, int size = 100, int from = 0, Dictionary<string, string> parameters = null)
{
size = size > 10000 ? 10000 : size;
return await Get<AccountHistoryDto[]>($"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<AccountHistoryDto[]>($"accounts/{address}/history?from={from}&size={size}{args}");
}

public async Task<AccountHistoryTokenDto[]> GetAccountHistoryToken(string address, string tokenIdentifier, int size = 100, int from = 0)
public async Task<AccountHistoryTokenDto[]> GetAccountHistoryToken(string address, string tokenIdentifier, int size = 100, int from = 0, Dictionary<string, string> parameters = null)
{
size = size > 10000 ? 10000 : size;
return await Get<AccountHistoryTokenDto[]>($"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<AccountHistoryTokenDto[]>($"accounts/{address}/history/{tokenIdentifier}?from={from}&size={size}{args}");
}

#endregion
Expand Down

0 comments on commit 39a1383

Please sign in to comment.