diff --git a/.github/workflows/consensus_tests.yml b/.github/workflows/consensus_tests.yml index afebbf72f9..dbec87668b 100644 --- a/.github/workflows/consensus_tests.yml +++ b/.github/workflows/consensus_tests.yml @@ -69,3 +69,5 @@ jobs: - name: lava plans unit Tests run: go test ./x/plans/ ./x/plans/keeper ./x/plans/types -v + - name: lava subscription unit Tests + run: go test ./x/subscription/... -v diff --git a/app/app.go b/app/app.go index 86015f79db..6008058321 100644 --- a/app/app.go +++ b/app/app.go @@ -99,14 +99,17 @@ import ( pairingmodule "github.com/lavanet/lava/x/pairing" pairingmodulekeeper "github.com/lavanet/lava/x/pairing/keeper" pairingmoduletypes "github.com/lavanet/lava/x/pairing/types" - plans "github.com/lavanet/lava/x/plans" + plansmodule "github.com/lavanet/lava/x/plans" plansmoduleclient "github.com/lavanet/lava/x/plans/client" plansmodulekeeper "github.com/lavanet/lava/x/plans/keeper" plansmoduletypes "github.com/lavanet/lava/x/plans/types" - "github.com/lavanet/lava/x/spec" + specmodule "github.com/lavanet/lava/x/spec" specmoduleclient "github.com/lavanet/lava/x/spec/client" specmodulekeeper "github.com/lavanet/lava/x/spec/keeper" specmoduletypes "github.com/lavanet/lava/x/spec/types" + subscriptionmodule "github.com/lavanet/lava/x/subscription" + subscriptionmodulekeeper "github.com/lavanet/lava/x/subscription/keeper" + subscriptionmoduletypes "github.com/lavanet/lava/x/subscription/types" "github.com/spf13/cast" abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" @@ -182,11 +185,12 @@ var ( evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, - spec.AppModuleBasic{}, + specmodule.AppModuleBasic{}, epochstoragemodule.AppModuleBasic{}, + subscriptionmodule.AppModuleBasic{}, pairingmodule.AppModuleBasic{}, conflictmodule.AppModuleBasic{}, - plans.AppModuleBasic{}, + plansmodule.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -200,6 +204,7 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, epochstoragemoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, + subscriptionmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, pairingmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, conflictmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, // this line is used by starport scaffolding # stargate/app/maccPerms @@ -281,6 +286,7 @@ func New( evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, specmoduletypes.StoreKey, epochstoragemoduletypes.StoreKey, + subscriptionmoduletypes.StoreKey, pairingmoduletypes.StoreKey, conflictmoduletypes.StoreKey, plansmoduletypes.StoreKey, @@ -358,7 +364,6 @@ func New( appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, ) - // // Initialize SpecKeeper prior to govRouter (order is critical) app.SpecKeeper = *specmodulekeeper.NewKeeper( appCodec, @@ -366,7 +371,7 @@ func New( keys[specmoduletypes.MemStoreKey], app.GetSubspace(specmoduletypes.ModuleName), ) - specModule := spec.NewAppModule(appCodec, app.SpecKeeper, app.AccountKeeper, app.BankKeeper) + specModule := specmodule.NewAppModule(appCodec, app.SpecKeeper, app.AccountKeeper, app.BankKeeper) // Initialize PackagesKeeper prior to govRouter (order is critical) app.PlansKeeper = *plansmodulekeeper.NewKeeper( @@ -375,18 +380,18 @@ func New( keys[plansmoduletypes.MemStoreKey], app.GetSubspace(plansmoduletypes.ModuleName), ) - plansModule := plans.NewAppModule(appCodec, app.PlansKeeper) + plansModule := plansmodule.NewAppModule(appCodec, app.PlansKeeper) // register the proposal types govRouter := govtypes.NewRouter() govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). // // user defined - AddRoute(specmoduletypes.ProposalsRouterKey, spec.NewSpecProposalsHandler(app.SpecKeeper)). + AddRoute(specmoduletypes.ProposalsRouterKey, specmodule.NewSpecProposalsHandler(app.SpecKeeper)). // copied the code from param and changed the handler to enable functionality - AddRoute(paramproposal.RouterKey, spec.NewParamChangeProposalHandler(app.ParamsKeeper)). + AddRoute(paramproposal.RouterKey, specmodule.NewParamChangeProposalHandler(app.ParamsKeeper)). // user defined - AddRoute(plansmoduletypes.ProposalsRouterKey, plans.NewPlansProposalsHandler(app.PlansKeeper)). + AddRoute(plansmoduletypes.ProposalsRouterKey, plansmodule.NewPlansProposalsHandler(app.PlansKeeper)). // // default @@ -440,6 +445,19 @@ func New( ) pairingModule := pairingmodule.NewAppModule(appCodec, app.PairingKeeper, app.AccountKeeper, app.BankKeeper) + app.SubscriptionKeeper = *subscriptionmodulekeeper.NewKeeper( + appCodec, + keys[subscriptionmoduletypes.StoreKey], + keys[subscriptionmoduletypes.MemStoreKey], + app.GetSubspace(subscriptionmoduletypes.ModuleName), + + app.BankKeeper, + app.AccountKeeper, + &app.EpochstorageKeeper, + app.PlansKeeper, + ) + subscriptionModule := subscriptionmodule.NewAppModule(appCodec, app.SubscriptionKeeper, app.AccountKeeper, app.BankKeeper) + app.ConflictKeeper = *conflictmodulekeeper.NewKeeper( appCodec, keys[conflictmoduletypes.StoreKey], @@ -495,6 +513,7 @@ func New( transferModule, specModule, epochstorageModule, + subscriptionModule, pairingModule, conflictModule, plansModule, @@ -521,6 +540,7 @@ func New( ibctransfertypes.ModuleName, specmoduletypes.ModuleName, epochstoragemoduletypes.ModuleName, + subscriptionmoduletypes.ModuleName, conflictmoduletypes.ModuleName, // conflict needs to change state before pairing changes stakes pairingmoduletypes.ModuleName, plansmoduletypes.ModuleName, @@ -545,6 +565,7 @@ func New( ibctransfertypes.ModuleName, specmoduletypes.ModuleName, epochstoragemoduletypes.ModuleName, + subscriptionmoduletypes.ModuleName, conflictmoduletypes.ModuleName, pairingmoduletypes.ModuleName, plansmoduletypes.ModuleName, @@ -574,6 +595,7 @@ func New( ibctransfertypes.ModuleName, specmoduletypes.ModuleName, epochstoragemoduletypes.ModuleName, // epochStyorage end block must come before pairing for proper epoch handling + subscriptionmoduletypes.ModuleName, pairingmoduletypes.ModuleName, plansmoduletypes.ModuleName, vestingtypes.ModuleName, @@ -609,6 +631,7 @@ func New( transferModule, specModule, epochstorageModule, + subscriptionModule, pairingModule, conflictModule, plansModule, @@ -828,6 +851,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibchost.ModuleName) paramsKeeper.Subspace(specmoduletypes.ModuleName) paramsKeeper.Subspace(epochstoragemoduletypes.ModuleName) + paramsKeeper.Subspace(subscriptionmoduletypes.ModuleName) paramsKeeper.Subspace(pairingmoduletypes.ModuleName) paramsKeeper.Subspace(conflictmoduletypes.ModuleName) paramsKeeper.Subspace(plansmoduletypes.ModuleName) diff --git a/app/keepers/lavaKeepers.go b/app/keepers/lavaKeepers.go index 480acb81c0..2f6175b50e 100644 --- a/app/keepers/lavaKeepers.go +++ b/app/keepers/lavaKeepers.go @@ -21,6 +21,7 @@ import ( pairingmodulekeeper "github.com/lavanet/lava/x/pairing/keeper" plansmodulekeeper "github.com/lavanet/lava/x/plans/keeper" specmodulekeeper "github.com/lavanet/lava/x/spec/keeper" + subscriptionmodulekeeper "github.com/lavanet/lava/x/subscription/keeper" // this line is used by starport scaffolding # stargate/app/moduleImport ) @@ -48,6 +49,7 @@ type LavaKeepers struct { // Special Keepers SpecKeeper specmodulekeeper.Keeper + SubscriptionKeeper subscriptionmodulekeeper.Keeper EpochstorageKeeper epochstoragemodulekeeper.Keeper PairingKeeper pairingmodulekeeper.Keeper ConflictKeeper conflictmodulekeeper.Keeper diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 8a81a1d75f..3f0362d7a1 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -32599,6 +32599,103 @@ paths: type: string tags: - Query + '/lavanet/lava/subscription/current_subscription/{consumer}': + get: + summary: Queries a list of CurrentSubscription items. + operationId: LavanetLavaSubscriptionCurrentSubscription + responses: + '200': + description: A successful response. + schema: + type: object + properties: + sub: + type: object + properties: + creator: + type: string + consumer: + type: string + block: + type: string + format: int64 + packageIndex: + type: string + packageBlock: + type: string + format: int64 + isYearly: + type: boolean + expiryTime: + type: string + format: uint64 + usedCU: + type: string + format: uint64 + remainingCU: + type: string + format: uint64 + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: consumer + in: path + required: true + type: string + tags: + - Query + /lavanet/lava/subscription/params: + get: + summary: Parameters queries the parameters of the module. + operationId: LavanetLavaSubscriptionParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + tags: + - Query definitions: cosmos.auth.v1beta1.Params: type: object @@ -56100,3 +56197,70 @@ definitions: type: array items: type: string + lavanet.lava.subscription.MsgSubscribeResponse: + type: object + lavanet.lava.subscription.Params: + type: object + description: Params defines the parameters for the module. + lavanet.lava.subscription.QueryCurrentSubscriptionResponse: + type: object + properties: + sub: + type: object + properties: + creator: + type: string + consumer: + type: string + block: + type: string + format: int64 + packageIndex: + type: string + packageBlock: + type: string + format: int64 + isYearly: + type: boolean + expiryTime: + type: string + format: uint64 + usedCU: + type: string + format: uint64 + remainingCU: + type: string + format: uint64 + lavanet.lava.subscription.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: QueryParamsResponse is response type for the Query/Params RPC method. + lavanet.lava.subscription.Subscription: + type: object + properties: + creator: + type: string + consumer: + type: string + block: + type: string + format: int64 + packageIndex: + type: string + packageBlock: + type: string + format: int64 + isYearly: + type: boolean + expiryTime: + type: string + format: uint64 + usedCU: + type: string + format: uint64 + remainingCU: + type: string + format: uint64 diff --git a/go.mod b/go.mod index 79fcebef6c..0ecde8db5c 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/stretchr/testify v1.8.1 github.com/tendermint/tendermint v0.34.23 github.com/tendermint/tm-db v0.6.7 - google.golang.org/genproto v0.0.0-20230221151758-ace64dc21148 + google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 google.golang.org/grpc v1.53.0 google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 gopkg.in/yaml.v2 v2.4.0 @@ -48,6 +48,8 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/gogo/googleapis v1.4.0 // indirect + github.com/golang/glog v1.0.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect golang.org/x/mod v0.7.0 // indirect golang.org/x/tools v0.2.0 // indirect diff --git a/go.sum b/go.sum index 3e138bb70f..ab0be1ee80 100644 --- a/go.sum +++ b/go.sum @@ -657,6 +657,8 @@ github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -781,6 +783,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -1986,8 +1990,8 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230221151758-ace64dc21148 h1:muK+gVBJBfFb4SejshDBlN2/UgxCCOKH9Y34ljqEGOc= -google.golang.org/genproto v0.0.0-20230221151758-ace64dc21148/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= +google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 h1:znp6mq/drrY+6khTAlJUDNFFcDGV2ENLYKpMq8SyCds= +google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= diff --git a/proto/subscription/genesis.proto b/proto/subscription/genesis.proto new file mode 100644 index 0000000000..82918a3913 --- /dev/null +++ b/proto/subscription/genesis.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package lavanet.lava.subscription; + +import "gogoproto/gogo.proto"; +import "subscription/params.proto"; +// this line is used by starport scaffolding # genesis/proto/import + +option go_package = "github.com/lavanet/lava/x/subscription/types"; + +// GenesisState defines the subscription 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/subscription/params.proto b/proto/subscription/params.proto new file mode 100644 index 0000000000..b21a6ba2b5 --- /dev/null +++ b/proto/subscription/params.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package lavanet.lava.subscription; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/lavanet/lava/x/subscription/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + +} diff --git a/proto/subscription/query.proto b/proto/subscription/query.proto new file mode 100644 index 0000000000..72b7ad08c3 --- /dev/null +++ b/proto/subscription/query.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; +package lavanet.lava.subscription; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "subscription/params.proto"; +// this line is used by starport scaffolding # 1 +import "subscription/subscription.proto"; + +option go_package = "github.com/lavanet/lava/x/subscription/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/lavanet/lava/subscription/params"; + } + // Queries a list of CurrentSubscription items. + rpc CurrentSubscription(QueryCurrentSubscriptionRequest) returns (QueryCurrentSubscriptionResponse) { + option (google.api.http).get = "/lavanet/lava/subscription/current_subscription/{consumer}"; + } + +// this line is used by starport scaffolding # 2 +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +message QueryCurrentSubscriptionRequest { + string consumer = 1; +} + +message QueryCurrentSubscriptionResponse { + Subscription sub = 1 [(gogoproto.nullable) = false]; +} + +// this line is used by starport scaffolding # 3 diff --git a/proto/subscription/subscription.proto b/proto/subscription/subscription.proto new file mode 100644 index 0000000000..7bbd45c903 --- /dev/null +++ b/proto/subscription/subscription.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package lavanet.lava.subscription; + +option go_package = "github.com/lavanet/lava/x/subscription/types"; + +message Subscription { + + string creator = 1; + string consumer = 2; + uint64 block = 3; + string plan_index = 4; + uint64 plan_block = 5; + bool is_yearly = 6; + uint64 expiry_time = 7; + uint64 usedCU = 8; + uint64 remainingCU = 9; +} diff --git a/proto/subscription/tx.proto b/proto/subscription/tx.proto new file mode 100644 index 0000000000..97502eb188 --- /dev/null +++ b/proto/subscription/tx.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package lavanet.lava.subscription; + +// this line is used by starport scaffolding # proto/tx/import + +option go_package = "github.com/lavanet/lava/x/subscription/types"; + +// Msg defines the Msg service. +service Msg { + rpc Subscribe(MsgSubscribe) returns (MsgSubscribeResponse); +// this line is used by starport scaffolding # proto/tx/rpc +} + +message MsgSubscribe { + string creator = 1; + string consumer = 2; + string index = 3; + bool isYearly = 4; +} + +message MsgSubscribeResponse { +} + +// this line is used by starport scaffolding # proto/tx/message diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/config/v1/config.pulsar.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/config/v1/config.pulsar.go index 7803bb3f23..80f2a90ab4 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/config/v1/config.pulsar.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/config/v1/config.pulsar.go @@ -595,7 +595,7 @@ var file_cosmos_tx_config_v1_config_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { }//file_cosmos_tx_config_v1_config_proto_init() } +func init() {} //file_cosmos_tx_config_v1_config_proto_init() } func file_cosmos_tx_config_v1_config_proto_init() { if File_cosmos_tx_config_v1_config_proto != nil { return diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/signing/v1beta1/signing.pulsar.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/signing/v1beta1/signing.pulsar.go index 1d77632d70..8b3559dc84 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/signing/v1beta1/signing.pulsar.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/signing/v1beta1/signing.pulsar.go @@ -3183,7 +3183,7 @@ var file_cosmos_tx_signing_v1beta1_signing_proto_depIdxs = []int32{ 0, // [0:8] is the sub-list for field type_name } -func init() { }//file_cosmos_tx_signing_v1beta1_signing_proto_init() } +func init() {} //file_cosmos_tx_signing_v1beta1_signing_proto_init() } func file_cosmos_tx_signing_v1beta1_signing_proto_init() { if File_cosmos_tx_signing_v1beta1_signing_proto != nil { return diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/v1beta1/service.pulsar.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/v1beta1/service.pulsar.go index 0922e549e7..05b91a94f6 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/v1beta1/service.pulsar.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/v1beta1/service.pulsar.go @@ -10242,8 +10242,8 @@ var file_cosmos_tx_v1beta1_service_proto_depIdxs = []int32{ 0, // [0:19] is the sub-list for field type_name } -func init() { - // file_cosmos_tx_v1beta1_service_proto_init() +func init() { + // file_cosmos_tx_v1beta1_service_proto_init() } func file_cosmos_tx_v1beta1_service_proto_init() { if File_cosmos_tx_v1beta1_service_proto != nil { diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/v1beta1/tx.pulsar.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/v1beta1/tx.pulsar.go index e86f3c60bf..ae2db593d8 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/v1beta1/tx.pulsar.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/cosmos/tx/v1beta1/tx.pulsar.go @@ -9197,8 +9197,8 @@ var file_cosmos_tx_v1beta1_tx_proto_depIdxs = []int32{ 0, // [0:21] is the sub-list for field type_name } -func init() { - file_cosmos_tx_v1beta1_tx_proto_init() +func init() { + file_cosmos_tx_v1beta1_tx_proto_init() } func file_cosmos_tx_v1beta1_tx_proto_init() { if File_cosmos_tx_v1beta1_tx_proto != nil { diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/ack.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/ack.pb.go index 842717253e..4154fcb409 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/ack.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/ack.pb.go @@ -91,7 +91,7 @@ func init() { //proto.RegisterType((*IncentivizedAcknowledgement)(nil), "ibc.applications.fee.v1.IncentivizedAcknowledgement") } -func init() { }//proto.RegisterFile("ibc/applications/fee/v1/ack.proto", fileDescriptor_ab2834946fb65ea4) } +func init() {} //proto.RegisterFile("ibc/applications/fee/v1/ack.proto", fileDescriptor_ab2834946fb65ea4) } var fileDescriptor_ab2834946fb65ea4 = []byte{ // 330 bytes of a gzipped FileDescriptorProto diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/fee.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/fee.pb.go index 8cd066af26..23e64ac9e0 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/fee.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/fee.pb.go @@ -7,9 +7,9 @@ import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" io "io" math "math" math_bits "math/bits" @@ -262,7 +262,7 @@ func init() { //proto.RegisterType((*IdentifiedPacketFees)(nil), "ibc.applications.fee.v1.IdentifiedPacketFees") } -func init() { }//proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } +func init() {} //proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ // 526 bytes of a gzipped FileDescriptorProto diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/genesis.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/genesis.pb.go index 30d8216512..9345aa8738 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/genesis.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/genesis.pb.go @@ -5,9 +5,9 @@ package types import ( fmt "fmt" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" io "io" math "math" math_bits "math/bits" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/query.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/query.pb.go index af87a63950..be078419de 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/query.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/query.pb.go @@ -9,10 +9,10 @@ import ( github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/tx.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/tx.pb.go index 7df022921f..c8948e73da 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/tx.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/29-fee/types/tx.pb.go @@ -6,10 +6,10 @@ package types import ( context "context" fmt "fmt" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -369,7 +369,7 @@ func init() { //proto.RegisterType((*MsgPayPacketFeeAsyncResponse)(nil), "ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse") } -func init() { }//proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } +func init() {} //proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ // 699 bytes of a gzipped FileDescriptorProto diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/controller/types/tx.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/controller/types/tx.pb.go index b25ddbd876..128eb3d26f 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/controller/types/tx.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/controller/types/tx.pb.go @@ -6,10 +6,10 @@ package types import ( context "context" fmt "fmt" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/genesis/types/genesis.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/genesis/types/genesis.pb.go index 91accc112d..8ae5398e4d 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/genesis/types/genesis.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/genesis/types/genesis.pb.go @@ -5,10 +5,10 @@ package types import ( fmt "fmt" - types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/host/types" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/controller/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/controller/types" + types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/interchain-accounts/host/types" io "io" math "math" math_bits "math/bits" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/transfer/types/tx.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/transfer/types/tx.pb.go index a34d525f5a..a820612076 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/transfer/types/tx.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/apps/transfer/types/tx.pb.go @@ -7,10 +7,10 @@ import ( context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/23-commitment/types/commitment.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/23-commitment/types/commitment.pb.go index ae7e7c5c93..42d19b509e 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/23-commitment/types/commitment.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/23-commitment/types/commitment.pb.go @@ -117,9 +117,9 @@ type MerklePath struct { KeyPath []string `protobuf:"bytes,1,rep,name=key_path,json=keyPath,proto3" json:"key_path,omitempty" yaml:"key_path"` } -func (m *MerklePath) Reset() { *m = MerklePath{} } +func (m *MerklePath) Reset() { *m = MerklePath{} } func (m *MerklePath) String() string { return proto.CompactTextString(m) } -func (*MerklePath) ProtoMessage() {} +func (*MerklePath) ProtoMessage() {} func (*MerklePath) Descriptor() ([]byte, []int) { return fileDescriptor_7921d88972a41469, []int{2} } diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/channel.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/channel.pb.go index eb6394bc1e..f27ff8acca 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/channel.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/channel.pb.go @@ -5,9 +5,9 @@ package types import ( fmt "fmt" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" io "io" math "math" math_bits "math/bits" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/query.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/query.pb.go index 8402cb7fa7..e033d7a95c 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/query.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/query.pb.go @@ -8,10 +8,10 @@ import ( fmt "fmt" types1 "github.com/cosmos/cosmos-sdk/codec/types" query "github.com/cosmos/cosmos-sdk/types/query" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/tx.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/tx.pb.go index 4f51895205..0b006cc927 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/tx.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types/tx.pb.go @@ -6,10 +6,10 @@ package types import ( context "context" fmt "fmt" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/migrations/v7/solomachine.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/migrations/v7/solomachine.pb.go index ecf5d91294..e83735d17a 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/migrations/v7/solomachine.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/migrations/v7/solomachine.pb.go @@ -6,10 +6,10 @@ package v7 import ( fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" - types2 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" - types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types2 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" + types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types" io "io" math "math" math_bits "math/bits" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types/client.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types/client.pb.go index cf1ae259e8..1d85c6eaf0 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types/client.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types/client.pb.go @@ -258,9 +258,9 @@ type UpgradeProposal struct { UpgradedClientState *types.Any `protobuf:"bytes,4,opt,name=upgraded_client_state,json=upgradedClientState,proto3" json:"upgraded_client_state,omitempty" yaml:"upgraded_client_state"` } -func (m *UpgradeProposal) Reset() { *m = UpgradeProposal{} } +func (m *UpgradeProposal) Reset() { *m = UpgradeProposal{} } func (m *UpgradeProposal) String() string { return proto.CompactTextString(m) } -func (*UpgradeProposal) ProtoMessage() {} +func (*UpgradeProposal) ProtoMessage() {} func (*UpgradeProposal) Descriptor() ([]byte, []int) { return fileDescriptor_b6bc4c8185546947, []int{4} } @@ -271,12 +271,12 @@ func (m *UpgradeProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, err // if deterministic { // return xxx_messageInfo_UpgradeProposal.Marshal(b, m, deterministic) // } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil // } } func (m *UpgradeProposal) XXX_Merge(src proto.Message) { @@ -308,9 +308,9 @@ type Height struct { RevisionHeight uint64 `protobuf:"varint,2,opt,name=revision_height,json=revisionHeight,proto3" json:"revision_height,omitempty" yaml:"revision_height"` } -func (m *Height) Reset() { *m = Height{} } +func (m *Height) Reset() { *m = Height{} } func (m *Height) String() string { return proto.CompactTextString(m) } -func (*Height) ProtoMessage() {} +func (*Height) ProtoMessage() {} func (*Height) Descriptor() ([]byte, []int) { return fileDescriptor_b6bc4c8185546947, []int{5} } @@ -321,12 +321,12 @@ func (m *Height) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { // if deterministic { // return xxx_messageInfo_Height.Marshal(b, m, deterministic) // } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil // } } func (m *Height) XXX_Merge(src proto.Message) { diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types/tx.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types/tx.pb.go index eab9c53e6a..3b3d2ee2da 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types/tx.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types/tx.pb.go @@ -374,7 +374,7 @@ func init() { //proto.RegisterType((*MsgSubmitMisbehaviourResponse)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviourResponse") } -func init() { }//proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } +func init() {} //proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } var fileDescriptor_cb5dc4651eb49a04 = []byte{ // 623 bytes of a gzipped FileDescriptorProto diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/connection.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/connection.pb.go index 2df52efe9f..eb92c8d6b7 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/connection.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/connection.pb.go @@ -5,9 +5,9 @@ package types import ( fmt "fmt" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/23-commitment/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/23-commitment/types" io "io" math "math" math_bits "math/bits" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/query.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/query.pb.go index 13c720e2d2..017d7a8884 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/query.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/query.pb.go @@ -8,10 +8,10 @@ import ( fmt "fmt" types1 "github.com/cosmos/cosmos-sdk/codec/types" query "github.com/cosmos/cosmos-sdk/types/query" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/tx.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/tx.pb.go index aec5242630..1f6c3fe4ce 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/tx.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types/tx.pb.go @@ -7,10 +7,10 @@ import ( context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" - types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/types/genesis.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/types/genesis.pb.go index 4f45c95261..26039b05f2 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/types/genesis.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/types/genesis.pb.go @@ -5,11 +5,11 @@ package types import ( fmt "fmt" - types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types" - types2 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + types2 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/channel/types" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" + types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/connection/types" io "io" math "math" math_bits "math/bits" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/light-clients/07-tendermint/tendermint.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/light-clients/07-tendermint/tendermint.pb.go index 0c210fd87c..0a7e46945a 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/light-clients/07-tendermint/tendermint.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/light-clients/07-tendermint/tendermint.pb.go @@ -6,11 +6,11 @@ package tendermint import ( fmt "fmt" _go "github.com/confio/ics23/go" - types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" - types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/23-commitment/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + types1 "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/23-commitment/types" + types "github.com/lavanet/lava/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/ibc/core/client/types" github_com_tendermint_tendermint_libs_bytes "github.com/tendermint/tendermint/libs/bytes" types2 "github.com/tendermint/tendermint/proto/tendermint/types" _ "google.golang.org/protobuf/types/known/durationpb" diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/gamm/types/gov.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/gamm/types/gov.pb.go index b9e6aef0eb..be26736663 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/gamm/types/gov.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/gamm/types/gov.pb.go @@ -34,9 +34,9 @@ type ReplaceMigrationRecordsProposal struct { Records []BalancerToConcentratedPoolLink `protobuf:"bytes,3,rep,name=records,proto3" json:"records"` } -func (m *ReplaceMigrationRecordsProposal) Reset() { *m = ReplaceMigrationRecordsProposal{} } +func (m *ReplaceMigrationRecordsProposal) Reset() { *m = ReplaceMigrationRecordsProposal{} } func (m *ReplaceMigrationRecordsProposal) String() string { return proto.CompactTextString(m) } -func (*ReplaceMigrationRecordsProposal) ProtoMessage() {} +func (*ReplaceMigrationRecordsProposal) ProtoMessage() {} func (*ReplaceMigrationRecordsProposal) Descriptor() ([]byte, []int) { return fileDescriptor_f31b9a6c0dbbdfa3, []int{0} } @@ -81,9 +81,9 @@ type UpdateMigrationRecordsProposal struct { Records []BalancerToConcentratedPoolLink `protobuf:"bytes,3,rep,name=records,proto3" json:"records"` } -func (m *UpdateMigrationRecordsProposal) Reset() { *m = UpdateMigrationRecordsProposal{} } +func (m *UpdateMigrationRecordsProposal) Reset() { *m = UpdateMigrationRecordsProposal{} } func (m *UpdateMigrationRecordsProposal) String() string { return proto.CompactTextString(m) } -func (*UpdateMigrationRecordsProposal) ProtoMessage() {} +func (*UpdateMigrationRecordsProposal) ProtoMessage() {} func (*UpdateMigrationRecordsProposal) Descriptor() ([]byte, []int) { return fileDescriptor_f31b9a6c0dbbdfa3, []int{1} } diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/mint/types/mint.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/mint/types/mint.pb.go index ef57136063..e4e7ac710a 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/mint/types/mint.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/mint/types/mint.pb.go @@ -192,9 +192,9 @@ type Params struct { MintingRewardsDistributionStartEpoch int64 `protobuf:"varint,8,opt,name=minting_rewards_distribution_start_epoch,json=mintingRewardsDistributionStartEpoch,proto3" json:"minting_rewards_distribution_start_epoch,omitempty" yaml:"minting_rewards_distribution_start_epoch"` } -func (m *Params) Reset() { *m = Params{} } +func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} +func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_ccb38f8335e0f45b, []int{3} } diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/pool-incentives/types/gov.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/pool-incentives/types/gov.pb.go index 49204ff1f3..5393210a15 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/pool-incentives/types/gov.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/pool-incentives/types/gov.pb.go @@ -36,9 +36,9 @@ type ReplacePoolIncentivesProposal struct { Records []DistrRecord `protobuf:"bytes,3,rep,name=records,proto3" json:"records"` } -func (m *ReplacePoolIncentivesProposal) Reset() { *m = ReplacePoolIncentivesProposal{} } +func (m *ReplacePoolIncentivesProposal) Reset() { *m = ReplacePoolIncentivesProposal{} } func (m *ReplacePoolIncentivesProposal) String() string { return proto.CompactTextString(m) } -func (*ReplacePoolIncentivesProposal) ProtoMessage() {} +func (*ReplacePoolIncentivesProposal) ProtoMessage() {} func (*ReplacePoolIncentivesProposal) Descriptor() ([]byte, []int) { return fileDescriptor_96caede426ba9516, []int{0} } @@ -82,9 +82,9 @@ type UpdatePoolIncentivesProposal struct { Records []DistrRecord `protobuf:"bytes,3,rep,name=records,proto3" json:"records"` } -func (m *UpdatePoolIncentivesProposal) Reset() { *m = UpdatePoolIncentivesProposal{} } +func (m *UpdatePoolIncentivesProposal) Reset() { *m = UpdatePoolIncentivesProposal{} } func (m *UpdatePoolIncentivesProposal) String() string { return proto.CompactTextString(m) } -func (*UpdatePoolIncentivesProposal) ProtoMessage() {} +func (*UpdatePoolIncentivesProposal) ProtoMessage() {} func (*UpdatePoolIncentivesProposal) Descriptor() ([]byte, []int) { return fileDescriptor_96caede426ba9516, []int{1} } diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/pool-incentives/types/incentives.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/pool-incentives/types/incentives.pb.go index 76409a42a0..1208472a03 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/pool-incentives/types/incentives.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/pool-incentives/types/incentives.pb.go @@ -36,9 +36,9 @@ type Params struct { MintedDenom string `protobuf:"bytes,1,opt,name=minted_denom,json=mintedDenom,proto3" json:"minted_denom,omitempty" yaml:"minted_denom"` } -func (m *Params) Reset() { *m = Params{} } +func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} +func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_a8153bad03e553d1, []int{0} } diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/protorev/types/gov.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/protorev/types/gov.pb.go index 37339eddd5..95b93d9828 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/protorev/types/gov.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/protorev/types/gov.pb.go @@ -31,9 +31,9 @@ type SetProtoRevEnabledProposal struct { Enabled bool `protobuf:"varint,3,opt,name=enabled,proto3" json:"enabled,omitempty"` } -func (m *SetProtoRevEnabledProposal) Reset() { *m = SetProtoRevEnabledProposal{} } +func (m *SetProtoRevEnabledProposal) Reset() { *m = SetProtoRevEnabledProposal{} } func (m *SetProtoRevEnabledProposal) String() string { return proto.CompactTextString(m) } -func (*SetProtoRevEnabledProposal) ProtoMessage() {} +func (*SetProtoRevEnabledProposal) ProtoMessage() {} func (*SetProtoRevEnabledProposal) Descriptor() ([]byte, []int) { return fileDescriptor_e1f85ff7f3eaf8bb, []int{0} } @@ -73,9 +73,9 @@ type SetProtoRevAdminAccountProposal struct { Account string `protobuf:"bytes,3,opt,name=account,proto3" json:"account,omitempty"` } -func (m *SetProtoRevAdminAccountProposal) Reset() { *m = SetProtoRevAdminAccountProposal{} } +func (m *SetProtoRevAdminAccountProposal) Reset() { *m = SetProtoRevAdminAccountProposal{} } func (m *SetProtoRevAdminAccountProposal) String() string { return proto.CompactTextString(m) } -func (*SetProtoRevAdminAccountProposal) ProtoMessage() {} +func (*SetProtoRevAdminAccountProposal) ProtoMessage() {} func (*SetProtoRevAdminAccountProposal) Descriptor() ([]byte, []int) { return fileDescriptor_e1f85ff7f3eaf8bb, []int{1} } diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/superfluid/types/gov.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/superfluid/types/gov.pb.go index 97d400bd83..f60f2da007 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/superfluid/types/gov.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/superfluid/types/gov.pb.go @@ -31,9 +31,9 @@ type SetSuperfluidAssetsProposal struct { Assets []SuperfluidAsset `protobuf:"bytes,3,rep,name=assets,proto3" json:"assets"` } -func (m *SetSuperfluidAssetsProposal) Reset() { *m = SetSuperfluidAssetsProposal{} } +func (m *SetSuperfluidAssetsProposal) Reset() { *m = SetSuperfluidAssetsProposal{} } func (m *SetSuperfluidAssetsProposal) String() string { return proto.CompactTextString(m) } -func (*SetSuperfluidAssetsProposal) ProtoMessage() {} +func (*SetSuperfluidAssetsProposal) ProtoMessage() {} func (*SetSuperfluidAssetsProposal) Descriptor() ([]byte, []int) { return fileDescriptor_2e37d6a8d0e42294, []int{0} } @@ -72,9 +72,9 @@ type RemoveSuperfluidAssetsProposal struct { SuperfluidAssetDenoms []string `protobuf:"bytes,3,rep,name=superfluid_asset_denoms,json=superfluidAssetDenoms,proto3" json:"superfluid_asset_denoms,omitempty"` } -func (m *RemoveSuperfluidAssetsProposal) Reset() { *m = RemoveSuperfluidAssetsProposal{} } +func (m *RemoveSuperfluidAssetsProposal) Reset() { *m = RemoveSuperfluidAssetsProposal{} } func (m *RemoveSuperfluidAssetsProposal) String() string { return proto.CompactTextString(m) } -func (*RemoveSuperfluidAssetsProposal) ProtoMessage() {} +func (*RemoveSuperfluidAssetsProposal) ProtoMessage() {} func (*RemoveSuperfluidAssetsProposal) Descriptor() ([]byte, []int) { return fileDescriptor_2e37d6a8d0e42294, []int{1} } @@ -114,9 +114,9 @@ type UpdateUnpoolWhiteListProposal struct { IsOverwrite bool `protobuf:"varint,4,opt,name=is_overwrite,json=isOverwrite,proto3" json:"is_overwrite,omitempty"` } -func (m *UpdateUnpoolWhiteListProposal) Reset() { *m = UpdateUnpoolWhiteListProposal{} } +func (m *UpdateUnpoolWhiteListProposal) Reset() { *m = UpdateUnpoolWhiteListProposal{} } func (m *UpdateUnpoolWhiteListProposal) String() string { return proto.CompactTextString(m) } -func (*UpdateUnpoolWhiteListProposal) ProtoMessage() {} +func (*UpdateUnpoolWhiteListProposal) ProtoMessage() {} func (*UpdateUnpoolWhiteListProposal) Descriptor() ([]byte, []int) { return fileDescriptor_2e37d6a8d0e42294, []int{2} } diff --git a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/txfees/types/gov.pb.go b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/txfees/types/gov.pb.go index d7258a88ca..e4f3c49030 100644 --- a/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/txfees/types/gov.pb.go +++ b/protocol/chainlib/chainproxy/thirdparty/thirdparty_utils/osmosis_protobufs/txfees/types/gov.pb.go @@ -34,9 +34,9 @@ type UpdateFeeTokenProposal struct { Feetoken FeeToken `protobuf:"bytes,3,opt,name=feetoken,proto3" json:"feetoken" yaml:"fee_token"` } -func (m *UpdateFeeTokenProposal) Reset() { *m = UpdateFeeTokenProposal{} } +func (m *UpdateFeeTokenProposal) Reset() { *m = UpdateFeeTokenProposal{} } func (m *UpdateFeeTokenProposal) String() string { return proto.CompactTextString(m) } -func (*UpdateFeeTokenProposal) ProtoMessage() {} +func (*UpdateFeeTokenProposal) ProtoMessage() {} func (*UpdateFeeTokenProposal) Descriptor() ([]byte, []int) { return fileDescriptor_2c4a51bafc82863d, []int{0} } diff --git a/testutil/common/common.go b/testutil/common/common.go index f2eb6d753d..40c7601cff 100644 --- a/testutil/common/common.go +++ b/testutil/common/common.go @@ -47,7 +47,7 @@ func CreateMockPlan() plantypes.Plan { Type: "rpc", Duration: 200, Block: 100, - Price: sdk.NewCoin("ulava", sdk.OneInt()), + Price: sdk.NewCoin("ulava", sdk.NewInt(100)), ComputeUnits: 1000, ComputeUnitsPerEpoch: 100, ServicersToPair: 3, diff --git a/testutil/keeper/keepers_init.go b/testutil/keeper/keepers_init.go index f52ce2cbf4..facf93af79 100644 --- a/testutil/keeper/keepers_init.go +++ b/testutil/keeper/keepers_init.go @@ -27,6 +27,8 @@ import ( "github.com/lavanet/lava/x/spec" speckeeper "github.com/lavanet/lava/x/spec/keeper" spectypes "github.com/lavanet/lava/x/spec/types" + subscriptionkeeper "github.com/lavanet/lava/x/subscription/keeper" + subscriptiontypes "github.com/lavanet/lava/x/subscription/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -45,6 +47,7 @@ type Keepers struct { Epochstorage epochstoragekeeper.Keeper Spec speckeeper.Keeper Plans planskeeper.Keeper + Subscription subscriptionkeeper.Keeper Pairing pairingkeeper.Keeper Conflict conflictkeeper.Keeper BankKeeper mockBankKeeper @@ -100,6 +103,11 @@ func InitAllKeepers(t testing.TB) (*Servers, *Keepers, context.Context) { stateStore.MountStoreWithDB(plansStoreKey, sdk.StoreTypeIAVL, db) stateStore.MountStoreWithDB(plansMemStoreKey, sdk.StoreTypeMemory, nil) + subscriptionStoreKey := sdk.NewKVStoreKey(subscriptiontypes.StoreKey) + subscriptionMemStoreKey := storetypes.NewMemoryStoreKey(subscriptiontypes.MemStoreKey) + stateStore.MountStoreWithDB(subscriptionStoreKey, sdk.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(subscriptionMemStoreKey, sdk.StoreTypeMemory, nil) + epochStoreKey := sdk.NewKVStoreKey(epochstoragetypes.StoreKey) epochMemStoreKey := storetypes.NewMemoryStoreKey(epochstoragetypes.MemStoreKey) stateStore.MountStoreWithDB(epochStoreKey, sdk.StoreTypeIAVL, db) @@ -119,6 +127,7 @@ func InitAllKeepers(t testing.TB) (*Servers, *Keepers, context.Context) { paramsKeeper := paramskeeper.NewKeeper(cdc, pairingtypes.Amino, paramsStoreKey, tkey) paramsKeeper.Subspace(spectypes.ModuleName) + paramsKeeper.Subspace(subscriptiontypes.ModuleName) paramsKeeper.Subspace(epochstoragetypes.ModuleName) paramsKeeper.Subspace(pairingtypes.ModuleName) // paramsKeeper.Subspace(conflicttypes.ModuleName) //TODO... @@ -131,6 +140,8 @@ func InitAllKeepers(t testing.TB) (*Servers, *Keepers, context.Context) { plansparamsSubspace, _ := paramsKeeper.GetSubspace(planstypes.ModuleName) + subscriptionparamsSubspace, _ := paramsKeeper.GetSubspace(subscriptiontypes.ModuleName) + conflictparamsSubspace := paramstypes.NewSubspace(cdc, conflicttypes.Amino, conflictStoreKey, @@ -144,6 +155,7 @@ func InitAllKeepers(t testing.TB) (*Servers, *Keepers, context.Context) { ks.Spec = *speckeeper.NewKeeper(cdc, specStoreKey, specMemStoreKey, specparamsSubspace) ks.Epochstorage = *epochstoragekeeper.NewKeeper(cdc, epochStoreKey, epochMemStoreKey, epochparamsSubspace, &ks.BankKeeper, &ks.AccountKeeper, ks.Spec) ks.Plans = *planskeeper.NewKeeper(cdc, plansStoreKey, plansMemStoreKey, plansparamsSubspace) + ks.Subscription = *subscriptionkeeper.NewKeeper(cdc, subscriptionStoreKey, subscriptionMemStoreKey, subscriptionparamsSubspace, &ks.BankKeeper, &ks.AccountKeeper, &ks.Epochstorage, ks.Plans) ks.Pairing = *pairingkeeper.NewKeeper(cdc, pairingStoreKey, pairingMemStoreKey, pairingparamsSubspace, &ks.BankKeeper, &ks.AccountKeeper, ks.Spec, &ks.Epochstorage) ks.ParamsKeeper = paramsKeeper ks.Conflict = *conflictkeeper.NewKeeper(cdc, conflictStoreKey, conflictMemStoreKey, conflictparamsSubspace, &ks.BankKeeper, &ks.AccountKeeper, ks.Pairing, ks.Epochstorage, ks.Spec) @@ -154,6 +166,7 @@ func InitAllKeepers(t testing.TB) (*Servers, *Keepers, context.Context) { // Initialize params ks.Pairing.SetParams(ctx, pairingtypes.DefaultParams()) ks.Spec.SetParams(ctx, spectypes.DefaultParams()) + ks.Subscription.SetParams(ctx, subscriptiontypes.DefaultParams()) ks.Epochstorage.SetParams(ctx, epochstoragetypes.DefaultParams()) ks.Conflict.SetParams(ctx, conflicttypes.DefaultParams()) ks.Plans.SetParams(ctx, planstypes.DefaultParams()) diff --git a/testutil/keeper/subscription.go b/testutil/keeper/subscription.go new file mode 100644 index 0000000000..ab758b1d61 --- /dev/null +++ b/testutil/keeper/subscription.go @@ -0,0 +1,73 @@ +package keeper + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + epochstoragekeeper "github.com/lavanet/lava/x/epochstorage/keeper" + planskeeper "github.com/lavanet/lava/x/plans/keeper" + "github.com/lavanet/lava/x/subscription/keeper" + "github.com/lavanet/lava/x/subscription/types" + "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" +) + +func SubscriptionKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "SubscriptionParams", + ) + + paramsSubspaceEpochstorage := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "EpochStorageParams", + ) + + paramsSubspacePlans := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "PlansParams", + ) + + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + nil, + nil, + epochstoragekeeper.NewKeeper(cdc, nil, nil, paramsSubspaceEpochstorage, nil, nil, nil), + planskeeper.NewKeeper(cdc, nil, nil, paramsSubspacePlans), + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/x/plans/keeper/plan.go b/x/plans/keeper/plan.go index b471e2a6f7..843f7ad526 100644 --- a/x/plans/keeper/plan.go +++ b/x/plans/keeper/plan.go @@ -23,9 +23,9 @@ func (k Keeper) AddPlan(ctx sdk.Context, planToAdd types.Plan) error { } // GetPlan gets a plan from the KVStore. It increases the plan's refCount by 1 -func (k Keeper) GetPlan(ctx sdk.Context, index string, block uint64) (val types.Plan, found bool) { +func (k Keeper) GetPlan(ctx sdk.Context, index string) (val types.Plan, found bool) { var plan types.Plan - err, _ := k.plansFs.GetEntry(ctx, index, block, &plan) + err, _ := k.plansFs.GetEntry(ctx, index, uint64(ctx.BlockHeight()), &plan) if err != nil { return types.Plan{}, false } @@ -43,13 +43,10 @@ func (k Keeper) FindPlan(ctx sdk.Context, index string, block uint64) (val types } // PutPlan gets a plan from the KVStore. It decreases the plan's refCount by 1 -func (k Keeper) PutPlan(ctx sdk.Context, index string, block uint64) (val types.Plan, found bool) { +func (k Keeper) PutPlan(ctx sdk.Context, index string, block uint64) bool { var plan types.Plan - err, _ := k.plansFs.PutEntry(ctx, index, block, &plan) - if err != nil { - return types.Plan{}, false - } - return plan, true + _, found := k.plansFs.PutEntry(ctx, index, block, &plan) + return found } // GetAllPlanIndices gets from the KVStore all the plans' indices diff --git a/x/plans/keeper/plan_test.go b/x/plans/keeper/plan_test.go index 254f23cff5..2f1562b6be 100644 --- a/x/plans/keeper/plan_test.go +++ b/x/plans/keeper/plan_test.go @@ -300,6 +300,11 @@ func TestPlansDeletion(t *testing.T) { testPlans[0].Block = firstPlanBlockHeight require.Nil(t, err) + // increase the first plans' refCount + firstPlanFromStore, found := ts.keepers.Plans.GetPlan(sdk.UnwrapSDKContext(ts.ctx), testPlans[0].GetIndex()) + require.True(t, found) + require.Equal(t, testPlans[0], firstPlanFromStore) + // advance an epoch ts.ctx = testkeeper.AdvanceEpoch(ts.ctx, ts.keepers) @@ -309,11 +314,8 @@ func TestPlansDeletion(t *testing.T) { testPlans[1].Block = secondPlanBlockHeight require.Nil(t, err) - // increase the plans' refCount - firstPlanFromStore, found := ts.keepers.Plans.GetPlan(sdk.UnwrapSDKContext(ts.ctx), testPlans[0].GetIndex(), firstPlanBlockHeight) - require.True(t, found) - require.Equal(t, testPlans[0], firstPlanFromStore) - secondPlanFromStore, found := ts.keepers.Plans.GetPlan(sdk.UnwrapSDKContext(ts.ctx), testPlans[1].GetIndex(), secondPlanBlockHeight) + // increase the second plans' refCount + secondPlanFromStore, found := ts.keepers.Plans.GetPlan(sdk.UnwrapSDKContext(ts.ctx), testPlans[1].GetIndex()) require.True(t, found) require.Equal(t, testPlans[1], secondPlanFromStore) @@ -342,12 +344,10 @@ func TestPlansDeletion(t *testing.T) { require.Equal(t, testPlans[1], secondPlanFromStore) // decrease the old plans' refCount - firstPlanFromStore, found = ts.keepers.Plans.PutPlan(sdk.UnwrapSDKContext(ts.ctx), testPlans[0].GetIndex(), firstPlanBlockHeight) + found = ts.keepers.Plans.PutPlan(sdk.UnwrapSDKContext(ts.ctx), testPlans[0].GetIndex(), firstPlanBlockHeight) require.True(t, found) - require.Equal(t, testPlans[0], firstPlanFromStore) - secondPlanFromStore, found = ts.keepers.Plans.PutPlan(sdk.UnwrapSDKContext(ts.ctx), testPlans[1].GetIndex(), secondPlanBlockHeight) + found = ts.keepers.Plans.PutPlan(sdk.UnwrapSDKContext(ts.ctx), testPlans[1].GetIndex(), secondPlanBlockHeight) require.True(t, found) - require.Equal(t, testPlans[1], secondPlanFromStore) // advance an epoch and create an newer plan to add (and trigger the plan deletion) ts.ctx = testkeeper.AdvanceEpoch(ts.ctx, ts.keepers) diff --git a/x/spec/keeper/spec_test.go b/x/spec/keeper/spec_test.go index 76af2c7dde..07f274d1c6 100644 --- a/x/spec/keeper/spec_test.go +++ b/x/spec/keeper/spec_test.go @@ -25,14 +25,14 @@ func prepareMockApis() []types.ServiceApi { mockApis[2*i] = api api.Enabled = false - mockApis[2*i + 1] = api + mockApis[2*i+1] = api } return mockApis } // selectMockApis returns a slice of ServiceApi corresponding to the given ids -func selectMockApis(apis []types.ServiceApi, ids []int) ([]types.ServiceApi) { +func selectMockApis(apis []types.ServiceApi, ids []int) []types.ServiceApi { var res []types.ServiceApi for _, i := range ids { @@ -95,7 +95,7 @@ func TestSpecGetAll(t *testing.T) { func prepareMockCurrentSpecs(keeper *keeper.Keeper, ctx sdk.Context, apis []types.ServiceApi) map[string]types.Spec { currentSpecs := make(map[string]types.Spec) - template := []struct{ + template := []struct { name string enabled bool imports []string @@ -124,7 +124,7 @@ func prepareMockCurrentSpecs(keeper *keeper.Keeper, ctx sdk.Context, apis []type // Note: the API identifiers below refer to the APIs from the // function prepareMockCurrentApis() above -var specTemplates = []struct{ +var specTemplates = []struct { desc string name string imports []string diff --git a/x/subscription/client/cli/query.go b/x/subscription/client/cli/query.go new file mode 100644 index 0000000000..cffd08e9bc --- /dev/null +++ b/x/subscription/client/cli/query.go @@ -0,0 +1,33 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/lavanet/lava/x/subscription/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group subscription queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdCurrentSubscription()) + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/subscription/client/cli/query_current_subscription.go b/x/subscription/client/cli/query_current_subscription.go new file mode 100644 index 0000000000..3fd204c56d --- /dev/null +++ b/x/subscription/client/cli/query_current_subscription.go @@ -0,0 +1,45 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/lavanet/lava/x/subscription/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdCurrentSubscription() *cobra.Command { + cmd := &cobra.Command{ + Use: "current-subscription [consumer]", + Short: "Query the current subscription of a consumer to a service plan", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqConsumer := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryCurrentSubscriptionRequest{ + Consumer: reqConsumer, + } + + res, err := queryClient.CurrentSubscription(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/subscription/client/cli/query_params.go b/x/subscription/client/cli/query_params.go new file mode 100644 index 0000000000..29edb28b47 --- /dev/null +++ b/x/subscription/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/lavanet/lava/x/subscription/types" + "github.com/spf13/cobra" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/subscription/client/cli/tx.go b/x/subscription/client/cli/tx.go new file mode 100644 index 0000000000..8a67548dbd --- /dev/null +++ b/x/subscription/client/cli/tx.go @@ -0,0 +1,35 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/lavanet/lava/x/subscription/types" +) + +var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdSubscribe()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/subscription/client/cli/tx_subscribe.go b/x/subscription/client/cli/tx_subscribe.go new file mode 100644 index 0000000000..759243ae4f --- /dev/null +++ b/x/subscription/client/cli/tx_subscribe.go @@ -0,0 +1,50 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/lavanet/lava/x/subscription/types" + "github.com/spf13/cast" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdSubscribe() *cobra.Command { + cmd := &cobra.Command{ + Use: "subscribe [consumer] [index] [is-yearly]", + Short: "Subscribe to a service plan", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argConsumer := args[0] + argIndex := args[1] + argIsYearly, err := cast.ToBoolE(args[2]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgSubscribe( + clientCtx.GetFromAddress().String(), + argConsumer, + argIndex, + argIsYearly, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/subscription/genesis.go b/x/subscription/genesis.go new file mode 100644 index 0000000000..42b655007c --- /dev/null +++ b/x/subscription/genesis.go @@ -0,0 +1,24 @@ +package subscription + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/subscription/keeper" + "github.com/lavanet/lava/x/subscription/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the capability module's exported genesis. +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/subscription/genesis_test.go b/x/subscription/genesis_test.go new file mode 100644 index 0000000000..18e09d96be --- /dev/null +++ b/x/subscription/genesis_test.go @@ -0,0 +1,29 @@ +package subscription_test + +import ( + "testing" + + keepertest "github.com/lavanet/lava/testutil/keeper" + "github.com/lavanet/lava/testutil/nullify" + "github.com/lavanet/lava/x/subscription" + "github.com/lavanet/lava/x/subscription/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.SubscriptionKeeper(t) + subscription.InitGenesis(ctx, *k, genesisState) + got := subscription.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/subscription/handler.go b/x/subscription/handler.go new file mode 100644 index 0000000000..2acb6c5af6 --- /dev/null +++ b/x/subscription/handler.go @@ -0,0 +1,29 @@ +package subscription + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/lavanet/lava/x/subscription/keeper" + "github.com/lavanet/lava/x/subscription/types" +) + +// NewHandler ... +func NewHandler(k keeper.Keeper) sdk.Handler { + msgServer := keeper.NewMsgServerImpl(k) + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + _ = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + case *types.MsgSubscribe: + res, err := msgServer.Subscribe(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/subscription/keeper/epoch_start.go b/x/subscription/keeper/epoch_start.go new file mode 100644 index 0000000000..6a5efd2f51 --- /dev/null +++ b/x/subscription/keeper/epoch_start.go @@ -0,0 +1,22 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/subscription/types" +) + +// EpochStart runs the functions that are supposed to run in epoch start +func (k Keeper) EpochStart(ctx sdk.Context) { + // On epoch start we need to iterate through all the subscriptions and + // check if they just expired. Those that expire get deleted. + + date := ctx.BlockTime().UTC() + subExpired := k.GetCondSubscription(ctx, func(sub types.Subscription) bool { + return sub.IsExpired(date) + }) + + // First collect, then remove (because removing may affect the iterator?) + for _, sub := range subExpired { + k.RemoveSubscription(ctx, sub.Consumer) + } +} diff --git a/x/subscription/keeper/epoch_start_test.go b/x/subscription/keeper/epoch_start_test.go new file mode 100644 index 0000000000..1ed2c5a1fa --- /dev/null +++ b/x/subscription/keeper/epoch_start_test.go @@ -0,0 +1,52 @@ +package keeper_test + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/relayer/sigs" + "github.com/lavanet/lava/testutil/common" + testkeeper "github.com/lavanet/lava/testutil/keeper" + epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" + "github.com/stretchr/testify/require" +) + +func TestSubscriptionExpire(t *testing.T) { + _, keepers, _ctx := testkeeper.InitAllKeepers(t) + ctx := sdk.UnwrapSDKContext(_ctx) + + keeper := keepers.Subscription + bank := keepers.BankKeeper + plansKeeper := keepers.Plans + + plan := common.CreateMockPlan() + plansKeeper.AddPlan(ctx, plan) + + _, account := sigs.GenerateFloatingKey() + coins := sdk.NewCoins(sdk.NewCoin(epochstoragetypes.TokenDenom, sdk.NewInt(10000))) + bank.SetBalance(ctx, account, coins) + + creator := account.String() + consumer := account.String() + + // advance block to reach time > 0 + _ctx = testkeeper.AdvanceBlock(_ctx, keepers, time.Minute) + ctx = sdk.UnwrapSDKContext(_ctx) + + err := keeper.CreateSubscription(ctx, creator, consumer, "mockPlan", false) + require.Nil(t, err) + + sub, found := keeper.GetSubscription(ctx, account.String()) + require.True(t, found) + + // change expiration time to 1 second ago + sub.ExpiryTime = uint64(ctx.BlockTime().Add(-time.Second).UTC().Unix()) + keeper.SetSubscription(ctx, sub) + + // trigger EpochStart() processing + keeper.EpochStart(ctx) + + sub, found = keeper.GetSubscription(ctx, account.String()) + require.False(t, found) +} diff --git a/x/subscription/keeper/grpc_query.go b/x/subscription/keeper/grpc_query.go new file mode 100644 index 0000000000..5686188e62 --- /dev/null +++ b/x/subscription/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/lavanet/lava/x/subscription/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/subscription/keeper/grpc_query_current_subscription.go b/x/subscription/keeper/grpc_query_current_subscription.go new file mode 100644 index 0000000000..e7e3d17461 --- /dev/null +++ b/x/subscription/keeper/grpc_query_current_subscription.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/subscription/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) CurrentSubscription(goCtx context.Context, req *types.QueryCurrentSubscriptionRequest) (*types.QueryCurrentSubscriptionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + res := types.QueryCurrentSubscriptionResponse{} + + // TODO: should indeed allow anyone to query about anyone? + sub, found := k.GetSubscription(ctx, req.Consumer) + if found { + res.Sub = sub + } + + return &res, nil +} diff --git a/x/subscription/keeper/grpc_query_params.go b/x/subscription/keeper/grpc_query_params.go new file mode 100644 index 0000000000..593cd6ab6a --- /dev/null +++ b/x/subscription/keeper/grpc_query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/subscription/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/subscription/keeper/grpc_query_params_test.go b/x/subscription/keeper/grpc_query_params_test.go new file mode 100644 index 0000000000..58736a61e9 --- /dev/null +++ b/x/subscription/keeper/grpc_query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + testkeeper "github.com/lavanet/lava/testutil/keeper" + "github.com/lavanet/lava/x/subscription/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.SubscriptionKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/subscription/keeper/keeper.go b/x/subscription/keeper/keeper.go new file mode 100644 index 0000000000..b405ba6a6c --- /dev/null +++ b/x/subscription/keeper/keeper.go @@ -0,0 +1,63 @@ +package keeper + +import ( + "fmt" + + "github.com/tendermint/tendermint/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/lavanet/lava/x/subscription/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey sdk.StoreKey + memKey sdk.StoreKey + paramstore paramtypes.Subspace + + bankKeeper types.BankKeeper + accountKeeper types.AccountKeeper + epochstorageKeeper types.EpochstorageKeeper + plansKeeper types.PlansKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey sdk.StoreKey, + ps paramtypes.Subspace, + + bankKeeper types.BankKeeper, + accountKeeper types.AccountKeeper, + epochstorageKeeper types.EpochstorageKeeper, + plansKeeper types.PlansKeeper, +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + + bankKeeper: bankKeeper, + accountKeeper: accountKeeper, + epochstorageKeeper: epochstorageKeeper, + plansKeeper: plansKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) IsEpochStart(ctx sdk.Context) bool { + return k.epochstorageKeeper.GetEpochStart(ctx) == uint64(ctx.BlockHeight()) +} diff --git a/x/subscription/keeper/msg_server.go b/x/subscription/keeper/msg_server.go new file mode 100644 index 0000000000..b1e4b66095 --- /dev/null +++ b/x/subscription/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/lavanet/lava/x/subscription/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/subscription/keeper/msg_server_subscribe.go b/x/subscription/keeper/msg_server_subscribe.go new file mode 100644 index 0000000000..53347a9438 --- /dev/null +++ b/x/subscription/keeper/msg_server_subscribe.go @@ -0,0 +1,16 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/subscription/types" +) + +func (k msgServer) Subscribe(goCtx context.Context, msg *types.MsgSubscribe) (*types.MsgSubscribeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + err := k.Keeper.CreateSubscription(ctx, msg.Creator, msg.Consumer, msg.Index, msg.IsYearly) + + return &types.MsgSubscribeResponse{}, err +} diff --git a/x/subscription/keeper/msg_server_test.go b/x/subscription/keeper/msg_server_test.go new file mode 100644 index 0000000000..45c08d3df9 --- /dev/null +++ b/x/subscription/keeper/msg_server_test.go @@ -0,0 +1,16 @@ +package keeper_test + +import ( + "context" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/lavanet/lava/testutil/keeper" + "github.com/lavanet/lava/x/subscription/keeper" + "github.com/lavanet/lava/x/subscription/types" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.SubscriptionKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} diff --git a/x/subscription/keeper/params.go b/x/subscription/keeper/params.go new file mode 100644 index 0000000000..6e81b5224e --- /dev/null +++ b/x/subscription/keeper/params.go @@ -0,0 +1,16 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/x/subscription/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams() +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/subscription/keeper/params_test.go b/x/subscription/keeper/params_test.go new file mode 100644 index 0000000000..b5b03402fd --- /dev/null +++ b/x/subscription/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/lavanet/lava/testutil/keeper" + "github.com/lavanet/lava/x/subscription/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.SubscriptionKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/subscription/keeper/subscription.go b/x/subscription/keeper/subscription.go new file mode 100644 index 0000000000..e1a578e2aa --- /dev/null +++ b/x/subscription/keeper/subscription.go @@ -0,0 +1,243 @@ +package keeper + +import ( + "strconv" + "time" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/lavanet/lava/utils" + epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" + "github.com/lavanet/lava/x/subscription/types" +) + +// SetSubscription sets a subscription (of a consumer) in the store +func (k Keeper) SetSubscription(ctx sdk.Context, sub types.Subscription) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.SubscriptionKeyPrefix)) + b := k.cdc.MustMarshal(&sub) + store.Set(types.SubscriptionKey(sub.Consumer), b) +} + +// GetSubscription returns the subscription of a given consumer +func (k Keeper) GetSubscription(ctx sdk.Context, consumer string) (val types.Subscription, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.SubscriptionKeyPrefix)) + + b := store.Get(types.SubscriptionKey(consumer)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveSubscription removes the subscription (of a consumer) from the store +func (k Keeper) RemoveSubscription(ctx sdk.Context, consumer string) { + sub, _ := k.GetSubscription(ctx, consumer) + + // (PlanIndex is empty only in testing of RemoveSubscription) + if sub.PlanIndex != "" { + k.plansKeeper.PutPlan(ctx, sub.PlanIndex, sub.Block) + } + + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.SubscriptionKeyPrefix)) + store.Delete(types.SubscriptionKey(consumer)) +} + +// GetAllSubscription returns all subscriptions that satisfy the condition +func (k Keeper) GetCondSubscription(ctx sdk.Context, cond func(sub types.Subscription) bool) (list []types.Subscription) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.SubscriptionKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Subscription + k.cdc.MustUnmarshal(iterator.Value(), &val) + if cond == nil || cond(val) { + list = append(list, val) + } + } + + return +} + +// GetAllSubscription returns all subscription (of all consumers) +func (k Keeper) GetAllSubscription(ctx sdk.Context) []types.Subscription { + return k.GetCondSubscription(ctx, nil) +} + +// endOfMonth returns the date of the last day of the month (assume UTC) +// (https://yourbasic.org/golang/last-day-month-date/) +func endOfMonth(date time.Time) time.Time { + return date.AddDate(0, 1, -date.Day()) +} + +// isLeapYear returns true if the year in the date is a leap year (assume UTC) +// (https://stackoverflow.com/questions/725098/leap-year-calculation) +func isLeapYear(date time.Time) bool { + year := date.Year() + // Leap year occurs every 4 years; but every 100 years it is skipped; + // except that every every 400 years it is kept. + return year%400 == 0 || (year%4 == 0 && year%100 != 0) +} + +// nextMonth returns the date of the same day next month (assumes UTC), +// adjusting for end-of-months differences if needed. +func nextMonth(date time.Time) time.Time { + next := date.AddDate(0, 1, 0) + + // https://golang.org/pkg/time/#Time.AddDate: + // AddDate normalizes its result in the same way that Date does, so, for + // example, adding one month to October 31 yields December 1, the normalized + // form for November 31. + // + // If we are at end of this month, then "manually" select end of next month; + // This properly handles transitions from short to longer months. + + if date.Day() == endOfMonth(date).Day() { + next = time.Date( + date.Year(), + date.Month()+1, + 1, + date.Hour(), + date.Minute(), + date.Second(), + date.Nanosecond(), + time.UTC) + return endOfMonth(next) + } + + return next +} + +// nextYear returns the date of the same day next year (assumes UTC), +// properly handling leap year variations on February. +func nextYear(date time.Time) time.Time { + next := date.AddDate(1, 0, 0) + + if date.Month() == 2 { + if date.Day() == 29 { + next = date.AddDate(1, 0, -1) + } + if date.Day() == 28 && isLeapYear(next) { + next = date.AddDate(1, 0, 1) + } + } + + return next +} + +// CreateSubscription creates a subscription for a consumer +func (k Keeper) CreateSubscription( + ctx sdk.Context, + creator string, + consumer string, + planIndex string, + isYearly bool, +) error { + var err error + + logger := k.Logger(ctx) + block := uint64(ctx.BlockHeight()) + + _, err = sdk.AccAddressFromBech32(consumer) + if err != nil { + details := map[string]string{ + "consumer": consumer, + "error": err.Error(), + } + return utils.LavaError(ctx, logger, "subscribe", details, "invalid consumer") + } + + creatorAcct, err := sdk.AccAddressFromBech32(creator) + if err != nil { + details := map[string]string{ + "creator": creator, + "error": err.Error(), + } + return utils.LavaError(ctx, logger, "subscribe", details, "invalid creator") + } + + // only one subscription per consumer + if _, found := k.GetSubscription(ctx, consumer); found { + details := map[string]string{"consumer": consumer} + return utils.LavaError(ctx, logger, "subscribe", details, "consumer has existing subscription") + } + + plan, found := k.plansKeeper.GetPlan(ctx, planIndex) + if !found { + details := map[string]string{ + "plan": planIndex, + "block": strconv.FormatInt(ctx.BlockHeight(), 10), + } + return utils.LavaError(ctx, logger, "subscribe", details, "invalid plan") + } + + // drop Plan reference in case of error: + // NOTE! FROM HERE ONWARD MUST SET ERR IF AN ERROR OCCURS + defer func() { + if err != nil { + k.plansKeeper.PutPlan(ctx, planIndex, plan.Block) + } + }() + + price := plan.GetPrice() + expiry := time.Now().UTC() + + duration := int(plan.GetDuration()) + for i := 0; i < duration; i++ { + expiry = nextMonth(expiry) + } + + if isYearly && duration < 12 { + // extend the duration to 1 year, and price pro-rata + expiry = nextYear(time.Now().UTC()) + price.Amount = price.Amount.MulRaw(12).QuoRaw(int64(duration)) + + // adjust cost if discount given + discount := plan.GetAnnualDiscountPercentage() + if discount > 0 { + factor := int64(100 - discount) + price.Amount = price.Amount.MulRaw(factor).QuoRaw(100) + } + } + + if k.bankKeeper.GetBalance(ctx, creatorAcct, epochstoragetypes.TokenDenom).IsLT(price) { + details := map[string]string{ + "creator": creator, + "price": price.String(), + "error": sdkerrors.ErrInsufficientFunds.Error(), + } + err = utils.LavaError(ctx, logger, "subscribe", details, "insufficient funds") + return err + } + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, creatorAcct, types.ModuleName, []sdk.Coin{price}) + if err != nil { + details := map[string]string{ + "creator": creator, + "price": price.String(), + "error": err.Error(), + } + err = utils.LavaError(ctx, logger, "subscribe", details, "funds transfer failed") + return err + } + + sub := types.Subscription{ + Creator: creator, + Consumer: consumer, + Block: block, + PlanIndex: planIndex, + PlanBlock: plan.Block, + IsYearly: isYearly, + ExpiryTime: uint64(expiry.Unix()), + RemainingCU: plan.GetComputeUnits(), + UsedCU: 0, + } + + k.SetSubscription(ctx, sub) + + return nil +} diff --git a/x/subscription/keeper/subscription_test.go b/x/subscription/keeper/subscription_test.go new file mode 100644 index 0000000000..0ea82b9f9b --- /dev/null +++ b/x/subscription/keeper/subscription_test.go @@ -0,0 +1,200 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/lavanet/lava/relayer/sigs" + "github.com/lavanet/lava/testutil/common" + keepertest "github.com/lavanet/lava/testutil/keeper" + "github.com/lavanet/lava/testutil/nullify" + epochstoragetypes "github.com/lavanet/lava/x/epochstorage/types" + "github.com/lavanet/lava/x/subscription/keeper" + "github.com/lavanet/lava/x/subscription/types" + "github.com/stretchr/testify/require" +) + +func createNSubscription(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Subscription { + items := make([]types.Subscription, n) + _, creator := sigs.GenerateFloatingKey() + + for i := range items { + items[i].Creator = creator.String() + items[i].Consumer = "consumer-" + strconv.Itoa(i) + items[i].Block = uint64(ctx.BlockHeight()) + items[i].PlanIndex = "testplan" + items[i].PlanBlock = uint64(ctx.BlockHeight()) + + keeper.SetSubscription(ctx, items[i]) + } + return items +} + +func TestSubscriptionGet(t *testing.T) { + keeper, ctx := keepertest.SubscriptionKeeper(t) + items := createNSubscription(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetSubscription(ctx, + item.Consumer, + ) + require.True(t, found) + + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} + +func TestSubscriptionRemove(t *testing.T) { + keeper, ctx := keepertest.SubscriptionKeeper(t) + items := createNSubscription(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveSubscription(ctx, + item.Creator, + ) + _, found := keeper.GetSubscription(ctx, + item.Creator, + ) + require.False(t, found) + } +} + +func TestSubscriptionGetAll(t *testing.T) { + keeper, ctx := keepertest.SubscriptionKeeper(t) + items := createNSubscription(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllSubscription(ctx)), + ) +} + +func TestCreateSubscription(t *testing. T) { + _, keepers, _ctx := keepertest.InitAllKeepers(t) + ctx := sdk.UnwrapSDKContext(_ctx) + + keeper := keepers.Subscription + bankKeeper := keepers.BankKeeper + plansKeeper := keepers.Plans + + plan := common.CreateMockPlan() + plansKeeper.AddPlan(ctx, plan) + + creators := []struct { + address string + amount int64 + }{ + { + address: "FILL", + amount: 100000, + }, + { + address: "FILL", + amount: 1, + }, + { + address: "invalid creator", + amount: 0, + }, + } + + for i := range creators { + if creators[i].address == "FILL" { + _, addr := sigs.GenerateFloatingKey() + creators[i].address = addr.String() + coins := sdk.NewCoins(sdk.NewCoin( + epochstoragetypes.TokenDenom, + sdk.NewInt(creators[i].amount), + )) + bankKeeper.SetBalance(ctx, addr, coins) + } + } + + consumers := make([]string, 4) + for i := range consumers { + _, addr := sigs.GenerateFloatingKey() + consumers[i] = addr.String() + } + consumers[3] = "invalid consumer" + + template := []struct { + name string + index string + creator int + consumers []int + success bool + }{ + { + name: "create subscriptions", + index: "mockPlan", + creator: 0, + consumers: []int{0, 1}, + success: true, + }, + { + name: "invalid creator", + index: "mockPlan", + creator: 2, + consumers: []int{2}, + success: false, + }, + { + name: "invalid consumer", + index: "mockPlan", + creator: 0, + consumers: []int{3}, + success: false, + }, + { + name: "insufficient funds", + index: "mockPlan", + creator: 1, + consumers: []int{2}, + success: false, + }, +// { +// name: "invalid plan", +// index: "", +// creator: 0, +// consumers: []int{2}, +// success: false, +// }, + { + name: "unknown plan", + index: "no-such-plan", + creator: 0, + consumers: []int{2}, + success: false, + }, + { + name: "double subscription", + index: "mockPlan", + creator: 0, + consumers: []int{0}, + success: false, + }, + } + + for _, tt := range template { + for _, consumer := range tt.consumers { + t.Run(tt.name, func(t *testing.T) { + sub := types.Subscription{ + Creator: creators[tt.creator].address, + Consumer: consumers[consumer], + PlanIndex: tt.index, + } + + err := keeper.CreateSubscription( + ctx, sub.Creator, sub.Consumer, sub.PlanIndex, sub.IsYearly) + if tt.success { + require.Nil(t, err, tt.name) + _, found := keeper.GetSubscription(ctx, sub.Consumer) + require.True(t, found, tt.name) + } else { + require.NotNil(t, err, tt.name) + } + }) + } + } +} diff --git a/x/subscription/module.go b/x/subscription/module.go new file mode 100644 index 0000000000..c8a86bfd8a --- /dev/null +++ b/x/subscription/module.go @@ -0,0 +1,181 @@ +package subscription + +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" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/lavanet/lava/x/subscription/client/cli" + "github.com/lavanet/lava/x/subscription/keeper" + "github.com/lavanet/lava/x/subscription/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// 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. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the capability module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the capability module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 2 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + if am.keeper.IsEpochStart(ctx) { + // run functions that are supposed to run in epoch start + am.keeper.EpochStart(ctx) + } +} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/subscription/module_simulation.go b/x/subscription/module_simulation.go new file mode 100644 index 0000000000..897e9d651b --- /dev/null +++ b/x/subscription/module_simulation.go @@ -0,0 +1,78 @@ +package subscription + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/lavanet/lava/testutil/sample" + subscriptionsimulation "github.com/lavanet/lava/x/subscription/simulation" + "github.com/lavanet/lava/x/subscription/types" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = subscriptionsimulation.FindAccount + _ = simappparams.StakePerAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace +) + +const ( + opWeightMsgSubscribe = "op_weight_msg_subscribe" + // TODO: Determine the simulation weight value + defaultWeightMsgSubscribe int = 100 + + // 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)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + subscriptionGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&subscriptionGenesis) +} + +// ProposalContents doesn't return any content functions for governance proposals +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized param changes for the simulator +func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + return []simtypes.ParamChange{} +} + +// RegisterStoreDecoder registers a decoder +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + var weightMsgSubscribe int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgSubscribe, &weightMsgSubscribe, nil, + func(_ *rand.Rand) { + weightMsgSubscribe = defaultWeightMsgSubscribe + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgSubscribe, + subscriptionsimulation.SimulateMsgSubscribe(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} diff --git a/x/subscription/simulation/simap.go b/x/subscription/simulation/simap.go new file mode 100644 index 0000000000..92c437c0d1 --- /dev/null +++ b/x/subscription/simulation/simap.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/subscription/simulation/subscribe.go b/x/subscription/simulation/subscribe.go new file mode 100644 index 0000000000..6e0b03a3c3 --- /dev/null +++ b/x/subscription/simulation/subscribe.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/lavanet/lava/x/subscription/keeper" + "github.com/lavanet/lava/x/subscription/types" +) + +func SimulateMsgSubscribe( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgSubscribe{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the Subscribe simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "Subscribe simulation not implemented"), nil, nil + } +} diff --git a/x/subscription/types/codec.go b/x/subscription/types/codec.go new file mode 100644 index 0000000000..98c961a75b --- /dev/null +++ b/x/subscription/types/codec.go @@ -0,0 +1,29 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + + // this line is used by starport scaffolding # 1 + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgSubscribe{}, "subscription/Subscribe", nil) + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgSubscribe{}, + ) + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/subscription/types/errors.go b/x/subscription/types/errors.go new file mode 100644 index 0000000000..772d0844a3 --- /dev/null +++ b/x/subscription/types/errors.go @@ -0,0 +1,13 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/subscription module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrBlankParameter = sdkerrors.New(ModuleName, 101, "required parameter is empty") +) diff --git a/x/subscription/types/expected_keepers.go b/x/subscription/types/expected_keepers.go new file mode 100644 index 0000000000..e957e86c82 --- /dev/null +++ b/x/subscription/types/expected_keepers.go @@ -0,0 +1,31 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" + planstypes "github.com/lavanet/lava/x/plans/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + // Methods imported from bank should be defined here +} + +type EpochstorageKeeper interface { + GetEpochStart(ctx sdk.Context) uint64 + // Methods imported from epochstorage should be defined here +} + +type PlansKeeper interface { + GetPlan(ctx sdk.Context, index string) (planstypes.Plan, bool) + PutPlan(ctx sdk.Context, index string, block uint64) bool + // Methods imported from planskeeper should be defined here +} diff --git a/x/subscription/types/genesis.go b/x/subscription/types/genesis.go new file mode 100644 index 0000000000..532bdecc79 --- /dev/null +++ b/x/subscription/types/genesis.go @@ -0,0 +1,22 @@ +package types + +// 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(), + } +} + +// 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/subscription/types/genesis.pb.go b/x/subscription/types/genesis.pb.go new file mode 100644 index 0000000000..b48df09654 --- /dev/null +++ b/x/subscription/types/genesis.pb.go @@ -0,0 +1,321 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: subscription/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + 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 + +// GenesisState defines the subscription module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_436ee45b4d54abbd, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "lavanet.lava.subscription.GenesisState") +} + +func init() { proto.RegisterFile("subscription/genesis.proto", fileDescriptor_436ee45b4d54abbd) } + +var fileDescriptor_436ee45b4d54abbd = []byte{ + // 193 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x2e, 0x4d, 0x2a, + 0x4e, 0x2e, 0xca, 0x2c, 0x28, 0xc9, 0xcc, 0xcf, 0xd3, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, + 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xcc, 0x49, 0x2c, 0x4b, 0xcc, 0x4b, 0x2d, 0xd1, + 0x03, 0xd1, 0x7a, 0xc8, 0x0a, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xaa, 0xf4, 0x41, 0x2c, + 0x88, 0x06, 0x29, 0x49, 0x14, 0xc3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x66, 0x29, 0xf9, 0x73, + 0xf1, 0xb8, 0x43, 0x0c, 0x0f, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xb2, 0xe7, 0x62, 0x83, 0xc8, 0x4b, + 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x29, 0xea, 0xe1, 0xb4, 0x4c, 0x2f, 0x00, 0xac, 0xd0, 0x89, + 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x36, 0x27, 0xb7, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, + 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, + 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x49, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, + 0x87, 0x1a, 0x0a, 0xa6, 0xf5, 0x2b, 0xf4, 0x51, 0xdc, 0x57, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, + 0x06, 0x76, 0x9f, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x51, 0x43, 0xa6, 0x30, 0x09, 0x01, 0x00, + 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) 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 = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + 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 := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/subscription/types/genesis_test.go b/x/subscription/types/genesis_test.go new file mode 100644 index 0000000000..3fdc672fca --- /dev/null +++ b/x/subscription/types/genesis_test.go @@ -0,0 +1,40 @@ +package types_test + +import ( + "testing" + + "github.com/lavanet/lava/x/subscription/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/subscription/types/keys.go b/x/subscription/types/keys.go new file mode 100644 index 0000000000..f1d970c630 --- /dev/null +++ b/x/subscription/types/keys.go @@ -0,0 +1,38 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "subscription" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route for slashing + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_subscription" +) + +const ( + // SubscriptionKeyPrefix is the prefix to retrieve all Subscription + SubscriptionKeyPrefix = "Subscribe/value/" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} + +// SubscriptionKey returns the store key to retrieve a Subscription from the consumer field +func SubscriptionKey(consumer string) []byte { + var key []byte + + indexBytes := []byte(consumer) + key = append(key, indexBytes...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/subscription/types/message_subscribe.go b/x/subscription/types/message_subscribe.go new file mode 100644 index 0000000000..33caa653d4 --- /dev/null +++ b/x/subscription/types/message_subscribe.go @@ -0,0 +1,58 @@ +package types + +import ( + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgSubscribe = "subscribe" + +var _ sdk.Msg = &MsgSubscribe{} + +func NewMsgSubscribe(creator string, consumer string, index string, isYearly bool) *MsgSubscribe { + return &MsgSubscribe{ + Creator: creator, + Consumer: consumer, + Index: index, + IsYearly: isYearly, + } +} + +func (msg *MsgSubscribe) Route() string { + return RouterKey +} + +func (msg *MsgSubscribe) Type() string { + return TypeMsgSubscribe +} + +func (msg *MsgSubscribe) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgSubscribe) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSubscribe) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + _, err = sdk.AccAddressFromBech32(msg.Consumer) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid consumer address (%s)", err) + } + if strings.TrimSpace(msg.Index) == "" { + return sdkerrors.Wrapf(ErrBlankParameter, "invalid plan index (%s)", msg.Index) + } + + return nil +} diff --git a/x/subscription/types/message_subscribe_test.go b/x/subscription/types/message_subscribe_test.go new file mode 100644 index 0000000000..b7f0f6b405 --- /dev/null +++ b/x/subscription/types/message_subscribe_test.go @@ -0,0 +1,59 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/lavanet/lava/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgSubscribe_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgSubscribe + err error + }{ + { + name: "invalid creator address", + msg: MsgSubscribe{ + Creator: "invalid_address", + Consumer: sample.AccAddress(), + Index: "plan-name", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "invalid consumer addresses", + msg: MsgSubscribe{ + Creator: sample.AccAddress(), + Consumer: "invalid_address", + Index: "plan-name", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid addresses", + msg: MsgSubscribe{ + Creator: sample.AccAddress(), + Consumer: sample.AccAddress(), + Index: "plan-name", + }, + }, { + name: "blank plan index", + msg: MsgSubscribe{ + Creator: sample.AccAddress(), + Consumer: sample.AccAddress(), + }, + err: ErrBlankParameter, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/subscription/types/params.go b/x/subscription/types/params.go new file mode 100644 index 0000000000..357196ad6a --- /dev/null +++ b/x/subscription/types/params.go @@ -0,0 +1,39 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/subscription/types/params.pb.go b/x/subscription/types/params.pb.go new file mode 100644 index 0000000000..6276f73144 --- /dev/null +++ b/x/subscription/types/params.pb.go @@ -0,0 +1,264 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: subscription/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + 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 + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_2e445ece5ef15599, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "lavanet.lava.subscription.Params") +} + +func init() { proto.RegisterFile("subscription/params.proto", fileDescriptor_2e445ece5ef15599) } + +var fileDescriptor_2e445ece5ef15599 = []byte{ + // 152 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x2e, 0x4d, 0x2a, + 0x4e, 0x2e, 0xca, 0x2c, 0x28, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xcc, 0x49, 0x2c, 0x4b, 0xcc, 0x4b, 0x2d, 0xd1, 0x03, + 0xd1, 0x7a, 0xc8, 0xea, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xaa, 0xf4, 0x41, 0x2c, 0x88, + 0x06, 0x25, 0x3e, 0x2e, 0xb6, 0x00, 0xb0, 0x01, 0x56, 0x2c, 0x33, 0x16, 0xc8, 0x33, 0x38, 0xb9, + 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, + 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, + 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x16, 0x30, 0xad, 0x5f, 0xa1, 0x8f, 0xe2, 0x9e, + 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xf1, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x5d, 0xc5, 0xb8, 0xe7, 0xac, 0x00, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/subscription/types/query.pb.go b/x/subscription/types/query.pb.go new file mode 100644 index 0000000000..f49d570b14 --- /dev/null +++ b/x/subscription/types/query.pb.go @@ -0,0 +1,924 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: subscription/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "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 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_02ee11f15145221b, []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 response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this 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_02ee11f15145221b, []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{} +} + +type QueryCurrentSubscriptionRequest struct { + Consumer string `protobuf:"bytes,1,opt,name=consumer,proto3" json:"consumer,omitempty"` +} + +func (m *QueryCurrentSubscriptionRequest) Reset() { *m = QueryCurrentSubscriptionRequest{} } +func (m *QueryCurrentSubscriptionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCurrentSubscriptionRequest) ProtoMessage() {} +func (*QueryCurrentSubscriptionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_02ee11f15145221b, []int{2} +} +func (m *QueryCurrentSubscriptionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCurrentSubscriptionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCurrentSubscriptionRequest.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 *QueryCurrentSubscriptionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCurrentSubscriptionRequest.Merge(m, src) +} +func (m *QueryCurrentSubscriptionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCurrentSubscriptionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCurrentSubscriptionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCurrentSubscriptionRequest proto.InternalMessageInfo + +func (m *QueryCurrentSubscriptionRequest) GetConsumer() string { + if m != nil { + return m.Consumer + } + return "" +} + +type QueryCurrentSubscriptionResponse struct { + Sub Subscription `protobuf:"bytes,1,opt,name=sub,proto3" json:"sub"` +} + +func (m *QueryCurrentSubscriptionResponse) Reset() { *m = QueryCurrentSubscriptionResponse{} } +func (m *QueryCurrentSubscriptionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCurrentSubscriptionResponse) ProtoMessage() {} +func (*QueryCurrentSubscriptionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_02ee11f15145221b, []int{3} +} +func (m *QueryCurrentSubscriptionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCurrentSubscriptionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCurrentSubscriptionResponse.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 *QueryCurrentSubscriptionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCurrentSubscriptionResponse.Merge(m, src) +} +func (m *QueryCurrentSubscriptionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCurrentSubscriptionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCurrentSubscriptionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCurrentSubscriptionResponse proto.InternalMessageInfo + +func (m *QueryCurrentSubscriptionResponse) GetSub() Subscription { + if m != nil { + return m.Sub + } + return Subscription{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "lavanet.lava.subscription.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "lavanet.lava.subscription.QueryParamsResponse") + proto.RegisterType((*QueryCurrentSubscriptionRequest)(nil), "lavanet.lava.subscription.QueryCurrentSubscriptionRequest") + proto.RegisterType((*QueryCurrentSubscriptionResponse)(nil), "lavanet.lava.subscription.QueryCurrentSubscriptionResponse") +} + +func init() { proto.RegisterFile("subscription/query.proto", fileDescriptor_02ee11f15145221b) } + +var fileDescriptor_02ee11f15145221b = []byte{ + // 411 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcf, 0x4e, 0xdb, 0x30, + 0x00, 0xc6, 0x93, 0x6e, 0xab, 0x36, 0xef, 0xe6, 0xf6, 0xd0, 0x46, 0x53, 0xda, 0x66, 0x87, 0xfd, + 0xd1, 0x16, 0xab, 0xdd, 0xad, 0xdb, 0x84, 0x54, 0x24, 0xce, 0x50, 0x24, 0x0e, 0x5c, 0x90, 0x13, + 0x59, 0x21, 0x52, 0x63, 0xa7, 0xb1, 0x53, 0x51, 0x21, 0x2e, 0x3c, 0x01, 0x82, 0x97, 0xea, 0xb1, + 0x82, 0x0b, 0x27, 0x84, 0x5a, 0x5e, 0x80, 0x37, 0x40, 0xb1, 0xdd, 0x2a, 0x11, 0x6d, 0x41, 0x9c, + 0x1c, 0xdb, 0xdf, 0xef, 0xfb, 0x3e, 0xdb, 0x01, 0x35, 0x9e, 0x7a, 0xdc, 0x4f, 0xc2, 0x58, 0x84, + 0x8c, 0xa2, 0x61, 0x4a, 0x92, 0xb1, 0x1b, 0x27, 0x4c, 0x30, 0x58, 0x1f, 0xe0, 0x11, 0xa6, 0x44, + 0xb8, 0xd9, 0xe8, 0xe6, 0x65, 0x56, 0x35, 0x60, 0x01, 0x93, 0x2a, 0x94, 0x7d, 0x29, 0xc0, 0xfa, + 0x12, 0x30, 0x16, 0x0c, 0x08, 0xc2, 0x71, 0x88, 0x30, 0xa5, 0x4c, 0xe0, 0x4c, 0xcc, 0xf5, 0xee, + 0x4f, 0x9f, 0xf1, 0x88, 0x71, 0xe4, 0x61, 0x4e, 0x54, 0x0e, 0x1a, 0xb5, 0x3d, 0x22, 0x70, 0x1b, + 0xc5, 0x38, 0x08, 0xa9, 0x14, 0x6b, 0x6d, 0xbd, 0x50, 0x2a, 0xc6, 0x09, 0x8e, 0x16, 0x36, 0x8d, + 0xc2, 0x56, 0x7e, 0xa2, 0x04, 0x4e, 0x15, 0xc0, 0xbd, 0xcc, 0x7d, 0x57, 0x52, 0x7d, 0x32, 0x4c, + 0x09, 0x17, 0xce, 0x01, 0xa8, 0x14, 0x56, 0x79, 0xcc, 0x28, 0x27, 0x70, 0x0b, 0x94, 0x95, 0x7b, + 0xcd, 0x6c, 0x9a, 0xdf, 0x3f, 0x77, 0x5a, 0xee, 0xda, 0x43, 0xbb, 0x0a, 0xed, 0xbd, 0x9f, 0xdc, + 0x35, 0x8c, 0xbe, 0xc6, 0x9c, 0xff, 0xa0, 0x21, 0x7d, 0xb7, 0xd3, 0x24, 0x21, 0x54, 0xec, 0xe7, + 0x00, 0x1d, 0x0d, 0x2d, 0xf0, 0xd1, 0x67, 0x94, 0xa7, 0x11, 0x49, 0x64, 0xca, 0xa7, 0xfe, 0x72, + 0xee, 0xf8, 0xa0, 0xb9, 0x1e, 0x5f, 0x76, 0x7c, 0xc7, 0x53, 0x4f, 0x17, 0xfc, 0xb6, 0xa1, 0x60, + 0x9e, 0xd6, 0x35, 0x33, 0xb2, 0xf3, 0x58, 0x02, 0x1f, 0x64, 0x0a, 0xbc, 0x34, 0x41, 0x59, 0x1d, + 0x03, 0xfe, 0xde, 0x60, 0xf4, 0xfc, 0xfe, 0x2c, 0xf7, 0xb5, 0x72, 0x55, 0xda, 0xf9, 0x71, 0x7e, + 0xf3, 0x70, 0x55, 0xfa, 0x0a, 0x5b, 0x48, 0x73, 0x72, 0x44, 0x2b, 0xde, 0x15, 0x5e, 0x9b, 0xa0, + 0xb2, 0xe2, 0xfc, 0xb0, 0xfb, 0x52, 0xe4, 0xfa, 0x3b, 0xb7, 0xfe, 0xbe, 0x89, 0xd5, 0xdd, 0x7b, + 0xb2, 0xfb, 0x3f, 0xd8, 0xdd, 0xd0, 0xdd, 0x57, 0xfc, 0x51, 0x61, 0xf1, 0x74, 0xf1, 0xae, 0x67, + 0xbd, 0x9d, 0xc9, 0xcc, 0x36, 0xa7, 0x33, 0xdb, 0xbc, 0x9f, 0xd9, 0xe6, 0xc5, 0xdc, 0x36, 0xa6, + 0x73, 0xdb, 0xb8, 0x9d, 0xdb, 0xc6, 0xe1, 0xaf, 0x20, 0x14, 0xc7, 0xa9, 0xe7, 0xfa, 0x2c, 0x2a, + 0xfa, 0x9f, 0x14, 0x13, 0xc4, 0x38, 0x26, 0xdc, 0x2b, 0xcb, 0x9f, 0xfa, 0xcf, 0x53, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x1c, 0x8c, 0xf0, 0x26, 0xa7, 0x03, 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 { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a list of CurrentSubscription items. + CurrentSubscription(ctx context.Context, in *QueryCurrentSubscriptionRequest, opts ...grpc.CallOption) (*QueryCurrentSubscriptionResponse, 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, "/lavanet.lava.subscription.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CurrentSubscription(ctx context.Context, in *QueryCurrentSubscriptionRequest, opts ...grpc.CallOption) (*QueryCurrentSubscriptionResponse, error) { + out := new(QueryCurrentSubscriptionResponse) + err := c.cc.Invoke(ctx, "/lavanet.lava.subscription.Query/CurrentSubscription", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a list of CurrentSubscription items. + CurrentSubscription(context.Context, *QueryCurrentSubscriptionRequest) (*QueryCurrentSubscriptionResponse, 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 (*UnimplementedQueryServer) CurrentSubscription(ctx context.Context, req *QueryCurrentSubscriptionRequest) (*QueryCurrentSubscriptionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CurrentSubscription 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: "/lavanet.lava.subscription.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_CurrentSubscription_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCurrentSubscriptionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CurrentSubscription(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lavanet.lava.subscription.Query/CurrentSubscription", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CurrentSubscription(ctx, req.(*QueryCurrentSubscriptionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lavanet.lava.subscription.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "CurrentSubscription", + Handler: _Query_CurrentSubscription_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "subscription/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 (m *QueryCurrentSubscriptionRequest) 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 *QueryCurrentSubscriptionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCurrentSubscriptionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Consumer) > 0 { + i -= len(m.Consumer) + copy(dAtA[i:], m.Consumer) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Consumer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryCurrentSubscriptionResponse) 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 *QueryCurrentSubscriptionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCurrentSubscriptionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Sub.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 (m *QueryCurrentSubscriptionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Consumer) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryCurrentSubscriptionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Sub.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 (m *QueryCurrentSubscriptionRequest) 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: QueryCurrentSubscriptionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCurrentSubscriptionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Consumer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Consumer = string(dAtA[iNdEx:postIndex]) + 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 (m *QueryCurrentSubscriptionResponse) 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: QueryCurrentSubscriptionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCurrentSubscriptionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sub", 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.Sub.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/subscription/types/query.pb.gw.go b/x/subscription/types/query.pb.gw.go new file mode 100644 index 0000000000..253bb5ac48 --- /dev/null +++ b/x/subscription/types/query.pb.gw.go @@ -0,0 +1,254 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: subscription/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 + +} + +func request_Query_CurrentSubscription_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCurrentSubscriptionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer") + } + + protoReq.Consumer, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer", err) + } + + msg, err := client.CurrentSubscription(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CurrentSubscription_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCurrentSubscriptionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer") + } + + protoReq.Consumer, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer", err) + } + + msg, err := server.CurrentSubscription(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()...) + + }) + + mux.Handle("GET", pattern_Query_CurrentSubscription_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_CurrentSubscription_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_CurrentSubscription_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()...) + + }) + + mux.Handle("GET", pattern_Query_CurrentSubscription_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_CurrentSubscription_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_CurrentSubscription_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{"lavanet", "lava", "subscription", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_CurrentSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"lavanet", "lava", "subscription", "current_subscription", "consumer"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_CurrentSubscription_0 = runtime.ForwardResponseMessage +) diff --git a/x/subscription/types/subscription.go b/x/subscription/types/subscription.go new file mode 100644 index 0000000000..f88bc0891b --- /dev/null +++ b/x/subscription/types/subscription.go @@ -0,0 +1,33 @@ +package types + +import ( + "strings" + "time" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (sub Subscription) IsExpired(date time.Time) bool { + expiry := time.Unix(int64(sub.ExpiryTime), 0).UTC() + return expiry.Before(date) +} + +// ValidateSubscription validates a subscription object fields +func (sub Subscription) ValidateSubscription() error { + // PlanIndex may not be blank + if len(strings.TrimSpace(sub.PlanIndex)) == 0 { + return sdkerrors.Wrap(ErrBlankParameter, "subscription plan cannot be blank") + } + + // Creator may not be blank + if len(strings.TrimSpace(sub.Creator)) == 0 { + return sdkerrors.Wrap(ErrBlankParameter, "subscription creator cannot be blank") + } + + // Consumer may not be blank + if len(strings.TrimSpace(sub.Consumer)) == 0 { + return sdkerrors.Wrap(ErrBlankParameter, "subscription consumer cannot be blank") + } + + return nil +} diff --git a/x/subscription/types/subscription.pb.go b/x/subscription/types/subscription.pb.go new file mode 100644 index 0000000000..131092ef38 --- /dev/null +++ b/x/subscription/types/subscription.pb.go @@ -0,0 +1,641 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: subscription/subscription.proto + +package types + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + 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 + +type Subscription struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Consumer string `protobuf:"bytes,2,opt,name=consumer,proto3" json:"consumer,omitempty"` + Block uint64 `protobuf:"varint,3,opt,name=block,proto3" json:"block,omitempty"` + PlanIndex string `protobuf:"bytes,4,opt,name=plan_index,json=planIndex,proto3" json:"plan_index,omitempty"` + PlanBlock uint64 `protobuf:"varint,5,opt,name=plan_block,json=planBlock,proto3" json:"plan_block,omitempty"` + IsYearly bool `protobuf:"varint,6,opt,name=is_yearly,json=isYearly,proto3" json:"is_yearly,omitempty"` + ExpiryTime uint64 `protobuf:"varint,7,opt,name=expiry_time,json=expiryTime,proto3" json:"expiry_time,omitempty"` + UsedCU uint64 `protobuf:"varint,8,opt,name=usedCU,proto3" json:"usedCU,omitempty"` + RemainingCU uint64 `protobuf:"varint,9,opt,name=remainingCU,proto3" json:"remainingCU,omitempty"` +} + +func (m *Subscription) Reset() { *m = Subscription{} } +func (m *Subscription) String() string { return proto.CompactTextString(m) } +func (*Subscription) ProtoMessage() {} +func (*Subscription) Descriptor() ([]byte, []int) { + return fileDescriptor_ac47bc0f89224537, []int{0} +} +func (m *Subscription) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Subscription) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Subscription.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 *Subscription) XXX_Merge(src proto.Message) { + xxx_messageInfo_Subscription.Merge(m, src) +} +func (m *Subscription) XXX_Size() int { + return m.Size() +} +func (m *Subscription) XXX_DiscardUnknown() { + xxx_messageInfo_Subscription.DiscardUnknown(m) +} + +var xxx_messageInfo_Subscription proto.InternalMessageInfo + +func (m *Subscription) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *Subscription) GetConsumer() string { + if m != nil { + return m.Consumer + } + return "" +} + +func (m *Subscription) GetBlock() uint64 { + if m != nil { + return m.Block + } + return 0 +} + +func (m *Subscription) GetPlanIndex() string { + if m != nil { + return m.PlanIndex + } + return "" +} + +func (m *Subscription) GetPlanBlock() uint64 { + if m != nil { + return m.PlanBlock + } + return 0 +} + +func (m *Subscription) GetIsYearly() bool { + if m != nil { + return m.IsYearly + } + return false +} + +func (m *Subscription) GetExpiryTime() uint64 { + if m != nil { + return m.ExpiryTime + } + return 0 +} + +func (m *Subscription) GetUsedCU() uint64 { + if m != nil { + return m.UsedCU + } + return 0 +} + +func (m *Subscription) GetRemainingCU() uint64 { + if m != nil { + return m.RemainingCU + } + return 0 +} + +func init() { + proto.RegisterType((*Subscription)(nil), "lavanet.lava.subscription.Subscription") +} + +func init() { proto.RegisterFile("subscription/subscription.proto", fileDescriptor_ac47bc0f89224537) } + +var fileDescriptor_ac47bc0f89224537 = []byte{ + // 295 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xbd, 0x4e, 0xc3, 0x30, + 0x14, 0x85, 0xeb, 0xd2, 0x9f, 0xe4, 0x96, 0xc9, 0x42, 0xc8, 0x80, 0x70, 0x23, 0xa6, 0x0e, 0x28, + 0x19, 0x78, 0x83, 0x56, 0x42, 0x62, 0x2d, 0x74, 0x80, 0xa5, 0x72, 0x52, 0xab, 0x58, 0x24, 0x76, + 0x64, 0x3b, 0xa8, 0x79, 0x8b, 0x3e, 0x16, 0x63, 0x47, 0x46, 0x94, 0xbc, 0x08, 0x8a, 0x53, 0xaa, + 0x30, 0x5d, 0x7d, 0xe7, 0xdc, 0x6f, 0x39, 0x30, 0x35, 0x45, 0x6c, 0x12, 0x2d, 0x72, 0x2b, 0x94, + 0x8c, 0xba, 0x10, 0xe6, 0x5a, 0x59, 0x85, 0xaf, 0x52, 0xf6, 0xc9, 0x24, 0xb7, 0x61, 0x73, 0xc3, + 0xee, 0xc3, 0xdd, 0xbe, 0x0f, 0xe7, 0xcf, 0x9d, 0x00, 0x13, 0x18, 0x27, 0x9a, 0x33, 0xab, 0x34, + 0x41, 0x01, 0x9a, 0xf9, 0xcb, 0x3f, 0xc4, 0xd7, 0xe0, 0x25, 0x4a, 0x9a, 0x22, 0xe3, 0x9a, 0xf4, + 0x5d, 0x75, 0x62, 0x7c, 0x01, 0xc3, 0x38, 0x55, 0xc9, 0x07, 0x39, 0x0b, 0xd0, 0x6c, 0xb0, 0x6c, + 0x01, 0xdf, 0x02, 0xe4, 0x29, 0x93, 0x6b, 0x21, 0x37, 0x7c, 0x47, 0x06, 0xce, 0xf1, 0x9b, 0xe4, + 0xa9, 0x09, 0x4e, 0x75, 0x6b, 0x0e, 0x9d, 0xe9, 0xea, 0xb9, 0xb3, 0x6f, 0xc0, 0x17, 0x66, 0x5d, + 0x72, 0xa6, 0xd3, 0x92, 0x8c, 0x02, 0x34, 0xf3, 0x96, 0x9e, 0x30, 0xaf, 0x8e, 0xf1, 0x14, 0x26, + 0x7c, 0x97, 0x0b, 0x5d, 0xae, 0xad, 0xc8, 0x38, 0x19, 0x3b, 0x19, 0xda, 0xe8, 0x45, 0x64, 0x1c, + 0x5f, 0xc2, 0xa8, 0x30, 0x7c, 0xb3, 0x58, 0x11, 0xcf, 0x75, 0x47, 0xc2, 0x01, 0x4c, 0x34, 0xcf, + 0x98, 0x90, 0x42, 0x6e, 0x17, 0x2b, 0xe2, 0xbb, 0xb2, 0x1b, 0xcd, 0x1f, 0xbf, 0x2a, 0x8a, 0x0e, + 0x15, 0x45, 0x3f, 0x15, 0x45, 0xfb, 0x9a, 0xf6, 0x0e, 0x35, 0xed, 0x7d, 0xd7, 0xb4, 0xf7, 0x76, + 0xbf, 0x15, 0xf6, 0xbd, 0x88, 0xc3, 0x44, 0x65, 0xd1, 0x71, 0x52, 0x77, 0xa3, 0xdd, 0xbf, 0xd5, + 0x23, 0x5b, 0xe6, 0xdc, 0xc4, 0x23, 0x37, 0xfe, 0xc3, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x51, + 0x84, 0xee, 0x9e, 0x9f, 0x01, 0x00, 0x00, +} + +func (m *Subscription) 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 *Subscription) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Subscription) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RemainingCU != 0 { + i = encodeVarintSubscription(dAtA, i, uint64(m.RemainingCU)) + i-- + dAtA[i] = 0x48 + } + if m.UsedCU != 0 { + i = encodeVarintSubscription(dAtA, i, uint64(m.UsedCU)) + i-- + dAtA[i] = 0x40 + } + if m.ExpiryTime != 0 { + i = encodeVarintSubscription(dAtA, i, uint64(m.ExpiryTime)) + i-- + dAtA[i] = 0x38 + } + if m.IsYearly { + i-- + if m.IsYearly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if m.PlanBlock != 0 { + i = encodeVarintSubscription(dAtA, i, uint64(m.PlanBlock)) + i-- + dAtA[i] = 0x28 + } + if len(m.PlanIndex) > 0 { + i -= len(m.PlanIndex) + copy(dAtA[i:], m.PlanIndex) + i = encodeVarintSubscription(dAtA, i, uint64(len(m.PlanIndex))) + i-- + dAtA[i] = 0x22 + } + if m.Block != 0 { + i = encodeVarintSubscription(dAtA, i, uint64(m.Block)) + i-- + dAtA[i] = 0x18 + } + if len(m.Consumer) > 0 { + i -= len(m.Consumer) + copy(dAtA[i:], m.Consumer) + i = encodeVarintSubscription(dAtA, i, uint64(len(m.Consumer))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintSubscription(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintSubscription(dAtA []byte, offset int, v uint64) int { + offset -= sovSubscription(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Subscription) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovSubscription(uint64(l)) + } + l = len(m.Consumer) + if l > 0 { + n += 1 + l + sovSubscription(uint64(l)) + } + if m.Block != 0 { + n += 1 + sovSubscription(uint64(m.Block)) + } + l = len(m.PlanIndex) + if l > 0 { + n += 1 + l + sovSubscription(uint64(l)) + } + if m.PlanBlock != 0 { + n += 1 + sovSubscription(uint64(m.PlanBlock)) + } + if m.IsYearly { + n += 2 + } + if m.ExpiryTime != 0 { + n += 1 + sovSubscription(uint64(m.ExpiryTime)) + } + if m.UsedCU != 0 { + n += 1 + sovSubscription(uint64(m.UsedCU)) + } + if m.RemainingCU != 0 { + n += 1 + sovSubscription(uint64(m.RemainingCU)) + } + return n +} + +func sovSubscription(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSubscription(x uint64) (n int) { + return sovSubscription(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Subscription) 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 ErrIntOverflowSubscription + } + 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: Subscription: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Subscription: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSubscription + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSubscription + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Consumer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSubscription + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSubscription + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Consumer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + } + m.Block = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Block |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSubscription + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSubscription + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PlanIndex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanBlock", wireType) + } + m.PlanBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PlanBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsYearly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsYearly = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpiryTime", wireType) + } + m.ExpiryTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExpiryTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UsedCU", wireType) + } + m.UsedCU = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UsedCU |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RemainingCU", wireType) + } + m.RemainingCU = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSubscription + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RemainingCU |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSubscription(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSubscription + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSubscription(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, ErrIntOverflowSubscription + } + 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, ErrIntOverflowSubscription + } + 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, ErrIntOverflowSubscription + } + 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, ErrInvalidLengthSubscription + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSubscription + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSubscription + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSubscription = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSubscription = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSubscription = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/subscription/types/tx.pb.go b/x/subscription/types/tx.pb.go new file mode 100644 index 0000000000..9c9773e25b --- /dev/null +++ b/x/subscription/types/tx.pb.go @@ -0,0 +1,667 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: subscription/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + 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 + +type MsgSubscribe struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Consumer string `protobuf:"bytes,2,opt,name=consumer,proto3" json:"consumer,omitempty"` + Index string `protobuf:"bytes,3,opt,name=index,proto3" json:"index,omitempty"` + IsYearly bool `protobuf:"varint,4,opt,name=isYearly,proto3" json:"isYearly,omitempty"` +} + +func (m *MsgSubscribe) Reset() { *m = MsgSubscribe{} } +func (m *MsgSubscribe) String() string { return proto.CompactTextString(m) } +func (*MsgSubscribe) ProtoMessage() {} +func (*MsgSubscribe) Descriptor() ([]byte, []int) { + return fileDescriptor_cc8b79a0f6744252, []int{0} +} +func (m *MsgSubscribe) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubscribe) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubscribe.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 *MsgSubscribe) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubscribe.Merge(m, src) +} +func (m *MsgSubscribe) XXX_Size() int { + return m.Size() +} +func (m *MsgSubscribe) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubscribe.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubscribe proto.InternalMessageInfo + +func (m *MsgSubscribe) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgSubscribe) GetConsumer() string { + if m != nil { + return m.Consumer + } + return "" +} + +func (m *MsgSubscribe) GetIndex() string { + if m != nil { + return m.Index + } + return "" +} + +func (m *MsgSubscribe) GetIsYearly() bool { + if m != nil { + return m.IsYearly + } + return false +} + +type MsgSubscribeResponse struct { +} + +func (m *MsgSubscribeResponse) Reset() { *m = MsgSubscribeResponse{} } +func (m *MsgSubscribeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubscribeResponse) ProtoMessage() {} +func (*MsgSubscribeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cc8b79a0f6744252, []int{1} +} +func (m *MsgSubscribeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubscribeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubscribeResponse.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 *MsgSubscribeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubscribeResponse.Merge(m, src) +} +func (m *MsgSubscribeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubscribeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubscribeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubscribeResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSubscribe)(nil), "lavanet.lava.subscription.MsgSubscribe") + proto.RegisterType((*MsgSubscribeResponse)(nil), "lavanet.lava.subscription.MsgSubscribeResponse") +} + +func init() { proto.RegisterFile("subscription/tx.proto", fileDescriptor_cc8b79a0f6744252) } + +var fileDescriptor_cc8b79a0f6744252 = []byte{ + // 245 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x2e, 0x4d, 0x2a, + 0x4e, 0x2e, 0xca, 0x2c, 0x28, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x92, 0xcc, 0x49, 0x2c, 0x4b, 0xcc, 0x4b, 0x2d, 0xd1, 0x03, 0xd1, 0x7a, 0xc8, 0x6a, + 0x94, 0xca, 0xb8, 0x78, 0x7c, 0x8b, 0xd3, 0x83, 0x21, 0x42, 0x49, 0xa9, 0x42, 0x12, 0x5c, 0xec, + 0xc9, 0x45, 0xa9, 0x89, 0x25, 0xf9, 0x45, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, + 0x90, 0x14, 0x17, 0x47, 0x72, 0x7e, 0x5e, 0x71, 0x69, 0x6e, 0x6a, 0x91, 0x04, 0x13, 0x58, 0x0a, + 0xce, 0x17, 0x12, 0xe1, 0x62, 0xcd, 0xcc, 0x4b, 0x49, 0xad, 0x90, 0x60, 0x06, 0x4b, 0x40, 0x38, + 0x20, 0x1d, 0x99, 0xc5, 0x91, 0xa9, 0x89, 0x45, 0x39, 0x95, 0x12, 0x2c, 0x0a, 0x8c, 0x1a, 0x1c, + 0x41, 0x70, 0xbe, 0x92, 0x18, 0x97, 0x08, 0xb2, 0xbd, 0x41, 0xa9, 0xc5, 0x05, 0xf9, 0x79, 0xc5, + 0xa9, 0x46, 0x39, 0x5c, 0xcc, 0xbe, 0xc5, 0xe9, 0x42, 0xa9, 0x5c, 0x9c, 0x08, 0x37, 0xa9, 0xeb, + 0xe1, 0x74, 0xbf, 0x1e, 0xb2, 0x21, 0x52, 0xfa, 0x44, 0x2a, 0x84, 0xd9, 0xe6, 0xe4, 0x76, 0xe2, + 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, + 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x3a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, + 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x50, 0x43, 0xc1, 0xb4, 0x7e, 0x85, 0x3e, 0x6a, 0x18, 0x57, 0x16, + 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xc3, 0xd9, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x63, 0x7b, + 0xf5, 0x80, 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 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + Subscribe(ctx context.Context, in *MsgSubscribe, opts ...grpc.CallOption) (*MsgSubscribeResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) Subscribe(ctx context.Context, in *MsgSubscribe, opts ...grpc.CallOption) (*MsgSubscribeResponse, error) { + out := new(MsgSubscribeResponse) + err := c.cc.Invoke(ctx, "/lavanet.lava.subscription.Msg/Subscribe", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + Subscribe(context.Context, *MsgSubscribe) (*MsgSubscribeResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) Subscribe(ctx context.Context, req *MsgSubscribe) (*MsgSubscribeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Subscribe not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_Subscribe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubscribe) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Subscribe(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lavanet.lava.subscription.Msg/Subscribe", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Subscribe(ctx, req.(*MsgSubscribe)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lavanet.lava.subscription.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Subscribe", + Handler: _Msg_Subscribe_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "subscription/tx.proto", +} + +func (m *MsgSubscribe) 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 *MsgSubscribe) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubscribe) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsYearly { + i-- + if m.IsYearly { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if len(m.Index) > 0 { + i -= len(m.Index) + copy(dAtA[i:], m.Index) + i = encodeVarintTx(dAtA, i, uint64(len(m.Index))) + i-- + dAtA[i] = 0x1a + } + if len(m.Consumer) > 0 { + i -= len(m.Consumer) + copy(dAtA[i:], m.Consumer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Consumer))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubscribeResponse) 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 *MsgSubscribeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubscribeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSubscribe) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Consumer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Index) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.IsYearly { + n += 2 + } + return n +} + +func (m *MsgSubscribeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSubscribe) 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 ErrIntOverflowTx + } + 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: MsgSubscribe: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubscribe: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Consumer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Consumer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Index = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsYearly", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsYearly = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSubscribeResponse) 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 ErrIntOverflowTx + } + 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: MsgSubscribeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubscribeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/subscription/types/types.go b/x/subscription/types/types.go new file mode 100644 index 0000000000..ab1254f4c2 --- /dev/null +++ b/x/subscription/types/types.go @@ -0,0 +1 @@ +package types