/* Copyright 2021 The caver-js Authors This file is part of the caver-js library. The caver-js library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The caver-js library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the caver-js. If not, see . */ import BN = require('bn.js') import BigNumber from 'bignumber.js' import { BlockNumber } from '../../caver-core/src' export interface Tally { ApprovalPercentage: number Key: string Value: string | number } export interface MyVote { Key: string Value: string | number | boolean Casted: boolean BlockNum: number } export interface Vote { key: string validator: string value: string | number | boolean } export interface ChainConfig { chainId: number istanbulCompatibleBlock?: number londonCompatibleBlock?: number ethTxTypeCompatibleBlock?: number magmaCompatibleBlock?: number deriveShaImpl: number governance: { governanceMode: string governingNode: string reward: { deferredTxFee: boolean minimumStake: number mintingAmount: number proposerUpdateInterval: number ratio: string stakingUpdateInterval: number useGiniCoeff: boolean } kip71?: { lowerboundbasefee: number upperboundbasefee: number gastarget: number maxblockgasusedforbasefee: number basefeedenominator: number } } istanbul: { epoch: number policy: number sub: number } unitPrice: number } export interface GovernanceItems { 'governance.governancemode': string 'governance.governingnode': string 'governance.unitprice': number 'istanbul.committeesize': number 'istanbul.epoch': number 'istanbul.policy': number 'reward.deferredtxfee': boolean 'reward.minimumstake': string 'reward.mintingamount': string 'reward.proposerupdateinterval': number 'reward.ratio': string 'reward.stakingupdateinterval': number 'reward.useginicoeff': boolean 'kip71.lowerboundbasefee'?: number 'kip71.upperboundbasefee'?: number 'kip71.gastarget'?: number 'kip71.maxblockgasusedforbasefee'?: number 'kip71.basefeedenominator'?: number } export interface VoteItems { 'governance.governancemode'?: string 'governance.governingnode'?: string 'governance.unitprice'?: number 'governance.addvalidator'?: string 'governance.removevalidator'?: string 'istanbul.epoch'?: number 'istanbul.committeesize'?: number 'istanbul.policy'?: number 'reward.mintingamount'?: string 'reward.ratio'?: string 'reward.useginicoeff'?: boolean 'reward.deferredtxfee'?: boolean 'reward.minimumstake'?: string 'reward.proposerupdateinterval'?: number 'reward.stakingupdateinterval'?: number 'kip71.lowerboundbasefee'?: number 'kip71.upperboundbasefee'?: number 'kip71.gastarget'?: number 'kip71.maxblockgasusedforbasefee'?: number 'kip71.basefeedenominator'?: number } export interface StakingInformation { BlockNum: number CouncilNodeAddrs: string[] CouncilRewardAddrs: string[] CouncilStakingAddrs: string[] CouncilStakingAmounts: number[] Gini: number KIRAddr: string PoCAddr: string // PoC is the previous name of KGF. UseGini: boolean } export class Governance { constructor(...args: any[]) vote(key: string, value: string | number | boolean, callback?: (error: Error, result: string) => void): Promise showTally(callback?: (error: Error, result: Tally[]) => void): Promise getTotalVotingPower(callback?: (error: Error, result: number) => void): Promise getMyVotingPower(callback?: (error: Error, result: number) => void): Promise getMyVotes(callback?: (error: Error, result: MyVote[]) => void): Promise getChainConfig(callback?: (error: Error, result: ChainConfig) => void): Promise getNodeAddress(callback?: (error: Error, result: string) => void): Promise getItemsAt(blockNumber: BlockNumber, callback?: (error: Error, result: GovernanceItems) => void): Promise getPendingChanges(callback?: (error: Error, result: VoteItems) => void): Promise getVotes(callback?: (error: Error, result: Vote[]) => void): Promise getIdxCache(callback?: (error: Error, result: number[]) => void): Promise getIdxCacheFromDb(callback?: (error: Error, result: number[]) => void): Promise getItemCacheFromDb( blockNumber: number | BN | BigNumber | string, callback?: (error: Error, result: GovernanceItems) => void ): Promise getStakingInfo(callback?: (error: Error, result: StakingInformation) => void): Promise getStakingInfo(blockNumber: BlockNumber, callback?: (error: Error, result: StakingInformation) => void): Promise }