Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Dec 10, 2023
1 parent fc8eb79 commit 0a72573
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 84 deletions.
104 changes: 36 additions & 68 deletions pkg/types/tendermint.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,37 @@ 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 {
Type string `json:"@type"`
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
Expand All @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 0 additions & 16 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a72573

Please sign in to comment.