mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-23 20:18:24 +00:00
Add failure screen and Retry button
This commit is contained in:
parent
76eb1415df
commit
c932cd686c
@ -1,17 +1,27 @@
|
|||||||
@page "/step4"
|
@page "/step4"
|
||||||
@inherits Step4Component
|
@inherits Step4Component
|
||||||
|
|
||||||
@if (TransactionHash != null)
|
@if (TransactionHash == null)
|
||||||
|
{
|
||||||
|
<TextWithIcon Text="Minting is in progress... Please wait." Icon="loading-3-quarters" Color="blue" Level="4" />
|
||||||
|
}
|
||||||
|
else if (TransactionHash.Value.IsSuccess)
|
||||||
{
|
{
|
||||||
<Result Status="success"
|
<Result Status="success"
|
||||||
Title="Transaction for token minting was successfully created!"
|
Title="Transaction was successfully created!"
|
||||||
SubTitle="@($"Transaction: {TransactionHash}. Please wait for 1-5 minutes till transaction is completed.")">
|
SubTitle="@($"Transaction: {TransactionHash}. Please wait for 1-5 minutes till transaction is completed.")">
|
||||||
<Extra>
|
<Extra>
|
||||||
<Button Type="primary" OnClick="@Reset">Start again</Button>
|
<Button Type="primary" OnClick="@Reset">Start new mint</Button>
|
||||||
</Extra>
|
</Extra>
|
||||||
</Result>
|
</Result>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<TextWithIcon Text="Minting is in progress... Please wait." Icon="loading-3-quarters" Color="blue" Level="4" />
|
<Result Status="error"
|
||||||
|
Title="Failed to create transaction"
|
||||||
|
SubTitle="@("Please ensure that you approve created transactions in Metamask")">
|
||||||
|
<Extra>
|
||||||
|
<Button Type="primary" OnClick="@Retry">Try again</Button>
|
||||||
|
</Extra>
|
||||||
|
</Result>
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
using System.Text;
|
using CSharpFunctionalExtensions;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using NftFaucet.Components;
|
using NftFaucet.Components;
|
||||||
using NftFaucet.Extensions;
|
using NftFaucet.Extensions;
|
||||||
using NftFaucet.Models.Enums;
|
using NftFaucet.Models.Enums;
|
||||||
using NftFaucet.Services;
|
using NftFaucet.Services;
|
||||||
|
using NftFaucet.Utils;
|
||||||
|
|
||||||
namespace NftFaucet.Pages;
|
namespace NftFaucet.Pages;
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ public class Step4Component : BasicComponent
|
|||||||
[Inject]
|
[Inject]
|
||||||
public IEthereumTransactionService TransactionService { get; set; }
|
public IEthereumTransactionService TransactionService { get; set; }
|
||||||
|
|
||||||
protected string TransactionHash { get; set; }
|
protected Result<string>? TransactionHash { get; set; }
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@ -31,14 +32,18 @@ public class Step4Component : BasicComponent
|
|||||||
|
|
||||||
public async Task Mint()
|
public async Task Mint()
|
||||||
{
|
{
|
||||||
|
var network = AppState.Metamask.Network!.Value;
|
||||||
|
var address = AppState.Storage.DestinationAddress;
|
||||||
|
var uri = AppState.Storage.TokenUrl;
|
||||||
|
|
||||||
if (AppState.Storage.TokenType == TokenType.ERC721)
|
if (AppState.Storage.TokenType == TokenType.ERC721)
|
||||||
{
|
{
|
||||||
TransactionHash = await TransactionService.MintErc721Token(AppState.Metamask.Network!.Value, AppState.Storage.DestinationAddress, AppState.Storage.TokenUrl);
|
TransactionHash = await ResultWrapper.Wrap(TransactionService.MintErc721Token(network, address, uri));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var amount = (int) AppState.Storage.TokenAmount;
|
var amount = (int) AppState.Storage.TokenAmount;
|
||||||
TransactionHash = await TransactionService.MintErc1155Token(AppState.Metamask.Network!.Value, AppState.Storage.DestinationAddress, amount, AppState.Storage.TokenUrl);
|
TransactionHash = await ResultWrapper.Wrap(TransactionService.MintErc1155Token(network, address, amount, uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshMediator.NotifyStateHasChangedSafe();
|
RefreshMediator.NotifyStateHasChangedSafe();
|
||||||
@ -49,4 +54,11 @@ public class Step4Component : BasicComponent
|
|||||||
AppState.Reset();
|
AppState.Reset();
|
||||||
UriHelper.NavigateToRelative("/");
|
UriHelper.NavigateToRelative("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async Task Retry()
|
||||||
|
{
|
||||||
|
TransactionHash = null;
|
||||||
|
RefreshMediator.NotifyStateHasChangedSafe();
|
||||||
|
Mint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user