import { JSONRPC } from "./types" ; import bigInteger from "big-integer" ; export class ResultStatus { public static fromJSON ( obj ) { return new ResultStatus ( NodeInfo . fromJSON ( obj . result . node_info ) , SyncInfo . fromJSON ( obj . result . sync_info ) , ValidatorInfo . fromJSON ( obj . result . validator_info ) ) ; } constructor ( public readonly nodeInfo , public readonly syncInfo , public readonly validatorInfo ) { } } export class NodeInfo { public static fromJSON ( obj ) { return new NodeInfo ( { p2p : parseInt ( obj . protocol_version . p2p , 10 ) , block : parseInt ( obj . protocol_version . block , 10 ) , app : parseInt ( obj . protocol_version . app , 10 ) } , obj . id , obj . listen_addr , obj . network , obj . version , obj . channels , obj . moniker , { txIndex : obj . other . tx_index === "on" ? true : false , rpcAddress : obj . other . rpc_address } ) ; } constructor ( public readonly protocolVersion , public readonly id , public readonly listenAddr , public readonly network , public readonly version , public readonly channels , public readonly moniker , public readonly other ) { } } export class SyncInfo { public static fromJSON ( obj ) { return new SyncInfo ( obj . latest_block_hash , obj . latest_app_hash , bigInteger ( obj . latest_block_height ) , new Date ( obj . latest_block_time ) , obj . catching_up ) ; } constructor ( public readonly latestBlockHash , public readonly latestAppHash , public readonly latestBlockHeight , public readonly latestBlockTime , public readonly catchingUp ) { } } export class ValidatorInfo { public static fromJSON ( obj ) { return new ValidatorInfo ( obj . address , obj . voting_power ) ; } constructor ( public readonly address , public readonly votingPower ) { } }