Enable proto JSON generally and remove HybridCodec (#6859)

* Remove HybridCodec

* WIP on fixing proto JSON issues

* WIP on fixing proto JSON issues

* WIP on fixing proto JSON issues

* WIP on fixing proto JSON issues

* WIP on fixing proto JSON issues

* Test fixes

* Delete hybrid_codec.go

* Fixes

* Fixes

* Fixes

* Test fixes

* Test fixes

* Test fixes

* Lint

* Sim fixes

* Sim fixes

* Revert

* Remove vesting account JSON tests

* Update CHANGELOG.md

* Lint

* Sim fixes

* Sim fixes

* Docs

* Migrate more amino usages

* Remove custom VoteOption String() and json marshaling

* Fix tests

* Add comments, update CHANGELOG.md

Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Aaron Craelius
2020-08-13 13:20:02 +00:00
committed by GitHub
co-authored by Jonathan Gimeno Alexander Bezobchuk
parent 134e1dcecd
commit 816c5a37bd
77 changed files with 325 additions and 845 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ func (sm *SimulationManager) WeightedOperations(simState SimulationState) []simu
// GenesisState generator function
type SimulationState struct {
AppParams simulation.AppParams
Cdc *codec.LegacyAmino // application codec
Cdc codec.JSONMarshaler // application codec
Rand *rand.Rand // random number
GenState map[string]json.RawMessage // genesis state
Accounts []simulation.Account // simulation accounts
+1 -1
View File
@@ -170,7 +170,7 @@ func ExamplePaginate() {
accountStore := prefix.NewStore(balancesStore, addr1.Bytes())
pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error {
var tempRes sdk.Coin
err := app.LegacyAmino().UnmarshalBinaryBare(value, &tempRes)
err := app.AppCodec().UnmarshalBinaryBare(value, &tempRes)
if err != nil {
return err
}
+4 -11
View File
@@ -45,7 +45,7 @@ func NewResponseWithHeight(height int64, result json.RawMessage) ResponseWithHei
// ParseResponseWithHeight returns the raw result from a JSON-encoded
// ResponseWithHeight object.
func ParseResponseWithHeight(cdc codec.JSONMarshaler, bz []byte) ([]byte, error) {
func ParseResponseWithHeight(cdc *codec.LegacyAmino, bz []byte) ([]byte, error) {
r := ResponseWithHeight{}
if err := cdc.UnmarshalJSON(bz, &r); err != nil {
return nil, err
@@ -279,7 +279,7 @@ func PostProcessResponseBare(w http.ResponseWriter, ctx client.Context, body int
resp = b
default:
resp, err = ctx.JSONMarshaler.MarshalJSON(body)
resp, err = ctx.LegacyAmino.MarshalJSON(body)
if CheckInternalServerError(w, err) {
return
}
@@ -303,15 +303,8 @@ func PostProcessResponse(w http.ResponseWriter, ctx client.Context, resp interfa
return
}
// TODO: Remove once PubKey Protobuf migration has been completed.
// ref: https://github.com/cosmos/cosmos-sdk/issues/6886
var marshaler codec.JSONMarshaler
if ctx.JSONMarshaler != nil {
marshaler = ctx.JSONMarshaler
} else {
marshaler = ctx.LegacyAmino
}
// LegacyAmino used intentionally for REST
marshaler := ctx.LegacyAmino
switch res := resp.(type) {
case []byte:
+2 -1
View File
@@ -310,7 +310,8 @@ func TestPostProcessResponseBare(t *testing.T) {
encodingConfig := simappparams.MakeEncodingConfig()
clientCtx := client.Context{}.
WithTxConfig(encodingConfig.TxConfig).
WithJSONMarshaler(encodingConfig.Marshaler)
WithJSONMarshaler(encodingConfig.Amino). // amino used intentionally here
WithLegacyAmino(encodingConfig.Amino) // amino used intentionally here
// write bytes
w := httptest.NewRecorder()
bs := []byte("text string")
+1 -1
View File
@@ -135,7 +135,7 @@ type AppParams map[string]json.RawMessage
// object. If it exists, it'll be decoded and returned. Otherwise, the provided
// ParamSimulator is used to generate a random value or default value (eg: in the
// case of operation weights where Rand is not used).
func (sp AppParams) GetOrGenerate(cdc *codec.LegacyAmino, key string, ptr interface{}, r *rand.Rand, ps ParamSimulator) {
func (sp AppParams) GetOrGenerate(cdc codec.JSONMarshaler, key string, ptr interface{}, r *rand.Rand, ps ParamSimulator) {
if v, ok := sp[key]; ok && v != nil {
cdc.MustUnmarshalJSON(v, ptr)
return