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