diff --git a/NftFaucet/Pages/ConnectMetamask.razor b/NftFaucet/Pages/ConnectMetamask.razor index aef4939..ffbcb6f 100644 --- a/NftFaucet/Pages/ConnectMetamask.razor +++ b/NftFaucet/Pages/ConnectMetamask.razor @@ -2,6 +2,18 @@ @layout EmptyLayout @inherits ConnectMetamaskComponent -

You should connect MetaMask first!

- - + + + + + metamask + + + @TitleText + + + + + + + diff --git a/NftFaucet/Pages/ConnectMetamask.razor.cs b/NftFaucet/Pages/ConnectMetamask.razor.cs index 53faff4..43367c9 100644 --- a/NftFaucet/Pages/ConnectMetamask.razor.cs +++ b/NftFaucet/Pages/ConnectMetamask.razor.cs @@ -1,3 +1,5 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; using NftFaucet.Components; using NftFaucet.Extensions; @@ -5,6 +7,13 @@ namespace NftFaucet.Pages; public class ConnectMetamaskComponent : BasicComponent { + [Inject] + protected IJSRuntime JsRuntime { get; set; } + + protected bool HasMetaMask { get; set; } + protected string TitleText => $"You should {(HasMetaMask ? "connect" : "install")} MetaMask first"; + protected string ButtonText => HasMetaMask ? "Connect" : "Install"; + protected override async Task OnInitializedAsync() { if (await Metamask.IsConnected()) @@ -12,10 +21,19 @@ public class ConnectMetamaskComponent : BasicComponent await Metamask.RefreshAddress(); UriHelper.NavigateToRelative("/"); } + + HasMetaMask = Metamask.HasMetaMask ?? false; } protected async Task Connect() { + if (!HasMetaMask) + { + string url = "https://metamask.io/download/"; + await JsRuntime.InvokeAsync("open", url, "_blank"); + return; + } + var isConnected = await Metamask.Connect(); if (isConnected) { diff --git a/NftFaucet/wwwroot/images/metamask_fox.svg b/NftFaucet/wwwroot/images/metamask_fox.svg new file mode 100644 index 0000000..d95d3ca --- /dev/null +++ b/NftFaucet/wwwroot/images/metamask_fox.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file