Skip to content

Commit

Permalink
fix signing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarom Swisa authored and Yarom Swisa committed Dec 12, 2024
1 parent 6680e44 commit f66fabb
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 13 deletions.
5 changes: 4 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,10 @@ func New(

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)
err := app.mm.RegisterServices(app.configurator)
if err != nil {
panic(err)
}

// setupUpgradeHandlers. must be called before LoadLatestVersion as storeloader is sealed after that
app.setupUpgradeHandlers()
Expand Down
5 changes: 2 additions & 3 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/x/auth/tx"

Expand All @@ -12,7 +11,7 @@ import (
// makeEncodingConfig creates an EncodingConfig for an amino based test configuration.
func makeEncodingConfig() params.EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
interfaceRegistry := params.MakeEncodingConfig().InterfaceRegistry
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)

Expand All @@ -29,7 +28,7 @@ func MakeEncodingConfig() params.EncodingConfig {
encodingConfig := makeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
// ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
39 changes: 39 additions & 0 deletions app/params/proto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package params

import (
"github.com/cosmos/gogoproto/proto"

"cosmossdk.io/x/tx/signing"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)

func MakeEncodingConfig() EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: signing.Options{
AddressCodec: address.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(),
},
ValidatorAddressCodec: address.Bech32Codec{
Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(),
},
},
})
if err != nil {
panic(err)
}
cdc := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes)
return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: cdc,
TxConfig: txCfg,
Amino: amino,
}
}
2 changes: 1 addition & 1 deletion cmd/lavad/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/lavanet/lava/v4/app"
)

func InitSDKConfig() {
func init() {
// Set prefixes
accountPubKeyPrefix := app.AccountAddressPrefix + "pub"
validatorAddressPrefix := app.AccountAddressPrefix + "valoper"
Expand Down
4 changes: 0 additions & 4 deletions cmd/lavad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ func initLavaProtocolRootCmd(
rootCmd *cobra.Command,
moduleBasics module.BasicManager,
) {
InitSDKConfig()
rootCmd.AddCommand(
tmcli.NewCompletionCmd(rootCmd, true),
)
Expand Down Expand Up @@ -233,9 +232,6 @@ func initRootCmd(
encodingConfig appparams.EncodingConfig,
moduleBasics module.BasicManager,
) {
// Set config
InitSDKConfig()

gentxModule, ok := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic)
if !ok {
panic("cant get gentx module")
Expand Down
2 changes: 0 additions & 2 deletions testutil/e2e/paymentE2E.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

cosmosmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/lavanet/lava/v4/cmd/lavad/cmd"
commonconsts "github.com/lavanet/lava/v4/testutil/common/consts"
e2esdk "github.com/lavanet/lava/v4/testutil/e2e/sdk"
"github.com/lavanet/lava/v4/utils"
Expand Down Expand Up @@ -267,7 +266,6 @@ var (
)

func runPaymentE2E(timeout time.Duration) {
cmd.InitSDKConfig()
os.RemoveAll(protocolLogsFolder)
gopath := os.Getenv("GOPATH")
if gopath == "" {
Expand Down
2 changes: 0 additions & 2 deletions x/spec/keeper/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/lavanet/lava/v4/cmd/lavad/cmd"
"github.com/lavanet/lava/v4/testutil/common"
keepertest "github.com/lavanet/lava/v4/testutil/keeper"
"github.com/lavanet/lava/v4/testutil/nullify"
Expand Down Expand Up @@ -228,7 +227,6 @@ func TestSpecRemove(t *testing.T) {

func TestMain(m *testing.M) {
// This code will run once before any test cases are executed.
cmd.InitSDKConfig()
// Run the actual tests
exitCode := m.Run()
os.Exit(exitCode)
Expand Down

0 comments on commit f66fabb

Please sign in to comment.