Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ proto-download-deps:
###############################################################################

golangci_version=v1.64.8
lint_base_rev?=origin/main
lint_pr_base_rev?=$(lint_base_rev)

lint-install:
@echo "--> Installing golangci-lint $(golangci_version)"
Expand All @@ -361,8 +363,20 @@ lint-install:
fi

lint: lint-install
@echo "--> Running linter"
@golangci-lint run --build-tags=$(GO_BUILD) --out-format=tab
@echo "--> Running linter on changes since $(lint_base_rev)"
@golangci-lint run --config=.golangci.yml --build-tags=$(GO_BUILD) --out-format=tab --new-from-rev=$(lint_base_rev) --timeout=15m

lint-fix: lint-install
@echo "--> Running linter with fixes on changes since $(lint_base_rev)"
@golangci-lint run --config=.golangci.yml --build-tags=$(GO_BUILD) --out-format=tab --new-from-rev=$(lint_base_rev) --timeout=15m --fix

lint-pr: lint-install
@echo "--> Running PR linter on changes since $(lint_pr_base_rev)"
@golangci-lint run --config=.golangci.yml --build-tags=$(GO_BUILD) --out-format=tab --new-from-rev=$(lint_pr_base_rev) --timeout=15m

lint-all: lint-install
@echo "--> Running linter on entire repository"
@golangci-lint run --config=.golangci.yml --build-tags=$(GO_BUILD) --out-format=tab --timeout=15m

format: lint-install
@golangci-lint run --build-tags=$(GO_BUILD) --out-format=tab --fix
Expand All @@ -376,7 +390,7 @@ shell-format:
#go install mvdan.cc/sh/v3/cmd/shfmt@v3.8.0
grep -r '^#!/usr/bin/env bash' --exclude-dir={node_modules,build} . | cut -d: -f1 | xargs shfmt -l -w -i 2

.PHONY: format lint shell-lint shell-format
.PHONY: format lint lint-fix lint-pr lint-all shell-lint shell-format

###############################################################################
### Tests & Simulation ###
Expand Down
4 changes: 2 additions & 2 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import (
"github.com/openmetaearth/me-hub/x/delayedack"
"github.com/openmetaearth/me-hub/x/denommetadata"
denommetadatamoduleclient "github.com/openmetaearth/me-hub/x/denommetadata/client"
did "github.com/openmetaearth/me-hub/x/did"
"github.com/openmetaearth/me-hub/x/did"
"github.com/openmetaearth/me-hub/x/eibc"
kyc "github.com/openmetaearth/me-hub/x/kyc"
"github.com/openmetaearth/me-hub/x/kyc"
groupmodule "github.com/openmetaearth/me-hub/x/megroup"
"github.com/openmetaearth/me-hub/x/rollapp"
rollappmoduleclient "github.com/openmetaearth/me-hub/x/rollapp/client"
Expand Down
5 changes: 3 additions & 2 deletions cmd/med/cmd/gen_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"encoding/json"
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -38,7 +39,7 @@ func GenRelayersCmd(defaultNodeHome string) *cobra.Command {
return fmt.Errorf("parse coins: %w", err)
}
if !coins.IsValid() {
return fmt.Errorf("invalid coins")
return errors.New("invalid coins")
}

rawAddrList := strings.Split(args[0], ",")
Expand All @@ -64,7 +65,7 @@ func GenRelayersCmd(defaultNodeHome string) *cobra.Command {
proposalRelayers = append(proposalRelayers, addrStr)
}
if len(addrs) == 0 {
return fmt.Errorf("no valid addresses provided")
return errors.New("no valid addresses provided")
}

genFile := config.GenesisFile()
Expand Down
3 changes: 1 addition & 2 deletions cmd/med/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/types/tx"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/gogoproto/proto"
Expand Down Expand Up @@ -80,7 +79,7 @@ func GetDecodeRawTxCommand() *cobra.Command {
} else {
txBz = []byte(args[0])
}
var rawTx tx.TxRaw
var rawTx txtypes.TxRaw
err := json.Unmarshal(txBz, &rawTx)
if err != nil {
return fmt.Errorf("failed to unmarshal raw tx: %w", err)
Expand Down
10 changes: 5 additions & 5 deletions x/dao/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ func (k msgServer) FreeGasAccount(goCtx context.Context, msg *types.MsgFreeGasAc
if isExist {
if account.IsFree {
return nil, sdkerrors.Wrap(types.ErrFreeGasAccountAlreadyExist, account.Address)
} else {
k.RemoveFreeGasAccount(ctx, account.Address)
}

k.RemoveFreeGasAccount(ctx, account.Address)
}

if !isExist {
if account.IsFree {
k.SetFreeGasAccount(ctx, account.Address)
} else {
if !account.IsFree {
return nil, sdkerrors.Wrap(types.ErrAccountIsNotFree, account.Address)
}

k.SetFreeGasAccount(ctx, account.Address)
}
}

Expand Down
3 changes: 2 additions & 1 deletion x/delayedack/types/params.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"errors"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -83,7 +84,7 @@ func validateEpochIdentifier(i interface{}) error {
return fmt.Errorf("invalid parameter type: %T", i)
}
if len(v) == 0 {
return fmt.Errorf("epoch identifier cannot be empty")
return errors.New("epoch identifier cannot be empty")
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions x/denommetadata/ibc_middleware.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package denommetadata

import (
. "slices"
"slices"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -142,7 +142,7 @@ func (im IBCModule) OnAcknowledgementPacket(
return gerrc.ErrNotFound
}

if !Contains(rollapp.RegisteredDenoms, dm.Base) {
if !slices.Contains(rollapp.RegisteredDenoms, dm.Base) {
// add the new token denom base to the list of rollapp's registered denoms
rollapp.RegisteredDenoms = append(rollapp.RegisteredDenoms, dm.Base)

Expand Down Expand Up @@ -215,7 +215,7 @@ func (m *ICS4Wrapper) SendPacket(
// At the first match, we assume that the rollapp already contains the metadata.
// It would be technically possible to have a race condition where the denom metadata is added to the rollapp
// from another packet before this packet is acknowledged.
if Contains(rollapp.RegisteredDenoms, packet.Denom) {
if slices.Contains(rollapp.RegisteredDenoms, packet.Denom) {
return m.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
}

Expand Down
3 changes: 2 additions & 1 deletion x/kyc/keeper/did.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"errors"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -44,7 +45,7 @@ func (k Keeper) SetKycIssers(ctx sdk.Context, oldDaoAddress, newDaoAddress []str

service, ok := k.GetService(ctx)
if !ok {
return fmt.Errorf("kyc service not found")
return errors.New("kyc service not found")
}

dids := []string{}
Expand Down
3 changes: 2 additions & 1 deletion x/kyc/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"errors"
"fmt"

"github.com/cometbft/cometbft/libs/log"
Expand Down Expand Up @@ -63,7 +64,7 @@ func (k *Keeper) MustAccAddressFromPubkeyString(s string) (sdk.AccAddress, error
}
return sdk.AccAddress(pk.Address()), nil
}
return sdk.AccAddress{}, fmt.Errorf("pubkey is empty")
return sdk.AccAddress{}, errors.New("pubkey is empty")
}

func (k *Keeper) RegisterEventHandler(eventType string, priority int, module string, handler handler.HandlerFunc) {
Expand Down
3 changes: 2 additions & 1 deletion x/sequencer/keeper/grpc_query_sequencers_by_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"errors"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
sed -n '1,140p' x/sequencer/keeper/grpc_query_sequencers_by_rollapp.go
rg -n 'UnConfirmSequencerAddressByRollappByStatus|errors\.New\("unsupport function"\)|status\.Error|codes\.Unimplemented' x/sequencer/keeper/grpc_query_sequencers_by_rollapp.go

Repository: openmetaearth/me-hub

Length of output: 5008


Return codes.Unimplemented from this handler. errors.New("unsupport function") is a generic error and will surface to clients as Unknown; use status.Error(codes.Unimplemented, "unsupported function") instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@x/sequencer/keeper/grpc_query_sequencers_by_rollapp.go` at line 5, The gRPC
handler in sequencersByRollapp should not return a generic error; replace the
current errors.New("unsupport function") return in the query handler with a
status error using codes.Unimplemented so clients receive the correct gRPC
status. Update the grpc_query_sequencers_by_rollapp.go handler to use
status.Error(codes.Unimplemented, "unsupported function") and ensure the needed
gRPC status/codes imports are present while removing the unused errors import.

Source: Path instructions

"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -87,7 +88,7 @@ func (k Keeper) UnConfirmSequencerAddressByRollappByStatus(goCtx context.Context
"cacheHeight", k.replaceSequencerCacheHeight)
}
*/
return nil, fmt.Errorf("unsupport function")
return nil, errors.New("unsupport function")
}

func (k Keeper) ReplaceProposerInfo(goCtx context.Context, req *types.QueryReplaceProposerInfoRequest) (*types.QueryReplaceProposerInfoResponse, error) {
Expand Down
7 changes: 4 additions & 3 deletions x/sequencer/keeper/replace_proposer.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package keeper

import (
"errors"
"fmt"

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

rollappTypes "github.com/openmetaearth/me-hub/x/rollapp/types"
rollapptypes "github.com/openmetaearth/me-hub/x/rollapp/types"
"github.com/openmetaearth/me-hub/x/sequencer/types"
)

func (k Keeper) SetReplaceProposer(ctx sdk.Context, data *types.MsgRepalceProposer) error {
if nil == data {
return fmt.Errorf("SetReplaceProposer data is nil")
return errors.New("SetReplaceProposer data is nil")
}
store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{})
val := store.Get(types.RepalceRollappProposerKey(data.RollappId))
Expand Down Expand Up @@ -93,7 +94,7 @@ func (k Keeper) IsReplacedSequencerAddress(ctx sdk.Context, rollappId, addr stri

*/

func (k Keeper) ProcSequencerByPendingStates(ctx sdk.Context, rollappId, creator string, rollappState *rollappTypes.StateInfo) error {
func (k Keeper) ProcSequencerByPendingStates(ctx sdk.Context, rollappId, creator string, rollappState *rollapptypes.StateInfo) error {
val, err := k.GetReplaceProposer(ctx, rollappId)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion x/sequencer/simulation/create_sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func SimulateMsgCreateSequencer(
for _, item := range simulation.GlobalSequencerAddressesList {
// check how many sequencers already attached to this rollapp
if item.RollappIndex == rollappIndex {
rollappSeqNum += 1
rollappSeqNum++
}
// check if we already created it
if item.Account.Address.String() == seqAddress {
Expand Down
7 changes: 5 additions & 2 deletions x/sequencer/types/genesis.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package types

import "fmt"
import (
"errors"
"fmt"
)

// DefaultGenesis returns the default Capability genesis state
func DefaultGenesis() *GenesisState {
Expand All @@ -25,7 +28,7 @@ func (gs GenesisState) Validate() error {

index := string(SequencerKey(elem.SequencerAddress))
if _, ok := sequencerIndexMap[index]; ok {
return fmt.Errorf("duplicated index for sequencer")
return errors.New("duplicated index for sequencer")
}
sequencerIndexMap[index] = struct{}{}

Expand Down
Loading