Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress {
// start at 100 so we can make up to 999 test addresses with valid test addresses
for i := 100; i < (accNum + 100); i++ {
numString := strconv.Itoa(i)
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string
_, _ = buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string

buffer.WriteString(numString) // adding on final two digits to make addresses unique
_, _ = buffer.WriteString(numString) // adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHexUnsafe(buffer.String())
bech := res.String()
addr, _ := TestAddr(buffer.String(), bech)
Expand Down Expand Up @@ -555,8 +555,8 @@ func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey {
// start at 10 to avoid changing 1 to 01, 2 to 02, etc
for i := 100; i < (numPubKeys + 100); i++ {
numString := strconv.Itoa(i)
buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string
buffer.WriteString(numString) // adding on final two digits to make pubkeys unique
_, _ = buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string
_, _ = buffer.WriteString(numString) // adding on final two digits to make pubkeys unique
publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String()))
buffer.Reset()
}
Expand Down
4 changes: 2 additions & 2 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
didtypes "github.com/openmetaearth/me-hub/x/did/types"
eibcmoduletypes "github.com/openmetaearth/me-hub/x/eibc/types"
kyctypes "github.com/openmetaearth/me-hub/x/kyc/types"
gourpTypes "github.com/openmetaearth/me-hub/x/megroup/types"
grouptypes "github.com/openmetaearth/me-hub/x/megroup/types"
rollappmoduletypes "github.com/openmetaearth/me-hub/x/rollapp/types"
sequencermoduletypes "github.com/openmetaearth/me-hub/x/sequencer/types"
trontypes "github.com/openmetaearth/me-hub/x/tron/types"
Expand Down Expand Up @@ -127,7 +127,7 @@ var KVStoreKeys = sdk.NewKVStoreKeys(
nftkeeper.StoreKey,
wasmtypes.StoreKey,
// megroup
gourpTypes.StoreKey,
grouptypes.StoreKey,
// gravity bridge
bsctypes.StoreKey,
trontypes.StoreKey,
Expand Down
2 changes: 1 addition & 1 deletion app/keepers/wasm_me_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func EncodeMeMsg(sender sdk.AccAddress, msg *MeMsg) ([]sdk.Msg, error) {
return nil, err
}

var outputs []banktypes.Output
outputs := make([]banktypes.Output, 0, len(msg.MultiSend.Output))
for _, o := range msg.MultiSend.Output {
amt, err := wasmkeeper.ConvertWasmCoinsToSdkCoins(o.Amount)
if err != nil {
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
1 change: 0 additions & 1 deletion cmd/med/cmd/genmoduleaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
// Add the new account to the set of genesis accounts and sanitize the
// accounts afterwards.
accs = append(accs, genAccount)

}
accs = authtypes.SanitizeGenesisAccounts(accs)

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
12 changes: 6 additions & 6 deletions x/kyc/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (
"github.com/openmetaearth/me-hub/x/kyc/types"
"github.com/openmetaearth/me-hub/x/wdistri"
"github.com/openmetaearth/me-hub/x/wmint"
wmintTypes "github.com/openmetaearth/me-hub/x/wmint/types"
wminttypes "github.com/openmetaearth/me-hub/x/wmint/types"
wstakingtypes "github.com/openmetaearth/me-hub/x/wstaking/types"
)

func (s *KeeperTestSuite) TestProtocol() {
s.SetupTest()

s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
wmint.BeginBlocker(s.Ctx, s.App.MintKeeper, nil)
wdistri.EndBlock(s.Ctx, abci.RequestEndBlock{Height: s.Ctx.BlockHeight()}, *s.App.DistrKeeper)

Expand All @@ -36,7 +36,7 @@ func (s *KeeperTestSuite) TestProtocol() {
func (s *KeeperTestSuite) TestDID() {
s.SetupTest()

s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
wmint.BeginBlocker(s.Ctx, s.App.MintKeeper, nil)
wdistri.EndBlock(s.Ctx, abci.RequestEndBlock{Height: s.Ctx.BlockHeight()}, *s.App.DistrKeeper)

Expand Down Expand Up @@ -71,7 +71,7 @@ func (s *KeeperTestSuite) TestDID() {
func (s *KeeperTestSuite) TestDIDs() {
s.SetupTest()

s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
wmint.BeginBlocker(s.Ctx, s.App.MintKeeper, nil)
wdistri.EndBlock(s.Ctx, abci.RequestEndBlock{Height: s.Ctx.BlockHeight()}, *s.App.DistrKeeper)

Expand Down Expand Up @@ -108,7 +108,7 @@ func (s *KeeperTestSuite) TestDIDs() {
func (s *KeeperTestSuite) TestKYC() {
s.SetupTest()

s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
wmint.BeginBlocker(s.Ctx, s.App.MintKeeper, nil)
wdistri.EndBlock(s.Ctx, abci.RequestEndBlock{Height: s.Ctx.BlockHeight()}, *s.App.DistrKeeper)

Expand Down Expand Up @@ -144,7 +144,7 @@ func (s *KeeperTestSuite) TestKYC() {
func (s *KeeperTestSuite) TestKYCs() {
s.SetupTest()

s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
wmint.BeginBlocker(s.Ctx, s.App.MintKeeper, nil)
wdistri.EndBlock(s.Ctx, abci.RequestEndBlock{Height: s.Ctx.BlockHeight()}, *s.App.DistrKeeper)

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
12 changes: 6 additions & 6 deletions x/kyc/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/openmetaearth/me-hub/x/kyc/types"
"github.com/openmetaearth/me-hub/x/wdistri"
"github.com/openmetaearth/me-hub/x/wmint"
wmintTypes "github.com/openmetaearth/me-hub/x/wmint/types"
wminttypes "github.com/openmetaearth/me-hub/x/wmint/types"
wstakingtypes "github.com/openmetaearth/me-hub/x/wstaking/types"
)

func (s *KeeperTestSuite) TestApprove() {
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
wmint.BeginBlocker(s.Ctx, s.App.MintKeeper, nil)
wdistri.EndBlock(s.Ctx, abci.RequestEndBlock{Height: s.Ctx.BlockHeight()}, *s.App.DistrKeeper)

Expand Down Expand Up @@ -65,7 +65,7 @@ func (s *KeeperTestSuite) TestApprove() {
func (s *KeeperTestSuite) TestRemove() {
s.SetupTest()

s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
wmint.BeginBlocker(s.Ctx, s.App.MintKeeper, nil)
wdistri.EndBlock(s.Ctx, abci.RequestEndBlock{Height: s.Ctx.BlockHeight()}, *s.App.DistrKeeper)

Expand Down Expand Up @@ -119,7 +119,7 @@ func (s *KeeperTestSuite) TestRemove() {
func (s *KeeperTestSuite) TestUpdate() {
s.SetupTest()

s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks).WithChainID(apptesting.TestChainID)
wmint.BeginBlocker(s.Ctx, s.App.MintKeeper, nil)
wdistri.EndBlock(s.Ctx, abci.RequestEndBlock{Height: s.Ctx.BlockHeight()}, *s.App.DistrKeeper)

Expand Down Expand Up @@ -153,7 +153,7 @@ func (s *KeeperTestSuite) TestUpdate() {
s.Require().Equal(delegation.Unmovable.String(), wstakingtypes.Bonus.String())
s.Require().Equal(delegation.ValidatorAddress, s.meEarthValidator.OperatorAddress)

s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wmintTypes.OneDayTotalBlocks + 1).WithChainID(apptesting.TestChainID)
s.Ctx = s.App.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(wminttypes.OneDayTotalBlocks + 1).WithChainID(apptesting.TestChainID)
// transfer kyc region
_, err = s.msgServer.Update(s.Ctx, &types.MsgUpdate{
Issuer: s.Dao.GlobalDao,
Expand All @@ -168,5 +168,5 @@ func (s *KeeperTestSuite) TestUpdate() {
s.Require().True(f)
s.Require().Equal(delegation.Unmovable.String(), wstakingtypes.Bonus.String())
s.Require().Equal(s.usaValidator.OperatorAddress, delegation.ValidatorAddress)
s.Require().EqualValues(delegation.StartHeight, wmintTypes.OneDayTotalBlocks+1)
s.Require().EqualValues(delegation.StartHeight, wminttypes.OneDayTotalBlocks+1)
}
8 changes: 4 additions & 4 deletions x/megroup/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import (
didtypes "github.com/openmetaearth/me-hub/x/did/types"
"github.com/openmetaearth/me-hub/x/kyc/handler"
bankkeeper "github.com/openmetaearth/me-hub/x/wbank/keeper"
stakingTypes "github.com/openmetaearth/me-hub/x/wstaking/types"
wstakingtypes "github.com/openmetaearth/me-hub/x/wstaking/types"
)

type StakingKeeper interface {
// Methods imported from staking should be defined here

// FIXME: wait wstaking keep and types.Meid ;Temporarily use MockMeid instead of MEID and MockRegion instead types.Region
// GetMeid(ctx sdk.Context, account string) (val types.Meid, found bool)
GetMeid(ctx sdk.Context, account string) (val stakingTypes.Meid, found bool)
GetMeid(ctx sdk.Context, account string) (val wstakingtypes.Meid, found bool)
// SetMeid(ctx sdk.Context, meid types.Meid)
SetMeid(ctx sdk.Context, meid stakingTypes.Meid)
SetMeid(ctx sdk.Context, meid wstakingtypes.Meid)

// GetRegion(ctx sdk.Context, regionId string) (val types.Region, found bool)
// GetRegion(ctx sdk.Context, regionId string) (val mock.MockRegion, found bool)

GetRegion(ctx sdk.Context, regionId string) (region stakingTypes.Region, found bool)
GetRegion(ctx sdk.Context, regionId string) (region wstakingtypes.Region, found bool)
}

// AccountKeeper defines the expected account keeper used for simulations (noalias)
Expand Down
Loading
Loading