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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ For more examples, see the [Examples](https://github.com/wireless90/IotaWallet.N
### Commands

- [x] BuildBasicOutput
- [x] BuildNftOutput
- [x] BurnNativeTokens
- [x] BurnNft
- [x] ClaimOutputs
Expand Down
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.BuildBasicOutput;
using IotaWalletNet.Application.AccountContext.Commands.BuildNftOutput;
using IotaWalletNet.Application.AccountContext.Commands.BurnNativeTokens;
using IotaWalletNet.Application.AccountContext.Commands.BurnNft;
using IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs;
Expand Down Expand Up @@ -90,6 +91,11 @@ public async Task<BuildBasicOutputResponse> BuildBasicOutputAsync(BuildBasicOutp
return await _mediator.Send(new BuildBasicOutputCommand(buildBasicOutputData, Username, this));
}

public async Task<BuildNftOutputResponse> BuildNftOutputAsync(BuildNftOutputData buildNftOutputData)
{
return await _mediator.Send(new BuildNftOutputCommand(buildNftOutputData, Username, this));
}

public async Task EnablePeriodicSyncing(int intervalInMilliSeconds, CancellationToken cancellationToken=default)
{
await _mediator.Send(new EnablePeriodicSyncingCommand(this, intervalInMilliSeconds), cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using IotaWalletNet.Application.Common.Interfaces;
using IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes;
using MediatR;

namespace IotaWalletNet.Application.AccountContext.Commands.BuildNftOutput
{
internal class BuildNftOutputCommand : IRequest<BuildNftOutputResponse>
{
public BuildNftOutputCommand(BuildNftOutputData data, string username, IAccount account)
{
Data = data;
Username = username;
Account = account;
}

public BuildNftOutputData Data { get; }
public string Username { get; }
public IAccount Account { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using IotaWalletNet.Domain.PlatformInvoke;
using MediatR;
using Newtonsoft.Json;

namespace IotaWalletNet.Application.AccountContext.Commands.BuildNftOutput
{
internal class BuildNftOutputCommandHandler : IRequestHandler<BuildNftOutputCommand, BuildNftOutputResponse>
{
public async Task<BuildNftOutputResponse> Handle(BuildNftOutputCommand request, CancellationToken cancellationToken)
{
BuildNftOutputCommandMessage message = new BuildNftOutputCommandMessage(request.Username, request.Data);

string jsonMessage = JsonConvert.SerializeObject(message);

RustBridgeGenericResponse rustBridgeGenericResponse = await request.Account.SendMessageAsync(jsonMessage);

BuildNftOutputResponse buildNftOutputResponse = rustBridgeGenericResponse.As<BuildNftOutputResponse>()!;

return buildNftOutputResponse;
}
}
}
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.BuildNftOutput
{
internal class BuildNftOutputCommandMessage : AccountMessage<BuildNftOutputData>
{
private const string METHOD_NAME = "buildNftOutput";
public BuildNftOutputCommandMessage(string username, BuildNftOutputData? methodData)
: base(username, METHOD_NAME, methodData)
{
}
}
}
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.BuildNftOutput
{
public class BuildNftOutputResponse : RustBridgeResponseBase<NftOutput>
{

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using IotaWalletNet.Application.AccountContext.Commands.BuildBasicOutput;
using IotaWalletNet.Application.AccountContext.Commands.BuildNftOutput;
using IotaWalletNet.Application.AccountContext.Commands.BurnNativeTokens;
using IotaWalletNet.Application.AccountContext.Commands.BurnNft;
using IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs;
Expand Down Expand Up @@ -78,5 +79,6 @@ public interface IAccount : IRustBridgeCommunicator
Task<BuildBasicOutputResponse> BuildBasicOutputAsync(BuildBasicOutputData buildBasicOutputData);
Task<SendOutputsResponse> SendOutputsAsync(List<IOutputType> outputs, TaggedDataPayload? taggedDataPayload = null);
Task<T> RetryAsyncFuncUntil<T>(Func<Task<T>> function, int intervalInMilliseconds, Func<T, bool> predicate, CancellationToken cancellationToken = default);
Task<BuildNftOutputResponse> BuildNftOutputAsync(BuildNftOutputData buildNftOutputData);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using IotaWalletNet.Domain.Common.Interfaces;
using IotaWalletNet.Domain.Common.Models.Coin;
using Newtonsoft.Json;

namespace IotaWalletNet.Domain.Common.Models.Output
{
Expand All @@ -13,16 +14,20 @@ protected CommonOutput(List<IUnlockConditionType> unlockConditions)
/// <summary>
/// The native tokens held by the output.
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public List<NativeToken>? NativeTokens { get; set; }

/// <summary>
/// The unlock conditions for the output.
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
///
public List<IUnlockConditionType> UnlockConditions { get; set; }

/// <summary>
/// Features contained by the output.
/// Features containe d by the output.
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public List<IFeatureType>? Features { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using IotaWalletNet.Domain.Common.Interfaces;
using IotaWalletNet.Domain.Common.Models.Coin;

namespace IotaWalletNet.Domain.Common.Models.Output.OutputDataTypes
{
public class BuildNftOutputData : BuildBasicOutputData
{
public BuildNftOutputData(string? amount, NativeToken? nativeTokens, List<IUnlockConditionType> unlockConditions, List<IFeatureType>? features, List<IFeatureType>? immutableFeatures, string? nftId)
: base(amount, nativeTokens, unlockConditions, features)
{
ImmutableFeatures = immutableFeatures;
NftId = nftId;
}

/// <summary>
/// If not provided, minimum storage deposit will be used
/// </summary>
public string? NftId { get; set; } = string.Empty;

public List<IFeatureType>? ImmutableFeatures { get; set; }
}
}