chore(x/): use cosmossdk.io/core/codec instead of github.com/cosmos/cosmos-sdk/codec (#23313)
This commit is contained in:
parent
e4d50b07da
commit
bc9ce394cb
@ -9,6 +9,7 @@ import (
|
||||
signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
|
||||
"cosmossdk.io/collections"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/event"
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/core/store"
|
||||
@ -17,7 +18,6 @@ import (
|
||||
accountsv1 "cosmossdk.io/x/accounts/v1"
|
||||
"cosmossdk.io/x/tx/signing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
|
||||
@ -9,9 +9,8 @@ import (
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/transaction"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// Dependencies are passed to the constructor of a smart account.
|
||||
|
||||
@ -9,12 +9,12 @@ import (
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/schema"
|
||||
"cosmossdk.io/x/accounts/cli"
|
||||
v1 "cosmossdk.io/x/accounts/v1"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
)
|
||||
@ -66,7 +66,11 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
|
||||
// App module genesis
|
||||
|
||||
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||
return am.cdc.MustMarshalJSON(&v1.GenesisState{})
|
||||
data, err := am.cdc.MarshalJSON(&v1.GenesisState{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (am AppModule) ValidateGenesis(message json.RawMessage) error {
|
||||
|
||||
@ -5,7 +5,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"cosmossdk.io/core/codec"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -101,7 +102,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
|
||||
|
||||
@ -8,12 +8,11 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/bank/v2/client/cli"
|
||||
"cosmossdk.io/x/bank/v2/keeper"
|
||||
"cosmossdk.io/x/bank/v2/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// ConsensusVersion defines the current x/bank/v2 module consensus version.
|
||||
@ -58,7 +57,11 @@ func (AppModule) RegisterInterfaces(registrar registry.InterfaceRegistrar) {
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the bank 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 bank module.
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/core/transaction"
|
||||
"cosmossdk.io/schema"
|
||||
@ -19,7 +20,6 @@ import (
|
||||
"cosmossdk.io/x/circuit/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
)
|
||||
|
||||
@ -81,7 +81,11 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the circuit 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 circuit module.
|
||||
|
||||
@ -9,13 +9,13 @@ import (
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/schema"
|
||||
"cosmossdk.io/x/consensus/keeper"
|
||||
"cosmossdk.io/x/consensus/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
)
|
||||
|
||||
|
||||
@ -7,9 +7,9 @@ import (
|
||||
gogotypes "github.com/cosmos/gogoproto/types"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/store"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -46,6 +46,9 @@ func GetPreviousProposerConsAddr(ctx context.Context, storeService store.KVStore
|
||||
// SetPreviousProposerConsAddr set the proposer public key for this block.
|
||||
func SetPreviousProposerConsAddr(ctx context.Context, storeService store.KVStoreService, cdc codec.BinaryCodec, consAddr sdk.ConsAddress) error {
|
||||
kvStore := storeService.OpenKVStore(ctx)
|
||||
bz := cdc.MustMarshal(&gogotypes.BytesValue{Value: consAddr})
|
||||
bz, err := cdc.Marshal(&gogotypes.BytesValue{Value: consAddr})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return kvStore.Set(OldProposerKey, bz)
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/schema"
|
||||
"cosmossdk.io/x/distribution/client/cli"
|
||||
@ -19,7 +20,6 @@ import (
|
||||
"cosmossdk.io/x/distribution/types"
|
||||
|
||||
sdkclient "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"
|
||||
@ -115,7 +115,11 @@ func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the distribution 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 distribution module.
|
||||
|
||||
@ -4,9 +4,9 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/x/distribution/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
)
|
||||
@ -18,14 +18,22 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
|
||||
switch {
|
||||
case bytes.Equal(kvA.Key[:1], types.FeePoolKey):
|
||||
var feePoolA, feePoolB types.FeePool
|
||||
cdc.MustUnmarshal(kvA.Value, &feePoolA)
|
||||
cdc.MustUnmarshal(kvB.Value, &feePoolB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &feePoolA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &feePoolB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", feePoolA, feePoolB)
|
||||
|
||||
case bytes.Equal(kvA.Key[:1], types.ValidatorOutstandingRewardsPrefix):
|
||||
var rewardsA, rewardsB types.ValidatorOutstandingRewards
|
||||
cdc.MustUnmarshal(kvA.Value, &rewardsA)
|
||||
cdc.MustUnmarshal(kvB.Value, &rewardsB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &rewardsA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &rewardsB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", rewardsA, rewardsB)
|
||||
|
||||
case bytes.Equal(kvA.Key[:1], types.DelegatorWithdrawAddrPrefix):
|
||||
@ -33,32 +41,52 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
|
||||
|
||||
case bytes.Equal(kvA.Key[:1], types.DelegatorStartingInfoPrefix):
|
||||
var infoA, infoB types.DelegatorStartingInfo
|
||||
cdc.MustUnmarshal(kvA.Value, &infoA)
|
||||
cdc.MustUnmarshal(kvB.Value, &infoB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &infoA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &infoB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", infoA, infoB)
|
||||
|
||||
case bytes.Equal(kvA.Key[:1], types.ValidatorHistoricalRewardsPrefix):
|
||||
var rewardsA, rewardsB types.ValidatorHistoricalRewards
|
||||
cdc.MustUnmarshal(kvA.Value, &rewardsA)
|
||||
cdc.MustUnmarshal(kvB.Value, &rewardsB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &rewardsA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &rewardsB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", rewardsA, rewardsB)
|
||||
|
||||
case bytes.Equal(kvA.Key[:1], types.ValidatorCurrentRewardsPrefix):
|
||||
var rewardsA, rewardsB types.ValidatorCurrentRewards
|
||||
cdc.MustUnmarshal(kvA.Value, &rewardsA)
|
||||
cdc.MustUnmarshal(kvB.Value, &rewardsB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &rewardsA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &rewardsB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", rewardsA, rewardsB)
|
||||
|
||||
case bytes.Equal(kvA.Key[:1], types.ValidatorAccumulatedCommissionPrefix):
|
||||
var commissionA, commissionB types.ValidatorAccumulatedCommission
|
||||
cdc.MustUnmarshal(kvA.Value, &commissionA)
|
||||
cdc.MustUnmarshal(kvB.Value, &commissionB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &commissionA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &commissionB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", commissionA, commissionB)
|
||||
|
||||
case bytes.Equal(kvA.Key[:1], types.ValidatorSlashEventPrefix):
|
||||
var eventA, eventB types.ValidatorSlashEvent
|
||||
cdc.MustUnmarshal(kvA.Value, &eventA)
|
||||
cdc.MustUnmarshal(kvB.Value, &eventB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &eventA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &eventB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", eventA, eventB)
|
||||
|
||||
default:
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/schema"
|
||||
"cosmossdk.io/x/epochs/keeper"
|
||||
@ -17,7 +18,6 @@ import (
|
||||
"cosmossdk.io/x/epochs/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
@ -75,7 +75,11 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
|
||||
|
||||
// DefaultGenesis returns the epochs module's default genesis state.
|
||||
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||
return am.cdc.MustMarshalJSON(types.DefaultGenesis())
|
||||
data, err := am.cdc.MarshalJSON(types.DefaultGenesis())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the epochs module.
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/comet"
|
||||
"cosmossdk.io/core/registry"
|
||||
eviclient "cosmossdk.io/x/evidence/client"
|
||||
@ -19,7 +20,6 @@ import (
|
||||
"cosmossdk.io/x/evidence/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
@ -100,7 +100,11 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
|
||||
|
||||
// DefaultGenesis returns the evidence module's default genesis state.
|
||||
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 evidence module.
|
||||
|
||||
@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/store"
|
||||
"cosmossdk.io/store/prefix"
|
||||
"cosmossdk.io/x/feegrant"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
)
|
||||
|
||||
|
||||
@ -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/feegrant"
|
||||
@ -17,7 +18,6 @@ import (
|
||||
"cosmossdk.io/x/feegrant/keeper"
|
||||
|
||||
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/types/module"
|
||||
)
|
||||
@ -103,7 +103,11 @@ func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the feegrant module.
|
||||
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||
return am.cdc.MustMarshalJSON(feegrant.DefaultGenesisState())
|
||||
data, err := am.cdc.MarshalJSON(feegrant.DefaultGenesisState())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the feegrant module.
|
||||
|
||||
@ -4,9 +4,9 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/x/feegrant"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
)
|
||||
|
||||
@ -17,8 +17,12 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
|
||||
switch {
|
||||
case bytes.Equal(kvA.Key[:1], feegrant.FeeAllowanceKeyPrefix):
|
||||
var grantA, grantB feegrant.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)
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid feegrant key %X", kvA.Key))
|
||||
|
||||
@ -3,11 +3,11 @@ package genutil
|
||||
import (
|
||||
modulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/depinject/appconfig"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
|
||||
|
||||
@ -7,9 +7,9 @@ import (
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
appmodulev2 "cosmossdk.io/core/appmodule/v2"
|
||||
"cosmossdk.io/core/codec"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
)
|
||||
@ -62,7 +62,11 @@ func (AppModule) Name() string {
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the genutil 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 genutil module.
|
||||
@ -79,7 +83,9 @@ func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
|
||||
// InitGenesis is skipped in a server/v2 application as DecodeGenesisJSON takes precedence.
|
||||
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) ([]module.ValidatorUpdate, error) {
|
||||
var genesisState types.GenesisState
|
||||
am.cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
if err := am.cdc.UnmarshalJSON(data, &genesisState); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig)
|
||||
}
|
||||
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
stakingtypes "cosmossdk.io/x/staking/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -47,7 +47,9 @@ func NewGenesisStateFromTx(txJSONEncoder sdk.TxEncoder, genTxs []sdk.Tx) *Genesi
|
||||
func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *GenesisState {
|
||||
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
|
||||
}
|
||||
@ -56,7 +58,10 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R
|
||||
func SetGenesisStateInAppState(
|
||||
cdc codec.JSONCodec, appState map[string]json.RawMessage, genesisState *GenesisState,
|
||||
) map[string]json.RawMessage {
|
||||
genesisStateBz := cdc.MustMarshalJSON(genesisState)
|
||||
genesisStateBz, err := cdc.MarshalJSON(genesisState)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
appState[ModuleName] = genesisStateBz
|
||||
return appState
|
||||
}
|
||||
|
||||
@ -9,12 +9,12 @@ import (
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
storetypes "cosmossdk.io/core/store"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/group/errors"
|
||||
"cosmossdk.io/x/group/internal/orm/prefixstore"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
)
|
||||
|
||||
@ -4,16 +4,17 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/group"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the group module's genesis state.
|
||||
func (k Keeper) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) error {
|
||||
var genesisState group.GenesisState
|
||||
cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
if err := cdc.UnmarshalJSON(data, &genesisState); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
store := k.KVStoreService.OpenKVStore(ctx)
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/group"
|
||||
"cosmossdk.io/x/group/client/cli"
|
||||
@ -17,7 +18,6 @@ import (
|
||||
"cosmossdk.io/x/group/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"
|
||||
@ -118,7 +118,11 @@ func (am AppModule) EndBlock(ctx context.Context) error {
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the group module.
|
||||
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||
return am.cdc.MustMarshalJSON(group.NewGenesisState())
|
||||
data, err := am.cdc.MarshalJSON(group.NewGenesisState())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the group module.
|
||||
|
||||
@ -4,10 +4,10 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/x/group"
|
||||
"cosmossdk.io/x/group/keeper"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
)
|
||||
|
||||
@ -19,36 +19,56 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
|
||||
case bytes.Equal(kvA.Key[:1], []byte{keeper.GroupTablePrefix}):
|
||||
var groupA, groupB group.GroupInfo
|
||||
|
||||
cdc.MustUnmarshal(kvA.Value, &groupA)
|
||||
cdc.MustUnmarshal(kvB.Value, &groupB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &groupA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &groupB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v\n%v", groupA, groupB)
|
||||
case bytes.Equal(kvA.Key[:1], []byte{keeper.GroupMemberTablePrefix}):
|
||||
var memberA, memberB group.GroupMember
|
||||
|
||||
cdc.MustUnmarshal(kvA.Value, &memberA)
|
||||
cdc.MustUnmarshal(kvB.Value, &memberB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &memberA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &memberB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v\n%v", memberA, memberB)
|
||||
case bytes.Equal(kvA.Key[:1], []byte{keeper.GroupPolicyTablePrefix}):
|
||||
var accA, accB group.GroupPolicyInfo
|
||||
|
||||
cdc.MustUnmarshal(kvA.Value, &accA)
|
||||
cdc.MustUnmarshal(kvB.Value, &accB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &accA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &accB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v\n%v", accA, accB)
|
||||
case bytes.Equal(kvA.Key[:1], []byte{keeper.ProposalTablePrefix}):
|
||||
var propA, propB group.Proposal
|
||||
|
||||
cdc.MustUnmarshal(kvA.Value, &propA)
|
||||
cdc.MustUnmarshal(kvB.Value, &propB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &propA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &propB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v\n%v", propA, propB)
|
||||
case bytes.Equal(kvA.Key[:1], []byte{keeper.VoteTablePrefix}):
|
||||
var voteA, voteB group.Vote
|
||||
|
||||
cdc.MustUnmarshal(kvA.Value, &voteA)
|
||||
cdc.MustUnmarshal(kvB.Value, &voteB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &voteA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &voteB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v\n%v", voteA, voteB)
|
||||
default:
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/schema"
|
||||
"cosmossdk.io/x/mint/keeper"
|
||||
@ -17,7 +18,6 @@ import (
|
||||
"cosmossdk.io/x/mint/types"
|
||||
|
||||
"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"
|
||||
@ -110,7 +110,11 @@ func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error {
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the mint 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 mint module.
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/errors"
|
||||
"cosmossdk.io/x/nft"
|
||||
@ -15,7 +16,6 @@ import (
|
||||
"cosmossdk.io/x/nft/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"
|
||||
@ -85,7 +85,11 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *gwr
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the nft module.
|
||||
func (am AppModule) DefaultGenesis() json.RawMessage {
|
||||
return am.cdc.MustMarshalJSON(nft.DefaultGenesisState())
|
||||
data, err := am.cdc.MarshalJSON(nft.DefaultGenesisState())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the nft module.
|
||||
|
||||
@ -4,10 +4,10 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/x/nft"
|
||||
"cosmossdk.io/x/nft/keeper"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
)
|
||||
@ -19,13 +19,21 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
|
||||
switch {
|
||||
case bytes.Equal(kvA.Key[:1], keeper.ClassKey):
|
||||
var classA, classB nft.Class
|
||||
cdc.MustUnmarshal(kvA.Value, &classA)
|
||||
cdc.MustUnmarshal(kvB.Value, &classB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &classA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &classB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", classA, classB)
|
||||
case bytes.Equal(kvA.Key[:1], keeper.NFTKey):
|
||||
var nftA, nftB nft.NFT
|
||||
cdc.MustUnmarshal(kvA.Value, &nftA)
|
||||
cdc.MustUnmarshal(kvB.Value, &nftB)
|
||||
if err := cdc.Unmarshal(kvA.Value, &nftA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, &nftB); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return fmt.Sprintf("%v\n%v", nftA, nftB)
|
||||
case bytes.Equal(kvA.Key[:1], keeper.NFTOfClassByOwnerKey):
|
||||
return fmt.Sprintf("%v\n%v", kvA.Value, kvB.Value)
|
||||
|
||||
@ -9,12 +9,12 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/x/protocolpool/keeper"
|
||||
"cosmossdk.io/x/protocolpool/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
)
|
||||
|
||||
@ -80,7 +80,11 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the protocolpool 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 protocolpool module.
|
||||
|
||||
@ -7,11 +7,11 @@ import (
|
||||
gogotypes "github.com/cosmos/gogoproto/types"
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/errors"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/slashing/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -74,7 +74,9 @@ func iterateValidatorSigningInfos(
|
||||
for ; iter.Valid(); iter.Next() {
|
||||
addr := ValidatorSigningInfoAddress(iter.Key())
|
||||
var info types.ValidatorSigningInfo
|
||||
cdc.MustUnmarshal(iter.Value(), &info)
|
||||
if err := cdc.Unmarshal(iter.Value(), &info); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if cb(addr, info) {
|
||||
break
|
||||
@ -97,7 +99,9 @@ func iterateValidatorMissedBlockBitArray(
|
||||
continue
|
||||
}
|
||||
|
||||
cdc.MustUnmarshal(bz, &missed)
|
||||
if err := cdc.Unmarshal(bz, &missed); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if cb(i, missed.Value) {
|
||||
break
|
||||
}
|
||||
|
||||
@ -5,11 +5,10 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/log"
|
||||
"cosmossdk.io/store/prefix"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
func migrateDelegationsByValidatorIndex(store storetypes.KVStore) error {
|
||||
|
||||
@ -3,9 +3,8 @@ package v6
|
||||
import (
|
||||
"context"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// MigrateStore performs in-place store migrations from v5 to v6.
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"cosmossdk.io/collections"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/core/registry"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/schema"
|
||||
@ -19,7 +20,6 @@ import (
|
||||
"cosmossdk.io/x/staking/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
)
|
||||
|
||||
@ -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.
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -4,10 +4,10 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/math"
|
||||
"cosmossdk.io/x/staking/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
)
|
||||
@ -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),
|
||||
@ -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, ¶msA)
|
||||
cdc.MustUnmarshal(kvB.Value, ¶msB)
|
||||
if err := cdc.Unmarshal(kvA.Value, ¶msA); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := cdc.Unmarshal(kvB.Value, ¶msB); 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:
|
||||
|
||||
@ -6,9 +6,9 @@ import (
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@ -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.
|
||||
@ -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
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -12,10 +12,10 @@ import (
|
||||
|
||||
"cosmossdk.io/core/address"
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/core/codec"
|
||||
"cosmossdk.io/errors"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user