diff --git a/app/app.go b/app/app.go index 4b97584e..30b8e881 100644 --- a/app/app.go +++ b/app/app.go @@ -121,6 +121,7 @@ import ( "github.com/althea-net/althea-L1/app/ante" altheaappparams "github.com/althea-net/althea-L1/app/params" altheacfg "github.com/althea-net/althea-L1/config" + "github.com/althea-net/althea-L1/x/gasfree" gasfreekeeper "github.com/althea-net/althea-L1/x/gasfree/keeper" gasfreetypes "github.com/althea-net/althea-L1/x/gasfree/types" lockup "github.com/althea-net/althea-L1/x/lockup" @@ -756,8 +757,9 @@ func NewAltheaApp( ibc.NewAppModule(&ibcKeeper), params.NewAppModule(paramsKeeper), ibcTransferAppModule, + gasfree.NewAppModule(gasfreeKeeper), lockup.NewAppModule(lockupKeeper, bankKeeper), - microtx.NewAppModule(microtxKeeper, accountKeeper, bankKeeper), + microtx.NewAppModule(microtxKeeper, accountKeeper), evm.NewAppModule(&evmKeeper, accountKeeper), erc20.NewAppModule(erc20Keeper, accountKeeper), feemarket.NewAppModule(feemarketKeeper), @@ -791,6 +793,7 @@ func NewAltheaApp( authz.ModuleName, govtypes.ModuleName, paramstypes.ModuleName, + gasfreetypes.ModuleName, lockuptypes.ModuleName, microtxtypes.ModuleName, erc20types.ModuleName, @@ -819,6 +822,7 @@ func NewAltheaApp( genutiltypes.ModuleName, authz.ModuleName, paramstypes.ModuleName, + gasfreetypes.ModuleName, lockuptypes.ModuleName, microtxtypes.ModuleName, erc20types.ModuleName, @@ -844,6 +848,7 @@ func NewAltheaApp( ibctransfertypes.ModuleName, authz.ModuleName, paramstypes.ModuleName, + gasfreetypes.ModuleName, lockuptypes.ModuleName, microtxtypes.ModuleName, erc20types.ModuleName, diff --git a/proto/althea/gasfree/v1/genesis.proto b/proto/althea/gasfree/v1/genesis.proto index 81261968..8ee81d87 100644 --- a/proto/althea/gasfree/v1/genesis.proto +++ b/proto/althea/gasfree/v1/genesis.proto @@ -7,7 +7,7 @@ option go_package = "github.com/althea-net/althea-L1/x/gasfree/types"; message Params { // Messages with one of these types will not be charged gas fees in the // AnteHandler, but will later be charged some form of fee in the Msg handler - repeated string gas_free_message_types = 3; + repeated string gas_free_message_types = 1; } message GenesisState { diff --git a/proto/althea/gasfree/v1/query.proto b/proto/althea/gasfree/v1/query.proto new file mode 100644 index 00000000..25da3adf --- /dev/null +++ b/proto/althea/gasfree/v1/query.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package althea.gasfree.v1; + +import "google/api/annotations.proto"; +import "gogoproto/gogo.proto"; +import "althea/gasfree/v1/genesis.proto"; + +option go_package = "github.com/althea-net/althea-L1/x/gasfree/types"; + +// Query defines the gRPC querier service. +service Query { + // Params retrieves the total set of onboarding parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/althea/gasfree/v1/params"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [ (gogoproto.nullable) = false ]; +} diff --git a/x/gasfree/cli/query.go b/x/gasfree/cli/query.go new file mode 100644 index 00000000..0afcf996 --- /dev/null +++ b/x/gasfree/cli/query.go @@ -0,0 +1,53 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/althea-net/althea-L1/x/gasfree/types" +) + +// GetQueryCmd bundles all the query subcmds together so they appear under the `query` or `q` subcommand +func GetQueryCmd() *cobra.Command { + // nolint: exhaustruct + gasfreeQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the gasfree module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + gasfreeQueryCmd.AddCommand([]*cobra.Command{ + CmdQueryParams(), + }...) + + return gasfreeQueryCmd +} + +// CmdQueryParams fetches the current microtx params +func CmdQueryParams() *cobra.Command { + // nolint: exhaustruct + cmd := &cobra.Command{ + Use: "params", + Args: cobra.NoArgs, + Short: "Query gasfree params", + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/gasfree/keeper/grpc_query.go b/x/gasfree/keeper/grpc_query.go new file mode 100644 index 00000000..13e0c586 --- /dev/null +++ b/x/gasfree/keeper/grpc_query.go @@ -0,0 +1,22 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/althea-net/althea-L1/x/gasfree/types" +) + +// nolint: exhaustruct +// Enforce via type assertion that the Keeper functions as a query server +var _ types.QueryServer = Keeper{} + +// Params queries the params of the microtx module +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + p, err := k.GetParamsIfSet(sdk.UnwrapSDKContext(c)) + if err != nil { + return nil, err // Force an empty response on error + } + return &types.QueryParamsResponse{Params: p}, nil +} diff --git a/x/gasfree/module.go b/x/gasfree/module.go index 0e2b95c2..e8f17b7e 100644 --- a/x/gasfree/module.go +++ b/x/gasfree/module.go @@ -1,6 +1,7 @@ package gasfree import ( + "context" "encoding/json" "fmt" "math/rand" @@ -15,11 +16,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" abci "github.com/tendermint/tendermint/abci/types" "github.com/althea-net/althea-L1/x/gasfree/keeper" "github.com/althea-net/althea-L1/x/gasfree/types" + "github.com/althea-net/althea-L1/x/microtx/client/cli" ) // type check to ensure the interface is properly implemented @@ -40,6 +41,7 @@ func (AppModuleBasic) Name() string { // RegisterLegacyAminoCodec implements app module basic func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + // types.RegisterCodec(cdc) } // DefaultGenesis implements app module basic @@ -63,8 +65,8 @@ func (AppModuleBasic) RegisterRESTRoutes(ctx client.Context, rtr *mux.Router) { // GetQueryCmd implements app module basic func (AppModuleBasic) GetQueryCmd() *cobra.Command { - // nolint: exhaustruct - return &cobra.Command{} + return cli.GetQueryCmd() + } // GetTxCmd implements app module basic @@ -74,12 +76,17 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command { } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the distribution module. -// also implements app modeul basic +// also implements app module basic func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + panic("Failed to register query handler") + } } -// RegisterInterfaces implements app bmodule basic +// RegisterInterfaces implements app module basic func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + // types.RegisterInterfaces(registry) } //____________________________________________________________________________ @@ -87,16 +94,14 @@ func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry // AppModule object for module implementation type AppModule struct { AppModuleBasic - keeper keeper.Keeper - bankKeeper bankkeeper.Keeper + keeper keeper.Keeper } // NewAppModule creates a new AppModule Object -func NewAppModule(k keeper.Keeper, bankKeeper bankkeeper.Keeper) AppModule { +func NewAppModule(k keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: k, - bankKeeper: bankKeeper, } } diff --git a/x/gasfree/types/genesis.pb.go b/x/gasfree/types/genesis.pb.go index 9601dab6..2e18b3a4 100644 --- a/x/gasfree/types/genesis.pb.go +++ b/x/gasfree/types/genesis.pb.go @@ -26,7 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { // Messages with one of these types will not be charged gas fees in the // AnteHandler, but will later be charged some form of fee in the Msg handler - GasFreeMessageTypes []string `protobuf:"bytes,3,rep,name=gas_free_message_types,json=gasFreeMessageTypes,proto3" json:"gas_free_message_types,omitempty"` + GasFreeMessageTypes []string `protobuf:"bytes,1,rep,name=gas_free_message_types,json=gasFreeMessageTypes,proto3" json:"gas_free_message_types,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -127,7 +127,7 @@ var fileDescriptor_1e21bc10ce13ce59 = []byte{ 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x28, 0xd0, 0x83, 0x2a, 0xd0, 0x2b, 0x33, 0x54, 0xb2, 0xe5, 0x62, 0x0b, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0x16, 0x32, 0xe6, 0x12, 0x4b, 0x4f, 0x2c, 0x8e, 0x07, 0x49, 0xc4, 0xe7, 0xa6, 0x16, 0x17, 0x27, 0xa6, - 0xa7, 0xc6, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x4b, 0x30, 0x2b, 0x30, 0x6b, 0x70, 0x06, 0x09, 0xa7, + 0xa7, 0xc6, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x06, 0x09, 0xa7, 0x27, 0x16, 0xbb, 0x15, 0xa5, 0xa6, 0xfa, 0x42, 0xe4, 0x42, 0x40, 0x52, 0x4a, 0x8e, 0x5c, 0x3c, 0xee, 0x10, 0x2b, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0x0c, 0xb9, 0xd8, 0x0a, 0xc0, 0xc6, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x49, 0xea, 0x61, 0x58, 0xa9, 0x07, 0xb1, 0x2f, 0x08, 0xaa, @@ -135,7 +135,7 @@ var fileDescriptor_1e21bc10ce13ce59 = []byte{ 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xf4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x21, 0xc6, 0xe8, 0xe6, 0xa5, 0x96, 0xc0, 0x98, 0x3e, 0x86, 0xfa, 0x15, 0x70, 0xaf, 0x82, 0x1d, 0x9a, 0xc4, 0x06, 0xf6, 0xa6, 0x31, 0x20, - 0x00, 0x00, 0xff, 0xff, 0xc7, 0x5c, 0xc0, 0x71, 0x09, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x7d, 0x3c, 0xf7, 0xc5, 0x09, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -164,7 +164,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.GasFreeMessageTypes[iNdEx]) i = encodeVarintGenesis(dAtA, i, uint64(len(m.GasFreeMessageTypes[iNdEx]))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0xa } } return len(dAtA) - i, nil @@ -279,7 +279,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 3: + case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field GasFreeMessageTypes", wireType) } diff --git a/x/gasfree/types/query.pb.go b/x/gasfree/types/query.pb.go new file mode 100644 index 00000000..5557c6cd --- /dev/null +++ b/x/gasfree/types/query.pb.go @@ -0,0 +1,535 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: althea/gasfree/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_7725dca9511d36d5, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7725dca9511d36d5, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "althea.gasfree.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "althea.gasfree.v1.QueryParamsResponse") +} + +func init() { proto.RegisterFile("althea/gasfree/v1/query.proto", fileDescriptor_7725dca9511d36d5) } + +var fileDescriptor_7725dca9511d36d5 = []byte{ + // 283 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0xcc, 0x29, 0xc9, + 0x48, 0x4d, 0xd4, 0x4f, 0x4f, 0x2c, 0x4e, 0x2b, 0x4a, 0x4d, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, + 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x48, 0xeb, 0x41, 0xa5, + 0xf5, 0xca, 0x0c, 0xa5, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, + 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0x1a, 0xa4, 0x44, 0xd2, + 0xf3, 0xd3, 0xf3, 0xc1, 0x4c, 0x7d, 0x10, 0x0b, 0x2a, 0x2a, 0x8f, 0x69, 0x4b, 0x7a, 0x6a, 0x5e, + 0x6a, 0x71, 0x26, 0x54, 0x9b, 0x92, 0x08, 0x97, 0x50, 0x20, 0xc8, 0xda, 0x80, 0xc4, 0xa2, 0xc4, + 0xdc, 0xe2, 0xa0, 0xd4, 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0x25, 0x3f, 0x2e, 0x61, 0x14, 0xd1, 0xe2, + 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x21, 0x73, 0x2e, 0xb6, 0x02, 0xb0, 0x88, 0x04, 0xa3, 0x02, 0xa3, + 0x06, 0xb7, 0x91, 0xa4, 0x1e, 0x86, 0x2b, 0xf5, 0x20, 0x5a, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, + 0x08, 0x82, 0x2a, 0x37, 0x6a, 0x66, 0xe4, 0x62, 0x05, 0x1b, 0x28, 0x54, 0xc5, 0xc5, 0x06, 0x51, + 0x21, 0xa4, 0x8a, 0x45, 0x33, 0xa6, 0x53, 0xa4, 0xd4, 0x08, 0x29, 0x83, 0xb8, 0x4d, 0x49, 0xb1, + 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0xd2, 0x42, 0x92, 0xfa, 0x98, 0x5e, 0x86, 0xb8, 0xc2, 0xc9, 0xf3, + 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, + 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xf4, 0xd3, 0x33, 0x4b, 0x32, 0x4a, + 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xa1, 0xda, 0x75, 0xf3, 0x52, 0x4b, 0x60, 0x4c, 0x1f, 0x43, 0xfd, + 0x0a, 0xb8, 0x71, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0xd0, 0x33, 0x06, 0x04, 0x00, + 0x00, 0xff, 0xff, 0x05, 0x49, 0x19, 0x5d, 0xc6, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params retrieves the total set of onboarding parameters. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/althea.gasfree.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params retrieves the total set of onboarding parameters. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/althea.gasfree.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "althea.gasfree.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "althea/gasfree/v1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/gasfree/types/query.pb.gw.go b/x/gasfree/types/query.pb.gw.go new file mode 100644 index 00000000..57c7feae --- /dev/null +++ b/x/gasfree/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: althea/gasfree/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"althea", "gasfree", "v1", "params"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/microtx/module.go b/x/microtx/module.go index 4afa88a2..717a7608 100644 --- a/x/microtx/module.go +++ b/x/microtx/module.go @@ -18,7 +18,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" abci "github.com/tendermint/tendermint/abci/types" "github.com/althea-net/althea-L1/x/microtx/client/cli" @@ -98,7 +97,6 @@ type AppModule struct { AppModuleBasic keeper keeper.Keeper accountKeeper authkeeper.AccountKeeper - bankKeeper bankkeeper.Keeper } func (am AppModule) ConsensusVersion() uint64 { @@ -106,12 +104,11 @@ func (am AppModule) ConsensusVersion() uint64 { } // NewAppModule creates a new AppModule Object -func NewAppModule(k keeper.Keeper, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper) AppModule { +func NewAppModule(k keeper.Keeper, accountKeeper authkeeper.AccountKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: k, accountKeeper: accountKeeper, - bankKeeper: bankKeeper, } }