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

patch auth register cdc #5892

Merged
merged 12 commits into from
Mar 30, 2020
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ to now accept a `codec.JSONMarshaler` for modular serialization of genesis state
* (modules) [\#5569](https://github.com/cosmos/cosmos-sdk/issues/5569) `InitGenesis`, for the relevant modules, now ensures module accounts exist.
* (crypto/keyring) [\#5844](https://github.com/cosmos/cosmos-sdk/pull/5844) Keybase/Keyring `Sign()` methods no longer decode amino signatures
when method receivers are offline/multisig keys.
* (x/auth) [\#5892](https://github.com/cosmos/cosmos-sdk/pull/5892) Add `RegisterKeyTypeCodec` to register new
types (eg. keys) to the `auth` module internal amino codec.

### State Machine Breaking

Expand Down
3 changes: 1 addition & 2 deletions x/auth/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/tendermint/tendermint/crypto"
yaml "gopkg.in/yaml.v2"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
)
Expand Down Expand Up @@ -61,7 +60,7 @@ func (acc BaseAccount) GetPubKey() (pk crypto.PubKey) {
return nil
}

codec.Cdc.MustUnmarshalBinaryBare(acc.PubKey, &pk)
amino.MustUnmarshalBinaryBare(acc.PubKey, &pk)
return pk
}

Expand Down
8 changes: 7 additions & 1 deletion x/auth/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ func RegisterCodec(cdc *codec.Codec) {
cdc.RegisterConcrete(StdTx{}, "cosmos-sdk/StdTx", nil)
}

// RegisterKeyTypeCodec registers an external concrete type defined in
// another module for the internal ModuleCdc.
func RegisterKeyTypeCodec(o interface{}, name string) {
amino.RegisterConcrete(o, name, nil)
ModuleCdc = codec.NewHybridCodec(amino)
}

var (
amino = codec.New()

Expand All @@ -41,5 +48,4 @@ var (
func init() {
RegisterCodec(amino)
codec.RegisterCrypto(amino)
amino.Seal()
}
2 changes: 1 addition & 1 deletion x/auth/types/stdtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (ss StdSignature) GetPubKey() (pk crypto.PubKey) {
return nil
}

codec.Cdc.MustUnmarshalBinaryBare(ss.PubKey, &pk)
amino.MustUnmarshalBinaryBare(ss.PubKey, &pk)
return pk
}

Expand Down