Skip to content

Commit 71c296f

Browse files
authored
Merge pull request #159 from IOTA-NET/158-feat-send-outputs
158 feat send outputs
2 parents 14e6676 + 0b023eb commit 71c296f

File tree

23 files changed

+227
-22
lines changed

23 files changed

+227
-22
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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using IotaWalletNet.Application.AccountContext.Commands.BurnNativeTokens;
1+
using IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput;
2+
using IotaWalletNet.Application.AccountContext.Commands.BurnNativeTokens;
23
using IotaWalletNet.Application.AccountContext.Commands.BurnNft;
34
using IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs;
45
using IotaWalletNet.Application.AccountContext.Commands.ConsolidateOutputs;
@@ -14,6 +15,7 @@
1415
using IotaWalletNet.Application.AccountContext.Commands.SendMicroAmount;
1516
using IotaWalletNet.Application.AccountContext.Commands.SendNativeTokens;
1617
using IotaWalletNet.Application.AccountContext.Commands.SendNfts;
18+
using IotaWalletNet.Application.AccountContext.Commands.SendOutputs;
1719
using IotaWalletNet.Application.AccountContext.Commands.SyncAccount;
1820
using IotaWalletNet.Application.AccountContext.Queries.GetAddresses;
1921
using IotaWalletNet.Application.AccountContext.Queries.GetAddressesWithUnspentOutputs;
@@ -34,6 +36,7 @@
3436
using IotaWalletNet.Domain.Common.Models.Network;
3537
using IotaWalletNet.Domain.Common.Models.Nft;
3638
using IotaWalletNet.Domain.Common.Models.Output;
39+
using IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes;
3740
using IotaWalletNet.Domain.Common.Models.Transaction.PayloadTypes;
3841
using IotaWalletNet.Domain.PlatformInvoke;
3942
using MediatR;
@@ -56,6 +59,16 @@ public Account(IMediator mediator, string username, IWallet wallet)
5659
public IWallet Wallet { get; }
5760

5861

62+
public async Task<SendOutputsResponse> SendOutputsAsync(List<IOutputType> outputs, TaggedDataPayload? taggedDataPayload = null)
63+
{
64+
return await _mediator.Send(new SendOutputsCommand(this, Username, outputs, taggedDataPayload));
65+
}
66+
67+
public async Task<BuildBasicOutputResponse> BuildBasicOutputAsync(BuildBasicOutputData buildBasicOutputData)
68+
{
69+
return await _mediator.Send(new BuildBasicOutputCommand(buildBasicOutputData, Username, this));
70+
}
71+
5972
public async Task<Task> EnablePeriodicSyncing(int intervalInMilliSeconds)
6073
{
6174
return await _mediator.Send(new EnablePeriodicSyncingCommand(this, intervalInMilliSeconds));
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using IotaWalletNet.Application.Common.Interfaces;
2+
using IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes;
3+
using MediatR;
4+
5+
namespace IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput
6+
{
7+
public class BuildBasicOutputCommand : IRequest<BuildBasicOutputResponse>
8+
{
9+
public BuildBasicOutputCommand(BuildBasicOutputData data, string username, IAccount account)
10+
{
11+
Data = data;
12+
Username = username;
13+
Account = account;
14+
}
15+
16+
public BuildBasicOutputData Data { get; set; }
17+
18+
public string Username { get; set; }
19+
20+
public IAccount Account { get; set; }
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using IotaWalletNet.Domain.PlatformInvoke;
2+
using MediatR;
3+
using Newtonsoft.Json;
4+
5+
namespace IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput
6+
{
7+
public class BuildBasicOutputCommandHandler : IRequestHandler<BuildBasicOutputCommand, BuildBasicOutputResponse>
8+
{
9+
public async Task<BuildBasicOutputResponse> Handle(BuildBasicOutputCommand request, CancellationToken cancellationToken)
10+
{
11+
BuildBasicOutputCommandMessage message = new BuildBasicOutputCommandMessage(request.Username, request.Data);
12+
string jsonMessage = JsonConvert.SerializeObject(message);
13+
14+
RustBridgeGenericResponse rustBridgeGenericResponse = await request.Account.SendMessageAsync(jsonMessage);
15+
16+
BuildBasicOutputResponse buildBasicOutputResponse = rustBridgeGenericResponse.As<BuildBasicOutputResponse>()!;
17+
18+
return buildBasicOutputResponse;
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using IotaWalletNet.Domain.Common.Models;
2+
using IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes;
3+
4+
namespace IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput
5+
{
6+
public class BuildBasicOutputCommandMessage : AccountMessage<BuildBasicOutputData>
7+
{
8+
private const string METHOD_NAME = "buildBasicOutput";
9+
public BuildBasicOutputCommandMessage(string username, BuildBasicOutputData? methodData)
10+
: base(username, METHOD_NAME, methodData)
11+
{
12+
}
13+
}
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using IotaWalletNet.Domain.Common.Models.Output.OutputTypes;
2+
using IotaWalletNet.Domain.PlatformInvoke;
3+
4+
namespace IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput
5+
{
6+
public class BuildBasicOutputResponse : RustBridgeResponseBase<BasicOutput>
7+
{
8+
9+
}
10+
}

csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/EnablePeriodicSyncing/EnablePeriodicSyncingCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public EnablePeriodicSyncingCommand(IAccount account, int intervalInMilliSeconds
1313

1414
public IAccount Account { get; set; }
1515

16-
public int IntervalInMilliSeconds { get;set; }
17-
16+
public int IntervalInMilliSeconds { get; set; }
17+
1818
}
1919
}

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+
}

0 commit comments

Comments
 (0)