import { Account } from 'shared/model/account' ; import { Address } from 'shared/model/types' ; import { IAssetRegister , IAssetStake , IAssetVote , Transaction } from 'shared/model/transaction' ; export interface IReferredUsers { add ( account ) : void ; delete ( account ) : void ; getUsers ( account , level ) : Array < IReferredUser > ; updateCountFactor ( trs , action ) : void ; updateRewardFactor ( trs , action ) : void ; updateStakeAmountFactor ( address , amount , action ) : void ; } export interface IReferredUser { address : Address ; isEmpty : boolean ; factors : ReferredUserFactor ; } export enum FactorType { COUNT , REWARD , STAKE_AMOUNT } export enum FactorAction { ADD = 1 , SUBTRACT = - 1 } export class ReferredUserFactor { static TYPE = FactorType ; static ACTION = FactorAction ; static COUNT : number = Object . keys ( FactorType ) . length / 2 ; static createEmpty ( ) { return new ReferredUserFactor ( ) ; } private readonly items : Array < number > ; constructor ( ) { this . items = new Array ( ReferredUserFactor . COUNT ) ; this . items [ FactorType . COUNT ] = 0 ; this . items [ FactorType . REWARD ] = 0 ; this . items [ FactorType . STAKE_AMOUNT ] = 0 ; } update ( factor , value , action = FactorAction . ADD ) { this . items [ factor ] += action * value ; } getItem ( factor ) { return this . items [ factor ] ; } getItems ( ) { return this . items ; } }