Skip to content

Commit

Permalink
refactor iris app
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamer committed Mar 6, 2024
1 parent ce91df7 commit 5fc89dd
Show file tree
Hide file tree
Showing 12 changed files with 810 additions and 717 deletions.
645 changes: 25 additions & 620 deletions app/app.go

Large diffs are not rendered by default.

34 changes: 4 additions & 30 deletions app/encoding.go
Original file line number Diff line number Diff line change
@@ -1,43 +1,17 @@
package app

import (
amino "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"
enccodec "github.com/evmos/ethermint/encoding/codec"

"github.com/irisnet/irishub/v2/app/params"
)

// MakeEncodingConfig creates an EncodingConfig for testing
func MakeEncodingConfig() params.EncodingConfig {
// RegisterEncodingConfig registers concrete types on codec
func RegisterEncodingConfig() params.EncodingConfig {
encodingConfig := params.MakeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)

return encodingConfig
}

// MakeConfig creates an EncodingConfig for testing
func MakeConfig(mb module.BasicManager) params.EncodingConfig {
cdc := amino.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
codec := amino.NewProtoCodec(interfaceRegistry)

encodingConfig := params.EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: codec,
TxConfig: tx.NewTxConfig(codec, tx.DefaultSignModes),
Amino: cdc,
}

enccodec.RegisterLegacyAminoCodec(encodingConfig.Amino)
mb.RegisterLegacyAminoCodec(encodingConfig.Amino)
enccodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
mb.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
2 changes: 1 addition & 1 deletion app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import (

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState() types.GenesisState {
encCfg := MakeEncodingConfig()
encCfg := RegisterEncodingConfig()
return ModuleBasics.DefaultGenesis(encCfg.Marshaler)
}
Loading

0 comments on commit 5fc89dd

Please sign in to comment.