mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-22 19:48:25 +00:00
Add check if selected network is supported
This commit is contained in:
parent
8c824d57c1
commit
8386ffb8b1
@ -1,6 +1,7 @@
|
||||
using AntDesign;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NftFaucet.Models;
|
||||
using NftFaucet.Options;
|
||||
using NftFaucet.Services;
|
||||
|
||||
namespace NftFaucet.Components;
|
||||
@ -17,10 +18,13 @@ public abstract class BasicComponent : ComponentBase
|
||||
protected RefreshMediator RefreshMediator { get; set; }
|
||||
|
||||
[Inject]
|
||||
public MessageService MessageService { get; set; }
|
||||
protected Settings Settings { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IIpfsService IpfsService { get; set; }
|
||||
protected MessageService MessageService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected IIpfsService IpfsService { get; set; }
|
||||
|
||||
protected MetamaskInfo Metamask => AppState?.Metamask;
|
||||
|
||||
|
@ -2,12 +2,18 @@
|
||||
@inherits Step3Component
|
||||
|
||||
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
|
||||
@if (!IsSupportedNetwork)
|
||||
{
|
||||
<SpaceItem>
|
||||
<Title Level="2" Strong="true" Style="color: red;">Selected network is not supported. Please change network in Metamask!</Title>
|
||||
</SpaceItem>
|
||||
}
|
||||
<SpaceItem>
|
||||
<Title Level="4" Style="margin-bottom: 0;">Token URI:</Title>
|
||||
</SpaceItem>
|
||||
<SpaceItem Class="drk-full-width">
|
||||
<div class="@TokenUrlClass">
|
||||
<Input Size="medium" @bind-Value="@AppState.Storage.TokenUrl" OnInput="@OnTokenUrlInputChange" />
|
||||
<Input Size="medium" @bind-Value="@AppState.Storage.TokenUrl" OnInput="@OnTokenUrlInputChange"/>
|
||||
</div>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
@ -15,7 +21,7 @@
|
||||
</SpaceItem>
|
||||
<SpaceItem Class="drk-full-width">
|
||||
<div class="@DestinationAddressClass">
|
||||
<Input Size="medium" @bind-Value="@AppState.Storage.DestinationAddress" OnInput="@OnDestinationAddressInputChange" />
|
||||
<Input Size="medium" @bind-Value="@AppState.Storage.DestinationAddress" OnInput="@OnDestinationAddressInputChange"/>
|
||||
</div>
|
||||
</SpaceItem>
|
||||
</Space>
|
||||
|
@ -10,6 +10,7 @@ public class Step3Component : BasicComponent
|
||||
protected string DestinationAddressErrorMessage { get; set; }
|
||||
protected string TokenUrlClass => string.IsNullOrWhiteSpace(TokenUrlErrorMessage) ? null : "invalid-input";
|
||||
protected string DestinationAddressClass => string.IsNullOrWhiteSpace(DestinationAddressErrorMessage) ? null : "invalid-input";
|
||||
protected bool IsSupportedNetwork => AppState?.Metamask?.Network != null && Settings?.GetEthereumNetworkOptions(AppState.Metamask.Network!.Value) != null;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@ -47,6 +48,6 @@ public class Step3Component : BasicComponent
|
||||
|
||||
RefreshMediator.NotifyStateHasChangedSafe();
|
||||
|
||||
return Task.FromResult(isValidTokenUri && isValidDestinationAddress);
|
||||
return Task.FromResult(isValidTokenUri && isValidDestinationAddress && IsSupportedNetwork);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user