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
6 changes: 6 additions & 0 deletions csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using IotaWalletNet.Application.AccountContext.Commands.BurnNft;
using IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs;
using IotaWalletNet.Application.AccountContext.Commands.GenerateAddresses;
using IotaWalletNet.Application.AccountContext.Commands.MintNfts;
using IotaWalletNet.Application.AccountContext.Commands.RequestFromFaucet;
Expand Down Expand Up @@ -51,6 +52,11 @@ public async Task<GetPendingTransactionsResponse> GetPendingTransactionsAsync()
return await _mediator.Send(new GetPendingTransactionsQuery(Username, this));
}

public async Task<ClaimOutputsResponse> ClaimOutputsAsync(List<string> outputIds)
{
return await _mediator.Send(new ClaimOutputsCommand(Username, this, outputIds));
}

public async Task<GetMinimumStorageDepositRequiredResponse> GetMinimumStorageDepositRequiredAsync(IOutputType outputType)
{
return await _mediator.Send(new GetMinimumStorageDepositRequiredQuery(Username, this, outputType));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using IotaWalletNet.Application.Common.Interfaces;
using MediatR;

namespace IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs
{
public class ClaimOutputsCommand : IRequest<ClaimOutputsResponse>
{
public ClaimOutputsCommand(string username, IAccount account, List<string> outputIds)
{
Account = account;
Username = username;
OutputIds = outputIds;
}
public IAccount Account { get; set; }
public string Username { get; set; }

public List<string> OutputIds { 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.Commands.ClaimOutputs
{
public class ClaimOutputsCommandHandler : IRequestHandler<ClaimOutputsCommand, ClaimOutputsResponse>
{
public async Task<ClaimOutputsResponse> Handle(ClaimOutputsCommand request, CancellationToken cancellationToken)
{
ClaimOutputsCommandMessage message = new ClaimOutputsCommandMessage(request.Username, request.OutputIds);
string messageJson = JsonConvert.SerializeObject(message);

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

ClaimOutputsResponse response = genericResponse.IsSuccess
? genericResponse.As<ClaimOutputsResponse>()!
: new ClaimOutputsResponse() { 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.Commands.ClaimOutputs
{
public class ClaimOutputsCommandMessage : AccountMessage<List<string>>
{
private const string METHOD_NAME = "claimOutputs";
public ClaimOutputsCommandMessage(string username, List<string> outputIds)
: base(username, METHOD_NAME, outputIds)
{

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

namespace IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs
{
public class ClaimOutputsResponse : RustBridgeResponseBase<Transaction>
{

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using IotaWalletNet.Application.AccountContext.Commands.BurnNft;
using IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs;
using IotaWalletNet.Application.AccountContext.Commands.GenerateAddresses;
using IotaWalletNet.Application.AccountContext.Commands.MintNfts;
using IotaWalletNet.Application.AccountContext.Commands.SendNfts;
Expand Down Expand Up @@ -44,5 +45,6 @@ public interface IAccount : IRustBridgeCommunicator
Task<GetMinimumStorageDepositRequiredResponse> GetMinimumStorageDepositRequiredAsync(IOutputType outputType);
Task<GetTransactionResponse> GetTransactionAsync(string transactionId);
Task<GetPendingTransactionsResponse> GetPendingTransactionsAsync();
Task<ClaimOutputsResponse> ClaimOutputsAsync(List<string> outputIds);
}
}