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
7 changes: 7 additions & 0 deletions csharp/IotaWalletNet/IotaWalletNet.Application/Account.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -47,6 +49,11 @@ public async Task<GetTransactionResponse> GetTransactionAsync(string transaction
return await _mediator.Send(new GetTransactionQuery(Username, this, transactionId));
}

public async Task<MintNativeTokensResponse> MintNativeTokensAsync(NativeTokenOptions nativeTokenOptions)
{
return await _mediator.Send(new MintNativeTokensCommand(Username, this, nativeTokenOptions));
}

public async Task<GetPendingTransactionsResponse> GetPendingTransactionsAsync()
{
return await _mediator.Send(new GetPendingTransactionsQuery(Username, this));
Expand Down
Original file line number Diff line number Diff line change
@@ -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; }
}

}
Original file line number Diff line number Diff line change
@@ -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<MintNativeTokensResponse>
{
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; }
}

}
Original file line number Diff line number Diff line change
@@ -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<MintNativeTokensCommand, MintNativeTokensResponse>
{
public async Task<MintNativeTokensResponse> 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<MintNativeTokensResponse>()!
: new MintNativeTokensResponse() { Error = genericResponse.As<RustBridgeErrorResponse>(), Type = "error" };

return response;
}
}

}
Original file line number Diff line number Diff line change
@@ -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; }
}

}
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.MintNativeTokens
{
public class MintNativeTokensResponse : RustBridgeResponseBase<MintTokenTransaction>
{

}

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -46,5 +48,6 @@ public interface IAccount : IRustBridgeCommunicator
Task<GetTransactionResponse> GetTransactionAsync(string transactionId);
Task<GetPendingTransactionsResponse> GetPendingTransactionsAsync();
Task<ClaimOutputsResponse> ClaimOutputsAsync(List<string> outputIds);
Task<MintNativeTokensResponse> MintNativeTokensAsync(NativeTokenOptions nativeTokenOptions);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace IotaWalletNet.Domain.Common.Models.Coin
{
public class NativeTokenOptions
{
public string? AliasId { get; set; }

/// <summary>
/// [HexEncoded Amount]
/// </summary>
public string CirculatingSupply { get; set; }

/// <summary>
/// [HexEncoded Amount]
/// </summary>
public string MaximumSupply { get; set; }

/// <summary>
/// [HexEncoded]
/// </summary>
public string? FoundryMetadata { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace IotaWalletNet.Domain.Common.Models.Transaction
{
/// <summary>
/// The result of a minting operation
/// </summary>
public class MintTokenTransaction
{
public MintTokenTransaction(string tokenId, Transaction transaction)
{
TokenId = tokenId;
Transaction = transaction;
}

/// <summary>
/// The token id of the minted token
/// </summary>
public string TokenId { get; set; }

/// <summary>
/// The transaction which minted the token
/// </summary>
public Transaction Transaction { get; set; }
}
}