From 0a72573665c72354d44cc43fb4fdd573b4e466b7 Mon Sep 17 00:00:00 2001 From: Techno Freak Date: Sun, 10 Dec 2023 18:31:02 +0300 Subject: [PATCH] chore: cleanup --- pkg/types/tendermint.go | 104 ++++++++++++++-------------------------- pkg/types/types.go | 16 ------- 2 files changed, 36 insertions(+), 84 deletions(-) diff --git a/pkg/types/tendermint.go b/pkg/types/tendermint.go index 31549b3..269b82c 100644 --- a/pkg/types/tendermint.go +++ b/pkg/types/tendermint.go @@ -17,17 +17,30 @@ type ValidatorResponse struct { } type Validator struct { - OperatorAddress string `json:"operator_address"` - ConsensusPubkey ConsensusPubkey `json:"consensus_pubkey"` - Jailed bool `json:"jailed"` - Status string `json:"status"` - Tokens string `json:"tokens"` - DelegatorShares string `json:"delegator_shares"` - Description ValidatorDescription `json:"description"` - UnbondingHeight string `json:"unbonding_height"` - UnbondingTime time.Time `json:"unbonding_time"` - Commission ValidatorCommission `json:"commission"` - MinSelfDelegation string `json:"min_self_delegation"` + OperatorAddress string `json:"operator_address"` + ConsensusPubkey ConsensusPubkey `json:"consensus_pubkey"` + Jailed bool `json:"jailed"` + Status string `json:"status"` + Tokens string `json:"tokens"` + DelegatorShares string `json:"delegator_shares"` + Description struct { + Moniker string `json:"moniker"` + Identity string `json:"identity"` + Website string `json:"website"` + SecurityContact string `json:"security_contact"` + Details string `json:"details"` + } `json:"description"` + UnbondingHeight string `json:"unbonding_height"` + UnbondingTime time.Time `json:"unbonding_time"` + Commission struct { + CommissionRates struct { + Rate string `json:"rate"` + MaxRate string `json:"max_rate"` + MaxChangeRate string `json:"max_change_rate"` + } `json:"commission_rates"` + UpdateTime time.Time `json:"update_time"` + } `json:"commission"` + MinSelfDelegation string `json:"min_self_delegation"` } type ConsensusPubkey struct { @@ -35,40 +48,6 @@ type ConsensusPubkey struct { Key string `json:"key"` } -type ValidatorDescription struct { - Moniker string `json:"moniker"` - Identity string `json:"identity"` - Website string `json:"website"` - SecurityContact string `json:"security_contact"` - Details string `json:"details"` -} - -type ValidatorCommission struct { - CommissionRates ValidatorCommissionRates `json:"commission_rates"` - UpdateTime time.Time `json:"update_time"` -} - -type ValidatorCommissionRates struct { - Rate string `json:"rate"` - MaxRate string `json:"max_rate"` - MaxChangeRate string `json:"max_change_rate"` -} - -type ValidatorInfo struct { - Address string - Moniker string - Identity string - Website string - SecurityContact string - Details string - Tokens float64 - Jailed bool - Status string - CommissionRate float64 - CommissionMaxRate float64 - CommissionMaxChangeRate float64 -} - func (key *ConsensusPubkey) GetValConsAddress(prefix string) (string, error) { encCfg := simapp.MakeTestEncodingConfig() interfaceRegistry := encCfg.InterfaceRegistry @@ -93,13 +72,6 @@ func (key *ConsensusPubkey) GetValConsAddress(prefix string) (string, error) { return properValCons, nil } -type ValidatorQuery struct { - Chain string - Address string - Queries []QueryInfo - Info ValidatorInfo -} - type PaginationResponse struct { Code int `json:"code"` Pagination Pagination `json:"pagination"` @@ -131,25 +103,21 @@ func (a ResponseAmount) ToAmount() Amount { } type SigningInfoResponse struct { - Code int `json:"code"` - ValSigningInfo ValidatorSigningInfo `json:"val_signing_info"` -} - -type ValidatorSigningInfo struct { - Address string `json:"address"` - StartHeight string `json:"start_height"` - IndexOffset string `json:"index_offset"` - JailedUntil time.Time `json:"jailed_until"` - Tombstoned bool `json:"tombstoned"` - MissedBlocksCounter string `json:"missed_blocks_counter"` + Code int `json:"code"` + ValSigningInfo struct { + Address string `json:"address"` + StartHeight string `json:"start_height"` + IndexOffset string `json:"index_offset"` + JailedUntil time.Time `json:"jailed_until"` + Tombstoned bool `json:"tombstoned"` + MissedBlocksCounter string `json:"missed_blocks_counter"` + } `json:"val_signing_info"` } type SlashingParamsResponse struct { - SlashingParams SlashingParams `json:"params"` -} - -type SlashingParams struct { - SignedBlocksWindow string `json:"signed_blocks_window"` + SlashingParams struct { + SignedBlocksWindow string `json:"signed_blocks_window"` + } `json:"params"` } type SingleDelegationResponse struct { diff --git a/pkg/types/types.go b/pkg/types/types.go index 6f58011..f7d918b 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -13,22 +13,6 @@ type QueryInfo struct { Success bool } -func (q *ValidatorQuery) GetSuccessfulQueriesCount() float64 { - var count int64 = 0 - - for _, query := range q.Queries { - if query.Success { - count++ - } - } - - return float64(count) -} - -func (q *ValidatorQuery) GetFailedQueriesCount() float64 { - return float64(len(q.Queries)) - q.GetSuccessfulQueriesCount() -} - type Amount struct { Amount float64 Denom string