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 @@ -5,10 +5,12 @@
using IotaWalletNet.Application.AccountContext.Commands.SyncAccount;
using IotaWalletNet.Application.AccountContext.Queries.GetAddresses;
using IotaWalletNet.Application.AccountContext.Queries.GetBalance;
using IotaWalletNet.Application.AccountContext.Queries.GetOutputs;
using IotaWalletNet.Application.Common.Interfaces;
using IotaWalletNet.Domain.Common.Models.Address;
using IotaWalletNet.Domain.Common.Models.Network;
using IotaWalletNet.Domain.Common.Models.Nft;
using IotaWalletNet.Domain.Common.Models.Output;
using IotaWalletNet.Domain.PlatformInvoke;
using MediatR;
using static IotaWalletNet.Application.AccountContext.Commands.SyncAccount.SyncAccountCommandHandler;
Expand All @@ -30,6 +32,11 @@ public Account(IMediator mediator, string username, IWallet wallet)
public string Username { get; }
public IWallet Wallet { get; }

public async Task<GetOutputsResponse> GetOutputs(OutputFilterOptions? outputFilterOptions=null)
{
return await _mediator.Send(new GetOutputsQuery(Username, this, outputFilterOptions));
}

public async Task<GenerateAddressesResponse> GenerateAddressesAsync(uint numberOfAddresses, NetworkType networkType)
{
return await _mediator.Send(new GenerateAddressesCommand(this, networkType, Username, numberOfAddresses));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using IotaWalletNet.Application.Common.Interfaces;
using IotaWalletNet.Domain.Common.Models.Output;
using MediatR;

namespace IotaWalletNet.Application.AccountContext.Queries.GetOutputs
{
public class GetOutputsQuery : IRequest<GetOutputsResponse>
{
public string Username { get; set; }

public OutputFilterOptions FilterOptions { get; set; }

public IAccount Account{ get; set; }
public GetOutputsQuery(string username, IAccount account, OutputFilterOptions? outputFilterOptions=null)
{
Username = username;
Account = account;
FilterOptions = outputFilterOptions ?? new OutputFilterOptions();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using IotaWalletNet.Domain.PlatformInvoke;
using MediatR;
using Newtonsoft.Json;

namespace IotaWalletNet.Application.AccountContext.Queries.GetOutputs
{
public class GetOutputsQueryHandler : IRequestHandler<GetOutputsQuery, GetOutputsResponse>
{
public async Task<GetOutputsResponse> Handle(GetOutputsQuery request, CancellationToken cancellationToken)
{
GetOutputsQueryMessageData messageData = new GetOutputsQueryMessageData(request.FilterOptions);
GetOutputsQueryMessage message = new GetOutputsQueryMessage(request.Username, messageData);

string json = JsonConvert.SerializeObject(message);
RustBridgeGenericResponse genericResponse = await request.Account.SendMessageAsync(json);

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

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

namespace IotaWalletNet.Application.AccountContext.Queries.GetOutputs
{
public class GetOutputsQueryMessage : AccountMessage<GetOutputsQueryMessageData>
{
private const string METHOD_NAME = "outputs";

public GetOutputsQueryMessage(string username, GetOutputsQueryMessageData getOutputsQueryMessageData)
:base(username, METHOD_NAME, getOutputsQueryMessageData)
{

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

namespace IotaWalletNet.Application.AccountContext.Queries.GetOutputs
{
public class GetOutputsQueryMessageData
{
public OutputFilterOptions FilterOptions { get; set; }

public GetOutputsQueryMessageData(OutputFilterOptions filterOptions)
{
FilterOptions = filterOptions;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using IotaWalletNet.Domain.Common.Models.Output;
using IotaWalletNet.Domain.PlatformInvoke;

namespace IotaWalletNet.Application.AccountContext.Queries.GetOutputs
{
public class GetOutputsResponse : RustBridgeResponseBase<List<OutputData>>
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
using IotaWalletNet.Application.AccountContext.Commands.MintNfts;
using IotaWalletNet.Application.AccountContext.Queries.GetAddresses;
using IotaWalletNet.Application.AccountContext.Queries.GetBalance;
using IotaWalletNet.Application.AccountContext.Queries.GetOutputs;
using IotaWalletNet.Domain.Common.Interfaces;
using IotaWalletNet.Domain.Common.Models.Address;
using IotaWalletNet.Domain.Common.Models.Network;
using IotaWalletNet.Domain.Common.Models.Nft;
using IotaWalletNet.Domain.Common.Models.Output;
using static IotaWalletNet.Application.AccountContext.Commands.SyncAccount.SyncAccountCommandHandler;

namespace IotaWalletNet.Application.Common.Interfaces
Expand All @@ -25,5 +27,6 @@ public interface IAccount : IRustBridgeCommunicator
Task<GenerateAddressesResponse> GenerateAddressesAsync(uint numberOfAddresses = 1, NetworkType networkType = default);
Task<MintNftsResponse> MintNftsAsync(List<NftOptions> nftsOptions);
Task<GetAddressesResponse> GetAddresses();
Task<GetOutputsResponse> GetOutputs(OutputFilterOptions? outputFilterOptions = null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace IotaWalletNet.Domain.Common.Models.Output
{
public class OutputFilterOptions
{
/// <summary>
/// Filter all outputs where the booked milestone index is below the specified timestamp
/// </summary>
public uint LowerBoundBookedTimestamp { get; set; }

/// <summary>
/// Filter all outputs where the booked milestone index is above the specified timestamp
/// </summary>
public uint UpperBoundBookedTimestamp { get; set; }
}
}