11package chainconfig
22
33import (
4- "cosmossdk.io/x/authz"
5- banktypes "cosmossdk.io/x/bank/types"
6- govv1 "cosmossdk.io/x/gov/types/v1"
7- govv1beta1 "cosmossdk.io/x/gov/types/v1beta1"
8- grouptypes "cosmossdk.io/x/group"
9- proposaltypes "cosmossdk.io/x/params/types/proposal"
4+ "github.com/cosmos/gogoproto/proto"
5+
6+ txsigning "cosmossdk.io/x/tx/signing"
107 upgradetypes "cosmossdk.io/x/upgrade/types"
118
129 "github.com/cosmos/cosmos-sdk/codec"
13- codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
10+ "github.com/cosmos/cosmos-sdk/codec/address"
11+ codectypes "github.com/cosmos/cosmos-sdk/codec/types"
1412 cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
13+ sdk "github.com/cosmos/cosmos-sdk/types"
1514 sdktestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
1615 txtypes "github.com/cosmos/cosmos-sdk/types/tx"
16+ authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
1717 authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
18+ "github.com/cosmos/cosmos-sdk/x/authz"
19+ banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
20+ consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
21+ distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
22+ govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
23+ govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
24+ grouptypes "github.com/cosmos/cosmos-sdk/x/group"
25+ minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
26+ proposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
27+ slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
28+ stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
1829
19- wasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
30+ ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
2031 icacontrollertypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/types"
2132 icahosttypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/host/types"
2233 feetypes "github.com/cosmos/ibc-go/v9/modules/apps/29-fee/types"
@@ -30,53 +41,72 @@ import (
3041 ibctmtypes "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint"
3142)
3243
33- // Codec returns the global E2E protobuf codec.
34- func Codec () * codec.ProtoCodec {
35- cdc , _ := codecAndEncodingConfig ()
36- return cdc
44+ // CosmosEncodingConfig returns the global E2E encoding config for simd.
45+ func CosmosEncodingConfig () * sdktestutil.TestEncodingConfig {
46+ return encodingConfig ("cosmos" )
3747}
3848
39- // SDKEncodingConfig returns the global E2E encoding config.
40- func SDKEncodingConfig () * sdktestutil.TestEncodingConfig {
41- _ , cfg := codecAndEncodingConfig ()
42- return & sdktestutil.TestEncodingConfig {
43- InterfaceRegistry : cfg .InterfaceRegistry ,
44- Codec : cfg .Codec ,
45- TxConfig : cfg .TxConfig ,
46- Amino : cfg .Amino ,
49+ // EncodingConfig returns the global E2E encoding config.
50+ // It includes CosmosSDK, IBC, and Wasm messages
51+ func encodingConfig (bech32Prefix string ) * sdktestutil.TestEncodingConfig {
52+ amino := codec .NewLegacyAmino ()
53+ interfaceRegistry , err := codectypes .NewInterfaceRegistryWithOptions (codectypes.InterfaceRegistryOptions {
54+ ProtoFiles : proto .HybridResolver ,
55+ SigningOptions : txsigning.Options {
56+ AddressCodec : address.Bech32Codec {
57+ Bech32Prefix : bech32Prefix ,
58+ },
59+ ValidatorAddressCodec : address.Bech32Codec {
60+ Bech32Prefix : bech32Prefix + sdk .PrefixValidator + sdk .PrefixOperator ,
61+ },
62+ },
63+ })
64+ if err != nil {
65+ panic (err )
4766 }
48- }
49-
50- // codecAndEncodingConfig returns the codec and encoding config used in the E2E tests.
51- // Note: any new types added to the codec must be added here.
52- func codecAndEncodingConfig () (* codec.ProtoCodec , sdktestutil.TestEncodingConfig ) {
53- cfg := sdktestutil .MakeTestEncodingConfig (codectestutil.CodecOptions {})
5467
5568 // ibc types
56- icacontrollertypes .RegisterInterfaces (cfg .InterfaceRegistry )
57- icahosttypes .RegisterInterfaces (cfg .InterfaceRegistry )
58- feetypes .RegisterInterfaces (cfg .InterfaceRegistry )
59- solomachine .RegisterInterfaces (cfg .InterfaceRegistry )
60- v7migrations .RegisterInterfaces (cfg .InterfaceRegistry )
61- transfertypes .RegisterInterfaces (cfg .InterfaceRegistry )
62- clienttypes .RegisterInterfaces (cfg .InterfaceRegistry )
63- channeltypes .RegisterInterfaces (cfg .InterfaceRegistry )
64- connectiontypes .RegisterInterfaces (cfg .InterfaceRegistry )
65- ibctmtypes .RegisterInterfaces (cfg .InterfaceRegistry )
66- wasmtypes .RegisterInterfaces (cfg .InterfaceRegistry )
67- channeltypesv2 .RegisterInterfaces (cfg .InterfaceRegistry )
69+ icacontrollertypes .RegisterInterfaces (interfaceRegistry )
70+ icahosttypes .RegisterInterfaces (interfaceRegistry )
71+ feetypes .RegisterInterfaces (interfaceRegistry )
72+ transfertypes .RegisterInterfaces (interfaceRegistry )
73+ v7migrations .RegisterInterfaces (interfaceRegistry )
74+ clienttypes .RegisterInterfaces (interfaceRegistry )
75+ connectiontypes .RegisterInterfaces (interfaceRegistry )
76+ channeltypes .RegisterInterfaces (interfaceRegistry )
77+ channeltypesv2 .RegisterInterfaces (interfaceRegistry )
78+ solomachine .RegisterInterfaces (interfaceRegistry )
79+ ibctmtypes .RegisterInterfaces (interfaceRegistry )
80+ ibcwasmtypes .RegisterInterfaces (interfaceRegistry )
81+
82+ // sdk types
83+ upgradetypes .RegisterInterfaces (interfaceRegistry )
84+ banktypes .RegisterInterfaces (interfaceRegistry )
85+ govv1beta1 .RegisterInterfaces (interfaceRegistry )
86+ govv1 .RegisterInterfaces (interfaceRegistry )
87+ authtypes .RegisterInterfaces (interfaceRegistry )
88+ cryptocodec .RegisterInterfaces (interfaceRegistry )
89+ grouptypes .RegisterInterfaces (interfaceRegistry )
90+ proposaltypes .RegisterInterfaces (interfaceRegistry )
91+ authz .RegisterInterfaces (interfaceRegistry )
92+ txtypes .RegisterInterfaces (interfaceRegistry )
93+ stakingtypes .RegisterInterfaces (interfaceRegistry )
94+ minttypes .RegisterInterfaces (interfaceRegistry )
95+ distrtypes .RegisterInterfaces (interfaceRegistry )
96+ slashingtypes .RegisterInterfaces (interfaceRegistry )
97+ consensustypes .RegisterInterfaces (interfaceRegistry )
98+
99+ // custom module types
100+ ibcwasmtypes .RegisterInterfaces (interfaceRegistry )
101+
102+ cdc := codec .NewProtoCodec (interfaceRegistry )
103+
104+ cfg := & sdktestutil.TestEncodingConfig {
105+ InterfaceRegistry : interfaceRegistry ,
106+ Codec : cdc ,
107+ TxConfig : authtx .NewTxConfig (cdc , authtx .DefaultSignModes ),
108+ Amino : amino ,
109+ }
68110
69- // all other types
70- upgradetypes .RegisterInterfaces (cfg .InterfaceRegistry )
71- banktypes .RegisterInterfaces (cfg .InterfaceRegistry )
72- govv1beta1 .RegisterInterfaces (cfg .InterfaceRegistry )
73- govv1 .RegisterInterfaces (cfg .InterfaceRegistry )
74- authtypes .RegisterInterfaces (cfg .InterfaceRegistry )
75- cryptocodec .RegisterInterfaces (cfg .InterfaceRegistry )
76- grouptypes .RegisterInterfaces (cfg .InterfaceRegistry )
77- proposaltypes .RegisterInterfaces (cfg .InterfaceRegistry )
78- authz .RegisterInterfaces (cfg .InterfaceRegistry )
79- txtypes .RegisterInterfaces (cfg .InterfaceRegistry )
80- cdc := codec .NewProtoCodec (cfg .InterfaceRegistry )
81- return cdc , cfg
111+ return cfg
82112}
0 commit comments