diff --git a/x/callback/client/cli/query.go b/x/callback/client/cli/query.go new file mode 100644 index 00000000..c8e07922 --- /dev/null +++ b/x/callback/client/cli/query.go @@ -0,0 +1,10 @@ +package cli + +import ( + "github.com/spf13/cobra" +) + +// GetQueryCmd builds query command group for the module. +func GetQueryCmd() *cobra.Command { + panic("unimplemented 👻") +} diff --git a/x/callback/client/cli/tx.go b/x/callback/client/cli/tx.go new file mode 100644 index 00000000..486ec8d1 --- /dev/null +++ b/x/callback/client/cli/tx.go @@ -0,0 +1,10 @@ +package cli + +import ( + "github.com/spf13/cobra" +) + +// GetTxCmd builds tx command group for the module. +func GetTxCmd() *cobra.Command { + panic("unimplemented 👻") +} diff --git a/x/callback/genesis.go b/x/callback/genesis.go new file mode 100644 index 00000000..edb79e41 --- /dev/null +++ b/x/callback/genesis.go @@ -0,0 +1,18 @@ +package callback + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/archway-network/archway/x/callback/keeper" + "github.com/archway-network/archway/x/callback/types" +) + +// InitGenesis initializes the module genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + panic("unimplemented 👻") +} + +// ExportGenesis exports the module genesis for the current block. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + panic("unimplemented 👻") +} diff --git a/x/callback/keeper/callback.go b/x/callback/keeper/callback.go new file mode 100644 index 00000000..b55569d4 --- /dev/null +++ b/x/callback/keeper/callback.go @@ -0,0 +1 @@ +package keeper diff --git a/x/callback/keeper/grpc_query.go b/x/callback/keeper/grpc_query.go new file mode 100644 index 00000000..f2361d5a --- /dev/null +++ b/x/callback/keeper/grpc_query.go @@ -0,0 +1,36 @@ +package keeper + +import ( + "context" + + "github.com/archway-network/archway/x/callback/types" +) + +var _ types.QueryServer = &QueryServer{} + +// QueryServer implements the module gRPC query service. +type QueryServer struct { + keeper Keeper +} + +// NewQueryServer creates a new gRPC query server. +func NewQueryServer(keeper Keeper) *QueryServer { + return &QueryServer{ + keeper: keeper, + } +} + +// Callbacks implements types.QueryServer. +func (*QueryServer) Callbacks(context.Context, *types.QueryCallbacksRequest) (*types.QueryCallbacksResponse, error) { + panic("unimplemented 👻") +} + +// EstimateCallbackFees implements types.QueryServer. +func (*QueryServer) EstimateCallbackFees(context.Context, *types.QueryEstimateCallbackFeesRequest) (*types.QueryEstimateCallbackFeesResponse, error) { + panic("unimplemented 👻") +} + +// Params implements types.QueryServer. +func (*QueryServer) Params(context.Context, *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + panic("unimplemented 👻") +} diff --git a/x/callback/keeper/keeper.go b/x/callback/keeper/keeper.go new file mode 100644 index 00000000..d27da287 --- /dev/null +++ b/x/callback/keeper/keeper.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + paramTypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/archway-network/archway/x/callback/types" +) + +// Keeper provides module state operations. +type Keeper struct { + cdc codec.Codec + paramStore paramTypes.Subspace +} + +// NewKeeper creates a new Keeper instance. +func NewKeeper(cdc codec.Codec, ps paramTypes.Subspace) Keeper { + return Keeper{ + cdc: cdc, + paramStore: ps, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} diff --git a/x/callback/keeper/msg_server.go b/x/callback/keeper/msg_server.go new file mode 100644 index 00000000..3ecdc916 --- /dev/null +++ b/x/callback/keeper/msg_server.go @@ -0,0 +1,36 @@ +package keeper + +import ( + "context" + + "github.com/archway-network/archway/x/callback/types" +) + +var _ types.MsgServer = (*MsgServer)(nil) + +// MsgServer implements the module gRPC messaging service. +type MsgServer struct { + keeper Keeper +} + +// NewMsgServer creates a new gRPC messaging server. +func NewMsgServer(keeper Keeper) *MsgServer { + return &MsgServer{ + keeper: keeper, + } +} + +// CancelCallback implements types.MsgServer. +func (*MsgServer) CancelCallback(context.Context, *types.MsgCancelCallback) (*types.MsgCancelCallbackResponse, error) { + panic("unimplemented 👻") +} + +// RequestCallback implements types.MsgServer. +func (*MsgServer) RequestCallback(context.Context, *types.MsgRequestCallback) (*types.MsgRequestCallbackResponse, error) { + panic("unimplemented 👻") +} + +// UpdateParams implements types.MsgServer. +func (*MsgServer) UpdateParams(context.Context, *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + panic("unimplemented 👻") +} diff --git a/x/callback/keeper/params.go b/x/callback/keeper/params.go new file mode 100644 index 00000000..b55569d4 --- /dev/null +++ b/x/callback/keeper/params.go @@ -0,0 +1 @@ +package keeper diff --git a/x/callback/module.go b/x/callback/module.go new file mode 100644 index 00000000..97eefea6 --- /dev/null +++ b/x/callback/module.go @@ -0,0 +1,131 @@ +package callback + +import ( + "context" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codecTypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/archway-network/archway/x/callback/client/cli" + "github.com/archway-network/archway/x/callback/keeper" + "github.com/archway-network/archway/x/callback/types" +) + +var ( + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = AppModule{} +) + +// AppModuleBasic defines the basic application module for this module. +type AppModuleBasic struct { + cdc codec.Codec +} + +// Name returns the module's name. +func (a AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the module's types on the given LegacyAmino codec. +func (a AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(amino) +} + +// RegisterInterfaces registers the module's interface types. +func (a AppModuleBasic) RegisterInterfaces(registry codecTypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the module. +func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the module. +func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var state types.GenesisState + if err := cdc.UnmarshalJSON(bz, &state); err != nil { + return fmt.Errorf("failed to unmarshal x/%s genesis state: %w", types.ModuleName, err) + } + + return state.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(clientCtx)); err != nil { + panic(fmt.Errorf("registering query handler for x/%s: %w", types.ModuleName, err)) + } +} + +// GetTxCmd returns the root tx command for the module. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns no root query command for the module. +func (a AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// AppModule implements an application module for this module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule object. +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + } +} + +// RegisterInvariants registers the module invariants. +func (a AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +} + +// RegisterServices registers the module services. +func (a AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(a.keeper)) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(a.keeper)) +} + +// InitGenesis performs genesis initialization for the module. It returns no validator updates. +func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(bz, &genesisState) + + InitGenesis(ctx, a.keeper, genesisState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the module. +func (a AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + state := ExportGenesis(ctx, a.keeper) + return cdc.MustMarshalJSON(state) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (a AppModule) ConsensusVersion() uint64 { + return 1 +} + +// BeginBlock returns the begin blocker for the module. +func (a AppModule) BeginBlock(ctx sdk.Context, block abci.RequestBeginBlock) {} + +// EndBlock returns the end blocker for the module. It returns no validator updates. +func (a AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/callback/types/codec.go b/x/callback/types/codec.go new file mode 100644 index 00000000..1100c0a5 --- /dev/null +++ b/x/callback/types/codec.go @@ -0,0 +1,29 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptoCodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// RegisterLegacyAminoCodec registers the necessary interfaces and concrete types on the provided LegacyAmino codec. +// These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} + +// RegisterInterfaces registers interfaces types with the interface registry. +func RegisterInterfaces(registry types.InterfaceRegistry) { +} + +var ( + ModuleCdc = codec.NewAminoCodec(amino) + amino = codec.NewLegacyAmino() +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptoCodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + amino.Seal() +} diff --git a/x/callback/types/errors.go b/x/callback/types/errors.go new file mode 100644 index 00000000..3be97671 --- /dev/null +++ b/x/callback/types/errors.go @@ -0,0 +1,8 @@ +package types + +import errorsmod "cosmossdk.io/errors" + +var ( + DefaultCodespace = ModuleName + ErrInternal = errorsmod.Register(DefaultCodespace, 0, "internal error") // smth went wrong +) diff --git a/x/callback/types/expected_keepers.go b/x/callback/types/expected_keepers.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/callback/types/expected_keepers.go @@ -0,0 +1 @@ +package types diff --git a/x/callback/types/genesis.go b/x/callback/types/genesis.go new file mode 100644 index 00000000..079f389b --- /dev/null +++ b/x/callback/types/genesis.go @@ -0,0 +1,18 @@ +package types + +// NewGenesisState creates a new GenesisState object. +func NewGenesisState( + params Params, +) *GenesisState { + panic("unimplemented 👻") +} + +// DefaultGenesisState returns a default genesis state. +func DefaultGenesis() *GenesisState { + panic("unimplemented 👻") +} + +// Validate perform object fields validation. +func (m GenesisState) Validate() error { + panic("unimplemented 👻") +} diff --git a/x/callback/types/keys.go b/x/callback/types/keys.go new file mode 100644 index 00000000..c9ec4391 --- /dev/null +++ b/x/callback/types/keys.go @@ -0,0 +1,10 @@ +package types + +const ( + // ModuleName is the module name. + ModuleName = "callback" + // StoreKey is the module KV storage prefix key. + StoreKey = ModuleName + // QuerierRoute is the querier route for the module. + QuerierRoute = ModuleName +) diff --git a/x/callback/types/params.go b/x/callback/types/params.go new file mode 100644 index 00000000..e56307b0 --- /dev/null +++ b/x/callback/types/params.go @@ -0,0 +1,20 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// NewParams creates a new Params instance. +func NewParams(inflationRewardsRatio, txFeeRebateRatio sdk.Dec, maxwithdrawRecords uint64) Params { + panic("unimplemented 👻") +} + +// DefaultParams returns a default set of parameters. +func DefaultParams() Params { + panic("unimplemented 👻") +} + +// Validate perform object fields validation. +func (m Params) Validate() error { + panic("unimplemented 👻") +} diff --git a/x/callback/types/types.go b/x/callback/types/types.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/callback/types/types.go @@ -0,0 +1 @@ +package types