codec: Rename codec and marshaler interfaces (#9226)
* codec: Rename codec and marshaler interfaces, ref: 8413 * codec: remove BinaryBare * changelog update * Update comments and documentation * adding doc string comments * Update CHANGELOG.md Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update codec/codec.go Co-authored-by: Marko <marbar3778@yahoo.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
co-authored by
Federico Kunze
Marko
Amaury
parent
c94e9eb1bb
commit
be4a965599
+3
-3
@@ -142,7 +142,7 @@ var (
|
||||
type SimApp struct {
|
||||
*baseapp.BaseApp
|
||||
legacyAmino *codec.LegacyAmino
|
||||
appCodec codec.Marshaler
|
||||
appCodec codec.Codec
|
||||
interfaceRegistry types.InterfaceRegistry
|
||||
|
||||
invCheckPeriod uint
|
||||
@@ -467,7 +467,7 @@ func (app *SimApp) LegacyAmino() *codec.LegacyAmino {
|
||||
//
|
||||
// NOTE: This is solely to be used for testing purposes as it may be desirable
|
||||
// for modules to register their own custom testing types.
|
||||
func (app *SimApp) AppCodec() codec.Marshaler {
|
||||
func (app *SimApp) AppCodec() codec.Codec {
|
||||
return app.appCodec
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ func GetMaccPerms() map[string][]string {
|
||||
}
|
||||
|
||||
// initParamsKeeper init params keeper and its subspaces
|
||||
func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
|
||||
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
|
||||
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
|
||||
|
||||
paramsKeeper.Subspace(authtypes.ModuleName)
|
||||
|
||||
+1
-1
@@ -16,6 +16,6 @@ import (
|
||||
type GenesisState map[string]json.RawMessage
|
||||
|
||||
// NewDefaultGenesisState generates the default state for the application.
|
||||
func NewDefaultGenesisState(cdc codec.JSONMarshaler) GenesisState {
|
||||
func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState {
|
||||
return ModuleBasics.DefaultGenesis(cdc)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
// This is provided for compatibility between protobuf and amino implementations.
|
||||
type EncodingConfig struct {
|
||||
InterfaceRegistry types.InterfaceRegistry
|
||||
Marshaler codec.Marshaler
|
||||
Marshaler codec.Codec
|
||||
TxConfig client.TxConfig
|
||||
Amino *codec.LegacyAmino
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
depCdc := clientCtx.JSONMarshaler
|
||||
cdc := depCdc.(codec.Marshaler)
|
||||
cdc := depCdc.(codec.Codec)
|
||||
|
||||
serverCtx := server.GetServerContextFromCmd(cmd)
|
||||
config := serverCtx.Config
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ import (
|
||||
// AppStateFn returns the initial application state using a genesis or the simulation parameters.
|
||||
// It panics if the user provides files for both of them.
|
||||
// If a file is not given for the genesis or the sim params, it creates a randomized one.
|
||||
func AppStateFn(cdc codec.JSONMarshaler, simManager *module.SimulationManager) simtypes.AppStateFn {
|
||||
func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn {
|
||||
return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config,
|
||||
) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) {
|
||||
|
||||
@@ -129,7 +129,7 @@ func AppStateFn(cdc codec.JSONMarshaler, simManager *module.SimulationManager) s
|
||||
// AppStateRandomizedFn creates calls each module's GenesisState generator function
|
||||
// and creates the simulation params
|
||||
func AppStateRandomizedFn(
|
||||
simManager *module.SimulationManager, r *rand.Rand, cdc codec.JSONMarshaler,
|
||||
simManager *module.SimulationManager, r *rand.Rand, cdc codec.JSONCodec,
|
||||
accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams,
|
||||
) (json.RawMessage, []simtypes.Account) {
|
||||
numAccs := int64(len(accs))
|
||||
@@ -183,7 +183,7 @@ func AppStateRandomizedFn(
|
||||
|
||||
// AppStateFromGenesisFileFn util function to generate the genesis AppState
|
||||
// from a genesis.json file.
|
||||
func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONMarshaler, genesisFile string) (tmtypes.GenesisDoc, []simtypes.Account) {
|
||||
func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile string) (tmtypes.GenesisDoc, []simtypes.Account) {
|
||||
bytes, err := ioutil.ReadFile(genesisFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string,
|
||||
|
||||
// SimulationOperations retrieves the simulation params from the provided file path
|
||||
// and returns all the modules weighted operations
|
||||
func SimulationOperations(app App, cdc codec.JSONMarshaler, config simtypes.Config) []simtypes.WeightedOperation {
|
||||
func SimulationOperations(app App, cdc codec.JSONCodec, config simtypes.Config) []simtypes.WeightedOperation {
|
||||
simState := module.SimulationState{
|
||||
AppParams: make(simtypes.AppParams),
|
||||
Cdc: cdc,
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestGetSimulationLog(t *testing.T) {
|
||||
},
|
||||
{
|
||||
authtypes.StoreKey,
|
||||
[]kv.Pair{{Key: authtypes.GlobalAccountNumberKey, Value: cdc.MustMarshalBinaryBare(uint64(10))}},
|
||||
[]kv.Pair{{Key: authtypes.GlobalAccountNumberKey, Value: cdc.MustMarshal(uint64(10))}},
|
||||
"10",
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user