cs-codex-dist-tests/Tools/BiblioTech/BaseNetCommand.cs

44 lines
1.4 KiB
C#
Raw Normal View History

2023-10-24 13:25:45 +00:00
using BiblioTech.Options;
using CodexContractsPlugin;
2023-10-20 08:14:56 +00:00
using Core;
using GethPlugin;
2023-10-20 07:49:23 +00:00
namespace BiblioTech
{
public abstract class BaseNetCommand : BaseCommand
{
2023-10-20 08:14:56 +00:00
private readonly CoreInterface ci;
2023-10-20 07:49:23 +00:00
2023-10-25 09:25:27 +00:00
public BaseNetCommand(CoreInterface ci)
2023-10-20 07:49:23 +00:00
{
2023-10-20 08:14:56 +00:00
this.ci = ci;
2023-10-20 07:49:23 +00:00
}
2023-10-24 13:25:45 +00:00
protected override async Task Invoke(CommandContext context)
2023-10-20 07:49:23 +00:00
{
2023-10-25 09:25:27 +00:00
var deployments = Program.DeploymentFilesMonitor.GetDeployments();
2023-10-20 07:49:23 +00:00
if (deployments.Length == 0)
{
2023-10-25 08:54:26 +00:00
await context.Followup("No deployments are currently available.");
2023-10-20 07:49:23 +00:00
return;
}
if (deployments.Length > 1)
{
2023-10-25 08:54:26 +00:00
await context.Followup("Multiple deployments are online. I don't know which one to pick!");
2023-10-20 07:49:23 +00:00
return;
}
2023-10-20 08:14:56 +00:00
var codexDeployment = deployments.Single();
var gethDeployment = codexDeployment.GethDeployment;
var contractsDeployment = codexDeployment.CodexContractsDeployment;
var gethNode = ci.WrapGethDeployment(gethDeployment);
2023-10-30 12:30:14 +00:00
var contracts = ci.WrapCodexContractsDeployment(gethNode, contractsDeployment);
2023-10-20 08:14:56 +00:00
2023-10-24 13:25:45 +00:00
await Execute(context, gethNode, contracts);
2023-10-20 07:49:23 +00:00
}
2023-10-24 13:25:45 +00:00
protected abstract Task Execute(CommandContext context, IGethNode gethNode, ICodexContracts contracts);
2023-10-20 07:49:23 +00:00
}
}