-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from IOTA-NET/158-feat-send-outputs
158 feat send outputs
- Loading branch information
Showing
23 changed files
with
227 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...WalletNet.Application/AccountContext/Commands/BuildBasicOutput/BuildBasicOutputCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using IotaWalletNet.Application.Common.Interfaces; | ||
using IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes; | ||
using MediatR; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput | ||
{ | ||
public class BuildBasicOutputCommand : IRequest<BuildBasicOutputResponse> | ||
{ | ||
public BuildBasicOutputCommand(BuildBasicOutputData data, string username, IAccount account) | ||
{ | ||
Data = data; | ||
Username = username; | ||
Account = account; | ||
} | ||
|
||
public BuildBasicOutputData Data { get; set; } | ||
|
||
public string Username { get; set; } | ||
|
||
public IAccount Account { get; set; } | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...et.Application/AccountContext/Commands/BuildBasicOutput/BuildBasicOutputCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using IotaWalletNet.Domain.PlatformInvoke; | ||
using MediatR; | ||
using Newtonsoft.Json; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput | ||
{ | ||
public class BuildBasicOutputCommandHandler : IRequestHandler<BuildBasicOutputCommand, BuildBasicOutputResponse> | ||
{ | ||
public async Task<BuildBasicOutputResponse> Handle(BuildBasicOutputCommand request, CancellationToken cancellationToken) | ||
{ | ||
BuildBasicOutputCommandMessage message = new BuildBasicOutputCommandMessage(request.Username, request.Data); | ||
string jsonMessage = JsonConvert.SerializeObject(message); | ||
|
||
RustBridgeGenericResponse rustBridgeGenericResponse = await request.Account.SendMessageAsync(jsonMessage); | ||
|
||
BuildBasicOutputResponse buildBasicOutputResponse = rustBridgeGenericResponse.As<BuildBasicOutputResponse>()!; | ||
|
||
return buildBasicOutputResponse; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...et.Application/AccountContext/Commands/BuildBasicOutput/BuildBasicOutputCommandMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using IotaWalletNet.Domain.Common.Models; | ||
using IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput | ||
{ | ||
public class BuildBasicOutputCommandMessage : AccountMessage<BuildBasicOutputData> | ||
{ | ||
private const string METHOD_NAME = "buildBasicOutput"; | ||
public BuildBasicOutputCommandMessage(string username, BuildBasicOutputData? methodData) | ||
: base(username, METHOD_NAME, methodData) | ||
{ | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...alletNet.Application/AccountContext/Commands/BuildBasicOutput/BuildBasicOutputResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using IotaWalletNet.Domain.Common.Models.Output.OutputTypes; | ||
using IotaWalletNet.Domain.PlatformInvoke; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput | ||
{ | ||
public class BuildBasicOutputResponse : RustBridgeResponseBase<BasicOutput> | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...etNet/IotaWalletNet.Application/AccountContext/Commands/SendOutputs/SendOutputsCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using IotaWalletNet.Application.Common.Interfaces; | ||
using IotaWalletNet.Domain.Common.Interfaces; | ||
using IotaWalletNet.Domain.Common.Models.Transaction.PayloadTypes; | ||
using MediatR; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs | ||
{ | ||
public class SendOutputsCommand : IRequest<SendOutputsResponse> | ||
{ | ||
public SendOutputsCommand(IAccount account, string username, List<IOutputType> outputs, TaggedDataPayload? taggedDataPayload = null) | ||
{ | ||
Account = account; | ||
Username = username; | ||
Outputs = outputs; | ||
TaggedDataPayload = taggedDataPayload; | ||
} | ||
|
||
public IAccount Account { get; set; } | ||
|
||
public string Username { get; set; } | ||
|
||
public List<IOutputType> Outputs { get; set; } | ||
|
||
public TaggedDataPayload? TaggedDataPayload { get; set; } | ||
|
||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...otaWalletNet.Application/AccountContext/Commands/SendOutputs/SendOutputsCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using IotaWalletNet.Domain.Common.Models.Transaction; | ||
using IotaWalletNet.Domain.PlatformInvoke; | ||
using MediatR; | ||
using Newtonsoft.Json; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs | ||
{ | ||
public class SendOutputsCommandHandler : IRequestHandler<SendOutputsCommand, SendOutputsResponse> | ||
{ | ||
public async Task<SendOutputsResponse> Handle(SendOutputsCommand request, CancellationToken cancellationToken) | ||
{ | ||
TransactionOptions transactionOptions = new TransactionOptions() { TaggedDataPayload = request.TaggedDataPayload }; | ||
|
||
SendOutputsCommandMessageData messageData = new SendOutputsCommandMessageData(request.Outputs, transactionOptions); | ||
|
||
SendOutputsCommandMessage message = new SendOutputsCommandMessage(request.Username, messageData); | ||
|
||
string messageJson = JsonConvert.SerializeObject(message); | ||
|
||
RustBridgeGenericResponse rustBridgeGenericResponse = await request.Account.SendMessageAsync(messageJson); | ||
|
||
SendOutputsResponse sendOutputsResponse = rustBridgeGenericResponse.As<SendOutputsResponse>()!; | ||
|
||
return sendOutputsResponse; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...otaWalletNet.Application/AccountContext/Commands/SendOutputs/SendOutputsCommandMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using IotaWalletNet.Domain.Common.Models; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs | ||
{ | ||
public class SendOutputsCommandMessage : AccountMessage<SendOutputsCommandMessageData> | ||
{ | ||
private const string METHOD_NAME = "sendOutputs"; | ||
public SendOutputsCommandMessage(string username, SendOutputsCommandMessageData? methodData) | ||
: base(username, METHOD_NAME, methodData) | ||
{ | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...alletNet.Application/AccountContext/Commands/SendOutputs/SendOutputsCommandMessageData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using IotaWalletNet.Domain.Common.Interfaces; | ||
using IotaWalletNet.Domain.Common.Models.Transaction; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs | ||
{ | ||
public class SendOutputsCommandMessageData | ||
{ | ||
public SendOutputsCommandMessageData(List<IOutputType> outputs, TransactionOptions options) | ||
{ | ||
Outputs = outputs; | ||
Options = options; | ||
} | ||
|
||
public List<IOutputType> Outputs { get; set; } | ||
|
||
public TransactionOptions Options { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...tNet/IotaWalletNet.Application/AccountContext/Commands/SendOutputs/SendOutputsResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using IotaWalletNet.Domain.Common.Models.Transaction; | ||
using IotaWalletNet.Domain.PlatformInvoke; | ||
|
||
namespace IotaWalletNet.Application.AccountContext.Commands.SendOutputs | ||
{ | ||
//Response | ||
public class SendOutputsResponse : RustBridgeResponseBase<Transaction> | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...lletNet/IotaWalletNet.Domain/Common/Models/Output/OutputDataTypes/BuildBasicOutputData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using IotaWalletNet.Domain.Common.Interfaces; | ||
using IotaWalletNet.Domain.Common.Models.Coin; | ||
|
||
namespace IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes | ||
{ | ||
public class BuildBasicOutputData | ||
{ | ||
public BuildBasicOutputData(string? amount, NativeToken? nativeTokens, List<IUnlockConditionType> unlockConditions, List<IFeatureType>? features) | ||
{ | ||
Amount = amount; | ||
NativeTokens = nativeTokens; | ||
UnlockConditions = unlockConditions; | ||
Features = features; | ||
} | ||
|
||
/// <summary> | ||
/// If not provided, minimum storage deposit will be used | ||
/// </summary> | ||
public string? Amount { get; set; } | ||
|
||
public NativeToken? NativeTokens { get; set; } | ||
|
||
public List<IUnlockConditionType> UnlockConditions { get; set; } | ||
|
||
public List<IFeatureType>? Features { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.