Skip to content
Closed
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
2 changes: 1 addition & 1 deletion x/staking/migrations/v5/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"cosmossdk.io/store/prefix"
storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
)

func migrateDelegationsByValidatorIndex(store storetypes.KVStore) error {
Expand Down
2 changes: 1 addition & 1 deletion x/staking/migrations/v6/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering to match project guidelines.

The imports need to be reordered following the project's guidelines: standard libs, default libs, cosmossdk.io prefixed imports, and github.com/cosmos/cosmos-sdk prefixed imports.

import (
	"context"

-	storetypes "cosmossdk.io/store/types"
-	"cosmossdk.io/core/codec"
+	"cosmossdk.io/core/codec"
+	storetypes "cosmossdk.io/store/types"
)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 golangci-lint (1.62.2)

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

import (
	"context"

	storetypes "cosmossdk.io/store/types"
-	"cosmossdk.io/core/codec"
+
+       "cosmossdk.io/core/codec"
)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 golangci-lint (1.62.2)

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be ordered according to the following pattern:

  • standard
  • default
  • prefix(cosmossdk.io)
  • prefix(github.com/cosmos/cosmos-sdk)
import (
	"context"

	storetypes "cosmossdk.io/store/types"
-	"cosmossdk.io/core/codec"
+
+	"cosmossdk.io/core/codec"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"context"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/core/codec"
)
🧰 Tools
🪛 golangci-lint (1.62.2)

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-8: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

)

// MigrateStore performs in-place store migrations from v5 to v6.
Expand Down
12 changes: 9 additions & 3 deletions x/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"cosmossdk.io/x/staking/keeper"
"cosmossdk.io/x/staking/types"

"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

import (
	"context"
	"encoding/json"
	"fmt"

	gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
	"github.com/spf13/cobra"
	"google.golang.org/grpc"

	"cosmossdk.io/collections"
	"cosmossdk.io/core/appmodule"
+	"cosmossdk.io/core/codec"
	"cosmossdk.io/core/registry"
	"cosmossdk.io/depinject"
	"cosmossdk.io/schema"
	"cosmossdk.io/x/staking/client/cli"
	"cosmossdk.io/x/staking/keeper"
	"cosmossdk.io/x/staking/types"

-	"cosmossdk.io/core/codec"
	"github.com/cosmos/cosmos-sdk/client"
	"github.com/cosmos/cosmos-sdk/types/module"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"context"
"encoding/json"
"fmt"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"cosmossdk.io/collections"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/core/registry"
"cosmossdk.io/depinject"
"cosmossdk.io/schema"
"cosmossdk.io/x/staking/client/cli"
"cosmossdk.io/x/staking/keeper"
"cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types/module"
)
🧰 Tools
🪛 GitHub Actions: Lint

[error] 13-21: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be ordered according to the following pattern:

  • standard
  • default
  • prefix(cosmossdk.io)
  • prefix(github.com/cosmos/cosmos-sdk)
import (
	"context"
	"encoding/json"
	"fmt"

	gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
	"github.com/spf13/cobra"
	"google.golang.org/grpc"

	"cosmossdk.io/collections"
	"cosmossdk.io/core/appmodule"
	"cosmossdk.io/core/registry"
	"cosmossdk.io/depinject"
	"cosmossdk.io/schema"
	"cosmossdk.io/x/staking/client/cli"
	"cosmossdk.io/x/staking/keeper"
	"cosmossdk.io/x/staking/types"
-	"cosmossdk.io/core/codec"
+
+	"cosmossdk.io/core/codec"
	"github.com/cosmos/cosmos-sdk/client"
	"github.com/cosmos/cosmos-sdk/types/module"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"context"
"encoding/json"
"fmt"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"cosmossdk.io/collections"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/registry"
"cosmossdk.io/core/codec"
"cosmossdk.io/depinject"
"cosmossdk.io/schema"
"cosmossdk.io/x/staking/client/cli"
"cosmossdk.io/x/staking/keeper"
"cosmossdk.io/x/staking/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types/module"
)
🧰 Tools
🪛 GitHub Actions: Lint

[error] 13-21: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
)

Expand Down Expand Up @@ -119,7 +119,11 @@ func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {

// DefaultGenesis returns default genesis state as raw bytes for the staking module.
func (am AppModule) DefaultGenesis() json.RawMessage {
return am.cdc.MustMarshalJSON(types.DefaultGenesisState())
data, err := am.cdc.MarshalJSON(types.DefaultGenesisState())
if err != nil {
panic(err)
}
return data
}

// ValidateGenesis performs genesis state validation for the staking module.
Expand All @@ -135,7 +139,9 @@ func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
// InitGenesis performs genesis initialization for the staking module.
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) ([]appmodule.ValidatorUpdate, error) {
var genesisState types.GenesisState
am.cdc.MustUnmarshalJSON(data, &genesisState)
if err := am.cdc.UnmarshalJSON(data, &genesisState); err != nil {
panic(err)
}
return am.keeper.InitGenesis(ctx, &genesisState)
}

Expand Down
58 changes: 43 additions & 15 deletions x/staking/simulation/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"cosmossdk.io/math"
"cosmossdk.io/x/staking/types"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering

The imports need to be reordered according to the project's guidelines:

--skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order
🧰 Tools
🪛 golangci-lint (1.62.2)

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

import (
	"bytes"
	"fmt"

	"cosmossdk.io/math"
	"cosmossdk.io/x/staking/types"
+	"cosmossdk.io/core/codec"

-	"cosmossdk.io/core/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/cosmos/cosmos-sdk/types/kv"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"bytes"
"fmt"
"cosmossdk.io/math"
"cosmossdk.io/x/staking/types"
"cosmossdk.io/core/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
)
🧰 Tools
🪛 golangci-lint (1.62.2)

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be ordered according to the following pattern:

  • standard
  • default
  • prefix(cosmossdk.io)
  • prefix(github.com/cosmos/cosmos-sdk)
import (
	"bytes"
	"fmt"

	"cosmossdk.io/math"
	"cosmossdk.io/x/staking/types"
-	"cosmossdk.io/core/codec"
+
+	"cosmossdk.io/core/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/cosmos/cosmos-sdk/types/kv"
)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 golangci-lint (1.62.2)

10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 6-10: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/kv"
)
Expand All @@ -30,8 +30,12 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
case bytes.Equal(kvA.Key[:1], types.ValidatorsKey):
var validatorA, validatorB types.Validator

cdc.MustUnmarshal(kvA.Value, &validatorA)
cdc.MustUnmarshal(kvB.Value, &validatorB)
if err := cdc.Unmarshal(kvA.Value, &validatorA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &validatorB); err != nil {
panic(err)
}

return fmt.Sprintf("%v\n%v", validatorA, validatorB)
case bytes.Equal(kvA.Key[:1], types.LastValidatorPowerKey),
Expand All @@ -42,45 +46,69 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
case bytes.Equal(kvA.Key[:1], types.DelegationKey):
var delegationA, delegationB types.Delegation

cdc.MustUnmarshal(kvA.Value, &delegationA)
cdc.MustUnmarshal(kvB.Value, &delegationB)
if err := cdc.Unmarshal(kvA.Value, &delegationA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &delegationB); err != nil {
panic(err)
}

return fmt.Sprintf("%v\n%v", delegationA, delegationB)
case bytes.Equal(kvA.Key[:1], types.UnbondingDelegationKey),
bytes.Equal(kvA.Key[:1], types.UnbondingDelegationByValIndexKey):
var ubdA, ubdB types.UnbondingDelegation

cdc.MustUnmarshal(kvA.Value, &ubdA)
cdc.MustUnmarshal(kvB.Value, &ubdB)
if err := cdc.Unmarshal(kvA.Value, &ubdA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &ubdB); err != nil {
panic(err)
}

return fmt.Sprintf("%v\n%v", ubdA, ubdB)
case bytes.Equal(kvA.Key[:1], types.RedelegationKey),
bytes.Equal(kvA.Key[:1], types.RedelegationByValSrcIndexKey):
var redA, redB types.Redelegation

cdc.MustUnmarshal(kvA.Value, &redA)
cdc.MustUnmarshal(kvB.Value, &redB)
if err := cdc.Unmarshal(kvA.Value, &redA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &redB); err != nil {
panic(err)
}

return fmt.Sprintf("%v\n%v", redA, redB)
case bytes.Equal(kvA.Key[:1], types.ParamsKey):
var paramsA, paramsB types.Params

cdc.MustUnmarshal(kvA.Value, &paramsA)
cdc.MustUnmarshal(kvB.Value, &paramsB)
if err := cdc.Unmarshal(kvA.Value, &paramsA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &paramsB); err != nil {
panic(err)
}

return fmt.Sprintf("%v\n%v", paramsA, paramsB)
case bytes.Equal(kvA.Key[:1], types.ValidatorConsPubKeyRotationHistoryKey):
var historyA, historyB types.ConsPubKeyRotationHistory

cdc.MustUnmarshal(kvA.Value, &historyA)
cdc.MustUnmarshal(kvB.Value, &historyB)
if err := cdc.Unmarshal(kvA.Value, &historyA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &historyB); err != nil {
panic(err)
}

return fmt.Sprintf("%v\n%v", historyA, historyB)
case bytes.Equal(kvA.Key[:1], types.ValidatorConsensusKeyRotationRecordQueueKey):
var historyA, historyB types.ValAddrsOfRotatedConsKeys

cdc.MustUnmarshal(kvA.Value, &historyA)
cdc.MustUnmarshal(kvB.Value, &historyB)
if err := cdc.Unmarshal(kvA.Value, &historyA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &historyB); err != nil {
panic(err)
}

return fmt.Sprintf("%v\n%v", historyA, historyB)
default:
Expand Down
20 changes: 16 additions & 4 deletions x/staking/types/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"cosmossdk.io/core/address"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering

The imports need to be reordered according to the project's guidelines:

--skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order
🧰 Tools
🪛 golangci-lint (1.62.2)

8-8: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)


11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

  1. Standard library imports
  2. Third-party imports
  3. cosmossdk.io imports
  4. github.com/cosmos/cosmos-sdk imports
🧰 Tools
🪛 golangci-lint (1.62.2)

11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

 import (
+	"encoding/json"
+	"strings"
+	"time"
+
+	"cosmossdk.io/core/address"
+	"cosmossdk.io/core/codec"
+	"cosmossdk.io/math"
+
+	sdk "github.com/cosmos/cosmos-sdk/types"
 )

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 golangci-lint (1.62.2)

11-11: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 8-11: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

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

Expand All @@ -26,7 +26,11 @@ func NewDelegation(delegatorAddr, validatorAddr string, shares math.LegacyDec) D

// MustMarshalDelegation returns the delegation bytes. Panics if fails
func MustMarshalDelegation(cdc codec.BinaryCodec, delegation Delegation) []byte {
return cdc.MustMarshal(&delegation)
data, err := cdc.Marshal(&delegation)
if err != nil {
panic(err)
}
return data
}

// MustUnmarshalDelegation return the unmarshaled delegation from bytes.
Expand Down Expand Up @@ -143,7 +147,11 @@ func (ubd *UnbondingDelegation) RemoveEntry(i int64) {

// return the unbonding delegation
func MustMarshalUBD(cdc codec.BinaryCodec, ubd UnbondingDelegation) []byte {
return cdc.MustMarshal(&ubd)
data, err := cdc.Marshal(&ubd)
if err != nil {
panic(err)
}
return data
}

// unmarshal a unbonding delegation from a store value
Expand Down Expand Up @@ -234,7 +242,11 @@ func (red *Redelegation) RemoveEntry(i int64) {

// MustMarshalRED returns the Redelegation bytes. Panics if fails.
func MustMarshalRED(cdc codec.BinaryCodec, red Redelegation) []byte {
return cdc.MustMarshal(&red)
data, err := cdc.Marshal(&red)
if err != nil {
panic(err)
}
return data
}

// MustUnmarshalRED unmarshals a redelegation from a store value. Panics if fails.
Expand Down
6 changes: 4 additions & 2 deletions x/staking/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

gogoprotoany "github.com/cosmos/gogoproto/types/any"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
)

// NewGenesisState creates a new GenesisState instance
Expand All @@ -30,7 +30,9 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R
var genesisState GenesisState

if appState[ModuleName] != nil {
cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState)
if err := cdc.UnmarshalJSON(appState[ModuleName], &genesisState); err != nil {
panic(err)
}
}

return &genesisState
Expand Down
8 changes: 6 additions & 2 deletions x/staking/types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"cosmossdk.io/errors"
"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"cosmossdk.io/core/codec"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering to match project guidelines.

The imports need to be reordered following the project's guidelines: standard libs, default libs, cosmossdk.io prefixed imports, and github.com/cosmos/cosmos-sdk prefixed imports.

import (
	"bytes"
	"fmt"
	"net/url"
	"sort"
	"strings"
	"time"

	gogoprotoany "github.com/cosmos/gogoproto/types/any"

	"cosmossdk.io/core/address"
	"cosmossdk.io/core/appmodule"
-	"cosmossdk.io/errors"
-	"cosmossdk.io/math"
-	"cosmossdk.io/core/codec"
+	"cosmossdk.io/core/codec"
+	"cosmossdk.io/errors"
+	"cosmossdk.io/math"
	codectypes "github.com/cosmos/cosmos-sdk/codec/types"
	cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
	sdk "github.com/cosmos/cosmos-sdk/types"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"bytes"
"fmt"
"net/url"
"sort"
"strings"
"time"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/errors"
"cosmossdk.io/math"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
🧰 Tools
🪛 golangci-lint (1.62.2)

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

  1. Standard library imports
  2. Third-party imports
  3. cosmossdk.io imports
  4. github.com/cosmos/cosmos-sdk imports
🧰 Tools
🪛 golangci-lint (1.62.2)

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix import ordering.

The imports need to be reordered according to the project's guidelines:

 import (
+	"bytes"
+	"fmt"
+	"net/url"
+	"sort"
+	"strings"
+	"time"
+
+	gogoprotoany "github.com/cosmos/gogoproto/types/any"
+
+	"cosmossdk.io/core/address"
+	"cosmossdk.io/core/appmodule"
+	"cosmossdk.io/core/codec"
+	"cosmossdk.io/errors"
+	"cosmossdk.io/math"
+
+	codectypes "github.com/cosmos/cosmos-sdk/codec/types"
+	cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
+	sdk "github.com/cosmos/cosmos-sdk/types"
+	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"cosmossdk.io/core/codec"
import (
"bytes"
"fmt"
"net/url"
"sort"
"strings"
"time"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/errors"
"cosmossdk.io/math"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
🧰 Tools
🪛 golangci-lint (1.62.2)

18-18: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

(gci)

🪛 GitHub Actions: Lint

[error] 14-18: File is not properly formatted with gci. Import ordering needs to follow: --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) --custom-order

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -152,7 +152,11 @@ func (v Validators) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error {

// return the redelegation
func MustMarshalValidator(cdc codec.BinaryCodec, validator *Validator) []byte {
return cdc.MustMarshal(validator)
data, err := cdc.Marshal(validator)
if err != nil {
panic(err)
}
return data
}

// unmarshal a redelegation from a store value
Expand Down
Loading