From 55cf483707ed4cb37c580b42f65d65c520616a38 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:58:20 +0900 Subject: [PATCH] cleanup unused codes --- app/app.go | 10 +++++----- app/app_test.go | 4 ++-- app/hook/move.go | 33 ++++----------------------------- cmd/minitiad/root.go | 1 - 4 files changed, 11 insertions(+), 37 deletions(-) diff --git a/app/app.go b/app/app.go index c1bf18d..1251c51 100644 --- a/app/app.go +++ b/app/app.go @@ -36,6 +36,7 @@ import ( nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" @@ -49,6 +50,7 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" cosmosante "github.com/cosmos/cosmos-sdk/x/auth/ante" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -68,8 +70,6 @@ import ( capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/cosmos/cosmos-sdk/runtime" - authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller" icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper" @@ -337,7 +337,7 @@ func NewMinitiaApp( runtime.NewKVStoreService(keys[opchildtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, - apphook.NewMoveBridgeHook(ac, app.MoveKeeper).Hook, + apphook.NewMoveBridgeHook(app.MoveKeeper).Hook, app.MsgServiceRouter(), authorityAddr, vc, @@ -588,7 +588,7 @@ func NewMinitiaApp( // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - // TODO - add crisis? + // TODO - add crisis module // skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: Any module instantiated in the module manager that is later modified @@ -720,7 +720,7 @@ func NewMinitiaApp( TxEncoder: app.txConfig.TxEncoder(), TxDecoder: app.txConfig.TxDecoder(), MaxBlockSpace: math.LegacyZeroDec(), - MaxTxs: 109, + MaxTxs: 100, SignerExtractor: signerExtractor, } freeLane := initialanes.NewFreeLane(freeConfig, applanes.FreeLaneMatchHandler()) diff --git a/app/app_test.go b/app/app_test.go index bd25116..7e2b58f 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -22,10 +22,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/consensus" groupmodule "github.com/cosmos/cosmos-sdk/x/group/module" "github.com/cosmos/ibc-go/modules/capability" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" "cosmossdk.io/x/upgrade" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - "github.com/cosmos/cosmos-sdk/x/params" ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts" "github.com/cosmos/ibc-go/v8/modules/apps/transfer" @@ -89,7 +89,6 @@ func TestInitGenesisOnMigration(t *testing.T) { "bank": bank.AppModule{}.ConsensusVersion(), "auth": auth.AppModule{}.ConsensusVersion(), "authz": authzmodule.AppModule{}.ConsensusVersion(), - "params": params.AppModule{}.ConsensusVersion(), "upgrade": upgrade.AppModule{}.ConsensusVersion(), "capability": capability.AppModule{}.ConsensusVersion(), "group": groupmodule.AppModule{}.ConsensusVersion(), @@ -126,4 +125,5 @@ func TestGetKey(t *testing.T) { db, nil, true, moveconfig.DefaultMoveConfig(), simtestutil.EmptyAppOptions{}) require.NotEmpty(t, app.GetKey(banktypes.StoreKey)) + require.NotEmpty(t, app.GetMemKey(capabilitytypes.MemStoreKey)) } diff --git a/app/hook/move.go b/app/hook/move.go index 797a4aa..9377165 100644 --- a/app/hook/move.go +++ b/app/hook/move.go @@ -4,22 +4,19 @@ import ( "context" "encoding/json" - "cosmossdk.io/core/address" sdk "github.com/cosmos/cosmos-sdk/types" movekeeper "github.com/initia-labs/initia/x/move/keeper" movetypes "github.com/initia-labs/initia/x/move/types" - vmtypes "github.com/initia-labs/initiavm/types" ) // bridge hook implementation for move type MoveBridgeHook struct { - ac address.Codec moveKeeper *movekeeper.Keeper } -func NewMoveBridgeHook(ac address.Codec, moveKeeper *movekeeper.Keeper) MoveBridgeHook { - return MoveBridgeHook{ac, moveKeeper} +func NewMoveBridgeHook(moveKeeper *movekeeper.Keeper) MoveBridgeHook { + return MoveBridgeHook{moveKeeper} } func (mbh MoveBridgeHook) Hook(ctx context.Context, sender sdk.AccAddress, msgBytes []byte) error { @@ -29,30 +26,8 @@ func (mbh MoveBridgeHook) Hook(ctx context.Context, sender sdk.AccAddress, msgBy return err } - senderAddr, err := vmtypes.NewAccountAddressFromBytes(sender) - if err != nil { - return err - } - - moduleAddress, err := movetypes.AccAddressFromString(mbh.ac, msg.ModuleAddress) - if err != nil { - return err - } - - typeArgs, err := movetypes.TypeTagsFromTypeArgs(msg.TypeArgs) - if err != nil { - return err - } - - err = mbh.moveKeeper.ExecuteEntryFunction( - ctx, - senderAddr, - moduleAddress, - msg.ModuleName, - msg.FunctionName, - typeArgs, - msg.Args, - ) + ms := movekeeper.NewMsgServerImpl(*mbh.moveKeeper) + _, err = ms.Execute(ctx, &msg) return err } diff --git a/cmd/minitiad/root.go b/cmd/minitiad/root.go index 5e842cf..0ad9cff 100644 --- a/cmd/minitiad/root.go +++ b/cmd/minitiad/root.go @@ -42,7 +42,6 @@ import ( // NewRootCmd creates a new root command for initiad. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - sdkConfig := sdk.GetConfig() sdkConfig.SetCoinType(minitiaapp.CoinType)