Skip to content

Commit

Permalink
chore final lint changes
Browse files Browse the repository at this point in the history
  • Loading branch information
h5law committed Jan 16, 2024
1 parent 1866316 commit 95cb78f
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 13 deletions.
14 changes: 14 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ issues:
# parameters and unchecked errors.
- path: ^x/.+/module\.go$
linters:
- lll
- gci
- revive
- errcheck
# Exclude cosmos-sdk module tx.go files as they are generated with unused
Expand Down Expand Up @@ -83,6 +85,18 @@ issues:
- path: errors\.go$
linters:
- lll
# Exclude app module code as it's generated with lots with long lines and
# improperly formatted imports.
- path: ^app
linters:
- lll
- gci
# Exclude cmd directory code as it's generated with lots with long lines and
# improperly formatted imports.
- path: ^cmd/poc
linters:
- lll
- gci
# TODO_IMPROVE: see https://golangci-lint.run/usage/configuration/#issues-configuration
#new: true,
#fix: true,
18 changes: 15 additions & 3 deletions x/application/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ func (gs GenesisState) Validate() error {
}
stake, err := sdk.ParseCoinNormalized(app.Stake.String())
if !stake.IsValid() {
return sdkerrors.Wrapf(ErrAppInvalidStake, "invalid stake amount for application %v; (%v)", app.Stake, stake.Validate())
return sdkerrors.Wrapf(
ErrAppInvalidStake,
"invalid stake amount for application %v; (%v)",
app.Stake, stake.Validate(),
)
}
if err != nil {
return sdkerrors.Wrapf(ErrAppInvalidStake, "cannot parse stake amount for application %v; (%v)", app.Stake, err)
return sdkerrors.Wrapf(
ErrAppInvalidStake,
"cannot parse stake amount for application %v; (%v)",
app.Stake, err,
)
}
if stake.IsZero() || stake.IsNegative() {
return sdkerrors.Wrapf(ErrAppInvalidStake, "invalid stake amount for application: %v <= 0", app.Stake)
Expand All @@ -58,7 +66,11 @@ func (gs GenesisState) Validate() error {
// Check that the application's delegated gateway addresses are valid
for _, gatewayAddr := range app.DelegateeGatewayAddresses {
if _, err := sdk.AccAddressFromBech32(gatewayAddr); err != nil {
return sdkerrors.Wrapf(ErrAppInvalidGatewayAddress, "invalid gateway address %s; (%v)", gatewayAddr, err)
return sdkerrors.Wrapf(
ErrAppInvalidGatewayAddress,
"invalid gateway address %s; (%v)",
gatewayAddr, err,
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/gateway/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

// this line is used by starport scaffolding # 1

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down
12 changes: 10 additions & 2 deletions x/gateway/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ func (gs GenesisState) Validate() error {
}
stake, err := sdk.ParseCoinNormalized(gateway.Stake.String())
if !stake.IsValid() {
return sdkerrors.Wrapf(ErrGatewayInvalidStake, "invalid stake amount for gateway %v; (%v)", gateway.Stake, stake.Validate())
return sdkerrors.Wrapf(
ErrGatewayInvalidStake,
"invalid stake amount for gateway %v; (%v)",
gateway.Stake, stake.Validate(),
)
}
if err != nil {
return sdkerrors.Wrapf(ErrGatewayInvalidStake, "cannot parse stake amount for gateway %v; (%v)", gateway.Stake, err)
return sdkerrors.Wrapf(
ErrGatewayInvalidStake,
"cannot parse stake amount for gateway %v; (%v)",
gateway.Stake, err,
)
}
if stake.IsZero() || stake.IsNegative() {
return sdkerrors.Wrapf(ErrGatewayInvalidStake, "invalid stake amount for gateway: %v <= 0", gateway.Stake)
Expand Down
2 changes: 1 addition & 1 deletion x/pocket/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"

// this line is used by starport scaffolding # 1

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down
6 changes: 4 additions & 2 deletions x/supplier/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import (

// this line is used by starport scaffolding # 1

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

"github.com/pokt-network/poktroll/x/supplier/client/cli"
"github.com/pokt-network/poktroll/x/supplier/keeper"
Expand Down
24 changes: 20 additions & 4 deletions x/supplier/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,32 @@ func (gs GenesisState) Validate() error {
}
stake, err := sdk.ParseCoinNormalized(supplier.Stake.String())
if !stake.IsValid() {
return sdkerrors.Wrapf(ErrSupplierInvalidStake, "invalid stake amount for supplier %v; (%v)", supplier.Stake, stake.Validate())
return sdkerrors.Wrapf(
ErrSupplierInvalidStake,
"invalid stake amount for supplier %v; (%v)",
supplier.Stake, stake.Validate(),
)
}
if err != nil {
return sdkerrors.Wrapf(ErrSupplierInvalidStake, "cannot parse stake amount for supplier %v; (%v)", supplier.Stake, err)
return sdkerrors.Wrapf(
ErrSupplierInvalidStake,
"cannot parse stake amount for supplier %v; (%v)",
supplier.Stake, err,
)
}
if stake.IsZero() || stake.IsNegative() {
return sdkerrors.Wrapf(ErrSupplierInvalidStake, "invalid stake amount for supplier: %v <= 0", supplier.Stake)
return sdkerrors.Wrapf(
ErrSupplierInvalidStake,
"invalid stake amount for supplier: %v <= 0",
supplier.Stake,
)
}
if stake.Denom != "upokt" {
return sdkerrors.Wrapf(ErrSupplierInvalidStake, "invalid stake amount denom for supplier %v", supplier.Stake)
return sdkerrors.Wrapf(
ErrSupplierInvalidStake,
"invalid stake amount denom for supplier %v",
supplier.Stake,
)
}

// Validate the application service configs
Expand Down

0 comments on commit 95cb78f

Please sign in to comment.