Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed Mar 27, 2024
1 parent 76289ca commit d458cab
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 92 deletions.
13 changes: 12 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ linters:
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- errcheck
- gci
- goconst
- gocritic
- gofmt
Expand Down Expand Up @@ -68,6 +68,17 @@ linters-settings:
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US
gci:
custom-order: true
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(cosmossdk.io)
- prefix(github.com/cosmos/cosmos-sdk)
- prefix(github.com/cosmos/ibc-go)
- prefix(github.com/CosmWasm/wasmd)
- prefix(github.com/Finschia/finschia-sdk)

run:
# default concurrency is a available CPU number
concurrency: 4
Expand Down
8 changes: 4 additions & 4 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package app
import (
"errors"

circuitante "cosmossdk.io/x/circuit/ante"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
"github.com/cosmos/ibc-go/v8/modules/core/keeper"

corestoretypes "cosmossdk.io/core/store"
circuitante "cosmossdk.io/x/circuit/ante"
circuitkeeper "cosmossdk.io/x/circuit/keeper"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"

ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
"github.com/cosmos/ibc-go/v8/modules/core/keeper"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
)
Expand Down
63 changes: 32 additions & 31 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,7 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
"github.com/cosmos/gogoproto/proto"
"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
"github.com/spf13/cast"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
Expand Down Expand Up @@ -114,6 +88,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
Expand All @@ -123,13 +98,39 @@ import (
"github.com/cosmos/cosmos-sdk/x/params"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
Expand Down Expand Up @@ -1027,8 +1028,8 @@ func (app *FnsaApp) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) {
return app.ModuleManager.EndBlock(ctx)
}

func (a *FnsaApp) Configurator() module.Configurator {
return a.configurator
func (app *FnsaApp) Configurator() module.Configurator {
return app.configurator
}

// InitChainer application update at chain initialization
Expand Down Expand Up @@ -1098,8 +1099,8 @@ func (app *FnsaApp) AutoCliOpts() autocli.AppOptions {
}

// DefaultGenesis returns a default genesis from the registered AppModuleBasic's.
func (a *FnsaApp) DefaultGenesis() map[string]json.RawMessage {
return a.BasicModuleManager.DefaultGenesis(a.appCodec)
func (app *FnsaApp) DefaultGenesis() map[string]json.RawMessage {
return app.BasicModuleManager.DefaultGenesis(app.appCodec)
}

// GetKey returns the KVStoreKey for the provided store key.
Expand Down Expand Up @@ -1211,7 +1212,7 @@ func BlockedAddresses() map[string]bool {

// allow the following addresses to receive funds
// TODO: uncomment it when authority is ready
//delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String())
// delete(modAccAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String())

return modAccAddrs
}
Expand Down
2 changes: 2 additions & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func TestBlockedAddrs(t *testing.T) {
gapp := Setup(t)

for acc := range BlockedAddresses() {
acc := acc

t.Run(acc, func(t *testing.T) {
var addr sdk.AccAddress
if modAddr, err := sdk.AccAddressFromBech32(acc); err == nil {
Expand Down
3 changes: 1 addition & 2 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package app
import (
"testing"

"github.com/Finschia/finschia/v3/app/params"
dbm "github.com/cosmos/cosmos-db"

"cosmossdk.io/log"

simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"

"github.com/Finschia/finschia/v3/app/params"
)

// MakeEncodingConfig creates a new EncodingConfig with all modules registered. For testing only
Expand Down
4 changes: 3 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func (app *FnsaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
if err != nil {
panic(err)
}
_, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz)
if _, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz); err != nil {
panic(err)
}
return false
})
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ func GenesisStateWithValSet(
}
validators = append(validators, validator)
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress().String(), sdk.ValAddress(val.Address).String(), sdkmath.LegacyOneDec()))

}

// set validators and delegations
Expand Down
6 changes: 3 additions & 3 deletions app/test_support.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package app

import (
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

"github.com/cosmos/cosmos-sdk/baseapp"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
)

Expand Down
8 changes: 4 additions & 4 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package app
import (
"fmt"

"github.com/Finschia/finschia/v3/app/upgrades"
"github.com/Finschia/finschia/v3/app/upgrades/noop"
v050 "github.com/Finschia/finschia/v3/app/upgrades/v050"

upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -20,10 +24,6 @@ import (

v2 "github.com/CosmWasm/wasmd/x/wasm/migrations/v2"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

"github.com/Finschia/finschia/v3/app/upgrades"
"github.com/Finschia/finschia/v3/app/upgrades/noop"
v050 "github.com/Finschia/finschia/v3/app/upgrades/v050"
)

// Upgrades list of chain upgrades
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/noop/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package noop
import (
"context"

"github.com/Finschia/finschia/v3/app/upgrades"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

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

"github.com/Finschia/finschia/v3/app/upgrades"
)

// NewUpgrade constructor
Expand Down
6 changes: 3 additions & 3 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package upgrades
import (
"context"

capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

Expand All @@ -14,6 +11,9 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"

capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
)

type AppKeepers struct {
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v050/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package v050
import (
"context"

"github.com/Finschia/finschia/v3/app/upgrades"

storetypes "cosmossdk.io/store/types"
circuittypes "cosmossdk.io/x/circuit/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

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

"github.com/Finschia/finschia/v3/app/upgrades"
)

// UpgradeName defines the on-chain upgrade name
Expand Down
7 changes: 3 additions & 4 deletions cmd/fnsad/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import (
"io"
"os"

"github.com/Finschia/finschia/v3/app"
cmtcfg "github.com/cometbft/cometbft/config"
dbm "github.com/cosmos/cosmos-db"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"cosmossdk.io/log"
confixcmd "cosmossdk.io/tools/confix/cmd"
cmtcfg "github.com/cometbft/cometbft/config"
dbm "github.com/cosmos/cosmos-db"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/debug"
Expand All @@ -38,8 +39,6 @@ import (
wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

"github.com/Finschia/finschia/v3/app"
)

// initCometBFTConfig helps to override default CometBFT Config values.
Expand Down
4 changes: 2 additions & 2 deletions cmd/fnsad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package main
import (
"os"

"github.com/Finschia/finschia/v3/app"

"cosmossdk.io/log"

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"github.com/Finschia/finschia/v3/app"
)

func main() {
Expand Down
17 changes: 11 additions & 6 deletions cmd/fnsad/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"os"

"github.com/Finschia/finschia/v3/app"
"github.com/Finschia/finschia/v3/app/params"
dbm "github.com/cosmos/cosmos-db"
"github.com/spf13/cobra"

Expand All @@ -22,9 +24,6 @@ import (

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

"github.com/Finschia/finschia/v3/app"
"github.com/Finschia/finschia/v3/app/params"
)

// NewRootCmd creates a new root command for wasmd. It is called once in the
Expand Down Expand Up @@ -81,7 +80,7 @@ func NewRootCmd() *cobra.Command {
// sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode
// is only available if the client is online.
if !initClientCtx.Offline {
enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
enabledSignModes := append(append([]signing.SignMode{}, tx.DefaultSignModes...), signing.SignMode_SIGN_MODE_TEXTUAL)
txConfigOpts := tx.ConfigOptions{
EnabledSignModes: enabledSignModes,
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx),
Expand Down Expand Up @@ -112,8 +111,14 @@ func NewRootCmd() *cobra.Command {

// add keyring to autocli opts
autoCliOpts := tempApp.AutoCliOpts()
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
initClientCtx, err := config.ReadFromClientConfig(initClientCtx)
if err != nil {
panic(err)
}
autoCliOpts.Keyring, err = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
if err != nil {
panic(err)
}
autoCliOpts.ClientCtx = initClientCtx

if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
Expand Down
Loading

0 comments on commit d458cab

Please sign in to comment.