From e082f8a31c66bd46e2ac775591d2e868d70a89ca Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 21 May 2024 13:09:46 +0200 Subject: [PATCH] Changes Mint-TT bot parameter to BigInt type. --- Framework/ArgsUniform/Assigner.cs | 12 ++++++++++++ .../CodexContractsPlugin/TestTokenExtensions.cs | 9 ++++++++- Tools/BiblioTech/Commands/MintCommand.cs | 2 +- Tools/BiblioTech/Configuration.cs | 3 ++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Framework/ArgsUniform/Assigner.cs b/Framework/ArgsUniform/Assigner.cs index 9083b0e..4db7a08 100644 --- a/Framework/ArgsUniform/Assigner.cs +++ b/Framework/ArgsUniform/Assigner.cs @@ -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(); diff --git a/ProjectPlugins/CodexContractsPlugin/TestTokenExtensions.cs b/ProjectPlugins/CodexContractsPlugin/TestTokenExtensions.cs index a19abde..eccc849 100644 --- a/ProjectPlugins/CodexContractsPlugin/TestTokenExtensions.cs +++ b/ProjectPlugins/CodexContractsPlugin/TestTokenExtensions.cs @@ -1,4 +1,6 @@ -namespace CodexContractsPlugin +using System.Numerics; + +namespace CodexContractsPlugin { public class TestToken : IComparable { @@ -41,5 +43,10 @@ { return new TestToken(i); } + + public static TestToken TestTokens(this BigInteger i) + { + return new TestToken((decimal)i); + } } } diff --git a/Tools/BiblioTech/Commands/MintCommand.cs b/Tools/BiblioTech/Commands/MintCommand.cs index a017ee2..d6d616f 100644 --- a/Tools/BiblioTech/Commands/MintCommand.cs +++ b/Tools/BiblioTech/Commands/MintCommand.cs @@ -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) diff --git a/Tools/BiblioTech/Configuration.cs b/Tools/BiblioTech/Configuration.cs index 9164cf7..b67689f 100644 --- a/Tools/BiblioTech/Configuration.cs +++ b/Tools/BiblioTech/Configuration.cs @@ -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 {