Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DiscoveryCommand Abstract

description

This class defines the abstraction layer used in any discovery commands. Note that discovery commands are always stateful modules due to the extension of StatefulModule in the parent class BaseCommand.

Additionally, discovery command also implement the CommandRunner interface from nest-commander. The run() method call is defined in BaseCommand and delegates the runtime to the method implemented in this class as runWithOptions.

abstract
since

v0.2.0

Hierarchy

Index

Constructors

Properties

argv: string[] = []

The arguments passed to the command. Typically, this holds required parameters of commands.

access

protected

var

{string[]}

dappConfig: DappConfig

The internal dApp configuration object. This object is used to configure key functionalities such as the name of a dApp and the enabled scopes of the backend runtime.

access

protected

var

{DappConfig}

discoverySource: Address

The discovery source. In most cases this will be the host dapp's main account public key.

access

protected

var

{Address}

logger: LogService
networkConfig: NetworkConfig

The internal dApp network configuration object. This object is used to configure the access to the underlying blockchain network.

access

protected

var

{NetworkConfig}

scope: string = "discovery"

The command scope. This is the scope that must be enabled through the configuration files for this command to be available.

This property is required through the extension of BaseCommand.

access

protected

var

{Scope}

Requires state information of the module. This object is typically populated upon first execution and updated any time later.

see

StateService

access

protected

var

{StateDocument}

stateService: StateService

Accessors

  • get command(): string
  • This method must return a command name. Note that it should use only characters of: A-Za-z0-9:-_.

    e.g. "scope:name"

    This property is required through the extension of BaseCommand but is intentionally forwarded to further child classes such that each command defines its own command name.

    abstract
    access

    protected

    Returns string

  • get signature(): string
  • This method must return a command signature that contains hints on the command name and its required and optional arguments.

    e.g. "command [--option value]"

    This property is required through the extension of BaseCommand but is intentionally forwarded to further child classes such that each command defines its own command signature.

    abstract
    access

    protected

    Returns string

  • get stateIdentifier(): string
  • Getter for the discovery state identifier, e.g. "discovery.accounts", "discovery.transactions", "payout.outputs" etc.

    This method is an implementation necessary because of the extensions of StatefulModule.

    see

    StatefulModule

    access

    public

    var

    {string}

    Returns string

Methods

  • debugLog(message: string): void
  • errorLog(message: string, stack?: string): void
  • getNextSource(sources: string[]): Promise<string>
  • This method will find the next relevant discovery source by iterating through the passed sources and checking individual synchronization state.

    Accounts that are fully synchronized require less requests for recent transactions. Note that a per-source state is persisted as well, to keep track of the last page number as well as to keep track of when the runtime reads the latest available page of transactions for said discovery source.

    Parameters

    • sources: string[]

      The discovery sources public keys and/or addresses.

    Returns Promise<string>

    The discovery source address.

  • getStateData(): any
  • This helper method should return the latest execution state such that it can be saved.

    Execution states refer to one module's required state data, potentially necessary during execution, and which is fetched in run before execution and updated in run after execution (using the name as an identifier).

    access

    protected

    Returns any

  • infoLog(message: string): void
  • parseSource(sourceOption: string): Address
  • This helper method serves as a parser for the -s or --source option of this command.

    The discovery source can contain either of a public key or an address, that will be parsed into discoverySource.

    Parameters

    • sourceOption: string

      The sourceArgument as passed in the terminal.

    Returns Address

    A parsed dHealth Account Address.

  • This method is the entry point of any command line executed command. nest-commander implements a flow where this method is called with parameters that are respectively the raw arguments and the parsed arguments to this command call.

    This method uses the stateService to fetch the current execution and also uses it to update the state.

    Note that the runWithOptions method is called inside a try-catch block to force the error handling process.

    access

    public

    Parameters

    Returns Promise<void>

  • usage(): string
  • This method prints usage information to the command line and is used by nest-commander to print a correctly formatted help message.

    Note that usage methods can be overwritten but must always print a standard command line signature.

    access

    public

    Returns string

Generated using TypeDoc