mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-23 03:58:23 +00:00
Update validation
This commit is contained in:
parent
84214e8999
commit
2897e396fb
@ -19,7 +19,7 @@ public class SolanaAddress : ValueObject<SolanaAddress>
|
|||||||
|
|
||||||
public static Result<SolanaAddress> Create(string value)
|
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))
|
if (!Regex.IsMatch(value, regex))
|
||||||
{
|
{
|
||||||
|
@ -21,4 +21,5 @@ public class StateStorage
|
|||||||
public string TokenSymbol { get; set; } = "DFNT";
|
public string TokenSymbol { get; set; } = "DFNT";
|
||||||
public bool IsTokenMutable { get; set; } = true;
|
public bool IsTokenMutable { get; set; } = true;
|
||||||
public double SellerFeeBasisPoints { get; set; } = 88;
|
public double SellerFeeBasisPoints { get; set; } = 88;
|
||||||
|
public bool IncludeMasterEdition { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
<SpaceItem Class="drk-full-width">
|
<SpaceItem Class="drk-full-width">
|
||||||
<Space Direction="DirectionVHType.Horizontal" Class="drk-vertical-space-center">
|
<Space Direction="DirectionVHType.Horizontal" Class="drk-vertical-space-center">
|
||||||
<SpaceItem>
|
<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>
|
<div>Ethereum</div>
|
||||||
</Button>
|
</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>
|
<div>Solana</div>
|
||||||
</Button>
|
</Button>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
<SpaceItem Class="drk-full-width">
|
<SpaceItem Class="drk-full-width">
|
||||||
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
|
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
<Title Level="4" Style="margin-bottom: 0;">Description:</Title>
|
<Title Level="4" Style="margin-bottom: 0;">Token symbol:</Title>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem Class="drk-full-width">
|
<SpaceItem Class="drk-full-width">
|
||||||
<div class="@SymbolClass">
|
<div class="@SymbolClass">
|
||||||
@ -116,6 +116,19 @@
|
|||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
}
|
}
|
||||||
@if (AppState.Storage.NetworkType == NetworkType.Solana)
|
@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">
|
<SpaceItem Class="drk-full-width">
|
||||||
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
|
<Space Align="start" Direction="DirectionVHType.Vertical" Class="drk-full-width">
|
||||||
@ -150,7 +163,8 @@
|
|||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
<div>
|
<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>
|
</div>
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
</Space>
|
</Space>
|
||||||
|
@ -2,6 +2,7 @@ using NftFaucet.Components;
|
|||||||
using NftFaucet.Extensions;
|
using NftFaucet.Extensions;
|
||||||
using NftFaucet.Models;
|
using NftFaucet.Models;
|
||||||
using NftFaucet.Models.Enums;
|
using NftFaucet.Models.Enums;
|
||||||
|
using Solnet.Wallet;
|
||||||
|
|
||||||
namespace NftFaucet.Pages;
|
namespace NftFaucet.Pages;
|
||||||
|
|
||||||
@ -35,8 +36,8 @@ public class Step4Component : BasicComponent
|
|||||||
protected Task<bool> ForwardHandler()
|
protected Task<bool> ForwardHandler()
|
||||||
{
|
{
|
||||||
var isValidTokenUri = !string.IsNullOrWhiteSpace(AppState.Storage.TokenUrl);
|
var isValidTokenUri = !string.IsNullOrWhiteSpace(AppState.Storage.TokenUrl);
|
||||||
var isValidDestinationAddress = AppState.Storage.NetworkType == NetworkType.Ethereum
|
var isValidDestinationAddress = AppState.Storage.NetworkType == NetworkType.Ethereum
|
||||||
? Address.Create(AppState.Storage.DestinationAddress).IsSuccess
|
? Address.Create(AppState.Storage.DestinationAddress).IsSuccess
|
||||||
: SolanaAddress.Create(AppState.Storage.DestinationAddress).IsSuccess;
|
: SolanaAddress.Create(AppState.Storage.DestinationAddress).IsSuccess;
|
||||||
|
|
||||||
if (!isValidTokenUri)
|
if (!isValidTokenUri)
|
||||||
|
@ -62,6 +62,7 @@ public class Step5Component : BasicComponent
|
|||||||
AppState.Storage.TokenName,
|
AppState.Storage.TokenName,
|
||||||
AppState.Storage.TokenSymbol,
|
AppState.Storage.TokenSymbol,
|
||||||
AppState.Storage.IsTokenMutable,
|
AppState.Storage.IsTokenMutable,
|
||||||
|
AppState.Storage.IncludeMasterEdition,
|
||||||
(uint)AppState.Storage.SellerFeeBasisPoints,
|
(uint)AppState.Storage.SellerFeeBasisPoints,
|
||||||
(ulong)AppState.Storage.TokenAmount));
|
(ulong)AppState.Storage.TokenAmount));
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ public interface ISolanaTransactionService
|
|||||||
string name,
|
string name,
|
||||||
string symbol,
|
string symbol,
|
||||||
bool isTokenMutable,
|
bool isTokenMutable,
|
||||||
|
bool includeMasterEdition,
|
||||||
uint sellerFeeBasisPoints,
|
uint sellerFeeBasisPoints,
|
||||||
ulong amount);
|
ulong amount);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ public class SolanaTransactionService : ISolanaTransactionService
|
|||||||
string name,
|
string name,
|
||||||
string symbol,
|
string symbol,
|
||||||
bool isTokenMutable,
|
bool isTokenMutable,
|
||||||
|
bool includeMasterEdition,
|
||||||
uint sellerFeeBasisPoints,
|
uint sellerFeeBasisPoints,
|
||||||
ulong amount)
|
ulong amount)
|
||||||
{
|
{
|
||||||
@ -44,6 +45,7 @@ public class SolanaTransactionService : ISolanaTransactionService
|
|||||||
var transaction = await client.GetTransactionAsync(airdropSig.Result);
|
var transaction = await client.GetTransactionAsync(airdropSig.Result);
|
||||||
|
|
||||||
airDropCompleted = transaction.WasRequestSuccessfullyHandled && transaction.ErrorData == null;
|
airDropCompleted = transaction.WasRequestSuccessfullyHandled && transaction.ErrorData == null;
|
||||||
|
await Task.Delay(2500);
|
||||||
} while (!airDropCompleted);
|
} while (!airDropCompleted);
|
||||||
|
|
||||||
var walletAddress = wallet.Account.PublicKey;
|
var walletAddress = wallet.Account.PublicKey;
|
||||||
@ -75,7 +77,11 @@ public class SolanaTransactionService : ISolanaTransactionService
|
|||||||
|
|
||||||
pipeline.InitializeForMint(walletAddress, destinationPublicKey, mintAddress, rentExemption.Result, (ulong)amount, tokenPrice);
|
pipeline.InitializeForMint(walletAddress, destinationPublicKey, mintAddress, rentExemption.Result, (ulong)amount, tokenPrice);
|
||||||
pipeline.AddMetadata(walletAddress, mintAddress, metadataAddress, data, isTokenMutable);
|
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;
|
var blockHash = (await client.GetRecentBlockHashAsync()).Result.Value.Blockhash;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user