Configurable testtoken and eth amounts for mint command

This commit is contained in:
Ben 2024-03-29 11:24:11 +01:00
parent b25c747522
commit 8bc63c1fdb
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
4 changed files with 18 additions and 14 deletions

View File

@ -7,7 +7,7 @@ namespace CodexDiscordBotPlugin
public class DiscordBotContainerRecipe : ContainerRecipeFactory
{
public override string AppName => "discordbot-bibliotech";
public override string Image => "thatbenbierens/codex-discordbot:initial";
public override string Image => "codexstorage/codex-discordbot:sha-b25c747";
public static string RewardsPort = "bot_rewards_port";
@ -40,8 +40,6 @@ namespace CodexDiscordBotPlugin
AddEnvVar("DATAPATH", config.DataPath);
AddVolume(config.DataPath, 1.GB());
}
AddVolume(name: "kubeconfig", mountPath: "/opt/kubeconfig.yaml", subPath: "kubeconfig.yaml", secret: "discordbot-sa-kubeconfig");
}
}
}

View File

@ -7,7 +7,7 @@ namespace CodexDiscordBotPlugin
public class RewarderBotContainerRecipe : ContainerRecipeFactory
{
public override string AppName => "discordbot-rewarder";
public override string Image => "codexstorage/codex-rewarderbot";
public override string Image => "codexstorage/codex-rewarderbot:sha-b25c747";
protected override void Initialize(StartupConfig startupConfig)
{

View File

@ -6,8 +6,6 @@ namespace BiblioTech.Commands
{
public class MintCommand : BaseGethCommand
{
private readonly Ether defaultEthToSend = 10.Eth();
private readonly TestToken defaultTestTokensToMint = 1024.TestTokens();
private readonly UserOption optionalUser = new UserOption(
description: "If set, mint tokens for this user. (Optional, admin-only)",
isRequired: false);
@ -47,9 +45,10 @@ namespace BiblioTech.Commands
{
if (ShouldMintTestTokens(contracts, addr))
{
var transaction = contracts.MintTestTokens(addr, defaultTestTokensToMint);
report.Add($"Minted {defaultTestTokensToMint} {FormatTransactionLink(transaction)}");
return new Transaction<TestToken>(defaultTestTokensToMint, transaction);
var tokens = Program.Config.MintTT.TestTokens();
var transaction = contracts.MintTestTokens(addr, tokens);
report.Add($"Minted {tokens} {FormatTransactionLink(transaction)}");
return new Transaction<TestToken>(tokens, transaction);
}
report.Add("TestToken balance over threshold. (No TestTokens minted.)");
@ -60,9 +59,10 @@ namespace BiblioTech.Commands
{
if (ShouldSendEth(gethNode, addr))
{
var transaction = gethNode.SendEth(addr, defaultEthToSend);
report.Add($"Sent {defaultEthToSend} {FormatTransactionLink(transaction)}");
return new Transaction<Ether>(defaultEthToSend, transaction);
var eth = Program.Config.SendEth.Eth();
var transaction = gethNode.SendEth(addr, eth);
report.Add($"Sent {eth} {FormatTransactionLink(transaction)}");
return new Transaction<Ether>(eth, transaction);
}
report.Add("Eth balance is over threshold. (No Eth sent.)");
return null;
@ -71,13 +71,13 @@ namespace BiblioTech.Commands
private bool ShouldMintTestTokens(ICodexContracts contracts, EthAddress addr)
{
var testTokens = contracts.GetTestTokenBalance(addr);
return testTokens.Amount < 64m;
return testTokens.Amount < Program.Config.MintTT;
}
private bool ShouldSendEth(IGethNode gethNode, EthAddress addr)
{
var eth = gethNode.GetEthBalance(addr);
return eth.Eth < 1.0m;
return eth.Eth < Program.Config.SendEth;
}
private string FormatTransactionLink(string transaction)

View File

@ -25,6 +25,12 @@ namespace BiblioTech
[Uniform("reward-api-port", "rp", "REWARDAPIPORT", false, "TCP listen port for the reward API.")]
public int RewardApiPort { get; set; } = 31080;
[Uniform("send-eth", "se", "SENDETH", false, "Amount of Eth send by the mint command. Default: 10.")]
public int SendEth { get; set; } = 10;
[Uniform("mint-tt", "mt", "MINTTT", false, "Amount of TestTokens minted by the mint command. Default: 1073741824")]
public int MintTT { get; set; } = 1073741824;
public string EndpointsPath
{
get