Skip to content

Commit 51924a8

Browse files
committed
Added SendOutputs
1 parent 41e0926 commit 51924a8

File tree

9 files changed

+110
-3
lines changed

9 files changed

+110
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ For more examples, see the [Examples](https://github.com/wireless90/IotaWallet.N
155155

156156
### Commands
157157

158+
- [x] BuildBasicOutput
158159
- [x] BurnNativeTokens
159160
- [x] BurnNft
160161
- [x] ClaimOutputs
@@ -171,6 +172,7 @@ For more examples, see the [Examples](https://github.com/wireless90/IotaWallet.N
171172
- [x] SendMicroAmount
172173
- [x] SendNativeTokens
173174
- [x] SendNfts
175+
- [x] SendOutputs
174176
- [x] SyncAccount
175177

176178
### Queries

csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using IotaWalletNet.Application.AccountContext.Commands.SendMicroAmount;
1616
using IotaWalletNet.Application.AccountContext.Commands.SendNativeTokens;
1717
using IotaWalletNet.Application.AccountContext.Commands.SendNfts;
18+
using IotaWalletNet.Application.AccountContext.Commands.SendOutputs;
1819
using IotaWalletNet.Application.AccountContext.Commands.SyncAccount;
1920
using IotaWalletNet.Application.AccountContext.Queries.GetAddresses;
2021
using IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs;
@@ -36,6 +37,7 @@
3637
using IotaWalletNet.Domain.Common.Models.Nft;
3738
using IotaWalletNet.Domain.Common.Models.Output;
3839
using IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes;
40+
using IotaWalletNet.Domain.Common.Models.Transaction;
3941
using IotaWalletNet.Domain.Common.Models.Transaction.PayloadTypes;
4042
using IotaWalletNet.Domain.PlatformInvoke;
4143
using MediatR;
@@ -58,7 +60,12 @@ public Account(IMediator mediator, string username, IWallet wallet)
5860
public IWallet Wallet { get; }
5961

6062

61-
public async Task<BuildBasicOutputResponse> BuildBasicOutput(BuildBasicOutputData buildBasicOutputData)
63+
public async Task<SendOutputsResponse> SendOutputsAsync(List<IOutputType> outputs, TaggedDataPayload? taggedDataPayload=null)
64+
{
65+
return await _mediator.Send(new SendOutputsCommand(this, Username, outputs, taggedDataPayload));
66+
}
67+
68+
public async Task<BuildBasicOutputResponse> BuildBasicOutputAsync(BuildBasicOutputData buildBasicOutputData)
6269
{
6370
return await _mediator.Send(new BuildBasicOutputCommand(buildBasicOutputData, Username, this));
6471
}

csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/SendAmount/SendAmountCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace IotaWalletNet.Application.AccountContext.Commands.SendAmount
77
{
88
public class SendAmountCommand : IRequest<SendAmountResponse>
99
{
10-
public SendAmountCommand(IAccount account, string username, List<AddressWithAmount> addressesWithAmount, TaggedDataPayload? taggedDataPayload)
10+
public SendAmountCommand(IAccount account, string username, List<AddressWithAmount> addressesWithAmount, TaggedDataPayload? taggedDataPayload = null)
1111
{
1212
Account = account;
1313
Username = username;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using IotaWalletNet.Application.Common.Interfaces;
2+
using IotaWalletNet.Domain.Common.Interfaces;
3+
using IotaWalletNet.Domain.Common.Models.Transaction.PayloadTypes;
4+
using MediatR;
5+
6+
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs
7+
{
8+
public class SendOutputsCommand : IRequest<SendOutputsResponse>
9+
{
10+
public SendOutputsCommand(IAccount account, string username, List<IOutputType> outputs, TaggedDataPayload? taggedDataPayload=null)
11+
{
12+
Account = account;
13+
Username = username;
14+
Outputs = outputs;
15+
TaggedDataPayload = taggedDataPayload;
16+
}
17+
18+
public IAccount Account { get; set; }
19+
20+
public string Username { get; set; }
21+
22+
public List<IOutputType> Outputs { get; set; }
23+
24+
public TaggedDataPayload? TaggedDataPayload { get; set; }
25+
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using IotaWalletNet.Domain.Common.Models.Transaction;
2+
using IotaWalletNet.Domain.PlatformInvoke;
3+
using MediatR;
4+
using Newtonsoft.Json;
5+
6+
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs
7+
{
8+
public class SendOutputsCommandHandler : IRequestHandler<SendOutputsCommand, SendOutputsResponse>
9+
{
10+
public async Task<SendOutputsResponse> Handle(SendOutputsCommand request, CancellationToken cancellationToken)
11+
{
12+
TransactionOptions transactionOptions = new TransactionOptions() { TaggedDataPayload = request.TaggedDataPayload };
13+
14+
SendOutputsCommandMessageData messageData = new SendOutputsCommandMessageData(request.Outputs, transactionOptions);
15+
16+
SendOutputsCommandMessage message = new SendOutputsCommandMessage(request.Username, messageData);
17+
18+
string messageJson = JsonConvert.SerializeObject(message);
19+
20+
RustBridgeGenericResponse rustBridgeGenericResponse = await request.Account.SendMessageAsync(messageJson);
21+
22+
SendOutputsResponse sendOutputsResponse = rustBridgeGenericResponse.As<SendOutputsResponse>()!;
23+
24+
return sendOutputsResponse;
25+
}
26+
}
27+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using IotaWalletNet.Domain.Common.Models;
2+
3+
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs
4+
{
5+
public class SendOutputsCommandMessage : AccountMessage<SendOutputsCommandMessageData>
6+
{
7+
private const string METHOD_NAME = "sendOutputs";
8+
public SendOutputsCommandMessage(string username, SendOutputsCommandMessageData? methodData)
9+
: base(username, METHOD_NAME, methodData)
10+
{
11+
}
12+
}
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using IotaWalletNet.Domain.Common.Interfaces;
2+
using IotaWalletNet.Domain.Common.Models.Transaction;
3+
4+
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs
5+
{
6+
public class SendOutputsCommandMessageData
7+
{
8+
public SendOutputsCommandMessageData(List<IOutputType> outputs, TransactionOptions options)
9+
{
10+
Outputs = outputs;
11+
Options = options;
12+
}
13+
14+
public List<IOutputType> Outputs { get; set; }
15+
16+
public TransactionOptions Options { get; set; }
17+
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using IotaWalletNet.Domain.Common.Models.Transaction;
2+
using IotaWalletNet.Domain.PlatformInvoke;
3+
4+
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs
5+
{
6+
//Response
7+
public class SendOutputsResponse : RustBridgeResponseBase<Transaction>
8+
{
9+
10+
}
11+
}

csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using IotaWalletNet.Application.AccountContext.Commands.SendMicroAmount;
1414
using IotaWalletNet.Application.AccountContext.Commands.SendNativeTokens;
1515
using IotaWalletNet.Application.AccountContext.Commands.SendNfts;
16+
using IotaWalletNet.Application.AccountContext.Commands.SendOutputs;
1617
using IotaWalletNet.Application.AccountContext.Commands.SyncAccount;
1718
using IotaWalletNet.Application.AccountContext.Queries.GetAddresses;
1819
using IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs;
@@ -74,6 +75,7 @@ public interface IAccount : IRustBridgeCommunicator
7475
SendMicroAmountBuilder SendMicroAmountUsingBuilder();
7576
Task<GetOutputsWithAdditionalUnlockConditionsResponse> GetOutputsWithAdditionalUnlockConditionsAsync(OutputTypeToClaim outputTypeToClaim);
7677
Task<Task> EnablePeriodicSyncing(int intervalInMilliSeconds);
77-
Task<BuildBasicOutputResponse> BuildBasicOutput(BuildBasicOutputData buildBasicOutputData);
78+
Task<BuildBasicOutputResponse> BuildBasicOutputAsync(BuildBasicOutputData buildBasicOutputData);
79+
Task<SendOutputsResponse> SendOutputsAsync(List<IOutputType> outputs, TaggedDataPayload? taggedDataPayload = null);
7880
}
7981
}

0 commit comments

Comments
 (0)