mirror of
https://github.com/codex-storage/cs-codex-dist-tests.git
synced 2025-02-03 07:43:52 +00:00
Adds eth address validation.
This commit is contained in:
parent
8ef2e6023e
commit
116f62e73e
@ -1,5 +1,6 @@
|
||||
using Discord.WebSocket;
|
||||
using GethPlugin;
|
||||
using Nethereum.Util;
|
||||
|
||||
namespace BiblioTech.Commands
|
||||
{
|
||||
@ -18,14 +19,21 @@ namespace BiblioTech.Commands
|
||||
var ethOptionData = command.Data.Options.SingleOrDefault(o => o.Name == Name);
|
||||
if (ethOptionData == null)
|
||||
{
|
||||
await command.RespondAsync("EthAddress option not received.");
|
||||
await command.FollowupAsync("EthAddress option not received.");
|
||||
return null;
|
||||
}
|
||||
var ethAddressStr = ethOptionData.Value as string;
|
||||
if (string.IsNullOrEmpty(ethAddressStr))
|
||||
{
|
||||
// todo, validate that it is an eth address.
|
||||
await command.RespondAsync("EthAddress is null or invalid.");
|
||||
await command.FollowupAsync("EthAddress is null or empty.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!AddressUtil.Current.IsValidAddressLength(ethAddressStr) ||
|
||||
!AddressUtil.Current.IsValidEthereumAddressHexFormat(ethAddressStr) ||
|
||||
!AddressUtil.Current.IsChecksumAddress(ethAddressStr))
|
||||
{
|
||||
await command.FollowupAsync("EthAddress is not valid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user