diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs index b4946a3..86328ea 100644 --- a/csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs @@ -1,6 +1,7 @@ using IotaWalletNet.Application.AccountContext.Commands.BurnNft; using IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs; using IotaWalletNet.Application.AccountContext.Commands.GenerateAddresses; +using IotaWalletNet.Application.AccountContext.Commands.MintNativeTokens; using IotaWalletNet.Application.AccountContext.Commands.MintNfts; using IotaWalletNet.Application.AccountContext.Commands.RequestFromFaucet; using IotaWalletNet.Application.AccountContext.Commands.SendAmount; @@ -18,6 +19,7 @@ using IotaWalletNet.Application.Common.Interfaces; using IotaWalletNet.Domain.Common.Interfaces; using IotaWalletNet.Domain.Common.Models.Address; +using IotaWalletNet.Domain.Common.Models.Coin; using IotaWalletNet.Domain.Common.Models.Network; using IotaWalletNet.Domain.Common.Models.Nft; using IotaWalletNet.Domain.Common.Models.Output; @@ -47,6 +49,11 @@ public async Task GetTransactionAsync(string transaction return await _mediator.Send(new GetTransactionQuery(Username, this, transactionId)); } + public async Task MintNativeTokensAsync(NativeTokenOptions nativeTokenOptions) + { + return await _mediator.Send(new MintNativeTokensCommand(Username, this, nativeTokenOptions)); + } + public async Task GetPendingTransactionsAsync() { return await _mediator.Send(new GetPendingTransactionsQuery(Username, this)); diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNAtiveTokensCommandMessage.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNAtiveTokensCommandMessage.cs new file mode 100644 index 0000000..e88a70b --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNAtiveTokensCommandMessage.cs @@ -0,0 +1,15 @@ +namespace IotaWalletNet.Application.AccountContext.Commands.MintNativeTokens +{ + public class MintNAtiveTokensCommandMessage + { + private const string METHOD_NAME = "mintNativeToken"; + + public MintNAtiveTokensCommandMessage(MintNativeTokensCommandMessageData data) + { + Data = data; + } + + public MintNativeTokensCommandMessageData Data { get; set; } + } + +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommand.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommand.cs new file mode 100644 index 0000000..690162a --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommand.cs @@ -0,0 +1,22 @@ +using IotaWalletNet.Application.Common.Interfaces; +using IotaWalletNet.Domain.Common.Models.Coin; +using MediatR; + +namespace IotaWalletNet.Application.AccountContext.Commands.MintNativeTokens +{ + public class MintNativeTokensCommand : IRequest + { + public MintNativeTokensCommand(string username, IAccount account, NativeTokenOptions nativeTokenOptions) + { + Username = username; + Account = account; + NativeTokenOptions = nativeTokenOptions; + } + + public string Username { get; set; } + public IAccount Account { get; set; } + + public NativeTokenOptions NativeTokenOptions { get; set; } + } + +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommandHandler.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommandHandler.cs new file mode 100644 index 0000000..394d99d --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommandHandler.cs @@ -0,0 +1,26 @@ +using IotaWalletNet.Domain.Common.Models.Transaction; +using IotaWalletNet.Domain.PlatformInvoke; +using MediatR; +using Newtonsoft.Json; + +namespace IotaWalletNet.Application.AccountContext.Commands.MintNativeTokens +{ + public class MintNativeTokensCommandHandler : IRequestHandler + { + public async Task Handle(MintNativeTokensCommand request, CancellationToken cancellationToken) + { + MintNativeTokensCommandMessageData messageData = new MintNativeTokensCommandMessageData(request.NativeTokenOptions, new TransactionOptions()); + MintNAtiveTokensCommandMessage message = new MintNAtiveTokensCommandMessage(messageData); + string messageJson = JsonConvert.SerializeObject(message); + + RustBridgeGenericResponse genericResponse = await request.Account.SendMessageAsync(messageJson); + + MintNativeTokensResponse response = genericResponse.IsSuccess + ? genericResponse.As()! + : new MintNativeTokensResponse() { Error = genericResponse.As(), Type = "error" }; + + return response; + } + } + +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommandMessageData.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommandMessageData.cs new file mode 100644 index 0000000..ebaf8bc --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensCommandMessageData.cs @@ -0,0 +1,19 @@ +using IotaWalletNet.Domain.Common.Models.Coin; +using IotaWalletNet.Domain.Common.Models.Transaction; + +namespace IotaWalletNet.Application.AccountContext.Commands.MintNativeTokens +{ + public class MintNativeTokensCommandMessageData + { + public MintNativeTokensCommandMessageData(NativeTokenOptions nativeTokenOptions, TransactionOptions options) + { + NativeTokenOptions = nativeTokenOptions; + Options = options; + } + + public NativeTokenOptions NativeTokenOptions { get; set; } + + public TransactionOptions Options { get; set; } + } + +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensResponse.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensResponse.cs new file mode 100644 index 0000000..41b7b17 --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/AccountContext/Commands/MintNativeTokens/MintNativeTokensResponse.cs @@ -0,0 +1,11 @@ +using IotaWalletNet.Domain.Common.Models.Transaction; +using IotaWalletNet.Domain.PlatformInvoke; + +namespace IotaWalletNet.Application.AccountContext.Commands.MintNativeTokens +{ + public class MintNativeTokensResponse : RustBridgeResponseBase + { + + } + +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs b/csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs index 7643061..dff2282 100644 --- a/csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs +++ b/csharp/IotaWalletNet/IotaWalletNet.Application/Common/Interfaces/IAccount.cs @@ -1,6 +1,7 @@ using IotaWalletNet.Application.AccountContext.Commands.BurnNft; using IotaWalletNet.Application.AccountContext.Commands.ClaimOutputs; using IotaWalletNet.Application.AccountContext.Commands.GenerateAddresses; +using IotaWalletNet.Application.AccountContext.Commands.MintNativeTokens; using IotaWalletNet.Application.AccountContext.Commands.MintNfts; using IotaWalletNet.Application.AccountContext.Commands.SendNfts; using IotaWalletNet.Application.AccountContext.Queries.GetAddresses; @@ -14,6 +15,7 @@ using IotaWalletNet.Application.AccountContext.Queries.GetUnspentOutputs; using IotaWalletNet.Domain.Common.Interfaces; using IotaWalletNet.Domain.Common.Models.Address; +using IotaWalletNet.Domain.Common.Models.Coin; using IotaWalletNet.Domain.Common.Models.Network; using IotaWalletNet.Domain.Common.Models.Nft; using IotaWalletNet.Domain.Common.Models.Output; @@ -46,5 +48,6 @@ public interface IAccount : IRustBridgeCommunicator Task GetTransactionAsync(string transactionId); Task GetPendingTransactionsAsync(); Task ClaimOutputsAsync(List outputIds); + Task MintNativeTokensAsync(NativeTokenOptions nativeTokenOptions); } } diff --git a/csharp/IotaWalletNet/IotaWalletNet.Domain/Common/Models/Coin/NativeTokenOptions.cs b/csharp/IotaWalletNet/IotaWalletNet.Domain/Common/Models/Coin/NativeTokenOptions.cs new file mode 100644 index 0000000..5ab4251 --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Domain/Common/Models/Coin/NativeTokenOptions.cs @@ -0,0 +1,22 @@ +namespace IotaWalletNet.Domain.Common.Models.Coin +{ + public class NativeTokenOptions + { + public string? AliasId { get; set; } + + /// + /// [HexEncoded Amount] + /// + public string CirculatingSupply { get; set; } + + /// + /// [HexEncoded Amount] + /// + public string MaximumSupply { get; set; } + + /// + /// [HexEncoded] + /// + public string? FoundryMetadata { get; set; } + } +} diff --git a/csharp/IotaWalletNet/IotaWalletNet.Domain/Common/Models/Transaction/MintTokenTransaction.cs b/csharp/IotaWalletNet/IotaWalletNet.Domain/Common/Models/Transaction/MintTokenTransaction.cs new file mode 100644 index 0000000..5379969 --- /dev/null +++ b/csharp/IotaWalletNet/IotaWalletNet.Domain/Common/Models/Transaction/MintTokenTransaction.cs @@ -0,0 +1,24 @@ +namespace IotaWalletNet.Domain.Common.Models.Transaction +{ + /// + /// The result of a minting operation + /// + public class MintTokenTransaction + { + public MintTokenTransaction(string tokenId, Transaction transaction) + { + TokenId = tokenId; + Transaction = transaction; + } + + /// + /// The token id of the minted token + /// + public string TokenId { get; set; } + + /// + /// The transaction which minted the token + /// + public Transaction Transaction { get; set; } + } +}