Skip to content

Commit

Permalink
Merge pull request #214 from cosmosquad-labs/hallazzang/internal-code…
Browse files Browse the repository at this point in the history
…-reivew-1-213

fix: apply suggestions code reivew 1
  • Loading branch information
dongsam authored Feb 28, 2022
2 parents 5d87fc9 + 396e25e commit 375ca21
Show file tree
Hide file tree
Showing 67 changed files with 350 additions and 572 deletions.
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

94 changes: 0 additions & 94 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4466,24 +4466,6 @@ paths:
description: >-
LiquidValidatorState is type LiquidValidator with state
added to return to query results.
pagination:
description: pagination defines the pagination in the response.
type: object
properties:
next_key:
type: string
format: byte
title: |-
next_key is the key to be passed to PageRequest.key to
query the next page most efficiently
total:
type: string
format: uint64
title: >-
total is total number of results available if
PageRequest.count_total
was set, its value is undefined otherwise
description: >-
QueryLiquidValidatorsResponse is the response type for the
Query/LiquidValidators RPC method.
Expand All @@ -4509,64 +4491,6 @@ paths:
value:
type: string
format: byte
parameters:
- name: pagination.key
description: |-
key is a value returned in PageResponse.next_key to begin
querying the next page most efficiently. Only one of offset or key
should be set.
in: query
required: false
type: string
format: byte
- name: pagination.offset
description: >-
offset is a numeric offset that can be used when key is unavailable.
It is less efficient than using key. Only one of offset or key
should
be set.
in: query
required: false
type: string
format: uint64
- name: pagination.limit
description: >-
limit is the total number of results to be returned in the result
page.
If left empty it will default to a value to be set by each app.
in: query
required: false
type: string
format: uint64
- name: pagination.count_total
description: >-
count_total is set to true to indicate that the result set should
include
a count of the total number of items available for pagination in
UIs.
count_total is only respected when offset is used. It is ignored
when key
is set.
in: query
required: false
type: boolean
format: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending
order.
in: query
required: false
type: boolean
format: boolean
tags:
- Query
externalDocs:
Expand Down Expand Up @@ -7112,24 +7036,6 @@ definitions:
description: >-
LiquidValidatorState is type LiquidValidator with state added to
return to query results.
pagination:
description: pagination defines the pagination in the response.
type: object
properties:
next_key:
type: string
format: byte
title: |-
next_key is the key to be passed to PageRequest.key to
query the next page most efficiently
total:
type: string
format: uint64
title: >-
total is total number of results available if
PageRequest.count_total
was set, its value is undefined otherwise
description: >-
QueryLiquidValidatorsResponse is the response type for the
Query/LiquidValidators RPC method.
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ require (
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.3
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/k0kubun/pp v3.0.1+incompatible
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/spf13/cast v1.4.1
Expand All @@ -29,7 +27,7 @@ require (
)

replace (
github.com/cosmos/cosmos-sdk => github.com/cosmosquad-labs/cosmos-sdk v0.44.5-enhanced-rc7
github.com/cosmos/cosmos-sdk => github.com/cosmosquad-labs/cosmos-sdk v0.44.5-enhanced-rc8
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
google.golang.org/grpc => google.golang.org/grpc v1.33.2
Expand Down
9 changes: 2 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6
github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI=
github.com/cosmosquad-labs/cosmos-sdk v0.44.5-enhanced-rc7 h1:KkRlQHMhQeiDk+J/Ql9isFs5GyERguy0xuDLDcDoWhA=
github.com/cosmosquad-labs/cosmos-sdk v0.44.5-enhanced-rc7/go.mod h1:maUA6m2TBxOJZkbwl0eRtEBgTX37kcaiOWU5t1HEGaY=
github.com/cosmosquad-labs/cosmos-sdk v0.44.5-enhanced-rc8 h1:NHYJIzXko7E6FXXVq6USPxgpRdb/dsOjJIrvzorDmEI=
github.com/cosmosquad-labs/cosmos-sdk v0.44.5-enhanced-rc8/go.mod h1:maUA6m2TBxOJZkbwl0eRtEBgTX37kcaiOWU5t1HEGaY=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
Expand Down Expand Up @@ -492,10 +492,6 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40=
github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand Down Expand Up @@ -531,7 +527,6 @@ github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaW
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
Expand Down
9 changes: 1 addition & 8 deletions proto/squad/liquidstaking/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ syntax = "proto3";
package squad.liquidstaking.v1beta1;

import "google/api/annotations.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "squad/liquidstaking/v1beta1/liquidstaking.proto";
import "gogoproto/gogo.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
Expand Down Expand Up @@ -75,17 +74,11 @@ message QueryParamsResponse {
}

// QueryLiquidValidatorsRequest is the request type for the Query/LiquidValidators RPC method.
message QueryLiquidValidatorsRequest {
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
message QueryLiquidValidatorsRequest {}

// QueryLiquidValidatorsResponse is the response type for the Query/LiquidValidators RPC method.
message QueryLiquidValidatorsResponse {
repeated LiquidValidatorState liquid_validators = 1 [(gogoproto.nullable) = false];

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryStatesRequest is the request type for the Query/States RPC method.
Expand Down
4 changes: 2 additions & 2 deletions proto/squad/mint/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ option go_package = "github.com/cosmosquad-labs/squad/x/mint/types";

// GenesisState defines the mint module's genesis state.
message GenesisState {
// last_block_time defines last block time, It used to calculate inflation.
// last_block_time defines the last block time, which is used to calculate inflation.
google.protobuf.Timestamp last_block_time = 1
[(gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"last_block_time\""];

// params defines all the paramaters of the module.
// params defines all the parameters of the module.
Params params = 2 [(gogoproto.nullable) = false];
}
4 changes: 0 additions & 4 deletions x/liquidstaking/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
k.UpdateLiquidValidatorSet(ctx)
}

func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
}
17 changes: 7 additions & 10 deletions x/liquidstaking/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package cli

import (
"context"
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/spf13/cobra"

"github.com/cosmosquad-labs/squad/x/liquidstaking/types"
)
Expand Down Expand Up @@ -57,7 +57,7 @@ $ %s query %s params

queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(
context.Background(),
cmd.Context(),
&types.QueryParamsRequest{},
)
if err != nil {
Expand Down Expand Up @@ -95,16 +95,13 @@ $ %s query %s liquid-validators
}

queryClient := types.NewQueryClient(clientCtx)
pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

res, err := queryClient.LiquidValidators(
context.Background(),
&types.QueryLiquidValidatorsRequest{
Pagination: pageReq,
},
cmd.Context(),
&types.QueryLiquidValidatorsRequest{},
)
if err != nil {
return err
Expand Down Expand Up @@ -143,7 +140,7 @@ $ %s query %s states
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.States(
context.Background(),
cmd.Context(),
&types.QueryStatesRequest{},
)
if err != nil {
Expand Down Expand Up @@ -188,7 +185,7 @@ $ %s query %s voting-power %s1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.VotingPower(
context.Background(),
cmd.Context(),
&types.QueryVotingPowerRequest{Voter: voter.String()},
)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions x/liquidstaking/client/testutil/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
paramscli "github.com/cosmos/cosmos-sdk/x/params/client/cli"

"github.com/cosmosquad-labs/squad/x/liquidstaking/client/cli"
)

Expand Down
16 changes: 8 additions & 8 deletions x/liquidstaking/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import (
"strings"
"time"

"github.com/stretchr/testify/suite"

"github.com/cosmos/cosmos-sdk/testutil"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli"
tmcli "github.com/tendermint/tendermint/libs/cli"
tmdb "github.com/tendermint/tm-db"

"github.com/cosmosquad-labs/squad/app"
"github.com/cosmosquad-labs/squad/x/liquidstaking/client/cli"
"github.com/cosmosquad-labs/squad/x/liquidstaking/types"
"github.com/stretchr/testify/suite"
tmdb "github.com/tendermint/tm-db"

tmcli "github.com/tendermint/tendermint/libs/cli"

clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type IntegrationTestSuite struct {
Expand Down
4 changes: 3 additions & 1 deletion x/liquidstaking/keeper/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package keeper_test

import (
_ "github.com/stretchr/testify/suite"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmosquad-labs/squad/x/liquidstaking/types"
_ "github.com/stretchr/testify/suite"
)

func (s *KeeperTestSuite) TestInitGenesis() {
Expand Down
6 changes: 3 additions & 3 deletions x/liquidstaking/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (h Hooks) AfterProposalVote(_ sdk.Context, _ uint64, _ sdk.AccAddress) {
func (h Hooks) AfterProposalFailedMinDeposit(_ sdk.Context, _ uint64) {}
func (h Hooks) AfterProposalVotingPeriodEnded(_ sdk.Context, _ uint64) {}

// GetOtherVotes calculate the voting power of the person who participated in liquid staking.
func (h Hooks) GetOtherVotes(ctx sdk.Context, votes *govtypes.Votes, otherVotes *govtypes.OtherVotes) {
h.k.TallyLiquidStakingGov(ctx, votes, otherVotes)
// SetAdditionalVotingPowers calculates and sets voting powers of the person who participated in liquid staking voters in votes.
func (h Hooks) SetAdditionalVotingPowers(ctx sdk.Context, votes govtypes.Votes, votingPowers *govtypes.AdditionalVotingPowers) {
h.k.SetLiquidStakingVotingPowers(ctx, votes, votingPowers)
}
1 change: 1 addition & 0 deletions x/liquidstaking/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/cosmosquad-labs/squad/x/liquidstaking/types"
)

Expand Down
3 changes: 1 addition & 2 deletions x/liquidstaking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package keeper
import (
"fmt"

"github.com/tendermint/tendermint/libs/log"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tendermint/tendermint/libs/log"

"github.com/cosmosquad-labs/squad/x/liquidstaking/types"
)
Expand Down
Loading

0 comments on commit 375ca21

Please sign in to comment.