Skip to content

Commit

Permalink
Rename clientCtx.JSONMarshaler to JSONCodec (cosmos#9251)
Browse files Browse the repository at this point in the history
* Rename clientCtx.JSONMarshaler to JSONCodec

* change md files

* Fix lint
  • Loading branch information
amaury1093 authored May 3, 2021
1 parent 8d080b8 commit 68d1c4e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion simd/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
depCdc := clientCtx.JSONMarshaler
depCdc := clientCtx.JSONCodec
cdc := depCdc.(codec.Codec)

serverCtx := server.GetServerContextFromCmd(cmd)
Expand Down
2 changes: 1 addition & 1 deletion simd/cmd/genaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestAddGenesisAccountCmd(t *testing.T) {
require.NoError(t, err)

serverCtx := server.NewContext(viper.New(), cfg, logger)
clientCtx := client.Context{}.WithJSONMarshaler(appCodec).WithHomeDir(home)
clientCtx := client.Context{}.WithJSONCodec(appCodec).WithHomeDir(home)

ctx := context.Background()
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
Expand Down
2 changes: 1 addition & 1 deletion simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
encodingConfig := simapp.MakeTestEncodingConfig()
initClientCtx := client.Context{}.
WithJSONMarshaler(encodingConfig.Marshaler).
WithJSONCodec(encodingConfig.Marshaler).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
Expand Down
12 changes: 6 additions & 6 deletions simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,26 +271,26 @@ func initGenFiles(
genFiles []string, numValidators int,
) error {

appGenState := mbm.DefaultGenesis(clientCtx.JSONMarshaler)
appGenState := mbm.DefaultGenesis(clientCtx.JSONCodec)

// set the accounts in the genesis state
var authGenState authtypes.GenesisState
clientCtx.JSONMarshaler.MustUnmarshalJSON(appGenState[authtypes.ModuleName], &authGenState)
clientCtx.JSONCodec.MustUnmarshalJSON(appGenState[authtypes.ModuleName], &authGenState)

accounts, err := authtypes.PackAccounts(genAccounts)
if err != nil {
return err
}

authGenState.Accounts = accounts
appGenState[authtypes.ModuleName] = clientCtx.JSONMarshaler.MustMarshalJSON(&authGenState)
appGenState[authtypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(&authGenState)

// set the balances in the genesis state
var bankGenState banktypes.GenesisState
clientCtx.JSONMarshaler.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState)
clientCtx.JSONCodec.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState)

bankGenState.Balances = genBalances
appGenState[banktypes.ModuleName] = clientCtx.JSONMarshaler.MustMarshalJSON(&bankGenState)
appGenState[banktypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(&bankGenState)

appGenStateJSON, err := json.MarshalIndent(appGenState, "", " ")
if err != nil {
Expand Down Expand Up @@ -337,7 +337,7 @@ func collectGenFiles(
return err
}

nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.JSONMarshaler, clientCtx.TxConfig, nodeConfig, initCfg, *genDoc, genBalIterator)
nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.JSONCodec, clientCtx.TxConfig, nodeConfig, initCfg, *genDoc, genBalIterator)
if err != nil {
return err
}
Expand Down

0 comments on commit 68d1c4e

Please sign in to comment.