Configurable testtoken and eth amounts for mint command
This commit is contained in:
parent
b25c747522
commit
8bc63c1fdb
|
@ -7,7 +7,7 @@ namespace CodexDiscordBotPlugin
|
||||||
public class DiscordBotContainerRecipe : ContainerRecipeFactory
|
public class DiscordBotContainerRecipe : ContainerRecipeFactory
|
||||||
{
|
{
|
||||||
public override string AppName => "discordbot-bibliotech";
|
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";
|
public static string RewardsPort = "bot_rewards_port";
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@ namespace CodexDiscordBotPlugin
|
||||||
AddEnvVar("DATAPATH", config.DataPath);
|
AddEnvVar("DATAPATH", config.DataPath);
|
||||||
AddVolume(config.DataPath, 1.GB());
|
AddVolume(config.DataPath, 1.GB());
|
||||||
}
|
}
|
||||||
|
|
||||||
AddVolume(name: "kubeconfig", mountPath: "/opt/kubeconfig.yaml", subPath: "kubeconfig.yaml", secret: "discordbot-sa-kubeconfig");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace CodexDiscordBotPlugin
|
||||||
public class RewarderBotContainerRecipe : ContainerRecipeFactory
|
public class RewarderBotContainerRecipe : ContainerRecipeFactory
|
||||||
{
|
{
|
||||||
public override string AppName => "discordbot-rewarder";
|
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)
|
protected override void Initialize(StartupConfig startupConfig)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,8 +6,6 @@ namespace BiblioTech.Commands
|
||||||
{
|
{
|
||||||
public class MintCommand : BaseGethCommand
|
public class MintCommand : BaseGethCommand
|
||||||
{
|
{
|
||||||
private readonly Ether defaultEthToSend = 10.Eth();
|
|
||||||
private readonly TestToken defaultTestTokensToMint = 1024.TestTokens();
|
|
||||||
private readonly UserOption optionalUser = new UserOption(
|
private readonly UserOption optionalUser = new UserOption(
|
||||||
description: "If set, mint tokens for this user. (Optional, admin-only)",
|
description: "If set, mint tokens for this user. (Optional, admin-only)",
|
||||||
isRequired: false);
|
isRequired: false);
|
||||||
|
@ -47,9 +45,10 @@ namespace BiblioTech.Commands
|
||||||
{
|
{
|
||||||
if (ShouldMintTestTokens(contracts, addr))
|
if (ShouldMintTestTokens(contracts, addr))
|
||||||
{
|
{
|
||||||
var transaction = contracts.MintTestTokens(addr, defaultTestTokensToMint);
|
var tokens = Program.Config.MintTT.TestTokens();
|
||||||
report.Add($"Minted {defaultTestTokensToMint} {FormatTransactionLink(transaction)}");
|
var transaction = contracts.MintTestTokens(addr, tokens);
|
||||||
return new Transaction<TestToken>(defaultTestTokensToMint, transaction);
|
report.Add($"Minted {tokens} {FormatTransactionLink(transaction)}");
|
||||||
|
return new Transaction<TestToken>(tokens, transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
report.Add("TestToken balance over threshold. (No TestTokens minted.)");
|
report.Add("TestToken balance over threshold. (No TestTokens minted.)");
|
||||||
|
@ -60,9 +59,10 @@ namespace BiblioTech.Commands
|
||||||
{
|
{
|
||||||
if (ShouldSendEth(gethNode, addr))
|
if (ShouldSendEth(gethNode, addr))
|
||||||
{
|
{
|
||||||
var transaction = gethNode.SendEth(addr, defaultEthToSend);
|
var eth = Program.Config.SendEth.Eth();
|
||||||
report.Add($"Sent {defaultEthToSend} {FormatTransactionLink(transaction)}");
|
var transaction = gethNode.SendEth(addr, eth);
|
||||||
return new Transaction<Ether>(defaultEthToSend, transaction);
|
report.Add($"Sent {eth} {FormatTransactionLink(transaction)}");
|
||||||
|
return new Transaction<Ether>(eth, transaction);
|
||||||
}
|
}
|
||||||
report.Add("Eth balance is over threshold. (No Eth sent.)");
|
report.Add("Eth balance is over threshold. (No Eth sent.)");
|
||||||
return null;
|
return null;
|
||||||
|
@ -71,13 +71,13 @@ 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 < 64m;
|
return testTokens.Amount < Program.Config.MintTT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ShouldSendEth(IGethNode gethNode, EthAddress addr)
|
private bool ShouldSendEth(IGethNode gethNode, EthAddress addr)
|
||||||
{
|
{
|
||||||
var eth = gethNode.GetEthBalance(addr);
|
var eth = gethNode.GetEthBalance(addr);
|
||||||
return eth.Eth < 1.0m;
|
return eth.Eth < Program.Config.SendEth;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FormatTransactionLink(string transaction)
|
private string FormatTransactionLink(string transaction)
|
||||||
|
|
|
@ -25,6 +25,12 @@ namespace BiblioTech
|
||||||
[Uniform("reward-api-port", "rp", "REWARDAPIPORT", false, "TCP listen port for the reward API.")]
|
[Uniform("reward-api-port", "rp", "REWARDAPIPORT", false, "TCP listen port for the reward API.")]
|
||||||
public int RewardApiPort { get; set; } = 31080;
|
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
|
public string EndpointsPath
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
Loading…
Reference in New Issue