diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b176664..22e32e1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,23 +20,22 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - WASM_DIR: ./wasmchain - MOVE_DIR: ./movechain - jobs: golangci: env: # for private repo access - GOPRIVATE: github.com/initia-labs/* + GOPRIVATE: github.com/initia-labs,github.com/skip-mev/slinky GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }} + GOLANGCI_LINT_VERSION: v1.59.1 name: golangci-lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v2.1.4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version: 1.22 - - uses: technote-space/get-diff-action@v5 + check-latest: true + - uses: technote-space/get-diff-action@v6.1.2 id: git_diff with: PATTERNS: | @@ -45,26 +44,43 @@ jobs: go.sum # for private repo access - run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/ - - name: run go linters + # install golangci-lint + - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} + - name: run go linters (long) + if: env.GIT_DIFF + id: lint_long run: | - make tools make lint - if: env.GIT_DIFF + - uses: technote-space/get-diff-action@v6.1.2 + if: steps.lint_long.outcome == 'skipped' + with: + PATTERNS: | + **/**.go + go.mod + go.sum + - name: run go linters (short) + if: steps.lint_long.outcome == 'skipped' && env.GIT_DIFF + run: | + make lint + env: + GIT_DIFF: ${{ env.GIT_DIFF }} + LINT_DIFF: 1 # Use --check or --exit-code when available (Go 1.19?) # https://github.com/golang/go/issues/27005 tidy: env: # for private repo access - GOPRIVATE: github.com/initia-labs/* + GOPRIVATE: github.com/initia-labs,github.com/skip-mev/slinky GITHUB_ACCESS_TOKEN: ${{ secrets.GH_READ_TOKEN }} runs-on: ubuntu-latest name: tidy steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.22 + check-latest: true # for private repo access - run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:x-oauth-basic@github.com/.insteadOf https://github.com/ - run: | diff --git a/Makefile b/Makefile index c05ad39..4f39785 100644 --- a/Makefile +++ b/Makefile @@ -235,10 +235,11 @@ benchmark: ############################################################################### lint: - golangci-lint run --out-format=tab + golangci-lint run --out-format=tab --timeout=15m lint-fix: - golangci-lint run --fix --out-format=tab --issues-exit-code=0 + golangci-lint run --fix --out-format=tab --timeout=15m + .PHONY: lint lint-fix format: diff --git a/app/app.go b/app/app.go index c12d6aa..c05e51f 100644 --- a/app/app.go +++ b/app/app.go @@ -1137,7 +1137,9 @@ func (app *MinitiaApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) + if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { + panic(err) + } return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState) } diff --git a/app/ibc-hooks/common_test.go b/app/ibc-hooks/common_test.go index 62385ae..e998440 100644 --- a/app/ibc-hooks/common_test.go +++ b/app/ibc-hooks/common_test.go @@ -42,7 +42,7 @@ import ( capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" ibc "github.com/cosmos/ibc-go/v8/modules/core" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -277,7 +277,7 @@ func _createTestInput( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ac, ) - ibcHooksKeeper.Params.Set(ctx, ibchookstypes.DefaultParams()) + ibcHooksKeeper.Params.Set(ctx, ibchookstypes.DefaultParams()) //nolint:errcheck wasmKeeper := wasmkeeper.NewKeeper( appCodec, diff --git a/app/test_helpers.go b/app/test_helpers.go index 95b43b0..bc0fa3c 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -95,7 +95,7 @@ func SetupWithGenesisAccounts( // allow empty validator if valSet == nil || len(valSet.Validators) == 0 { privVal := ed25519.GenPrivKey() - pubKey, err := cryptocodec.ToTmPubKeyInterface(privVal.PubKey()) + pubKey, err := cryptocodec.ToTmPubKeyInterface(privVal.PubKey()) //nolint:staticcheck if err != nil { panic(err) } @@ -106,7 +106,7 @@ func SetupWithGenesisAccounts( validators := make([]opchildtypes.Validator, 0, len(valSet.Validators)) for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) + pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) //nolint:staticcheck if err != nil { panic(err) } diff --git a/x/tokenfactory/client/cli/tx.go b/x/tokenfactory/client/cli/tx.go index 498cd48..d520763 100644 --- a/x/tokenfactory/client/cli/tx.go +++ b/x/tokenfactory/client/cli/tx.go @@ -199,12 +199,6 @@ func NewSetBeforeSendHookCmd(ac address.Codec) *cobra.Command { return err } - txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) - if err != nil { - return err - } - txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - msg := types.NewMsgSetBeforeSendHook( fromAddr, args[0], diff --git a/x/tokenfactory/keeper/before_send.go b/x/tokenfactory/keeper/before_send.go index badc34f..b39f8d8 100644 --- a/x/tokenfactory/keeper/before_send.go +++ b/x/tokenfactory/keeper/before_send.go @@ -23,8 +23,7 @@ func (k Keeper) setBeforeSendHook(ctx context.Context, denom string, cosmwasmAdd // delete the store for denom prefix store when cosmwasm address is nil if cosmwasmAddress == "" { - k.DenomHookAddr.Remove(ctx, denom) - return nil + return k.DenomHookAddr.Remove(ctx, denom) } _, err = k.ac.StringToBytes(cosmwasmAddress) @@ -32,9 +31,7 @@ func (k Keeper) setBeforeSendHook(ctx context.Context, denom string, cosmwasmAdd return err } - k.DenomHookAddr.Set(ctx, denom, cosmwasmAddress) - - return nil + return k.DenomHookAddr.Set(ctx, denom, cosmwasmAddress) } func (k Keeper) GetBeforeSendHook(ctx context.Context, denom string) string { diff --git a/x/tokenfactory/keeper/common_test.go b/x/tokenfactory/keeper/common_test.go index 96dcf5e..5ba311b 100644 --- a/x/tokenfactory/keeper/common_test.go +++ b/x/tokenfactory/keeper/common_test.go @@ -68,7 +68,7 @@ var ModuleBasics = module.NewBasicManager( ) var ( - valPubKeys = testutilsims.CreateTestPubKeys(5) + valPubKeys = testutilsims.CreateTestPubKeys(5) //nolint:unused pubKeys = []crypto.PubKey{ secp256k1.GenPrivKey().PubKey(), @@ -86,6 +86,7 @@ var ( sdk.AccAddress(pubKeys[4].Address()), } + //nolint:unused valAddrs = []sdk.ValAddress{ sdk.ValAddress(pubKeys[0].Address()), sdk.ValAddress(pubKeys[1].Address()), diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index 2eec913..607d4c0 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -53,8 +53,7 @@ func (k Keeper) createDenomAfterValidation(ctx context.Context, creatorAddr stri return err } - k.addDenomFromCreator(ctx, creatorAddr, denom) - return nil + return k.addDenomFromCreator(ctx, creatorAddr, denom) } func (k Keeper) validateCreateDenom(ctx context.Context, creatorAddr string, subdenom string) (newTokenDenom string, err error) { diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go index 1cb123b..37d9e49 100644 --- a/x/tokenfactory/keeper/createdenom_test.go +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -85,7 +85,7 @@ func TestCreateDenom(t *testing.T) { // Set denom creation fee in params input.Faucet.Fund(ctx, addrs[0], defaultDenomCreationFee.DenomCreationFee...) - tokenFactoryKeeper.SetParams(ctx, tc.denomCreationFee) + tokenFactoryKeeper.SetParams(ctx, tc.denomCreationFee) //nolint:errcheck denomCreationFee := tokenFactoryKeeper.GetParams(ctx).DenomCreationFee require.Equal(t, tc.denomCreationFee.DenomCreationFee, denomCreationFee) @@ -181,7 +181,7 @@ func TestGasConsume(t *testing.T) { // set params with the gas consume amount tokenFactoryKeeper := input.TokenFactoryKeeper - tokenFactoryKeeper.SetParams(ctx, types.NewParams(nil, tc.gasConsume)) + tokenFactoryKeeper.SetParams(ctx, types.NewParams(nil, tc.gasConsume)) //nolint:errcheck // amount of gas consumed prior to the denom creation gasConsumedBefore := ctx.GasMeter().GasConsumed() diff --git a/x/tokenfactory/keeper/creators.go b/x/tokenfactory/keeper/creators.go index 43c3823..89a6dad 100644 --- a/x/tokenfactory/keeper/creators.go +++ b/x/tokenfactory/keeper/creators.go @@ -12,9 +12,12 @@ func (k Keeper) addDenomFromCreator(ctx context.Context, creator, denom string) func (k Keeper) getDenomsFromCreator(ctx context.Context, creator string) []string { denoms := []string{} - k.CreatorDenoms.Walk(ctx, collections.NewPrefixedPairRange[string, string](creator), func(key collections.Pair[string, string]) (stop bool, err error) { + err := k.CreatorDenoms.Walk(ctx, collections.NewPrefixedPairRange[string, string](creator), func(key collections.Pair[string, string]) (stop bool, err error) { denoms = append(denoms, key.K2()) return false, nil }) + if err != nil { + panic(err) + } return denoms } diff --git a/x/tokenfactory/keeper/genesis.go b/x/tokenfactory/keeper/genesis.go index 85eb11d..42d0fb5 100644 --- a/x/tokenfactory/keeper/genesis.go +++ b/x/tokenfactory/keeper/genesis.go @@ -39,7 +39,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { // ExportGenesis returns the tokenfactory module's exported genesis. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { genDenoms := []types.GenesisDenom{} - k.CreatorDenoms.Walk(ctx, nil, func(key collections.Pair[string, string]) (stop bool, err error) { + err := k.CreatorDenoms.Walk(ctx, nil, func(key collections.Pair[string, string]) (stop bool, err error) { denom := key.K2() authorityMetadata, err := k.GetAuthorityMetadata(ctx, denom) @@ -53,6 +53,9 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { }) return false, nil }) + if err != nil { + panic(err) + } return &types.GenesisState{ FactoryDenoms: genDenoms, diff --git a/x/tokenfactory/keeper/genesis_test.go b/x/tokenfactory/keeper/genesis_test.go index f00d270..a1d4c3c 100644 --- a/x/tokenfactory/keeper/genesis_test.go +++ b/x/tokenfactory/keeper/genesis_test.go @@ -68,7 +68,7 @@ func TestGenesis(t *testing.T) { tokenfactoryModuleAccount := accountKeeper.GetAccount(ctx, accountKeeper.GetModuleAddress(types.ModuleName)) require.Nil(t, tokenfactoryModuleAccount) - tokenFactoryKeeper.SetParams(ctx, types.Params{DenomCreationFee: sdk.Coins{sdk.NewInt64Coin("uinit", 100)}}) + tokenFactoryKeeper.SetParams(ctx, types.Params{DenomCreationFee: sdk.Coins{sdk.NewInt64Coin("uinit", 100)}}) //nolint:errcheck tokenFactoryKeeper.InitGenesis(ctx, genesisState) // check that the module account is now initialized @@ -80,7 +80,7 @@ func TestGenesis(t *testing.T) { require.Equal(t, genesisState, *exportedGenesis) // verify that the exported bank genesis is valid - bankKeeper.SetParams(ctx, banktypes.DefaultParams()) + bankKeeper.SetParams(ctx, banktypes.DefaultParams()) //nolint:errcheck exportedBankGenesis := bankKeeper.ExportGenesis(ctx) require.NoError(t, exportedBankGenesis.Validate())