diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs index 3a5effd..b4946a3 100644 --- a/csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs @@ -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; @@ -51,6 +52,11 @@ public async Task GetPendingTransactionsAsync() return await _mediator.Send(new GetPendingTransactionsQuery(Username, this)); } + public async Task ClaimOutputsAsync(List outputIds) + { + return await _mediator.Send(new ClaimOutputsCommand(Username, this, outputIds)); + } + public async Task GetMinimumStorageDepositRequiredAsync(IOutputType outputType) { return await _mediator.Send(new GetMinimumStorageDepositRequiredQuery(Username, this, outputType)); diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommand.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommand.cs new file mode 100644 index 0000000..40e8b46 --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommand.cs @@ -0,0 +1,19 @@ +using IotaWalletNet.Application.Common.Interfaces; +using MediatR; + +namespace IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs +{ + public class ClaimOutputsCommand : IRequest + { + public ClaimOutputsCommand(string username, IAccount account, List outputIds) + { + Account = account; + Username = username; + OutputIds = outputIds; + } + public IAccount Account { get; set; } + public string Username { get; set; } + + public List OutputIds { get; set; } + } +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommandHandler.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommandHandler.cs new file mode 100644 index 0000000..3e06d8c --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommandHandler.cs @@ -0,0 +1,23 @@ +using IotaWalletNet.Domain.PlatformInvoke; +using MediatR; +using Newtonsoft.Json; + +namespace IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs +{ + public class ClaimOutputsCommandHandler : IRequestHandler + { + public async Task 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()! + : new ClaimOutputsResponse() { Error = genericResponse.As(), Type = "error" }; + + return response; + } + } +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommandMessage.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommandMessage.cs new file mode 100644 index 0000000..4c4dc12 --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsCommandMessage.cs @@ -0,0 +1,14 @@ +using IotaWalletNet.Domain.Common.Models; + +namespace IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs +{ + public class ClaimOutputsCommandMessage : AccountMessage> + { + private const string METHOD_NAME = "claimOutputs"; + public ClaimOutputsCommandMessage(string username, List outputIds) + : base(username, METHOD_NAME, outputIds) + { + + } + } +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsResponse.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsResponse.cs new file mode 100644 index 0000000..59fc556 --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/ClaimOutputs/ClaimOutputsResponse.cs @@ -0,0 +1,10 @@ +using IotaWalletNet.Domain.Common.Models.Transaction; +using IotaWalletNet.Domain.PlatformInvoke; + +namespace IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs +{ + public class ClaimOutputsResponse : RustBridgeResponseBase + { + + } +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs index d7195de..7643061 100644 --- a/csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs @@ -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; @@ -44,5 +45,6 @@ public interface IAccount : IRustBridgeCommunicator Task GetMinimumStorageDepositRequiredAsync(IOutputType outputType); Task GetTransactionAsync(string transactionId); Task GetPendingTransactionsAsync(); + Task ClaimOutputsAsync(List outputIds); } }