Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
puneet2019 committed Jun 20, 2023
1 parent 6a57b69 commit 54478a8
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ linters:
- deadcode
- depguard
- dogsled
# - errcheck
- errcheck
- goconst
- gocritic
- gofmt
Expand Down
16 changes: 8 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -990,14 +990,14 @@ func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) {
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey store.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable())
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable())
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable())
paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable())
paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable())
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1types.ParamKeyTable())
paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable())
paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) //nolint:staticcheck,nolintlint
paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1types.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
Expand Down
6 changes: 3 additions & 3 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (app *PstakeApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
app.DistrKeeper.SetFeePool(ctx, feePool)

app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
_ = app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
return false
})

Expand All @@ -116,8 +116,8 @@ func (app *PstakeApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
}

delAddr := sdk.MustAccAddressFromBech32(del.DelegatorAddress)
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
_ = app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
_ = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
}

// reset context height
Expand Down
6 changes: 3 additions & 3 deletions docker/exposer/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func executeCommand(name string, arg ...string) string {
func getNodeIDHandler(w http.ResponseWriter, r *http.Request) {
homeDir := os.Getenv(homeDirKey)
clientName := os.Getenv(clientNameKey)
io.WriteString(w, executeCommand(clientName, "tendermint", "show-node-id", "--home", homeDir))
_, _ = io.WriteString(w, executeCommand(clientName, "tendermint", "show-node-id", "--home", homeDir))
}

func getPubKeyHandler(w http.ResponseWriter, r *http.Request) {
homeDir := os.Getenv(homeDirKey)
clientName := os.Getenv(clientNameKey)
io.WriteString(w, executeCommand(clientName, "tendermint", "show-validator", "--home", homeDir))
_, _ = io.WriteString(w, executeCommand(clientName, "tendermint", "show-validator", "--home", homeDir))
}

func getGenesisHandler(w http.ResponseWriter, r *http.Request) {
Expand All @@ -59,7 +59,7 @@ func getGenesisHandler(w http.ResponseWriter, r *http.Request) {

w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
w.Write(byteValue)
_, _ = w.Write(byteValue)
}

func main() {
Expand Down
11 changes: 6 additions & 5 deletions docker/pstake/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.19-alpine AS build-env

# Set up dependencies
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
RUN apk add --no-cache curl make git libc-dev bash gcc linux-headers eudev-dev python3

# Set working directory for the build
WORKDIR /go/src/github.com/persistenceOne/pstake-native
Expand All @@ -10,17 +10,18 @@ WORKDIR /go/src/github.com/persistenceOne/pstake-native
COPY . .

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apk add --no-cache $PACKAGES && \
make install
RUN make install

# Final image
FROM alpine:edge

# Install ca-certificates
RUN apk add --update ca-certificates jq bash curl
RUN apk add --update ca-certificates jq bash curl perl

# Set working directory
WORKDIR /root

# Copy over binaries from the build-env
COPY --from=build-env /go/bin/pstaked /usr/bin/pstaked

EXPOSE 26657
EXPOSE 26657
32 changes: 16 additions & 16 deletions x/lscosmos/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func CmdQueryHostChainParams() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.HostChainParams(context.Background(), &types.QueryHostChainParamsRequest{})
if err != nil {
Expand All @@ -81,7 +81,7 @@ func CmdQueryAllState() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.AllState(context.Background(), &types.QueryAllStateRequest{})
if err != nil {
Expand All @@ -106,7 +106,7 @@ func CmdQueryDelegationState() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.DelegationState(context.Background(), &types.QueryDelegationStateRequest{})
if err != nil {
Expand All @@ -131,7 +131,7 @@ func CmdQueryAllowListedValidators() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.AllowListedValidators(context.Background(), &types.QueryAllowListedValidatorsRequest{})
if err != nil {
Expand All @@ -156,7 +156,7 @@ func CmdQueryCValue() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.CValue(context.Background(), &types.QueryCValueRequest{})
if err != nil {
Expand All @@ -181,7 +181,7 @@ func CmdQueryModuleState() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.ModuleState(context.Background(), &types.QueryModuleStateRequest{})
if err != nil {
Expand All @@ -206,7 +206,7 @@ func CmdQueryIBCTransientStore() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.IBCTransientStore(context.Background(), &types.QueryIBCTransientStoreRequest{})
if err != nil {
Expand All @@ -231,7 +231,7 @@ func CmdQueryUnclaimed() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

delegatorAddress, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
Expand Down Expand Up @@ -261,7 +261,7 @@ func CmdQueryFailedUnbondings() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

_, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
Expand Down Expand Up @@ -291,7 +291,7 @@ func CmdQueryPendingUnbondings() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

_, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
Expand Down Expand Up @@ -321,7 +321,7 @@ func CmdQueryUnbondingEpoch() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

epochNumber, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
Expand Down Expand Up @@ -351,7 +351,7 @@ func CmdQueryHostAccountUndelegation() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

epochNumber, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
Expand Down Expand Up @@ -381,7 +381,7 @@ func CmdQueryDelegatorUnbodingEpochEntry() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

delegatorAddress, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
Expand Down Expand Up @@ -416,7 +416,7 @@ func CmdQueryHostAccounts() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.HostAccounts(context.Background(), &types.QueryHostAccountsRequest{})
if err != nil {
Expand All @@ -441,7 +441,7 @@ func CmdQueryDepositModuleAccount() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.DepositModuleAccount(context.Background(), &types.QueryDepositModuleAccountRequest{})
if err != nil {
Expand All @@ -466,7 +466,7 @@ func CmdDelegatorUnbondingEpochEntries() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

delegatorAddress, err := sdk.AccAddressFromBech32(args[0])
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/lscosmos/client/cli/query_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func CmdQueryParams() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)
queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck

res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions x/lscosmos/keeper/governance_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
)

// HandleMinDepositAndFeeChangeProposal changes host chain params for desired min-deposit and protocol fee
func HandleMinDepositAndFeeChangeProposal(ctx sdk.Context, k Keeper, content types.MinDepositAndFeeChangeProposal) error {
func HandleMinDepositAndFeeChangeProposal(ctx sdk.Context, k Keeper, content types.MinDepositAndFeeChangeProposal) error { //nolint:staticcheck
return types.ErrDeprecated
}

// HandlePstakeFeeAddressChangeProposal changes fee collector address
func HandlePstakeFeeAddressChangeProposal(ctx sdk.Context, k Keeper, content types.PstakeFeeAddressChangeProposal) error {
func HandlePstakeFeeAddressChangeProposal(ctx sdk.Context, k Keeper, content types.PstakeFeeAddressChangeProposal) error { //nolint:staticcheck
return types.ErrDeprecated
}

// HandleAllowListedValidatorSetChangeProposal changes the allowList validator set
func HandleAllowListedValidatorSetChangeProposal(ctx sdk.Context, k Keeper, content types.AllowListedValidatorSetChangeProposal) error {
func HandleAllowListedValidatorSetChangeProposal(ctx sdk.Context, k Keeper, content types.AllowListedValidatorSetChangeProposal) error { //nolint:staticcheck
return types.ErrDeprecated
}
2 changes: 1 addition & 1 deletion x/lscosmos/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/persistenceOne/pstake-native/v2/x/lscosmos/types"
)

var _ types.QueryServer = Keeper{}
var _ types.QueryServer = Keeper{} //nolint:staticcheck

// AllState returns genesis state
func (k Keeper) AllState(c context.Context, request *types.QueryAllStateRequest) (*types.QueryAllStateResponse, error) {
Expand Down
2 changes: 1 addition & 1 deletion x/lscosmos/keeper/migrate_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (k Keeper) Migrate(ctx sdk.Context) error {
}

// set validators
var validators []*liquidstakeibctypes.Validator
var validators []*liquidstakeibctypes.Validator //nolint:prealloc
for _, delval := range delegationState.HostAccountDelegations {
allowlistedVal := types.AllowListedValidator{
ValidatorAddress: delval.ValidatorAddress,
Expand Down
5 changes: 3 additions & 2 deletions x/lscosmos/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"

"github.com/persistenceOne/pstake-native/v2/x/lscosmos/types"
)

Expand All @@ -11,11 +12,11 @@ type msgServer struct {

// NewMsgServerImpl returns an implementation of the MsgServer interface
// for the provided Keeper.
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
func NewMsgServerImpl(keeper Keeper) types.MsgServer { //nolint:staticcheck
return &msgServer{Keeper: keeper}
}

var _ types.MsgServer = msgServer{}
var _ types.MsgServer = msgServer{} //nolint:staticcheck

// LiquidStake defines a method for liquid staking tokens
func (m msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) (*types.MsgLiquidStakeResponse, error) {
Expand Down
9 changes: 6 additions & 3 deletions x/lscosmos/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
// this line is used by starport scaffolding # 2
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:staticcheck
if err != nil {
panic(err)
}

}

Expand Down Expand Up @@ -127,8 +130,8 @@ func (AppModule) QuerierRoute() string { return types.QuerierRoute }
// RegisterServices registers a GRPC query service to respond to the
// module-specific GRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) //TODO remove in next version, kept to give proper error messages.
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) //nolint:staticcheck //TODO remove in next version, kept to give proper error messages.
types.RegisterQueryServer(cfg.QueryServer(), am.keeper) //nolint:staticcheck
}

// RegisterInvariants registers the capability module's invariants.
Expand Down
1 change: 0 additions & 1 deletion x/lscosmos/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package types
// DefaultGenesis returns the default Capability genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{

// this line is used by starport scaffolding # genesis/types/default
Params: DefaultParams(),
ModuleEnabled: false,
Expand Down
5 changes: 4 additions & 1 deletion x/lspersistence/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
if genState.Params.WhitelistedValidators == nil || len(genState.Params.WhitelistedValidators) == 0 {
genState.Params.WhitelistedValidators = []types.WhitelistedValidator{}
}
k.SetParams(ctx, genState.Params)
err := k.SetParams(ctx, genState.Params)
if err != nil {
panic(err)
}

for _, lv := range genState.LiquidValidators {
k.SetLiquidValidator(ctx, lv)
Expand Down
5 changes: 4 additions & 1 deletion x/lspersistence/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParam
return nil, errorsmod.Wrapf(sdkerrors.ErrorInvalidSigner, "invalid authority; expected %s or %s, got %s", k.authority, params.AdminAddress, msg.Authority)
}

k.SetParams(ctx, msg.Params)
err := k.SetParams(ctx, msg.Params)
if err != nil {
return nil, err
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
Expand Down
Loading

0 comments on commit 54478a8

Please sign in to comment.