Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(x/gov, x/authz): use cosmossdk.io/core/codec instead of github.com/cosmos/cosmos-sdk/codec #23292

Merged
merged 14 commits into from
Jan 13, 2025
2 changes: 1 addition & 1 deletion x/authz/migrations/v2/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"

"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/store/prefix"
"cosmossdk.io/x/authz"
"cosmossdk.io/x/authz/internal/conv"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/runtime"
)

Expand Down
8 changes: 6 additions & 2 deletions x/authz/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"

"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/core/registry"
"cosmossdk.io/errors"
"cosmossdk.io/x/authz"
Expand All @@ -18,7 +19,6 @@ import (
"cosmossdk.io/x/authz/simulation"

sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/simsx"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -110,7 +110,11 @@ func (AppModule) GetTxCmd() *cobra.Command {

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

// ValidateGenesis performs genesis state validation for the authz module.
Expand Down
18 changes: 13 additions & 5 deletions x/authz/simulation/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"bytes"
"fmt"

"cosmossdk.io/core/codec"
"cosmossdk.io/x/authz"
"cosmossdk.io/x/authz/keeper"

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

Expand All @@ -18,13 +18,21 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
switch {
case bytes.Equal(kvA.Key[:1], keeper.GrantKey):
var grantA, grantB authz.Grant
cdc.MustUnmarshal(kvA.Value, &grantA)
cdc.MustUnmarshal(kvB.Value, &grantB)
if err := cdc.Unmarshal(kvA.Value, &grantA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &grantB); err != nil {
panic(err)
}
return fmt.Sprintf("%v\n%v", grantA, grantB)
case bytes.Equal(kvA.Key[:1], keeper.GrantQueuePrefix):
var grantA, grantB authz.GrantQueueItem
cdc.MustUnmarshal(kvA.Value, &grantA)
cdc.MustUnmarshal(kvB.Value, &grantB)
if err := cdc.Unmarshal(kvA.Value, &grantA); err != nil {
panic(err)
}
if err := cdc.Unmarshal(kvB.Value, &grantB); err != nil {
panic(err)
}
return fmt.Sprintf("%v\n%v", grantA, grantB)
default:
panic(fmt.Sprintf("invalid authz key %X", kvA.Key))
Expand Down
3 changes: 1 addition & 2 deletions x/gov/migrations/v5/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"context"

"cosmossdk.io/collections"
"cosmossdk.io/core/codec"
corestoretypes "cosmossdk.io/core/store"
govv1 "cosmossdk.io/x/gov/types/v1"

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

var (
Expand Down
8 changes: 6 additions & 2 deletions x/gov/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"google.golang.org/grpc"

"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/codec"
"cosmossdk.io/core/registry"
govclient "cosmossdk.io/x/gov/client"
"cosmossdk.io/x/gov/client/cli"
Expand All @@ -20,7 +21,6 @@ import (
"cosmossdk.io/x/gov/types/v1beta1"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simsx"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
Expand Down Expand Up @@ -157,7 +157,11 @@ func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {

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

// ValidateGenesis performs genesis state validation for the gov module.
Expand Down
Loading