Skip to content

Commit

Permalink
patch auth register cdc (#5892)
Browse files Browse the repository at this point in the history
* readd RegisterAccountTypeCodec

* fix

* remove seal

* update BaseAccount and StdSig to use amino codec

* remove comments

* rename

* changelog

* rename
  • Loading branch information
fedekunze authored Mar 30, 2020
1 parent e5bde01 commit 6a6fd1c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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

0 comments on commit 6a6fd1c

Please sign in to comment.