2
0
mirror of synced 2025-01-12 01:24:23 +00:00

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.Globalization;
using System.Numerics;
using System.Reflection; using System.Reflection;
namespace ArgsUniform namespace ArgsUniform
@ -105,6 +106,7 @@ namespace ArgsUniform
if (uniformProperty.PropertyType.IsEnum) return AssignEnum(result, uniformProperty, value); if (uniformProperty.PropertyType.IsEnum) return AssignEnum(result, uniformProperty, value);
if (uniformProperty.PropertyType == typeof(bool)) return AssignBool(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(ulong)) return AssignUlong(result, uniformProperty, value);
if (uniformProperty.PropertyType == typeof(BigInteger)) return AssignBigInt(result, uniformProperty, value);
throw new NotSupportedException( throw new NotSupportedException(
$"Unsupported property type '${uniformProperty.PropertyType}' " + $"Unsupported property type '${uniformProperty.PropertyType}' " +
@ -144,6 +146,16 @@ namespace ArgsUniform
return false; 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) private static bool AssignBool(T result, PropertyInfo uniformProperty, object value)
{ {
var s = value.ToString(); var s = value.ToString();

View File

@ -1,4 +1,6 @@
namespace CodexContractsPlugin using System.Numerics;
namespace CodexContractsPlugin
{ {
public class TestToken : IComparable<TestToken> public class TestToken : IComparable<TestToken>
{ {
@ -41,5 +43,10 @@
{ {
return new TestToken(i); 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) private bool ShouldMintTestTokens(ICodexContracts contracts, EthAddress addr)
{ {
var testTokens = contracts.GetTestTokenBalance(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) private bool ShouldSendEth(IGethNode gethNode, EthAddress addr)

View File

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