Options
All
  • Public
  • Public/Protected
  • All
Menu
description

The implementation for the transaction discovery scheduler. Contains source code for the execution logic of a command with name: discovery:DiscoverTransactions.

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[]}

configService: ConfigService<Record<string, unknown>, false>
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}

lastPageNumber: number

Memory store for the last page number being read. This is used in getStateData to update the latest execution state.

access

private

var

{number}

lastUsedAccount: string

Memory store for the last account being read. This is used in getStateData to update the latest execution state.

access

private

var

{string}

logService: LogService
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}

networkService: NetworkService
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
totalNumberOfTransactions: number

Memory store for the total number of transactions. This is used in getStateData to update the latest execution state.

access

private

var

{number}

transactions: Transaction[] = []

Memory store for all transactions processed in one run of this command. Note that it contains only transfer transactions as those are the only relevant to this discovery command.

access

protected

var

{SdkTransaction[]}

transactionsService: TransactionsService

Accessors

  • get command(): string
  • get signature(): 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
  • extractAssets(transaction: Transaction): ObjectLiteral[]
  • extractRecipientAddress(transaction: Transaction): string
  • extractSignerAddress(transaction: Transaction): string
  • extractSignerPublicKey(transaction: Transaction): string
  • extractTransactionBlock(transaction: Transaction): number
  • extractTransactionBody(transaction: Transaction): string
  • extractTransactionHash(transaction: Transaction): string
  • extractTransactionMessage(transaction: Transaction): string
  • extractTransactionSignature(transaction: Transaction): string
  • extractTransactionType(transaction: Transaction): string
  • Helper method to extract the transaction type as defined by the dApps Framework.

    Note that in the first draft of the framework, the only transaction type that is effectively used is "transfer" because all operations are executed using transfer transactions.

    Parameters

    • transaction: Transaction

    Returns string

  • 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.

  • getTransactionQueriesForPage(pageNumber: number, includeUnconfirmed?: boolean, includePartial?: boolean): Promise<Page<Transaction>>[]
  • This method creates one or more transaction page queries that are executed using the @dhealth/sdk transactions repository.

    Note that the unconfirmed- and partial- transaction pools do not use multiple pages and thereby always return recent transactions.

    Parameters

    • pageNumber: number
    • includeUnconfirmed: boolean = false
    • includePartial: boolean = false

    Returns Promise<Page<Transaction>>[]

    An array of promises for transaction pages.

  • getTransactionQuery(pageNumber?: number, transactionTypes?: TransactionType[], unfoldEmbedded?: boolean, pageSize?: number, order?: Order): any
  • This method returns a transactions query that is compatible with dHealth Network Node's REST gateway. It uses the runtime arguments to determine a query mode of: "incoming", "outgoing" or "both".

    access

    protected

    Parameters

    • pageNumber: number = 1

      The page number to be fetched (defaults to 1). (optional)

    • transactionTypes: TransactionType[] = ...

      The transaction types that must be included (defaults to any type). (optional)

    • unfoldEmbedded: boolean = true

      Whether embedded transactions must be unfold or not (default to true). (optional)

    • pageSize: number = 100

      The page size (defaults to 100). (optional)

    • order: Order = Order.Asc

      The ordering strategy that is used for the query (defaults to Order.Asc). (optional)

    Returns any

  • infoLog(message: string): void
  • parsePartialFlag(partialOption: string): boolean
  • parseSource(sourceOption: string): Address
  • parseTransactionTypes(transactionTypes: string): TransactionType[]
  • parseUnconfirmedFlag(unconfirmedOption: string): boolean
  • 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>

  • runAsScheduler(): Promise<void>
  • This method is the entry point of this scheduler. Due to the usage of the Cron decorator, and the implementation the nest backend runtime is able to discover this when the discovery scope is enabled.

    This method is necessary to make sure this command is run with the correct --source option.

    This scheduler is registered to run every 1 minute.

    see

    BaseCommand

    access

    public

    async

    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