From da2ead66ceb56c9d48fe32716a4bb56968563d46 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Fri, 4 Aug 2023 22:02:42 +0200 Subject: [PATCH 1/2] refactor: remove Starport placeholders and module handlers (#906) * remove sp placeholders * remove handlers --- app/app.go | 4 ---- cmd/zetacored/root.go | 2 -- proto/crosschain/genesis.proto | 3 --- proto/crosschain/query.proto | 5 ----- proto/crosschain/tx.proto | 3 --- proto/emissions/genesis.proto | 2 -- proto/emissions/query.proto | 5 ----- proto/emissions/tx.proto | 5 ----- proto/fungible/genesis.proto | 2 -- proto/fungible/query.proto | 3 --- proto/fungible/tx.proto | 5 ----- proto/observer/query.proto | 5 ----- proto/observer/tx.proto | 5 ----- x/crosschain/client/cli/query.go | 2 -- x/crosschain/client/cli/tx.go | 1 - x/crosschain/genesis.go | 3 --- x/crosschain/genesis_test.go | 2 -- x/crosschain/handler.go | 24 -------------------- x/crosschain/keeper/keeper.go | 6 ----- x/crosschain/module.go | 2 -- x/crosschain/module_simulation.go | 7 ------ x/crosschain/types/codec.go | 3 --- x/crosschain/types/genesis.go | 9 ++------ x/crosschain/types/genesis_test.go | 2 -- x/crosschain/types/tx.pb.go | 1 - x/emissions/client/cli/query.go | 2 -- x/emissions/client/cli/tx.go | 2 -- x/emissions/genesis.go | 3 --- x/emissions/module.go | 3 --- x/emissions/types/codec.go | 3 --- x/emissions/types/genesis.go | 7 ------ x/emissions/types/genesis_test.go | 8 ++----- x/fungible/client/cli/query.go | 1 - x/fungible/client/cli/tx.go | 1 - x/fungible/genesis.go | 3 +-- x/fungible/genesis_test.go | 2 -- x/fungible/module_simulation.go | 7 ------ x/fungible/types/codec.go | 3 --- x/fungible/types/genesis.go | 4 +--- x/fungible/types/genesis_test.go | 3 --- x/observer/client/cli/query.go | 2 -- x/observer/client/cli/tx.go | 2 -- x/observer/handler.go | 35 ------------------------------ x/observer/module.go | 2 -- x/observer/module_simulation.go | 5 ----- x/observer/types/codec.go | 2 -- x/observer/types/genesis_test.go | 8 ++----- 47 files changed, 8 insertions(+), 211 deletions(-) delete mode 100644 x/crosschain/handler.go delete mode 100644 x/observer/handler.go diff --git a/app/app.go b/app/app.go index cf6c6d1f9e..ccd07b956c 100644 --- a/app/app.go +++ b/app/app.go @@ -101,7 +101,6 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" tmjson "github.com/tendermint/tendermint/libs/json" - // this line is used by starport scaffolding # stargate/app/moduleImport zetaCoreModule "github.com/zeta-chain/zetacore/x/crosschain" zetaCoreModuleTypes "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -151,8 +150,6 @@ var ( Bech32PrefixConsPub = AccountAddressPrefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic ) -// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals - func getGovProposalHandlers() []govclient.ProposalHandler { var govProposalHandlers []govclient.ProposalHandler govProposalHandlers = append(govProposalHandlers, @@ -759,7 +756,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(evmtypes.ModuleName) paramsKeeper.Subspace(feemarkettypes.ModuleName) paramsKeeper.Subspace(group.ModuleName) - // this line is used by starport scaffolding # stargate/app/paramSubspace paramsKeeper.Subspace(zetaCoreModuleTypes.ModuleName) paramsKeeper.Subspace(zetaObserverModuleTypes.ModuleName) paramsKeeper.Subspace(fungibleModuleTypes.ModuleName) diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 54ba5aea8b..c4635ebd8f 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -282,7 +282,6 @@ func (ac appCreator) appExport( homePath, uint(1), ac.encCfg, - // this line is used by starport scaffolding # stargate/root/exportArgument appOpts, ) @@ -299,7 +298,6 @@ func (ac appCreator) appExport( homePath, uint(1), ac.encCfg, - // this line is used by starport scaffolding # stargate/root/noHeightExportArgument appOpts, ) } diff --git a/proto/crosschain/genesis.proto b/proto/crosschain/genesis.proto index a710591325..d890a8adb1 100644 --- a/proto/crosschain/genesis.proto +++ b/proto/crosschain/genesis.proto @@ -9,7 +9,6 @@ import "crosschain/last_block_height.proto"; import "crosschain/out_tx_tracker.proto"; import "crosschain/params.proto"; import "crosschain/tss.proto"; -// this line is used by starport scaffolding # genesis/proto/import import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types"; @@ -25,6 +24,4 @@ message GenesisState { repeated LastBlockHeight lastBlockHeightList = 8; repeated InTxHashToCctx inTxHashToCctxList = 9 [(gogoproto.nullable) = false]; - - // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/crosschain/query.proto b/proto/crosschain/query.proto index 7325483325..cb82c2d018 100644 --- a/proto/crosschain/query.proto +++ b/proto/crosschain/query.proto @@ -11,7 +11,6 @@ import "crosschain/nonce_to_cctx.proto"; import "crosschain/out_tx_tracker.proto"; import "crosschain/params.proto"; import "crosschain/tss.proto"; -// this line is used by starport scaffolding # 1 import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; @@ -53,8 +52,6 @@ service Query { option (google.api.http).get = "/zeta-chain/crosschain/get_tss_address"; } - // this line is used by starport scaffolding # 2 - // Queries a tSS by index. rpc TSS(QueryGetTSSRequest) returns (QueryGetTSSResponse) { option (google.api.http).get = "/zeta-chain/crosschain/TSS"; @@ -183,8 +180,6 @@ message QueryGetTssAddressResponse { string btc = 2; } -// this line is used by starport scaffolding # 3 - message QueryGetTSSRequest {} message QueryGetTSSResponse { diff --git a/proto/crosschain/tx.proto b/proto/crosschain/tx.proto index 5097bea4c9..6fe71215d2 100644 --- a/proto/crosschain/tx.proto +++ b/proto/crosschain/tx.proto @@ -1,7 +1,6 @@ syntax = "proto3"; package zetachain.zetacore.crosschain; -// this line is used by starport scaffolding # proto/tx/import import "common/common.proto"; import "gogoproto/gogo.proto"; @@ -16,7 +15,6 @@ service Msg { rpc NonceVoter(MsgNonceVoter) returns (MsgNonceVoterResponse); rpc VoteOnObservedOutboundTx(MsgVoteOnObservedOutboundTx) returns (MsgVoteOnObservedOutboundTxResponse); rpc VoteOnObservedInboundTx(MsgVoteOnObservedInboundTx) returns (MsgVoteOnObservedInboundTxResponse); - // this line is used by starport scaffolding # proto/tx/rpc } message MsgAddToOutTxTracker { @@ -36,7 +34,6 @@ message MsgRemoveFromOutTxTracker { message MsgRemoveFromOutTxTrackerResponse {} -// this line is used by starport scaffolding # proto/tx/message message MsgCreateTSSVoter { string creator = 1; string tss_pubkey = 2; diff --git a/proto/emissions/genesis.proto b/proto/emissions/genesis.proto index f6d8ea93ba..eff9d61c41 100644 --- a/proto/emissions/genesis.proto +++ b/proto/emissions/genesis.proto @@ -3,12 +3,10 @@ package zetachain.zetacore.emissions; import "emissions/params.proto"; import "gogoproto/gogo.proto"; -// this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/zeta-chain/zetacore/x/emissions/types"; // GenesisState defines the emissions module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; - // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/emissions/query.proto b/proto/emissions/query.proto index 397b344803..b050c1af9a 100644 --- a/proto/emissions/query.proto +++ b/proto/emissions/query.proto @@ -5,7 +5,6 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "emissions/params.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -// this line is used by starport scaffolding # 1 option go_package = "github.com/zeta-chain/zetacore/x/emissions/types"; @@ -19,8 +18,6 @@ service Query { rpc ListPoolAddresses(QueryListPoolAddressesRequest) returns (QueryListPoolAddressesResponse) { option (google.api.http).get = "/zeta-chain/zetacore/emissions/list_addresses"; } - - // this line is used by starport scaffolding # 2 } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -39,5 +36,3 @@ message QueryListPoolAddressesResponse { string undistributed_tss_balances_address = 2; string emission_module_address = 3; } - -// this line is used by starport scaffolding # 3 diff --git a/proto/emissions/tx.proto b/proto/emissions/tx.proto index c05f35747e..b969095454 100644 --- a/proto/emissions/tx.proto +++ b/proto/emissions/tx.proto @@ -1,15 +1,10 @@ syntax = "proto3"; package zetachain.zetacore.emissions; -// this line is used by starport scaffolding # proto/tx/import - import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/x/emissions/types"; // Msg defines the Msg service. service Msg { - // this line is used by starport scaffolding # proto/tx/rpc } - -// this line is used by starport scaffolding # proto/tx/message diff --git a/proto/fungible/genesis.proto b/proto/fungible/genesis.proto index d54c52886d..bc6f804145 100644 --- a/proto/fungible/genesis.proto +++ b/proto/fungible/genesis.proto @@ -5,7 +5,6 @@ import "fungible/foreign_coins.proto"; import "fungible/params.proto"; import "fungible/system_contract.proto"; import "gogoproto/gogo.proto"; -// this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; @@ -14,5 +13,4 @@ message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; repeated ForeignCoins foreignCoinsList = 2 [(gogoproto.nullable) = false]; SystemContract systemContract = 3; - // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/fungible/query.proto b/proto/fungible/query.proto index 3e228a8e99..4c6fe9e699 100644 --- a/proto/fungible/query.proto +++ b/proto/fungible/query.proto @@ -7,7 +7,6 @@ import "fungible/params.proto"; import "fungible/system_contract.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -// this line is used by starport scaffolding # 1 option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; @@ -31,7 +30,6 @@ service Query { rpc SystemContract(QueryGetSystemContractRequest) returns (QueryGetSystemContractResponse) { option (google.api.http).get = "/zeta-chain/zetacore/fungible/system_contract"; } - // this line is used by starport scaffolding # 2 } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -65,4 +63,3 @@ message QueryGetSystemContractRequest {} message QueryGetSystemContractResponse { SystemContract SystemContract = 1 [(gogoproto.nullable) = false]; } -// this line is used by starport scaffolding # 3 diff --git a/proto/fungible/tx.proto b/proto/fungible/tx.proto index db40c3fe69..64eb1cfc86 100644 --- a/proto/fungible/tx.proto +++ b/proto/fungible/tx.proto @@ -3,15 +3,12 @@ package zetachain.zetacore.fungible; import "common/common.proto"; -// this line is used by starport scaffolding # proto/tx/import - option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; // Msg defines the Msg service. service Msg { rpc DeployFungibleCoinZRC20(MsgDeployFungibleCoinZRC20) returns (MsgDeployFungibleCoinZRC20Response); rpc RemoveForeignCoin(MsgRemoveForeignCoin) returns (MsgRemoveForeignCoinResponse); - // this line is used by starport scaffolding # proto/tx/rpc } message MsgDeployFungibleCoinZRC20 { @@ -33,5 +30,3 @@ message MsgRemoveForeignCoin { } message MsgRemoveForeignCoinResponse {} - -// this line is used by starport scaffolding # proto/tx/message diff --git a/proto/observer/query.proto b/proto/observer/query.proto index 109f217469..ca70ceb2c6 100644 --- a/proto/observer/query.proto +++ b/proto/observer/query.proto @@ -3,7 +3,6 @@ package zetachain.zetacore.observer; import "common/common.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -// this line is used by starport scaffolding # 1 import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "observer/ballot.proto"; @@ -80,8 +79,6 @@ service Query { rpc GetAllBlameRecords(QueryAllBlameRecordsRequest) returns (QueryAllBlameRecordsResponse) { option (google.api.http).get = "/zeta-chain/observer/get_all_blame_records"; } - - // this line is used by starport scaffolding # 2 } message QueryParamsRequest {} @@ -188,5 +185,3 @@ message QueryAllBlameRecordsRequest {} message QueryAllBlameRecordsResponse { repeated Blame blameInfo = 1; } - -// this line is used by starport scaffolding # 3 diff --git a/proto/observer/tx.proto b/proto/observer/tx.proto index 7e5f8c8004..28e5bdabb7 100644 --- a/proto/observer/tx.proto +++ b/proto/observer/tx.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package zetachain.zetacore.observer; -// this line is used by starport scaffolding # proto/tx/import - import "common/common.proto"; import "gogoproto/gogo.proto"; import "observer/blame.proto"; @@ -18,7 +16,6 @@ service Msg { rpc AddBlameVote(MsgAddBlameVote) returns (MsgAddBlameVoteResponse); rpc UpdatePermissionFlags(MsgUpdatePermissionFlags) returns (MsgUpdatePermissionFlagsResponse); rpc UpdateKeygen(MsgUpdateKeygen) returns (MsgUpdateKeygenResponse); - // this line is used by starport scaffolding # proto/tx/rpc } message MsgUpdateCoreParams { @@ -55,5 +52,3 @@ message MsgUpdateKeygen { } message MsgUpdateKeygenResponse {} - -// this line is used by starport scaffolding # proto/tx/message diff --git a/x/crosschain/client/cli/query.go b/x/crosschain/client/cli/query.go index 2618a7e794..e9fbb213e9 100644 --- a/x/crosschain/client/cli/query.go +++ b/x/crosschain/client/cli/query.go @@ -45,7 +45,5 @@ func GetQueryCmd(queryRoute string) *cobra.Command { CmdGetTssAddress(), ) - // this line is used by starport scaffolding # 1 - return cmd } diff --git a/x/crosschain/client/cli/tx.go b/x/crosschain/client/cli/tx.go index 571b468bf1..7b0b14303a 100644 --- a/x/crosschain/client/cli/tx.go +++ b/x/crosschain/client/cli/tx.go @@ -31,7 +31,6 @@ func GetTxCmd() *cobra.Command { cli.CmdUpdatePermissionFlags(), cli.CmdUpdateKeygen(), ) - // this line is used by starport scaffolding # 1 return cmd } diff --git a/x/crosschain/genesis.go b/x/crosschain/genesis.go index 4d8287ed45..07901f8419 100644 --- a/x/crosschain/genesis.go +++ b/x/crosschain/genesis.go @@ -18,8 +18,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetInTxHashToCctx(ctx, elem) } - // this line is used by starport scaffolding # genesis/module/init - // Set all the gasPrice for _, elem := range genState.GasPriceList { k.SetGasPrice(ctx, *elem) @@ -53,7 +51,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.OutTxTrackerList = k.GetAllOutTxTracker(ctx) genesis.InTxHashToCctxList = k.GetAllInTxHashToCctx(ctx) - // this line is used by starport scaffolding # genesis/module/export // Get all keygen // Get all tSSVoter diff --git a/x/crosschain/genesis_test.go b/x/crosschain/genesis_test.go index 6f1e8d6cb2..39dc4bd12b 100644 --- a/x/crosschain/genesis_test.go +++ b/x/crosschain/genesis_test.go @@ -31,7 +31,6 @@ func TestGenesis(t *testing.T) { //PermissionFlags: &types.PermissionFlags{ // IsInboundEnabled: true, //}, - // this line is used by starport scaffolding # genesis/test/state } k, ctx := keepertest.ZetacoreKeeper(t) @@ -45,5 +44,4 @@ func TestGenesis(t *testing.T) { require.ElementsMatch(t, genesisState.OutTxTrackerList, got.OutTxTrackerList) require.ElementsMatch(t, genesisState.InTxHashToCctxList, got.InTxHashToCctxList) //require.Equal(t, genesisState.PermissionFlags, got.PermissionFlags) - // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/crosschain/handler.go b/x/crosschain/handler.go deleted file mode 100644 index 53ae665c8b..0000000000 --- a/x/crosschain/handler.go +++ /dev/null @@ -1,24 +0,0 @@ -package crosschain - -import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/x/crosschain/keeper" - "github.com/zeta-chain/zetacore/x/crosschain/types" -) - -// NewHandler : keeping this function here to assist ignite scaffolding, we do not use this . -func NewHandler(k keeper.Keeper) sdk.Handler { - _ = keeper.NewMsgServerImpl(k) - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - // this line is used by starport scaffolding # 1 - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - } -} diff --git a/x/crosschain/keeper/keeper.go b/x/crosschain/keeper/keeper.go index de9cf5b042..dd81b8f0c3 100644 --- a/x/crosschain/keeper/keeper.go +++ b/x/crosschain/keeper/keeper.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/zetacore/x/crosschain/types" - // this line is used by starport scaffolding # ibc/keeper/import ) type ( @@ -26,8 +25,6 @@ type ( bankKeeper types.BankKeeper zetaObserverKeeper types.ZetaObserverKeeper fungibleKeeper fungibleModuleKeeper.Keeper - // this line is used by starport scaffolding # ibc/keeper/attribute - } ) @@ -41,8 +38,6 @@ func NewKeeper( bankKeeper types.BankKeeper, zetaObserverKeeper types.ZetaObserverKeeper, fungibleKeeper fungibleModuleKeeper.Keeper, - // this line is used by starport scaffolding # ibc/keeper/parameter - ) *Keeper { // ensure governance module account is set // FIXME: enable this check! (disabled for now to avoid unit test panic) @@ -60,7 +55,6 @@ func NewKeeper( bankKeeper: bankKeeper, zetaObserverKeeper: zetaObserverKeeper, fungibleKeeper: fungibleKeeper, - // this line is used by starport scaffolding # ibc/keeper/return } } diff --git a/x/crosschain/module.go b/x/crosschain/module.go index e7992b90d8..83a933a7db 100644 --- a/x/crosschain/module.go +++ b/x/crosschain/module.go @@ -19,13 +19,11 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/zeta-chain/zetacore/x/crosschain/client/cli" "github.com/zeta-chain/zetacore/x/crosschain/types" - // this line is used by starport scaffolding # ibc/module/import ) var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} - // this line is used by starport scaffolding # ibc/module/interface ) // ---------------------------------------------------------------------------- diff --git a/x/crosschain/module_simulation.go b/x/crosschain/module_simulation.go index 26118e09aa..cfc647ad6d 100644 --- a/x/crosschain/module_simulation.go +++ b/x/crosschain/module_simulation.go @@ -9,10 +9,6 @@ import ( "github.com/zeta-chain/zetacore/x/crosschain/types" ) -const ( -// this line is used by starport scaffolding # simapp/module/const -) - // GenerateGenesisState creates a randomized GenState of the module func (AppModule) GenerateGenesisState(simState *module.SimulationState) { accs := make([]string, len(simState.Accounts)) @@ -21,7 +17,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } crosschainGenesis := types.GenesisState{ Params: types.DefaultParams(), - // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&crosschainGenesis) } @@ -44,7 +39,5 @@ func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) - // this line is used by starport scaffolding # simapp/module/operation - return operations } diff --git a/x/crosschain/types/codec.go b/x/crosschain/types/codec.go index 1dbd981cfd..0d9a0cf29d 100644 --- a/x/crosschain/types/codec.go +++ b/x/crosschain/types/codec.go @@ -16,8 +16,6 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgVoteOnObservedOutboundTxResponse{}, "crosschain/ReceiveConfirmation", nil) cdc.RegisterConcrete(&MsgVoteOnObservedInboundTx{}, "crosschain/SendVoter", nil) cdc.RegisterConcrete(&MsgSetNodeKeys{}, "crosschain/SetNodeKeys", nil) - - // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -32,7 +30,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgSetNodeKeys{}, ) - // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/crosschain/types/genesis.go b/x/crosschain/types/genesis.go index c2d5923c2a..09bff11162 100644 --- a/x/crosschain/types/genesis.go +++ b/x/crosschain/types/genesis.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "github.com/cosmos/cosmos-sdk/codec" - // this line is used by starport scaffolding # ibc/genesistype/import ) // DefaultIndex is the default capability global index @@ -13,12 +12,10 @@ const DefaultIndex uint64 = 1 // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - // this line is used by starport scaffolding # ibc/genesistype/default OutTxTrackerList: []OutTxTracker{}, InTxHashToCctxList: []InTxHashToCctx{}, - // this line is used by starport scaffolding # genesis/types/default - GasPriceList: []*GasPrice{}, - ChainNoncesList: []*ChainNonces{}, + GasPriceList: []*GasPrice{}, + ChainNoncesList: []*ChainNonces{}, //CCTX: []*Send{}, } @@ -27,8 +24,6 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - // this line is used by starport scaffolding # ibc/genesistype/validate - // Check for duplicated index in outTxTracker outTxTrackerIndexMap := make(map[string]struct{}) diff --git a/x/crosschain/types/genesis_test.go b/x/crosschain/types/genesis_test.go index 632a3811e4..57241bb186 100644 --- a/x/crosschain/types/genesis_test.go +++ b/x/crosschain/types/genesis_test.go @@ -49,7 +49,6 @@ func TestGenesisState_Validate(t *testing.T) { //PermissionFlags: &types.PermissionFlags{ // IsInboundEnabled: true, //}, - // this line is used by starport scaffolding # types/genesis/validField }, valid: true, }, @@ -81,7 +80,6 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, - // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() diff --git a/x/crosschain/types/tx.pb.go b/x/crosschain/types/tx.pb.go index 6e6c8d7a55..e846fc7274 100644 --- a/x/crosschain/types/tx.pb.go +++ b/x/crosschain/types/tx.pb.go @@ -230,7 +230,6 @@ func (m *MsgRemoveFromOutTxTrackerResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveFromOutTxTrackerResponse proto.InternalMessageInfo -// this line is used by starport scaffolding # proto/tx/message type MsgCreateTSSVoter struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` TssPubkey string `protobuf:"bytes,2,opt,name=tss_pubkey,json=tssPubkey,proto3" json:"tss_pubkey,omitempty"` diff --git a/x/emissions/client/cli/query.go b/x/emissions/client/cli/query.go index efd2cfad5c..56f9bbca7d 100644 --- a/x/emissions/client/cli/query.go +++ b/x/emissions/client/cli/query.go @@ -29,7 +29,5 @@ func GetQueryCmd(queryRoute string) *cobra.Command { CmdListPoolAddresses(), ) - // this line is used by starport scaffolding # 1 - return cmd } diff --git a/x/emissions/client/cli/tx.go b/x/emissions/client/cli/tx.go index 924d223e29..6635a6e3a7 100644 --- a/x/emissions/client/cli/tx.go +++ b/x/emissions/client/cli/tx.go @@ -19,7 +19,5 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - // this line is used by starport scaffolding # 1 - return cmd } diff --git a/x/emissions/genesis.go b/x/emissions/genesis.go index 2a2bd33f88..0d5593f5aa 100644 --- a/x/emissions/genesis.go +++ b/x/emissions/genesis.go @@ -9,7 +9,6 @@ import ( // InitGenesis initializes the capability module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, ak types.AccountKeeper, genState types.GenesisState) { - // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) ak.GetModuleAccount(ctx, types.ModuleName) ak.GetModuleAccount(ctx, types.UndistributedTssRewardsPool) @@ -22,7 +21,5 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) - // this line is used by starport scaffolding # genesis/module/export - return genesis } diff --git a/x/emissions/module.go b/x/emissions/module.go index b3b44da26a..1972204919 100644 --- a/x/emissions/module.go +++ b/x/emissions/module.go @@ -4,8 +4,6 @@ import ( "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -78,7 +76,6 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - // this line is used by starport scaffolding # 2 } // GetTxCmd returns the capability module's root tx command. diff --git a/x/emissions/types/codec.go b/x/emissions/types/codec.go index 8eb43994e7..b70e2a444a 100644 --- a/x/emissions/types/codec.go +++ b/x/emissions/types/codec.go @@ -7,12 +7,9 @@ import ( ) func RegisterCodec(cdc *codec.LegacyAmino) { - // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // this line is used by starport scaffolding # 3 - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/emissions/types/genesis.go b/x/emissions/types/genesis.go index 8df94bae23..0785224ae9 100644 --- a/x/emissions/types/genesis.go +++ b/x/emissions/types/genesis.go @@ -1,16 +1,11 @@ package types -import ( -// this line is used by starport scaffolding # genesis/types/import -) - // DefaultIndex is the default capability global index const DefaultIndex uint64 = 1 // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } } @@ -18,7 +13,5 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - // this line is used by starport scaffolding # genesis/types/validate - return gs.Params.Validate() } diff --git a/x/emissions/types/genesis_test.go b/x/emissions/types/genesis_test.go index eff333de84..6e0f27b4bc 100644 --- a/x/emissions/types/genesis_test.go +++ b/x/emissions/types/genesis_test.go @@ -20,13 +20,9 @@ func TestGenesisState_Validate(t *testing.T) { }, { desc: "valid genesis state", - genState: &types.GenesisState{ - - // this line is used by starport scaffolding # types/genesis/validField - }, - valid: true, + genState: &types.GenesisState{}, + valid: true, }, - // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() diff --git a/x/fungible/client/cli/query.go b/x/fungible/client/cli/query.go index 0a0ce40cd0..d41e244928 100644 --- a/x/fungible/client/cli/query.go +++ b/x/fungible/client/cli/query.go @@ -29,7 +29,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command { CmdListForeignCoins(), CmdShowForeignCoins(), ) - // this line is used by starport scaffolding # 1 return cmd } diff --git a/x/fungible/client/cli/tx.go b/x/fungible/client/cli/tx.go index 827ec0851e..90c7fa92d3 100644 --- a/x/fungible/client/cli/tx.go +++ b/x/fungible/client/cli/tx.go @@ -23,7 +23,6 @@ func GetTxCmd() *cobra.Command { CmdDeployFungibleCoinZRC4(), CmdRemoveForeignCoin(), ) - // this line is used by starport scaffolding # 1 return cmd } diff --git a/x/fungible/genesis.go b/x/fungible/genesis.go index d8ee10fe96..569c17cfa8 100644 --- a/x/fungible/genesis.go +++ b/x/fungible/genesis.go @@ -17,7 +17,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState, if genState.SystemContract != nil { k.SetSystemContract(ctx, *genState.SystemContract) } - // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) // ensure fungible module account is set on genesis if acc := authKeeper.GetModuleAccount(ctx, types.ModuleName); acc == nil { @@ -37,7 +37,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { if found { genesis.SystemContract = &system } - // this line is used by starport scaffolding # genesis/module/export return genesis } diff --git a/x/fungible/genesis_test.go b/x/fungible/genesis_test.go index 47e14fb5b4..f32a3dfa10 100644 --- a/x/fungible/genesis_test.go +++ b/x/fungible/genesis_test.go @@ -16,7 +16,6 @@ package fungible_test // SystemContract: &types.SystemContract{ // SystemContract: "29", // }, -// // this line is used by starport scaffolding # genesis/test/state // } // // k, ctx := keepertest.FungibleKeeper(t) @@ -28,5 +27,4 @@ package fungible_test // nullify.Fill(got) // // require.ElementsMatch(t, genesisState.ForeignCoinsList, got.ForeignCoinsList) -// // this line is used by starport scaffolding # genesis/test/assert //} diff --git a/x/fungible/module_simulation.go b/x/fungible/module_simulation.go index b757c60a6b..3a94d3ed03 100644 --- a/x/fungible/module_simulation.go +++ b/x/fungible/module_simulation.go @@ -9,10 +9,6 @@ import ( "github.com/zeta-chain/zetacore/x/fungible/types" ) -const ( -// this line is used by starport scaffolding # simapp/module/const -) - // GenerateGenesisState creates a randomized GenState of the module func (AppModule) GenerateGenesisState(simState *module.SimulationState) { accs := make([]string, len(simState.Accounts)) @@ -21,7 +17,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } fungibleGenesis := types.GenesisState{ Params: types.DefaultParams(), - // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&fungibleGenesis) } @@ -44,7 +39,5 @@ func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) - // this line is used by starport scaffolding # simapp/module/operation - return operations } diff --git a/x/fungible/types/codec.go b/x/fungible/types/codec.go index 8343265cbb..2f8689e4c2 100644 --- a/x/fungible/types/codec.go +++ b/x/fungible/types/codec.go @@ -10,7 +10,6 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgDeployFungibleCoinZRC20{}, "fungible/DeployFungibleCoinZRC20", nil) cdc.RegisterConcrete(&MsgRemoveForeignCoin{}, "fungible/RemoveForeignCoin", nil) - // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -19,8 +18,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgRemoveForeignCoin{}, ) - // this line is used by starport scaffolding # 3 - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/fungible/types/genesis.go b/x/fungible/types/genesis.go index 68bb0dd2a7..3887321f85 100644 --- a/x/fungible/types/genesis.go +++ b/x/fungible/types/genesis.go @@ -12,8 +12,7 @@ func DefaultGenesis() *GenesisState { return &GenesisState{ ForeignCoinsList: []ForeignCoins{}, SystemContract: nil, - // this line is used by starport scaffolding # genesis/types/default - Params: DefaultParams(), + Params: DefaultParams(), } } @@ -30,7 +29,6 @@ func (gs GenesisState) Validate() error { } foreignCoinsIndexMap[index] = struct{}{} } - // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() } diff --git a/x/fungible/types/genesis_test.go b/x/fungible/types/genesis_test.go index 20c7d3ab87..57927528af 100644 --- a/x/fungible/types/genesis_test.go +++ b/x/fungible/types/genesis_test.go @@ -30,8 +30,6 @@ func TestGenesisState_Validate(t *testing.T) { Zrc20ContractAddress: "1", }, }, - - // this line is used by starport scaffolding # types/genesis/validField }, valid: true, }, @@ -49,7 +47,6 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, - // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() diff --git a/x/observer/client/cli/query.go b/x/observer/client/cli/query.go index d67a0be176..a6db31fc0d 100644 --- a/x/observer/client/cli/query.go +++ b/x/observer/client/cli/query.go @@ -41,7 +41,5 @@ func GetQueryCmd(queryRoute string) *cobra.Command { CmdGetAllBlameRecords(), ) - // this line is used by starport scaffolding # 1 - return cmd } diff --git a/x/observer/client/cli/tx.go b/x/observer/client/cli/tx.go index f81743030b..826fe0586c 100644 --- a/x/observer/client/cli/tx.go +++ b/x/observer/client/cli/tx.go @@ -28,7 +28,5 @@ func GetTxCmd() *cobra.Command { CmdEncode(), ) - // this line is used by starport scaffolding # 1 - return cmd } diff --git a/x/observer/handler.go b/x/observer/handler.go deleted file mode 100644 index d94d633733..0000000000 --- a/x/observer/handler.go +++ /dev/null @@ -1,35 +0,0 @@ -package observer - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/x/observer/keeper" - "github.com/zeta-chain/zetacore/x/observer/types" -) - -// NewHandler ... -func NewHandler(k keeper.Keeper) sdk.Handler { - // this line is used by starport scaffolding # handler/msgServer - msgServer := keeper.NewMsgServerImpl(k) - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgUpdateCoreParams: - res, err := msgServer.UpdateCoreParams(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgUpdateKeygen: - res, err := msgServer.UpdateKeygen(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgUpdatePermissionFlags: - res, err := msgServer.UpdatePermissionFlags(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - // this line is used by starport scaffolding # 1 - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } - } -} diff --git a/x/observer/module.go b/x/observer/module.go index fdce29770d..84e0d5bdbf 100644 --- a/x/observer/module.go +++ b/x/observer/module.go @@ -5,8 +5,6 @@ import ( "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" diff --git a/x/observer/module_simulation.go b/x/observer/module_simulation.go index 6ee008cb23..89c8bc6444 100644 --- a/x/observer/module_simulation.go +++ b/x/observer/module_simulation.go @@ -14,8 +14,6 @@ const ( opWeightMsgUpdateClientParams = "op_weight_msg_update_client_params" // TODO: Determine the simulation weight value defaultWeightMsgUpdateClientParams int = 100 - - // this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module @@ -27,7 +25,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { defaultParams := types.DefaultParams() observerGenesis := types.GenesisState{ Params: &defaultParams, - // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&observerGenesis) } @@ -57,7 +54,5 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp }, ) - // this line is used by starport scaffolding # simapp/module/operation - return operations } diff --git a/x/observer/types/codec.go b/x/observer/types/codec.go index 7fe3c684dd..30bb82b86b 100644 --- a/x/observer/types/codec.go +++ b/x/observer/types/codec.go @@ -11,7 +11,6 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateCoreParams{}, "observer/UpdateClientParams", nil) cdc.RegisterConcrete(&MsgUpdatePermissionFlags{}, "crosschain/UpdatePermissionFlags", nil) cdc.RegisterConcrete(&MsgUpdateKeygen{}, "crosschain/UpdateKeygen", nil) - // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -20,7 +19,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgUpdatePermissionFlags{}, &MsgUpdateKeygen{}, ) - // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/observer/types/genesis_test.go b/x/observer/types/genesis_test.go index 157a944331..3bde1d8f5d 100644 --- a/x/observer/types/genesis_test.go +++ b/x/observer/types/genesis_test.go @@ -20,13 +20,9 @@ func TestGenesisState_Validate(t *testing.T) { }, { desc: "valid genesis state", - genState: &types.GenesisState{ - - // this line is used by starport scaffolding # types/genesis/validField - }, - valid: true, + genState: &types.GenesisState{}, + valid: true, }, - // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() From b77c02ff78afa0ba3d7dc2dec633327199464208 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Fri, 4 Aug 2023 22:31:26 +0200 Subject: [PATCH 2/2] refactor(`crosschain`): define interface for fungible keeper reference (#905) * fix crosschain test keeper * fungible expected keeper * use new type * genesis rename import * fix keeper_test * fix test files --------- Co-authored-by: brewmaster012 <88689859+brewmaster012@users.noreply.github.com> --- app/app.go | 2 +- .../keeper/{zetacore.go => crosschain.go} | 34 ++++++------- x/crosschain/genesis_test.go | 4 +- .../grpc_query_in_tx_hash_to_cctx_test.go | 4 +- .../keeper/in_tx_hash_to_cctx_test.go | 6 +-- x/crosschain/keeper/keeper.go | 5 +- .../keeper/keeper_out_tx_tracker_test.go | 6 +-- x/crosschain/keeper/keeper_test.go | 28 +++++------ x/crosschain/types/expected_keepers.go | 49 ++++++++++++++++++- 9 files changed, 91 insertions(+), 47 deletions(-) rename testutil/keeper/{zetacore.go => crosschain.go} (67%) diff --git a/app/app.go b/app/app.go index ccd07b956c..973601bbc9 100644 --- a/app/app.go +++ b/app/app.go @@ -402,7 +402,7 @@ func New( app.AccountKeeper, app.BankKeeper, app.ZetaObserverKeeper, - app.FungibleKeeper, + &app.FungibleKeeper, ) app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper, group.Config{ MaxExecutionPeriod: 2 * time.Hour, // Two hours. diff --git a/testutil/keeper/zetacore.go b/testutil/keeper/crosschain.go similarity index 67% rename from testutil/keeper/zetacore.go rename to testutil/keeper/crosschain.go index 480104ef27..b5c66023e9 100644 --- a/testutil/keeper/zetacore.go +++ b/testutil/keeper/crosschain.go @@ -1,9 +1,6 @@ package keeper import ( - authkeeper2 "github.com/cosmos/cosmos-sdk/x/auth/keeper" - bankkeeper2 "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/zeta-chain/zetacore/x/crosschain/keeper" "testing" "github.com/cosmos/cosmos-sdk/codec" @@ -11,19 +8,22 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmdb "github.com/tendermint/tm-db" - "github.com/zeta-chain/zetacore/x/crosschain/types" - fungibleKeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" - zetaobserverKeeper "github.com/zeta-chain/zetacore/x/observer/keeper" - typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/zeta-chain/zetacore/x/crosschain/keeper" + "github.com/zeta-chain/zetacore/x/crosschain/types" + fungiblekeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" + observerkeeper "github.com/zeta-chain/zetacore/x/observer/keeper" ) -func ZetacoreKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { +func CrosschainKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { storeKey := sdk.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) @@ -36,17 +36,17 @@ func ZetacoreKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { registry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(registry) - paramsSubspace := typesparams.NewSubspace(cdc, + paramsSubspace := paramstypes.NewSubspace(cdc, types.Amino, storeKey, memStoreKey, "ZetacoreParams", ) - bankkeeper := bankkeeper2.BaseKeeper{} - authkeeper := authkeeper2.AccountKeeper{} - zetaobserverKeeper := zetaobserverKeeper.Keeper{} - fungibleKeeper := fungibleKeeper.Keeper{} + bankKeeper := bankkeeper.BaseKeeper{} + authKeeper := authkeeper.AccountKeeper{} + observerKeeper := observerkeeper.Keeper{} + fungibleKeeper := fungiblekeeper.Keeper{} k := keeper.NewKeeper( codec.NewProtoCodec(registry), @@ -54,10 +54,10 @@ func ZetacoreKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { memStoreKey, stakingkeeper.Keeper{}, // custom paramsSubspace, - authkeeper, - bankkeeper, - zetaobserverKeeper, - fungibleKeeper, + authKeeper, + bankKeeper, + observerKeeper, + &fungibleKeeper, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/crosschain/genesis_test.go b/x/crosschain/genesis_test.go index 39dc4bd12b..1bfad7bdd0 100644 --- a/x/crosschain/genesis_test.go +++ b/x/crosschain/genesis_test.go @@ -1,12 +1,12 @@ package crosschain_test import ( - "github.com/zeta-chain/zetacore/x/crosschain" "testing" "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" + "github.com/zeta-chain/zetacore/x/crosschain" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -33,7 +33,7 @@ func TestGenesis(t *testing.T) { //}, } - k, ctx := keepertest.ZetacoreKeeper(t) + k, ctx := keepertest.CrosschainKeeper(t) crosschain.InitGenesis(ctx, *k, genesisState) got := crosschain.ExportGenesis(ctx, *k) require.NotNil(t, got) diff --git a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go index c8efaf967a..f9fa2f597e 100644 --- a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go +++ b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go @@ -19,7 +19,7 @@ import ( var _ = strconv.IntSize func TestInTxHashToCctxQuerySingle(t *testing.T) { - keeper, ctx := keepertest.ZetacoreKeeper(t) + keeper, ctx := keepertest.CrosschainKeeper(t) wctx := sdk.WrapSDKContext(ctx) msgs := createNInTxHashToCctx(keeper, ctx, 2) for _, tc := range []struct { @@ -70,7 +70,7 @@ func TestInTxHashToCctxQuerySingle(t *testing.T) { } func TestInTxHashToCctxQueryPaginated(t *testing.T) { - keeper, ctx := keepertest.ZetacoreKeeper(t) + keeper, ctx := keepertest.CrosschainKeeper(t) wctx := sdk.WrapSDKContext(ctx) msgs := createNInTxHashToCctx(keeper, ctx, 5) diff --git a/x/crosschain/keeper/in_tx_hash_to_cctx_test.go b/x/crosschain/keeper/in_tx_hash_to_cctx_test.go index e1784d1c35..3c8113b7ce 100644 --- a/x/crosschain/keeper/in_tx_hash_to_cctx_test.go +++ b/x/crosschain/keeper/in_tx_hash_to_cctx_test.go @@ -26,7 +26,7 @@ func createNInTxHashToCctx(keeper *keeper.Keeper, ctx sdk.Context, n int) []type } func TestInTxHashToCctxGet(t *testing.T) { - keeper, ctx := keepertest.ZetacoreKeeper(t) + keeper, ctx := keepertest.CrosschainKeeper(t) items := createNInTxHashToCctx(keeper, ctx, 10) for _, item := range items { rst, found := keeper.GetInTxHashToCctx(ctx, @@ -40,7 +40,7 @@ func TestInTxHashToCctxGet(t *testing.T) { } } func TestInTxHashToCctxRemove(t *testing.T) { - keeper, ctx := keepertest.ZetacoreKeeper(t) + keeper, ctx := keepertest.CrosschainKeeper(t) items := createNInTxHashToCctx(keeper, ctx, 10) for _, item := range items { keeper.RemoveInTxHashToCctx(ctx, @@ -54,7 +54,7 @@ func TestInTxHashToCctxRemove(t *testing.T) { } func TestInTxHashToCctxGetAll(t *testing.T) { - keeper, ctx := keepertest.ZetacoreKeeper(t) + keeper, ctx := keepertest.CrosschainKeeper(t) items := createNInTxHashToCctx(keeper, ctx, 10) require.ElementsMatch(t, nullify.Fill(items), diff --git a/x/crosschain/keeper/keeper.go b/x/crosschain/keeper/keeper.go index dd81b8f0c3..81218c877b 100644 --- a/x/crosschain/keeper/keeper.go +++ b/x/crosschain/keeper/keeper.go @@ -4,7 +4,6 @@ import ( "fmt" storetypes "github.com/cosmos/cosmos-sdk/store/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - fungibleModuleKeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" "github.com/tendermint/tendermint/libs/log" @@ -24,7 +23,7 @@ type ( authKeeper types.AccountKeeper bankKeeper types.BankKeeper zetaObserverKeeper types.ZetaObserverKeeper - fungibleKeeper fungibleModuleKeeper.Keeper + fungibleKeeper types.FungibleKeeper } ) @@ -37,7 +36,7 @@ func NewKeeper( authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, zetaObserverKeeper types.ZetaObserverKeeper, - fungibleKeeper fungibleModuleKeeper.Keeper, + fungibleKeeper types.FungibleKeeper, ) *Keeper { // ensure governance module account is set // FIXME: enable this check! (disabled for now to avoid unit test panic) diff --git a/x/crosschain/keeper/keeper_out_tx_tracker_test.go b/x/crosschain/keeper/keeper_out_tx_tracker_test.go index cc6db0be4c..9267871da6 100644 --- a/x/crosschain/keeper/keeper_out_tx_tracker_test.go +++ b/x/crosschain/keeper/keeper_out_tx_tracker_test.go @@ -30,7 +30,7 @@ func createNOutTxTracker(keeper *keeper.Keeper, ctx sdk.Context, n int) []types. } func TestOutTxTrackerGet(t *testing.T) { - keeper, ctx := keepertest.ZetacoreKeeper(t) + keeper, ctx := keepertest.CrosschainKeeper(t) items := createNOutTxTracker(keeper, ctx, 10) for _, item := range items { rst, found := keeper.GetOutTxTracker(ctx, @@ -45,7 +45,7 @@ func TestOutTxTrackerGet(t *testing.T) { } } func TestOutTxTrackerRemove(t *testing.T) { - k, ctx := keepertest.ZetacoreKeeper(t) + k, ctx := keepertest.CrosschainKeeper(t) items := createNOutTxTracker(k, ctx, 10) for _, item := range items { k.RemoveOutTxTracker(ctx, @@ -61,7 +61,7 @@ func TestOutTxTrackerRemove(t *testing.T) { } func TestOutTxTrackerGetAll(t *testing.T) { - keeper, ctx := keepertest.ZetacoreKeeper(t) + keeper, ctx := keepertest.CrosschainKeeper(t) items := createNOutTxTracker(keeper, ctx, 10) require.ElementsMatch(t, nullify.Fill(items), diff --git a/x/crosschain/keeper/keeper_test.go b/x/crosschain/keeper/keeper_test.go index 98014a4e27..d7ad574eb2 100644 --- a/x/crosschain/keeper/keeper_test.go +++ b/x/crosschain/keeper/keeper_test.go @@ -1,10 +1,6 @@ package keeper import ( - authkeeper2 "github.com/cosmos/cosmos-sdk/x/auth/keeper" - bankkeeper2 "github.com/cosmos/cosmos-sdk/x/bank/keeper" - fungibleKeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" - "github.com/zeta-chain/zetacore/x/observer/keeper" "testing" "github.com/cosmos/cosmos-sdk/codec" @@ -12,14 +8,18 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmdb "github.com/tendermint/tm-db" - "github.com/zeta-chain/zetacore/x/crosschain/types" - typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/zeta-chain/zetacore/x/crosschain/types" + fungiblekeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" + "github.com/zeta-chain/zetacore/x/observer/keeper" ) func setupKeeper(t testing.TB) (*Keeper, sdk.Context) { @@ -41,10 +41,10 @@ func setupKeeper(t testing.TB) (*Keeper, sdk.Context) { memStoreKey, "ZetacoreParams", ) - bankkeeper := bankkeeper2.BaseKeeper{} - authkeeper := authkeeper2.AccountKeeper{} - zetaobserverKeeper := keeper.Keeper{} - fungibleKeeper := fungibleKeeper.Keeper{} + bankKeeper := bankkeeper.BaseKeeper{} + authKeeper := authkeeper.AccountKeeper{} + observerKeeper := keeper.Keeper{} + fungibleKeeper := fungiblekeeper.Keeper{} k := NewKeeper( codec.NewProtoCodec(registry), @@ -52,10 +52,10 @@ func setupKeeper(t testing.TB) (*Keeper, sdk.Context) { memStoreKey, stakingkeeper.Keeper{}, // custom paramsSubspace, - authkeeper, - bankkeeper, - zetaobserverKeeper, - fungibleKeeper, + authKeeper, + bankKeeper, + observerKeeper, + &fungibleKeeper, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index 1f0fa50b6c..319c76bd36 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -1,10 +1,16 @@ package types import ( + "math/big" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + eth "github.com/ethereum/go-ethereum/common" + evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/zeta-chain/zetacore/common" + + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -54,8 +60,47 @@ type ZetaObserverKeeper interface { SetKeygen(ctx sdk.Context, keygen zetaObserverTypes.Keygen) SetPermissionFlags(ctx sdk.Context, permissionFlags zetaObserverTypes.PermissionFlags) SetLastObserverCount(ctx sdk.Context, lbc *zetaObserverTypes.LastObserverCount) - AddVoteToBallot(ctx sdk.Context, ballot zetaObserverTypes.Ballot, address string, observationType zetaObserverTypes.VoteType) (zetaObserverTypes.Ballot, error) + AddVoteToBallot( + ctx sdk.Context, + ballot zetaObserverTypes.Ballot, + address string, + observationType zetaObserverTypes.VoteType, + ) (zetaObserverTypes.Ballot, error) CheckIfFinalizingVote(ctx sdk.Context, ballot zetaObserverTypes.Ballot) (zetaObserverTypes.Ballot, bool) IsAuthorized(ctx sdk.Context, address string, chain *common.Chain) (bool, error) - FindBallot(ctx sdk.Context, index string, chain *common.Chain, observationType zetaObserverTypes.ObservationType) (ballot zetaObserverTypes.Ballot, isNew bool, err error) + FindBallot( + ctx sdk.Context, + index string, + chain *common.Chain, + observationType zetaObserverTypes.ObservationType, + ) (ballot zetaObserverTypes.Ballot, isNew bool, err error) +} + +type FungibleKeeper interface { + GetForeignCoins(ctx sdk.Context, zrc20Addr string) (val fungibletypes.ForeignCoins, found bool) + GetAllForeignCoinsForChain(ctx sdk.Context, foreignChainID int64) (list []fungibletypes.ForeignCoins) + GetSystemContract(ctx sdk.Context) (val fungibletypes.SystemContract, found bool) + QuerySystemContractGasCoinZRC20(ctx sdk.Context, chainID *big.Int) (eth.Address, error) + QueryUniswapv2RouterGetAmountsIn(ctx sdk.Context, amountOut *big.Int, outZRC4 eth.Address) (*big.Int, error) + SetGasPrice(ctx sdk.Context, chainID *big.Int, gasPrice *big.Int) (uint64, error) + DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int) error + ZRC20DepositAndCallContract( + ctx sdk.Context, + to eth.Address, + amount *big.Int, + senderChain *common.Chain, + message string, + contract eth.Address, + data []byte, + coinType common.CoinType, + asset string, + ) (*evmtypes.MsgEthereumTxResponse, error) + CallUniswapv2RouterSwapExactETHForToken( + ctx sdk.Context, + sender eth.Address, + to eth.Address, + amountIn *big.Int, + outZRC4 eth.Address, + ) ([]*big.Int, error) + CallZRC20Burn(ctx sdk.Context, sender eth.Address, zrc20address eth.Address, amount *big.Int) error }