Update validation

This commit is contained in:
Yurii Didyk 2022-06-06 11:31:38 +03:00
parent 84214e8999
commit 2897e396fb
8 changed files with 32 additions and 8 deletions

View File

@ -19,7 +19,7 @@ public class SolanaAddress : ValueObject<SolanaAddress>
public static Result<SolanaAddress> Create(string value)
{
var regex = "[1-9A-HJ-NP-Za-km-z]";
var regex = "^[1-9A-HJ-NP-Za-km-z]{32,44}$";
if (!Regex.IsMatch(value, regex))
{

View File

@ -21,4 +21,5 @@ public class StateStorage
public string TokenSymbol { get; set; } = "DFNT";
public bool IsTokenMutable { get; set; } = true;
public double SellerFeeBasisPoints { get; set; } = 88;
public bool IncludeMasterEdition { get; set; } = true;
}

View File

@ -7,10 +7,10 @@
<SpaceItem Class="drk-full-width">
<Space Direction="DirectionVHType.Horizontal" Class="drk-vertical-space-center">
<SpaceItem>
<Button Type="@ButtonType.Primary" Size="large" OnClick="OnEthereumSelected">
<Button Type="@ButtonType.Primary" Style="width: 150px; height: 100px" Size="large" OnClick="OnEthereumSelected">
<div>Ethereum</div>
</Button>
<Button Type="@ButtonType.Primary" Size="large" OnClick="OnSolanaSelected">
<Button Type="@ButtonType.Primary" Style="width: 150px; height: 100px" Color="Color.Red5" Size="large" OnClick="OnSolanaSelected">
<div>Solana</div>
</Button>
</SpaceItem>

View File

@ -72,7 +72,7 @@
<SpaceItem Class="drk-full-width">
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
<SpaceItem>
<Title Level="4" Style="margin-bottom: 0;">Description:</Title>
<Title Level="4" Style="margin-bottom: 0;">Token symbol:</Title>
</SpaceItem>
<SpaceItem Class="drk-full-width">
<div class="@SymbolClass">
@ -116,6 +116,19 @@
</SpaceItem>
}
@if (AppState.Storage.NetworkType == NetworkType.Solana)
{
<SpaceItem Class="drk-full-width">
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
<SpaceItem>
<Title Level="4" Style="margin-bottom: 0;">Include master edition:</Title>
</SpaceItem>
<SpaceItem>
<Checkbox @bind-Value="AppState.Storage.IncludeMasterEdition"/>
</SpaceItem>
</Space>
</SpaceItem>
}
@if (AppState.Storage.NetworkType == NetworkType.Solana)
{
<SpaceItem Class="drk-full-width">
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
@ -150,7 +163,8 @@
</SpaceItem>
<SpaceItem>
<div>
<AntDesign.InputNumber @bind-Value="@AppState.Storage.TokenAmount" Disabled="@(AppState.Storage.TokenType == TokenType.ERC721)" Min="1" Max="1000" DefaultValue="1"></AntDesign.InputNumber>
<AntDesign.InputNumber @bind-Value="@AppState.Storage.TokenAmount" Disabled="@(AppState.Storage.NetworkType == NetworkType.Ethereum
&& AppState.Storage.TokenType == TokenType.ERC721)" Min="1" Max="1000" DefaultValue="1"></AntDesign.InputNumber>
</div>
</SpaceItem>
</Space>

View File

@ -2,6 +2,7 @@ using NftFaucet.Components;
using NftFaucet.Extensions;
using NftFaucet.Models;
using NftFaucet.Models.Enums;
using Solnet.Wallet;
namespace NftFaucet.Pages;
@ -35,8 +36,8 @@ public class Step4Component : BasicComponent
protected Task<bool> ForwardHandler()
{
var isValidTokenUri = !string.IsNullOrWhiteSpace(AppState.Storage.TokenUrl);
var isValidDestinationAddress = AppState.Storage.NetworkType == NetworkType.Ethereum
? Address.Create(AppState.Storage.DestinationAddress).IsSuccess
var isValidDestinationAddress = AppState.Storage.NetworkType == NetworkType.Ethereum
? Address.Create(AppState.Storage.DestinationAddress).IsSuccess
: SolanaAddress.Create(AppState.Storage.DestinationAddress).IsSuccess;
if (!isValidTokenUri)

View File

@ -62,6 +62,7 @@ public class Step5Component : BasicComponent
AppState.Storage.TokenName,
AppState.Storage.TokenSymbol,
AppState.Storage.IsTokenMutable,
AppState.Storage.IncludeMasterEdition,
(uint)AppState.Storage.SellerFeeBasisPoints,
(ulong)AppState.Storage.TokenAmount));
}

View File

@ -10,6 +10,7 @@ public interface ISolanaTransactionService
string name,
string symbol,
bool isTokenMutable,
bool includeMasterEdition,
uint sellerFeeBasisPoints,
ulong amount);
}

View File

@ -20,6 +20,7 @@ public class SolanaTransactionService : ISolanaTransactionService
string name,
string symbol,
bool isTokenMutable,
bool includeMasterEdition,
uint sellerFeeBasisPoints,
ulong amount)
{
@ -44,6 +45,7 @@ public class SolanaTransactionService : ISolanaTransactionService
var transaction = await client.GetTransactionAsync(airdropSig.Result);
airDropCompleted = transaction.WasRequestSuccessfullyHandled && transaction.ErrorData == null;
await Task.Delay(2500);
} while (!airDropCompleted);
var walletAddress = wallet.Account.PublicKey;
@ -75,7 +77,11 @@ public class SolanaTransactionService : ISolanaTransactionService
pipeline.InitializeForMint(walletAddress, destinationPublicKey, mintAddress, rentExemption.Result, (ulong)amount, tokenPrice);
pipeline.AddMetadata(walletAddress, mintAddress, metadataAddress, data, isTokenMutable);
pipeline.AddMasterEdition(walletAddress, mintAddress, masterEditionAddress, metadataAddress, data);
if (includeMasterEdition)
{
pipeline.AddMasterEdition(walletAddress, mintAddress, masterEditionAddress, metadataAddress, data);
}
var blockHash = (await client.GetRecentBlockHashAsync()).Result.Value.Blockhash;