From 1e751a051c90f05b69d9b8375d08e2078efa7f47 Mon Sep 17 00:00:00 2001 From: haodi Date: Sun, 20 Oct 2024 11:21:15 +0800 Subject: [PATCH] fixed lint --- client/server/distribution.go | 34 +++++++++++++++++----------------- client/server/staking.go | 4 ++-- lib/k1util/k1util.go | 8 ++++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/client/server/distribution.go b/client/server/distribution.go index aade2160..5abf5d8d 100644 --- a/client/server/distribution.go +++ b/client/server/distribution.go @@ -48,12 +48,12 @@ func (s *Server) GetDistributionParams(r *http.Request) (resp any, err error) { // GetDistributionValidatorByValidatorAddress queries validator commission and self-delegation rewards for validator. func (s *Server) GetDistributionValidatorByValidatorAddress(r *http.Request) (resp any, err error) { - queryContext, err := s.createQueryContextByHeader(r) + valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) if err != nil { return nil, err } - valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } @@ -70,12 +70,12 @@ func (s *Server) GetDistributionValidatorByValidatorAddress(r *http.Request) (re // GetValidatorCommissionByValidatorAddress queries accumulated commission for a validator. func (s *Server) GetValidatorCommissionByValidatorAddress(r *http.Request) (resp any, err error) { - queryContext, err := s.createQueryContextByHeader(r) + valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) if err != nil { return nil, err } - valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } @@ -93,12 +93,12 @@ func (s *Server) GetValidatorCommissionByValidatorAddress(r *http.Request) (resp // GetValidatorOutstandingRewardsByValidatorAddress queries rewards of a validator address. func (s *Server) GetValidatorOutstandingRewardsByValidatorAddress(r *http.Request) (resp any, err error) { - queryContext, err := s.createQueryContextByHeader(r) + valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) if err != nil { return nil, err } - valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } @@ -157,12 +157,12 @@ func (s *Server) GetAllValidatorOutstandingRewards(req *getAllValidatorOutstandi // GetValidatorSlashesByValidatorAddress queries slash events of a validator. func (s *Server) GetValidatorSlashesByValidatorAddress(req *getValidatorSlashesByValidatorAddressRequest, r *http.Request) (resp any, err error) { - queryContext, err := s.createQueryContextByHeader(r) + valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) if err != nil { return nil, err } - valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } @@ -189,12 +189,12 @@ func (s *Server) GetValidatorSlashesByValidatorAddress(req *getValidatorSlashesB // GetDistributionValidatorsByDelegatorAddress queries the validators of a delegator. func (s *Server) GetDistributionValidatorsByDelegatorAddress(r *http.Request) (resp any, err error) { - queryContext, err := s.createQueryContextByHeader(r) + delAddr, err := k1util.CmpPubKeyToDelegatorAddress(mux.Vars(r)["delegator_pub_key"]) if err != nil { return nil, err } - delAddr, err := k1util.CmpPubKeyToDelegatorAddress(mux.Vars(r)["delegator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } @@ -212,12 +212,12 @@ func (s *Server) GetDistributionValidatorsByDelegatorAddress(r *http.Request) (r // GetDelegatorRewardsByDelegatorAddress queries the total rewards accrued by each validator. func (s *Server) GetDelegatorRewardsByDelegatorAddress(r *http.Request) (resp any, err error) { - queryContext, err := s.createQueryContextByHeader(r) + delAddr, err := k1util.CmpPubKeyToDelegatorAddress(mux.Vars(r)["delegator_pub_key"]) if err != nil { return nil, err } - delAddr, err := k1util.CmpPubKeyToDelegatorAddress(mux.Vars(r)["delegator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } @@ -235,17 +235,17 @@ func (s *Server) GetDelegatorRewardsByDelegatorAddress(r *http.Request) (resp an // GetDelegatorRewardsByDelegatorAddressValidatorAddress queries the total rewards accrued by a delegation. func (s *Server) GetDelegatorRewardsByDelegatorAddressValidatorAddress(r *http.Request) (resp any, err error) { - queryContext, err := s.createQueryContextByHeader(r) + valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) if err != nil { return nil, err } - valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) + delAddr, err := k1util.CmpPubKeyToDelegatorAddress(mux.Vars(r)["delegator_pub_key"]) if err != nil { return nil, err } - delAddr, err := k1util.CmpPubKeyToDelegatorAddress(mux.Vars(r)["delegator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } @@ -264,12 +264,12 @@ func (s *Server) GetDelegatorRewardsByDelegatorAddressValidatorAddress(r *http.R // GetDelegatorWithdrawAddressByDelegatorAddress queries withdraw address of a delegator. func (s *Server) GetDelegatorWithdrawAddressByDelegatorAddress(r *http.Request) (resp any, err error) { - queryContext, err := s.createQueryContextByHeader(r) + delAddr, err := k1util.CmpPubKeyToDelegatorAddress(mux.Vars(r)["delegator_pub_key"]) if err != nil { return nil, err } - delAddr, err := k1util.CmpPubKeyToDelegatorAddress(mux.Vars(r)["delegator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } diff --git a/client/server/staking.go b/client/server/staking.go index c3ed49c7..f2104884 100644 --- a/client/server/staking.go +++ b/client/server/staking.go @@ -154,12 +154,12 @@ func (s *Server) GetValidatorByValidatorAddress(r *http.Request) (resp any, err // GetValidatorDelegationsByValidatorAddress queries delegate info for given validator. func (s *Server) GetValidatorDelegationsByValidatorAddress(req *getValidatorDelegationsByValidatorAddressRequest, r *http.Request) (resp any, err error) { - valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) + queryContext, err := s.createQueryContextByHeader(r) if err != nil { return nil, err } - queryContext, err := s.createQueryContextByHeader(r) + valAddr, err := k1util.CmpPubKeyToValidatorAddress(mux.Vars(r)["validator_pub_key"]) if err != nil { return nil, err } diff --git a/lib/k1util/k1util.go b/lib/k1util/k1util.go index 23d0fbf7..e040a476 100644 --- a/lib/k1util/k1util.go +++ b/lib/k1util/k1util.go @@ -4,21 +4,21 @@ package k1util import ( stdecdsa "crypto/ecdsa" "encoding/hex" + "strings" + "github.com/cometbft/cometbft/crypto" k1 "github.com/cometbft/cometbft/crypto/secp256k1" cryptopb "github.com/cometbft/cometbft/proto/tendermint/crypto" cosmosk1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cosmoscrypto "github.com/cosmos/cosmos-sdk/crypto/types" + cosmostypes "github.com/cosmos/cosmos-sdk/types" "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa" "github.com/ethereum/go-ethereum/common" ethcrypto "github.com/ethereum/go-ethereum/crypto" - "strings" "github.com/piplabs/story/lib/cast" "github.com/piplabs/story/lib/errors" - - cosmoscrypto "github.com/cosmos/cosmos-sdk/crypto/types" - cosmostypes "github.com/cosmos/cosmos-sdk/types" ) // privKeyLen is the length of a secp256k1 private key.