-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAccount.cs
43 lines (38 loc) · 1.25 KB
/
Account.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Threading.Tasks;
using Erdcsharp.Provider;
namespace Erdcsharp.Domain
{
public class Account
{
public Address Address { get; }
public TokenAmount Balance { get; private set; }
public long Nonce { get; private set; }
public string UserName { get; private set; }
public Account(Address address)
{
Address = address;
Nonce = 0;
Balance = TokenAmount.Zero();
UserName = null;
}
/// <summary>
/// Synchronizes account properties (such as nonce, balance) with the ones queried from the Network
/// </summary>
/// <param name="provider"></param>
/// <returns></returns>
public async Task Sync(IElrondProvider provider)
{
var accountDto = await provider.GetAccount(Address.Bech32);
Balance = TokenAmount.From(accountDto.Balance, Token.EGLD());
Nonce = accountDto.Nonce;
UserName = accountDto.Username;
}
/// <summary>
/// Increments (locally) the nonce (the account sequence number).
/// </summary>
public void IncrementNonce()
{
Nonce++;
}
}
}