Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using IotaWalletNet.Application.AccountContext.Commands.SendNfts;
using IotaWalletNet.Application.AccountContext.Commands.SyncAccount;
using IotaWalletNet.Application.AccountContext.Queries.GetAddresses;
using IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs;
using IotaWalletNet.Application.AccountContext.Queries.GetBalance;
using IotaWalletNet.Application.AccountContext.Queries.GetOutputs;
using IotaWalletNet.Application.AccountContext.Queries.GetUnspentOutputs;
Expand Down Expand Up @@ -35,6 +36,12 @@ public Account(IMediator mediator, string username, IWallet wallet)
public string Username { get; }
public IWallet Wallet { get; }


public async Task<GetAddressesWithUnspentOutputsResponse> GetAddressesWithUnspentOutputs()
{
return await _mediator.Send(new GetAddressesWithUnspentOutputsQuery(Username, this));
}

public async Task<SendNftsResponse> SendNftsAsync(List<AddressAndNftId> addressAndNftIds)
{
return await _mediator.Send(new SendNftsCommand(Username, this, addressAndNftIds));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using IotaWalletNet.Application.Common.Interfaces;
using MediatR;

namespace IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs
{
public class GetAddressesWithUnspentOutputsQuery : IRequest<GetAddressesWithUnspentOutputsResponse>
{
public GetAddressesWithUnspentOutputsQuery(string username, IAccount account)
{
Username = username;
Account = account;
}

public string Username { get; set; }
public IAccount Account { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using IotaWalletNet.Domain.PlatformInvoke;
using MediatR;
using Newtonsoft.Json;

namespace IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs
{
public class GetAddressesWithUnspentOutputsQueryHandler : IRequestHandler<GetAddressesWithUnspentOutputsQuery, GetAddressesWithUnspentOutputsResponse>
{
public async Task<GetAddressesWithUnspentOutputsResponse> Handle(GetAddressesWithUnspentOutputsQuery request, CancellationToken cancellationToken)
{
GetAddressesWithUnspentOutputsQueryMessage message = new GetAddressesWithUnspentOutputsQueryMessage(request.Username);
string json = JsonConvert.SerializeObject(message);

RustBridgeGenericResponse genericResponse = await request.Account.SendMessageAsync(json);

GetAddressesWithUnspentOutputsResponse response = genericResponse.IsSuccess
? genericResponse.As<GetAddressesWithUnspentOutputsResponse>()!
: new GetAddressesWithUnspentOutputsResponse() { Error = genericResponse.As<RustBridgeErrorResponse>(), Type = "error" };

return response;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using IotaWalletNet.Domain.Common.Models;

namespace IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs
{
public class GetAddressesWithUnspentOutputsQueryMessage : AccountMessage
{
private const string METHOD_NAME = "addressesWithUnspentOutputs";
public GetAddressesWithUnspentOutputsQueryMessage(string username)
: base(username, METHOD_NAME)
{

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using IotaWalletNet.Domain.Common.Models.Address;
using IotaWalletNet.Domain.PlatformInvoke;

namespace IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs
{
public class GetAddressesWithUnspentOutputsResponse : RustBridgeResponseBase<List<AddressWithUnspentOutputs>>
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using IotaWalletNet.Application.AccountContext.Commands.MintNfts;
using IotaWalletNet.Application.AccountContext.Commands.SendNfts;
using IotaWalletNet.Application.AccountContext.Queries.GetAddresses;
using IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs;
using IotaWalletNet.Application.AccountContext.Queries.GetBalance;
using IotaWalletNet.Application.AccountContext.Queries.GetOutputs;
using IotaWalletNet.Application.AccountContext.Queries.GetUnspentOutputs;
Expand Down Expand Up @@ -34,5 +35,6 @@ public interface IAccount : IRustBridgeCommunicator
Task<SendNftsResponse> SendNftsAsync(List<AddressAndNftId> addressAndNftIds);
Task<BurnNftResponse> BurnNftAsync(string nftId);
Task<GetUnspentOutputsResponse> GetUnspentOutputs();
Task<GetAddressesWithUnspentOutputsResponse> GetAddressesWithUnspentOutputs();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class DependencyTestBase : IDisposable
protected const string ANOTHER_WALLET_ADDRESS = "rms1qz8wf6jrchvsfmcnsfhlf6s53x3u85y0j4hvwth9a5ff3xhrxtmvvyc9ae7";
protected const int SLEEP_DURATION_SECONDS_TRANSACTION = 5;
protected const int SLEEP_DURATION_SECONDS_FAUCET = 15;
protected const int SLEEP_DURATION_SECONDS_API_RATE_LIMIT = 10;
protected const int SLEEP_DURATION_SECONDS_API_RATE_LIMIT = 15;
public DependencyTestBase()
{

Expand Down