mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-23 03:58:23 +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 AntDesign;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using NftFaucet.Models;
|
using NftFaucet.Models;
|
||||||
|
using NftFaucet.Options;
|
||||||
using NftFaucet.Services;
|
using NftFaucet.Services;
|
||||||
|
|
||||||
namespace NftFaucet.Components;
|
namespace NftFaucet.Components;
|
||||||
@ -17,10 +18,13 @@ public abstract class BasicComponent : ComponentBase
|
|||||||
protected RefreshMediator RefreshMediator { get; set; }
|
protected RefreshMediator RefreshMediator { get; set; }
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public MessageService MessageService { get; set; }
|
protected Settings Settings { get; set; }
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public IIpfsService IpfsService { get; set; }
|
protected MessageService MessageService { get; set; }
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
protected IIpfsService IpfsService { get; set; }
|
||||||
|
|
||||||
protected MetamaskInfo Metamask => AppState?.Metamask;
|
protected MetamaskInfo Metamask => AppState?.Metamask;
|
||||||
|
|
||||||
|
@ -2,12 +2,18 @@
|
|||||||
@inherits Step3Component
|
@inherits Step3Component
|
||||||
|
|
||||||
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
|
<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>
|
<SpaceItem>
|
||||||
<Title Level="4" Style="margin-bottom: 0;">Token URI:</Title>
|
<Title Level="4" Style="margin-bottom: 0;">Token URI:</Title>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem Class="drk-full-width">
|
<SpaceItem Class="drk-full-width">
|
||||||
<div class="@TokenUrlClass">
|
<div class="@TokenUrlClass">
|
||||||
<Input Size="medium" @bind-Value="@AppState.Storage.TokenUrl" OnInput="@OnTokenUrlInputChange" />
|
<Input Size="medium" @bind-Value="@AppState.Storage.TokenUrl" OnInput="@OnTokenUrlInputChange"/>
|
||||||
</div>
|
</div>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
@ -15,7 +21,7 @@
|
|||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem Class="drk-full-width">
|
<SpaceItem Class="drk-full-width">
|
||||||
<div class="@DestinationAddressClass">
|
<div class="@DestinationAddressClass">
|
||||||
<Input Size="medium" @bind-Value="@AppState.Storage.DestinationAddress" OnInput="@OnDestinationAddressInputChange" />
|
<Input Size="medium" @bind-Value="@AppState.Storage.DestinationAddress" OnInput="@OnDestinationAddressInputChange"/>
|
||||||
</div>
|
</div>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
</Space>
|
</Space>
|
||||||
|
@ -10,6 +10,7 @@ public class Step3Component : BasicComponent
|
|||||||
protected string DestinationAddressErrorMessage { get; set; }
|
protected string DestinationAddressErrorMessage { get; set; }
|
||||||
protected string TokenUrlClass => string.IsNullOrWhiteSpace(TokenUrlErrorMessage) ? null : "invalid-input";
|
protected string TokenUrlClass => string.IsNullOrWhiteSpace(TokenUrlErrorMessage) ? null : "invalid-input";
|
||||||
protected string DestinationAddressClass => string.IsNullOrWhiteSpace(DestinationAddressErrorMessage) ? 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()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@ -47,6 +48,6 @@ public class Step3Component : BasicComponent
|
|||||||
|
|
||||||
RefreshMediator.NotifyStateHasChangedSafe();
|
RefreshMediator.NotifyStateHasChangedSafe();
|
||||||
|
|
||||||
return Task.FromResult(isValidTokenUri && isValidDestinationAddress);
|
return Task.FromResult(isValidTokenUri && isValidDestinationAddress && IsSupportedNetwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user