Changes Mint-TT bot parameter to BigInt type.

This commit is contained in:
Ben 2024-05-21 13:09:46 +02:00
parent ad2181db0b
commit e082f8a31c
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
4 changed files with 23 additions and 3 deletions

View File

@ -1,4 +1,5 @@
using System.Globalization;
using System.Numerics;
using System.Reflection;
namespace ArgsUniform
@ -105,6 +106,7 @@ namespace ArgsUniform
if (uniformProperty.PropertyType.IsEnum) return AssignEnum(result, uniformProperty, value);
if (uniformProperty.PropertyType == typeof(bool)) return AssignBool(result, uniformProperty, value);
if (uniformProperty.PropertyType == typeof(ulong)) return AssignUlong(result, uniformProperty, value);
if (uniformProperty.PropertyType == typeof(BigInteger)) return AssignBigInt(result, uniformProperty, value);
throw new NotSupportedException(
$"Unsupported property type '${uniformProperty.PropertyType}' " +
@ -144,6 +146,16 @@ namespace ArgsUniform
return false;
}
private bool AssignBigInt(T result, PropertyInfo uniformProperty, object value)
{
if (BigInteger.TryParse(value.ToString(), CultureInfo.InvariantCulture, out BigInteger i))
{
uniformProperty.SetValue(result, i);
return true;
}
return false;
}
private static bool AssignBool(T result, PropertyInfo uniformProperty, object value)
{
var s = value.ToString();

View File

@ -1,4 +1,6 @@
namespace CodexContractsPlugin
using System.Numerics;
namespace CodexContractsPlugin
{
public class TestToken : IComparable<TestToken>
{
@ -41,5 +43,10 @@
{
return new TestToken(i);
}
public static TestToken TestTokens(this BigInteger i)
{
return new TestToken((decimal)i);
}
}
}

View File

@ -77,7 +77,7 @@ namespace BiblioTech.Commands
private bool ShouldMintTestTokens(ICodexContracts contracts, EthAddress addr)
{
var testTokens = contracts.GetTestTokenBalance(addr);
return testTokens.Amount < Program.Config.MintTT;
return testTokens.Amount < Program.Config.MintTT.TestTokens().Amount;
}
private bool ShouldSendEth(IGethNode gethNode, EthAddress addr)

View File

@ -1,4 +1,5 @@
using ArgsUniform;
using System.Numerics;
namespace BiblioTech
{
@ -32,7 +33,7 @@ namespace BiblioTech
public int SendEth { get; set; } = 10;
[Uniform("mint-tt", "mt", "MINTTT", true, "Amount of TestTokens minted by the mint command.")]
public int MintTT { get; set; } = 1073741824;
public BigInteger MintTT { get; set; } = 1073741824;
public string EndpointsPath
{