mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-24 04:28:29 +00:00
52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using System.Text;
|
|
using Microsoft.AspNetCore.Components;
|
|
using NftFaucet.Components;
|
|
using NftFaucet.Models.Enums;
|
|
using NftFaucet.Services;
|
|
|
|
namespace NftFaucet.Pages;
|
|
|
|
public class Step4Component : BasicComponent
|
|
{
|
|
[Inject]
|
|
public IIpfsService IpfsService { get; set; }
|
|
|
|
[Inject]
|
|
public IEthereumTransactionService TransactionService { get; set; }
|
|
|
|
protected string TransactionHash { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
if (!await AppState.Metamask.IsReady() || string.IsNullOrEmpty(AppState.Storage.DestinationAddress))
|
|
{
|
|
UriHelper.NavigateTo("/");
|
|
}
|
|
else
|
|
{
|
|
Task.Run(Mint);
|
|
}
|
|
}
|
|
|
|
public async Task Mint()
|
|
{
|
|
if (AppState.Storage.TokenType == TokenType.ERC721)
|
|
{
|
|
TransactionHash = await TransactionService.MintErc721Token(AppState.Metamask.Network!.Value, AppState.Storage.DestinationAddress, AppState.Storage.TokenUrl);
|
|
}
|
|
else
|
|
{
|
|
var amount = (int) AppState.Storage.TokenAmount;
|
|
TransactionHash = await TransactionService.MintErc1155Token(AppState.Metamask.Network!.Value, AppState.Storage.DestinationAddress, amount, AppState.Storage.TokenUrl);
|
|
}
|
|
|
|
RefreshMediator.NotifyStateHasChangedSafe();
|
|
}
|
|
|
|
protected void Reset()
|
|
{
|
|
AppState.Reset();
|
|
UriHelper.NavigateTo("/");
|
|
}
|
|
}
|