/ Tools / BiblioTech / BaseGethCommand.cs
BaseGethCommand.cs
 1  using BiblioTech.Options;
 2  using CodexContractsPlugin;
 3  using GethPlugin;
 4  
 5  namespace BiblioTech
 6  {
 7      public abstract class BaseGethCommand : BaseCommand
 8      {
 9          protected override async Task Invoke(CommandContext context)
10          {
11              if (Program.GethLink == null)
12              {
13                  await context.Followup("Blockchain operations are (temporarily) unavailable.");
14                  return;
15              }
16  
17              var gethNode = Program.GethLink.Node;
18              var contracts = Program.GethLink.Contracts;
19  
20              if (!contracts.IsDeployed())
21              {
22                  await context.Followup("I'm sorry, the Codex SmartContracts are not currently deployed.");
23                  return;
24              }
25  
26              await Execute(context, gethNode, contracts);
27          }
28  
29          protected abstract Task Execute(CommandContext context, IGethNode gethNode, ICodexContracts contracts);
30      }
31  }