forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: register gov and group amino codec
- Loading branch information
1 parent
79ac73d
commit f0db6bc
Showing
28 changed files
with
337 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package testutil | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
"github.com/cosmos/cosmos-sdk/std" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
"github.com/cosmos/cosmos-sdk/x/auth/tx" | ||
) | ||
|
||
// TestEncodingConfig defines an encoding configuration that is used for testing | ||
// purposes. Note, MakeTestEncodingConfig takes a series of AppModuleBasic types | ||
// which should only contain the relevant module being tested and any potential | ||
// dependencies. | ||
type TestEncodingConfig struct { | ||
InterfaceRegistry types.InterfaceRegistry | ||
Codec codec.Codec | ||
TxConfig client.TxConfig | ||
Amino *codec.LegacyAmino | ||
} | ||
|
||
func MakeTestEncodingConfig(modules ...module.AppModuleBasic) TestEncodingConfig { | ||
cdc := codec.NewLegacyAmino() | ||
interfaceRegistry := types.NewInterfaceRegistry() | ||
codec := codec.NewProtoCodec(interfaceRegistry) | ||
|
||
encCfg := TestEncodingConfig{ | ||
InterfaceRegistry: interfaceRegistry, | ||
Codec: codec, | ||
TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes), | ||
Amino: cdc, | ||
} | ||
|
||
mb := module.NewBasicManager(modules...) | ||
|
||
std.RegisterLegacyAminoCodec(encCfg.Amino) | ||
std.RegisterInterfaces(encCfg.InterfaceRegistry) | ||
mb.RegisterLegacyAminoCodec(encCfg.Amino) | ||
mb.RegisterInterfaces(encCfg.InterfaceRegistry) | ||
|
||
return encCfg | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package codec | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
var ( | ||
Amino = codec.NewLegacyAmino() | ||
ModuleCdc = codec.NewAminoCodec(Amino) | ||
) | ||
|
||
func init() { | ||
cryptocodec.RegisterCrypto(Amino) | ||
codec.RegisterEvidences(Amino) | ||
sdk.RegisterLegacyAminoCodec(Amino) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Package codec provides a singleton instance of Amino codec that should be used to register | ||
any concrete type that can later be referenced inside a MsgSubmitProposal instance so that they | ||
can be (de)serialized properly. | ||
Amino types should be ideally registered inside this codec within the init function of each module's | ||
codec.go file as follows: | ||
func init() { | ||
// ... | ||
RegisterLegacyAminoCodec(govcodec.Amino) | ||
RegisterLegacyAminoCodec(groupcodec.Amino) | ||
} | ||
The codec instance is put inside this package and not the x/gov/types package in order to avoid any dependency cycle. | ||
*/ | ||
package codec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.