-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
677 additions
and
698 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,29 +1,54 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec/legacy" | ||
"github.com/cosmos/cosmos-sdk/std" | ||
"cosmossdk.io/client/v2/autocli" | ||
"cosmossdk.io/core/appmodule" | ||
"cosmossdk.io/log" | ||
dbm "github.com/cosmos/cosmos-db" | ||
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" | ||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" | ||
|
||
moveconfig "github.com/initia-labs/initia/x/move/config" | ||
"github.com/initia-labs/minimove/app/params" | ||
) | ||
|
||
var legacyCodecRegistered = false | ||
|
||
// MakeEncodingConfig creates an EncodingConfig for testing | ||
func MakeEncodingConfig() params.EncodingConfig { | ||
encodingConfig := params.MakeEncodingConfig() | ||
std.RegisterLegacyAminoCodec(encodingConfig.Amino) | ||
std.RegisterInterfaces(encodingConfig.InterfaceRegistry) | ||
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) | ||
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) | ||
|
||
if !legacyCodecRegistered { | ||
// authz module use this codec to get signbytes. | ||
// authz MsgExec can execute all message types, | ||
// so legacy.Cdc need to register all amino messages to get proper signature | ||
ModuleBasics.RegisterLegacyAminoCodec(legacy.Cdc) | ||
legacyCodecRegistered = true | ||
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, moveconfig.DefaultMoveConfig(), simtestutil.EmptyAppOptions{}) | ||
encodingConfig := params.EncodingConfig{ | ||
InterfaceRegistry: tempApp.InterfaceRegistry(), | ||
Codec: tempApp.AppCodec(), | ||
TxConfig: tempApp.TxConfig(), | ||
Amino: tempApp.LegacyAmino(), | ||
} | ||
|
||
return encodingConfig | ||
} | ||
|
||
func AutoCliOpts() autocli.AppOptions { | ||
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, moveconfig.DefaultMoveConfig(), simtestutil.EmptyAppOptions{}) | ||
modules := make(map[string]appmodule.AppModule, 0) | ||
for _, m := range tempApp.ModuleManager.Modules { | ||
if moduleWithName, ok := m.(module.HasName); ok { | ||
moduleName := moduleWithName.Name() | ||
if appModule, ok := moduleWithName.(appmodule.AppModule); ok { | ||
modules[moduleName] = appModule | ||
} | ||
} | ||
} | ||
|
||
return autocli.AppOptions{ | ||
Modules: modules, | ||
ModuleOptions: runtimeservices.ExtractAutoCLIOptions(tempApp.ModuleManager.Modules), | ||
AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), | ||
ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), | ||
ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), | ||
} | ||
} | ||
|
||
func BasicManager() module.BasicManager { | ||
tempApp := NewMinitiaApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, moveconfig.DefaultMoveConfig(), simtestutil.EmptyAppOptions{}) | ||
return tempApp.BasicModuleManager | ||
} |
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
Oops, something went wrong.