Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PrepareActivityPayouts

label

PAYOUT

description

The implementation for the payout preparation scheduler. Contains source code for the execution logic of a command with name: processor:PrepareActivityPayouts.

Notably, this command fetches activities that have not been the subject of payouts yet and then creates transactions and signs transactions.

since

v0.4.0

Hierarchy

Index

Constructors

Properties

argv: string[] = []

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

access

protected

var

{string[]}

baseAsset: AssetParameters

Memory store for the fees asset configuration object. This object defines which assets are discoverable on dHealth Network and used to pay for transaction fees.

This asset configuration is referred to as the base asset used in a specific dApp. The reason for this is that transactions on the underlying dHealth Network are always paid with one and the same asset.

access

protected

var

{DiscoverableAssetsMap}

boosterParameters: ReferralBoosterParameters

A configuration object that determines the total number of referrals that are necessary to be assigned the corresponding booster.

Note that the keys of this configuration object should contain the booster asset's identifier as defined inside config/assets.ts.

link

SocialConfig

var

{ReferralBoosterParameters}

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}

dappIdentifier: string

Contains the dApp Identifier as attached to contracts on-chain. Typically, the dApp identifier is created using a slug-format of the dappName configuration inside config/dapp.ts.

access

protected

var

{string}

earnAsset: AssetParameters

Memory store for the earn asset configuration object. This object defines which assets are discoverable on dHealth Network and used to tokenize a particular operation.

This asset configuration is referred to as the earn asset used in a specific dApp. The reason for this is that individual dApps may want their end-users to earn a custom asset, or not.

access

protected

var

{DiscoverableAssetsMap}

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

payoutsService: PayoutsService
scope: string = "payout"

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}

signerService: SignerService

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
totalNumberPrepared: number

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

access

private

var

{number}

Accessors

  • get collection(): string
  • get command(): string
  • get shouldSetSubjectPayoutState(): boolean
  • 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
  • This method must return an asset amount which will be attached to a transfer transaction.

    Note that an empty total time elapsed will always return a 0-amount. The total time elapsed in used in the formula in a division operation.

    This implementation defines the payout formula used to compute asset amounts depending on the intensity of an activity. Note that the activityData field must contain fields including:

    • calories: Number of kilocalories burned (C || kC).
    • distance: Number of meters distance (D). (* some formula express this in different unit of measure)
    • elevation: Number of meters elevation gain (E || A). This field uses an adjusted value in case it is empty.
    • elapsedTime: Number of seconds spent during activity (T).
    • kilojoules: Number of kilojoules produced during activity (Rides only) (J).

      Note that the below listed formula may use a different unit of measure than the one listed in the database, e.g. in-formula the distance may be used and expressed in centimeters or dekameters depending of sports.

      Following formulas are currently applied to compute amounts:
    • Walk: (D / T) x 1.2
    • Run: (D / T) x 1.5
    • Ride: (D / T) x 0.8
    • Swim: ((D*10) / T) x 1.7
    • Others: (D / T) x 1.6
    todo

    document formula in developer documentations

    access

    protected

    Parameters

    • subject: ActivityDocument

      The payout subject (activity) of which activityData is used.

    • multiplier: number = 1

      The amount multiplier (in case of "boosters"). Defaults to 1.

    Returns number

    An amount that is computed and depends on the intensity of an activity.

  • getAssetIdentifier(): string
  • getMultiplier(subjectAddress: string): Promise<number>
  • infoLog(message: string): void
  • 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 processor scope is enabled.

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

    This scheduler is registered to run every 30 seconds.

    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